From c03f7040182c82e4e2221c1ff75406c519b6c18b Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 21 Jun 2016 14:39:56 -0700 Subject: [PATCH] fix http api. --- lib/bcoin/http/server.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/bcoin/http/server.js b/lib/bcoin/http/server.js index c66f34ec..3d815419 100644 --- a/lib/bcoin/http/server.js +++ b/lib/bcoin/http/server.js @@ -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);