fix http api.
This commit is contained in:
parent
61782a70ba
commit
c03f704018
@ -88,9 +88,6 @@ HTTPServer.prototype._init = function _init() {
|
||||
bcoin.debug('Params:');
|
||||
bcoin.debug(params);
|
||||
|
||||
if (params.subtractFee)
|
||||
options.subtractFee = params.subtractFee;
|
||||
|
||||
if (params.id) {
|
||||
assert(params.id !== '!all');
|
||||
options.id = params.id;
|
||||
@ -126,6 +123,9 @@ HTTPServer.prototype._init = function _init() {
|
||||
if (params.rate)
|
||||
options.rate = utils.satoshi(params.rate);
|
||||
|
||||
if (params.subtractFee)
|
||||
options.subtractFee = params.subtractFee;
|
||||
|
||||
if (Array.isArray(params.outputs)) {
|
||||
options.outputs = params.outputs.map(function(output) {
|
||||
return {
|
||||
@ -145,7 +145,10 @@ HTTPServer.prototype._init = function _init() {
|
||||
|
||||
if (params.tx) {
|
||||
try {
|
||||
options.tx = bcoin.tx.fromRaw(params.tx, 'hex');
|
||||
if (typeof params.tx === 'object')
|
||||
options.tx = bcoin.tx.fromJSON(params.tx);
|
||||
else
|
||||
options.tx = bcoin.tx.fromRaw(params.tx, 'hex');
|
||||
} catch (e) {
|
||||
return next(e);
|
||||
}
|
||||
@ -439,12 +442,8 @@ HTTPServer.prototype._init = function _init() {
|
||||
this.post('/wallet/:id/create', function(req, res, next, send) {
|
||||
var id = req.options.id;
|
||||
var options = req.options;
|
||||
var outputs = req.options.outputs;
|
||||
|
||||
if (!Array.isArray(outputs))
|
||||
return send(400);
|
||||
|
||||
self.walletdb.createTX(id, options, outputs, function(err, tx) {
|
||||
self.walletdb.createTX(id, options, function(err, tx) {
|
||||
if (err)
|
||||
return next(err);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user