api fixes.
This commit is contained in:
parent
1283e8bd2a
commit
edbd42b2c2
@ -271,7 +271,7 @@ function sendTX(callback) {
|
||||
output.address = argv.address || argv.args[0];
|
||||
output.value = utils.satoshi(argv.value || argv.args[1]);
|
||||
}
|
||||
client.walletSend(id, options, [output], function(err, tx) {
|
||||
client.walletSend(id, {outputs:[output]}, function(err, tx) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
utils.print(tx);
|
||||
@ -370,7 +370,7 @@ function main(callback) {
|
||||
case 'create':
|
||||
return createTX(callback);
|
||||
case 'send':
|
||||
return send(callback);
|
||||
return sendTX(callback);
|
||||
case 'zap':
|
||||
return zap(callback);
|
||||
case 'broadcast':
|
||||
|
||||
@ -792,17 +792,15 @@ HTTPClient.prototype.broadcast = function broadcast(tx, callback) {
|
||||
* @param {Function} callback - Returns [Error, {@link TX}].
|
||||
*/
|
||||
|
||||
HTTPClient.prototype.walletSend = function walletSend(id, options, outputs, callback) {
|
||||
if (typeof outputs === 'function') {
|
||||
callback = outputs;
|
||||
outputs = null;
|
||||
}
|
||||
|
||||
HTTPClient.prototype.walletSend = function walletSend(id, options, callback) {
|
||||
options = utils.merge({}, options);
|
||||
options.outputs = outputs || options.outputs || [];
|
||||
options.outputs = options.outputs || [];
|
||||
|
||||
if (!Array.isArray(options.outputs))
|
||||
options.outputs = [options.outputs];
|
||||
if (options.outputs.length === 0)
|
||||
options.outputs.push(options);
|
||||
|
||||
if (options.rate)
|
||||
options.rate = utils.btc(options.rate);
|
||||
|
||||
options.outputs = options.outputs.map(function(output) {
|
||||
return {
|
||||
|
||||
@ -120,6 +120,9 @@ HTTPServer.prototype._init = function _init() {
|
||||
options.address = params.address;
|
||||
}
|
||||
|
||||
if (params.rate)
|
||||
options.rate = utils.satoshi(params.rate);
|
||||
|
||||
if (Array.isArray(params.outputs)) {
|
||||
options.outputs = params.outputs.map(function(output) {
|
||||
return {
|
||||
@ -128,12 +131,6 @@ HTTPServer.prototype._init = function _init() {
|
||||
value: utils.satoshi(output.value)
|
||||
};
|
||||
});
|
||||
} else if (params.value) {
|
||||
options.outputs = [{
|
||||
address: params.address,
|
||||
script: decodeScript(params.script),
|
||||
value: utils.satoshi(params.value)
|
||||
}];
|
||||
}
|
||||
|
||||
if (params.addresses) {
|
||||
@ -151,8 +148,8 @@ HTTPServer.prototype._init = function _init() {
|
||||
}
|
||||
}
|
||||
|
||||
if (params.account)
|
||||
options.account = params.account;
|
||||
if (params.account != null)
|
||||
options.account = params.account || null;
|
||||
|
||||
if (params.name)
|
||||
options.name = params.name;
|
||||
@ -796,15 +793,22 @@ HTTPServer.prototype._initIO = function _initIO() {
|
||||
});
|
||||
|
||||
this.walletdb.on('address', function(receive, change, map) {
|
||||
receive = receive.map(function(address) {
|
||||
return address.toJSON();
|
||||
});
|
||||
change = change.map(function(address) {
|
||||
return address.toJSON();
|
||||
});
|
||||
if (receive) {
|
||||
receive = receive.map(function(address) {
|
||||
return address.toJSON();
|
||||
});
|
||||
}
|
||||
|
||||
if (change) {
|
||||
change = change.map(function(address) {
|
||||
return address.toJSON();
|
||||
});
|
||||
}
|
||||
|
||||
map.all.forEach(function(id) {
|
||||
self.server.io.to(id).emit('address', receive, change, map);
|
||||
});
|
||||
|
||||
self.server.io.to('!all').emit('address', receive, change, map);
|
||||
});
|
||||
};
|
||||
|
||||
@ -183,8 +183,8 @@ HTTPWallet.prototype.createTX = function createTX(tx, options, outputs, callback
|
||||
* @see HTTPClient#walletSend
|
||||
*/
|
||||
|
||||
HTTPWallet.prototype.send = function send(tx, options, outputs, callback) {
|
||||
return this.client.walletSend(this.id, tx, options, outputs, callback);
|
||||
HTTPWallet.prototype.send = function send(tx, options, callback) {
|
||||
return this.client.walletSend(this.id, tx, options, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -169,8 +169,11 @@ TXDB.prototype.mapAddresses = function mapAddresses(address, callback) {
|
||||
if (err)
|
||||
return next(err);
|
||||
|
||||
if (!paths)
|
||||
if (!paths) {
|
||||
assert(!table[address]);
|
||||
table[address] = [];
|
||||
return next();
|
||||
}
|
||||
|
||||
keys = Object.keys(paths);
|
||||
values = [];
|
||||
|
||||
@ -1105,14 +1105,9 @@ WalletDB.prototype.sign = function sign(id, tx, options, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
WalletDB.prototype.createTX = function createTX(id, options, outputs, callback) {
|
||||
if (typeof outputs === 'function') {
|
||||
callback = outputs;
|
||||
outputs = null;
|
||||
}
|
||||
|
||||
WalletDB.prototype.createTX = function createTX(id, options, callback) {
|
||||
this.fetchWallet(id, callback, function(wallet, callback) {
|
||||
wallet.createTX(options, outputs, callback);
|
||||
wallet.createTX(options, callback);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user