Getting Started With BitGoD

BitGoD serves as a drop-in replacement for bitcoind, and proxies wallet-related commands to the BitGo API. For developers who are already using bitcoind in their stack and want to start using BitGo wallets, BitGoD is the solution.

Installation

Before you install BitGoD, create your account at test.bitgo.com, login to the account, and create 2 wallets which for this guide we’ll refer to as <send_wallet> and <recieve_wallet>. You’ll also want to create a developer access token so you can create a BitGoD session. To do this, see the Authentication Guide. Once you’ve created the token export it to your environment variables as $ACCESS_TOKEN for later use. You will also need to install bitcoind so you can use the bitcoin-cli tool to send commands to BitGoD.

Now you’re ready to install BitGoD.

$ npm install -g bitgod

Setting A Wallet

Run it as a background process on port 19332 with the following command (later, you can start it in production mode by using port 9332):

$ nohup bitgod -rpcport=19332 &

If at any point you want to stop bitgod, run the following command:

$ kill -15 `ps aux | grep bitgod | grep -v grep| awk '{print $2}'`

Create your session with BitGoD by using the access token you created earlier:

$ bitcoin-cli -rpcport=19332 settoken $ACCESS_TOKEN

Then set your wallet with the following command (you can also find your wallet id by selecting your wallet on test.bitgo.com, and getting the address from the URL):

$ bitcoin-cli -rpcport=19332 setwallet send_wallet

You can view what scopes are available with your current wallet by printing the session:

$ bitcoin-cli -rpcport=19332 session

Sending Coin

With BitGoD it’s possible to send bitcoin from one wallet to another. First, you’ll need some testnet bitcoin in your <send_wallet>. Head over to this bitcoin faucet, input your <send_wallet> address, and wait around 10 minutes for the faucet to send some bitcoin to your BitGo wallet. You can verify that you’ve received your testnet bitcoin by running:

$ bitcoin-cli -rpcport=19332 getbalance

and you should see a non-zero value for the wallet’s amount.

Now you’re ready to send testnet bitcoin to the <receive_wallet>. Anytime you do a critical operation with a BitGo wallet, such as sending coin or sharing a wallet, you first need to unlock the wallet using a one-time-password (OTP). You might be familiar with this if you’ve seen other 2FA services like Authy or Google Authenticator. If you were using BitGoD to talk to the mainnet bitcoin blockchain then you would need to supply a real OTP code, but since you’ve made a testnet wallet BitGo let’s you use the same code ‘0000000’ to ease development. So, you unlock with:

$ bitcoin-cli -rpcport=19332 unlock 0000000

Then, enter the password for your wallet to decrypt it:

$ bitcoin-cli -rpcport=19332 walletpassphrase your_wallet_password 4000

where here the <your_wallet_password> is the wallet’s password (which should be your account password unless you chose to enter a wallet-specific passphrase), and the 4000 argument specifies the password will exist in memory for 4000 seconds before being deleted. At last, you’ve verified you are the owner of the wallet, and so you can send 0.01 BTC to <receive_wallet> with the command:

$ bitcoin-cli -rpcport=19332 sendtoaddress receive_address 0.01 “my first bitgo transaction”

You’ll see the transaction id (txid) printed out. After you wait about 10 minutes for the block to be confirmed you can see that the bitcoin has arrived by running the following two commands

$ bitcoin-cli -rpcport=19332 setwallet receive_wallet
$ bitcoin-cli -rpcport=19332 getbalance

In this guide we’ve seen how to setup BitGoD, use it to authenticate with BitGo’s servers, and finally set a wallet and send its coins to another BitGo wallet.