Bitcoin Wallet API Programming
The bitcoin wallet is your entry door into the bitcoin network.
This post discusses different ways you can write your own program to interact with the live bitcoin blockchain (known as main net). (Also read Bitcoin Wallet Basics).
You can program against the current mainnet (bitcoin’s main blockchain) using a couple of different options::
- Option 1 – Run your own Bitcoin client in Server Mode ( more on this in a separate post)
- Option 2 – Run a thin API client and hook into Blockchain.com’s API – that is in turn hooked into the mainnet.
Option 2 – Hook into Blockchain.com’s API. Blockchain.com provides developer APIs for payment processing and for a bitcoin wallet.
Steps 1 and 2 – Request an API Key, Create a bitcoin wallet on blockchain.com
Request an API Key from blockchain.com
Create a wallet, and validate your email address. Login using your newly created wallet address and your password. Associate your wallet with your API (Account Settings –> IP Restrictions –> allow API Access)
Step 3 – Create a VM, Install node, npm and blockchain wallet service
Setup a VM ( either a VPS from digital ocean or a google compute engine instance ).
sudo-apt-get update sudo apt-get intall nodejs sudo apt-get install npm npm install -d blockchain-wallet-service
Step 4 – Launch your wallet service
cd /usr/local/bin node blockchain-wallet-service start -port 3030
Step 5 – Check that our API key works
http://127.0.0.1:3030/merchant/MY-GUID/login?password=MY-PWD&api_code=MYAPIKEY
Although this request will fail, check your email. Blockchain.com would have sent you an email containing your IP address and your API key. In the email, will be a link to ‘authorize your IP’. Once you do, you can re-request the URL above and you should see a success.
Step 6 – Start Using Your Wallet
Try creating a new bitcoin address:
http://127.0.0.1:3030/merchant/MY-GUID/new_address?password=MY-PWD&api_code=MYAPIKEY
Summary
This is a quick, getting started guide to using the bitcoin wallet API. While this is a perfectly valid approach to building wallet apps, this relies on an already running node elsewhere. You may want to also run your own full bitcoin node, which will the topic of a future post.
Leave a Reply