You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
#!/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);
|
|
});
|
|
|