bitcore-wallet-service/bit-wallet/bit-send

45 lines
1.1 KiB
Plaintext
Raw Normal View History

2015-02-13 07:45:05 -08:00
#!/usr/bin/env node
var program = require('commander');
2015-02-15 06:33:04 -08:00
var Client = require('../lib/client');
2015-02-15 08:14:36 -08:00
var utils = require('./cli-utils');
2015-02-21 06:59:33 -08:00
program = utils.configureCommander(program);
2015-02-13 07:45:05 -08:00
program
2015-02-19 18:44:41 -08:00
.usage('[options] <address> <amount> [note]')
.description('Create a proposal for sending bitcoins to a destination address.\n The amount can be specified in bit, btc or sat (the default).');
program.on('--help', function(){
console.log(' Examples:');
console.log('');
console.log(' $ bit-send n2HRFgtoihgAhx1qAEXcdBMjoMvAx7AcDc 500bit');
console.log(' $ bit-send mgWeRvUC6d1LRPKtdDbvYEpaUEmApS4XrY 0.2btc "dinner with friends"');
console.log('');
});
program.parse(process.argv);
2015-02-13 07:45:05 -08:00
var args = program.args;
2015-02-19 18:44:41 -08:00
if (!args[0] || !args[1])
2015-02-13 07:45:05 -08:00
program.help();
2015-02-15 08:14:36 -08:00
var address = args[0];
2015-02-19 16:37:13 -08:00
var amount;
try {
amount = utils.parseAmount(args[1]);
} catch (ex) {
utils.die(ex);
}
2015-02-19 18:44:41 -08:00
var note = args[2];
2015-02-13 07:45:05 -08:00
2015-02-15 08:14:36 -08:00
var client = utils.getClient(program);
2015-02-13 08:35:20 -08:00
2015-02-15 08:14:36 -08:00
client.sendTxProposal({
toAddress: address,
amount: amount,
2015-02-19 18:44:41 -08:00
message: note
2015-02-15 08:14:36 -08:00
}, function(err, x) {
utils.die(err);
console.log(' * Tx created: ID %s [%s] RequiredSignatures:',
x.id, x.status, x.requiredSignatures);
});