This commit is contained in:
Christopher Jeffrey 2016-04-01 22:12:05 -07:00
parent 4f03675b9f
commit 8289544b81
3 changed files with 27 additions and 20 deletions

View File

@ -244,20 +244,20 @@ function main(callback) {
default:
utils.print('Unrecognized command.');
utils.print('Commands:');
utils.print(' $ wallet [id] --keys [hdkeys]'
+ ' --type [pubkeyhash/multisig] -m [m-value]
utils.print(' $ wallet [id] --keys [hdkeys]'
+ ' --type [pubkeyhash/multisig] -m [m-value]'
+ ' -n [n-value] --witness: View or create wallet by ID.');
utils.print(' $ getwallet [id]: View wallet by ID.');
utils.print(' $ addkey [id] --keys [hdkeys]: Add keys to wallet.');
utils.print(' $ rmkey [id] --keys [hdkeys]: Remove keys from wallet.');
utils.print(' $ balance [id]: Get wallet balance.');
utils.print(' $ history [id]: View wallet TX history.');
utils.print(' $ send [id] [address] [value] --script [code]: Send transaction.');
utils.print(' $ zap [id] --now [now] --age [age]: Zap pending wallet TXs.');
utils.print(' $ mempool: Get mempool snapshot.');
utils.print(' $ tx [hash/address]: View transactions.');
utils.print(' $ coin [hash+index/address]: View coins.');
utils.print(' $ block [hash/height]: View block.');
utils.print(' $ getwallet [id]: View wallet by ID.');
utils.print(' $ addkey [id] --keys [hdkeys]: Add keys to wallet.');
utils.print(' $ rmkey [id] --keys [hdkeys]: Remove keys from wallet.');
utils.print(' $ balance [id]: Get wallet balance.');
utils.print(' $ history [id]: View wallet TX history.');
utils.print(' $ send [id] [address] [value] --script [code]: Send transaction.');
utils.print(' $ zap [id] --now [now] --age [age]: Zap pending wallet TXs.');
utils.print(' $ mempool: Get mempool snapshot.');
utils.print(' $ tx [hash/address]: View transactions.');
utils.print(' $ coin [hash+index/address]: View coins.');
utils.print(' $ block [hash/height]: View block.');
return callback();
}
}
@ -316,11 +316,13 @@ function parseArg(argv) {
}
client.getInfo(function(err, info) {
if (err)
throw err;
if (err) {
console.error(err.stack + '');
return process.exit(1);
}
if (!argv.args[0])
return utils.print(info);
utils.print(info);
main(function(err) {
if (err) {

View File

@ -47,6 +47,10 @@ Client.prototype._init = function _init() {
this.socket = new io.Socket(this.uri);
this.socket.on('error', function(err) {
self.emit('error', err);
});
this.socket.on('open', function() {
self.socket.on('version', function(info) {
utils.debug('Connected to bcoin server: %s (%s)',
@ -100,10 +104,6 @@ Client.prototype._init = function _init() {
self.emit('balances', balances);
});
self.socket.on('error', function(err) {
self.emit('error', err);
});
self.loaded = true;
self.emit('open');
});

View File

@ -194,6 +194,11 @@ function request(options, callback, stream) {
res.socket.on('end', done);
});
req.on('error', function(err) {
stream.destroy();
stream.emit('error', err);
});
if (body)
req.write(body);