Skip to content

Self hosted cryptocurrency wallet as a service

License

Notifications You must be signed in to change notification settings

mclauncherlinux/Bitez

Repository files navigation

Bitez: Self hosted cryptocurrency wallet as a service

Bitez (pronounced Bit Easy) is a self hosted cryptocurrency wallet server you can use to create BTC/BCH wallets and perform multiple operations such as transactions and wallets generation with a simple HTTP interface.

You will need mongodb to store wallets, user accounts and api keys. Of course, private keys are encrypted before getting stored.

I created Bitez because I wanted a free alternative to Block.io.

Important: Bitez is still in alpha and therefore shouldn't be used for serving a large application with a large user base. Serving it for a small application is probably fine. I'm 20 and I'm broke so I don't want to be involved in any lawsuit haha

Installation

After cloning this repository, you'll need to install all the dependencies:

# using pip
pip install requirements.txt

# or using Pipenv
pipenv install

Then you'll need to create a file at the root directory called (.env) with the following vars to store your secret environnement variables:

DB_HOST='<mongodb URI>'
DB_PORT='<mongodb port>'
DB_CLIENT='<mongodb client>'
SECRET_KEY='<random string used for jwt salting>'
MAIL_SERVER='<email smtp server>'
MAIL_PORT='<email smtp server port>'
MAIL_USERNAME='<email address for account activation>'
MAIL_PASSWORD='<password for accessing email account>'
ENCRYPTION_SECRET='<random string used for prkey encryption>'

After saving the file, start the server with one of the following commands:

# mainnet server
python main.py

# or

# testnet server
python main.py --dev

# or

# mainnet production server
gunicorn main:app

Guide

Before accessing the API, you need to create an account and generate an API key:

Account creation:

  • Register:
curl -X POST /api/auth/register {
    "username":"<USERNAME>",
    "email":"<EMAIL>",
    "password":"<PASSWORD>"
}
  • Activate account:
curl -X PUT /api/auth/activate {
    "activation_code":"<ACTIVATION_CODE>"
}
  • Login to account:
# This will generate a JWT Token
curl -X GET /api/auth/login {
    "email":"<EMAIL>",
    "password":"<PASSWORD>"
}
  • API key generation:
curl -X GET /api/generate_key
-H 'Authorization: jwt <JWT_TOKEN>'
  • Get all API keys:
curl -X GET /api/keys
-H 'Authorization: jwt <JWT_TOKEN>'

Generate a new address:

# BTC
curl -X GET /api/btc/generate?api_key=<API_KEY>

# BCH
curl -X GET /api/bch/generate?api_key=<API_KEY>

Get all addresses:

# BTC
curl -X GET /api/btc/addresses?api_key=<API_KEY>

# BCH
curl -X GET /api/bch/addresses?api_key=<API_KEY>

Get wallet balance:

# BTC
curl -X GET /api/btc/balance?api_key=<API_KEY>&currency=<CURRENCY>

# BCH
curl -X GET /api/bch/balance?api_key=<API_KEY>&currency=<CURRENCY>

# available currencies: btc, bch, usd, eur, gbp, jpy and other major currencies like cad and chf

Get transaction history:

# BTC
curl -X GET /api/btc/history?api_key=<API_KEY>

# BCH
curl -X GET /api/bch/history?api_key=<API_KEY>

Get current rates:

# BTC
curl -X GET /api/btc/rates?api_key=<API_KEY>&currency=<CURRENCY>

# BCH
curl -X GET /api/bch/rates?api_key=<API_KEY>&currency=<CURRENCY>

# available currencies: btc, bch, usd, eur, gbp, jpy and other major currencies like cad and chf

Get a fiat amount in crypto:

# BTC
curl -X GET /api/btc/rates?api_key=<API_KEY>&currency=<CURRENCY>&amount=<AMOUNT>

# BCH
curl -X GET /api/bch/rates?api_key=<API_KEY>&currency=<CURRENCY>&amount=<AMOUNT>

# available currencies: btc, bch, usd, eur, gbp, jpy and other major currencies like cad and chf

Check if an address is valid:

# BTC
curl -X GET /api/btc/validate?api_key=<API_KEY>&address=<ADDRESS>

# BCH
curl -X GET /api/bch/validate?api_key=<API_KEY>&address=<ADDRESS>

Perform a transaction:

# BTC
curl -X POST /api/btc/tx?api_key=<API_KEY>
-H 'Content-Type: application/json'
-d {
    "recipient":"<ADDRESS>",
    "amount": <AMOUNT>,
    "currency": "<CURRENCY>"
}

# BCH
curl -X POST /api/bch/tx?api_key=<API_KEY>
-H 'Content-Type: application/json'
-d {
    "recipient":"<ADDRESS>",
    "amount": <AMOUNT>,
    "currency": "<CURRENCY>"
}

# available currencies: btc, bch, satoshi, usd, eur, gbp, jpy and other major currencies like cad and chf

Donate

Based on community needs, I will keep improving the project and adding new functionalities. You can help me do that by contributing to the project or by donating a little something to encourage me.

Donate BTC: 1HHMRuezg1WAPqGRQ3S8xFKGgmMHZZrCoa

Donate BCH: bitcoincash:qrxjktfjdse3ll0ttrll20gykuhqjw764queg3w2tj

Donate Love: Just tweet me something cool :)

Contributing

If you like Bitez and want to contribute to it, you can make a pull request on a new branch wether it is for a bugfix or for a new feature.

You can also request a feature or report a bug by using Github issues, or by dropping me an email.

Promoting the project is also considered a huge contribution! Any action is welcome as long as it helps Bitez grow!

Notes and credits

  • I really wanted to thank Ofek Lev for his library bit and Sporestack with his fork bitcash which made Bitez possible without me having a headache!

  • The rates and transaction API for BCH doesn't work on the testnet (dev server) because of a dependency issue. It should be fixed soon.

About

Self hosted cryptocurrency wallet as a service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published