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

45 lines
1.1 KiB
JavaScript
Executable File

#!/usr/bin/env node
var program = require('commander');
var Client = require('../lib/client');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
program
.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);
var args = program.args;
if (!args[0] || !args[1])
program.help();
var address = args[0];
var amount;
try {
amount = utils.parseAmount(args[1]);
} catch (ex) {
utils.die(ex);
}
var note = args[2];
var client = utils.getClient(program);
client.sendTxProposal({
toAddress: address,
amount: amount,
message: note
}, function(err, x) {
utils.die(err);
console.log(' * Tx created: ID %s [%s] RequiredSignatures:',
x.id, x.status, x.requiredSignatures);
});