Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@MasonBorda
Last active June 8, 2017 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MasonBorda/a6ee13af9db8974374d0 to your computer and use it in GitHub Desktop.
Save MasonBorda/a6ee13af9db8974374d0 to your computer and use it in GitHub Desktop.
Getting Started With the BitGo SDK
var BitGoJS = require('bitgo');
var bitgo = new BitGoJS.BitGo({env: 'test', accessToken: process.env.ACCESS_TOKEN});
if (process.argv.length < 6) {
console.log("usage:\n\t" + process.argv[0] + " " + process.argv[1] + " <walletId> <walletPassphrase> <destinationAddress> <amountSatoshis>");
process.exit(-1);
}
var walletId = process.argv[2];
var walletPassphrase = process.argv[3];
var destinationAddress = process.argv[4];
var amountSatoshis = parseInt(process.argv[5], 10);
var sendBitcoin = function() {
console.log("Getting wallet..");
// Now get the wallet
bitgo.wallets().get({id: walletId}, function(err, wallet) {
if (err) { console.log("Error getting wallet!"); console.dir(err); return process.exit(-1); }
console.log("Balance is: " + (wallet.balance() / 1e8).toFixed(4));
wallet.sendCoins({ address: destinationAddress, amount: amountSatoshis, walletPassphrase: walletPassphrase, minConfirms: 0 },
function(err, result) {
if (err) { console.log("Error sending coins!"); console.dir(err); return process.exit(-1); }
console.dir(result);
process.exit(0);
}
);
});
};
sendBitcoin();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment