Last active
June 8, 2017 23:52
-
-
Save MasonBorda/a6ee13af9db8974374d0 to your computer and use it in GitHub Desktop.
Getting Started With the BitGo SDK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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