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:');
|
||||||
bcoin.debug(params);
|
bcoin.debug(params);
|
||||||
|
|
||||||
if (params.subtractFee)
|
|
||||||
options.subtractFee = params.subtractFee;
|
|
||||||
|
|
||||||
if (params.id) {
|
if (params.id) {
|
||||||
assert(params.id !== '!all');
|
assert(params.id !== '!all');
|
||||||
options.id = params.id;
|
options.id = params.id;
|
||||||
@ -126,6 +123,9 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
if (params.rate)
|
if (params.rate)
|
||||||
options.rate = utils.satoshi(params.rate);
|
options.rate = utils.satoshi(params.rate);
|
||||||
|
|
||||||
|
if (params.subtractFee)
|
||||||
|
options.subtractFee = params.subtractFee;
|
||||||
|
|
||||||
if (Array.isArray(params.outputs)) {
|
if (Array.isArray(params.outputs)) {
|
||||||
options.outputs = params.outputs.map(function(output) {
|
options.outputs = params.outputs.map(function(output) {
|
||||||
return {
|
return {
|
||||||
@ -145,7 +145,10 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
|
|
||||||
if (params.tx) {
|
if (params.tx) {
|
||||||
try {
|
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) {
|
} catch (e) {
|
||||||
return next(e);
|
return next(e);
|
||||||
}
|
}
|
||||||
@ -439,12 +442,8 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
this.post('/wallet/:id/create', function(req, res, next, send) {
|
this.post('/wallet/:id/create', function(req, res, next, send) {
|
||||||
var id = req.options.id;
|
var id = req.options.id;
|
||||||
var options = req.options;
|
var options = req.options;
|
||||||
var outputs = req.options.outputs;
|
|
||||||
|
|
||||||
if (!Array.isArray(outputs))
|
self.walletdb.createTX(id, options, function(err, tx) {
|
||||||
return send(400);
|
|
||||||
|
|
||||||
self.walletdb.createTX(id, options, outputs, function(err, tx) {
|
|
||||||
if (err)
|
if (err)
|
||||||
return next(err);
|
return next(err);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user