From f494762a679c035bbd7c14359338f89bcfde6fc4 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 16 Jun 2016 15:37:22 -0700 Subject: [PATCH] api: create address. --- lib/bcoin/http/server.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/bcoin/http/server.js b/lib/bcoin/http/server.js index 4c1095c9..d23eb5b8 100644 --- a/lib/bcoin/http/server.js +++ b/lib/bcoin/http/server.js @@ -148,8 +148,10 @@ HTTPServer.prototype._init = function _init() { } } - if (params.account != null) + if (typeof params.account === 'string') options.account = params.account || null; + else if (typeof params.account === 'number') + options.account = params.account; if (params.name) options.name = params.name; @@ -520,6 +522,18 @@ HTTPServer.prototype._init = function _init() { }); }); + // Create address + this.post('/wallet/:id/address', function(req, res, next, send) { + var id = req.options.id; + var account = req.options.account; + self.walletdb.createAddress(id, account, false, function(err, address) { + if (err) + return next(err); + + send(200, address.toJSON()); + }); + }); + // Wallet Balance this.get('/wallet/:id/balance', function(req, res, next, send) { var id = req.options.id;