diff --git a/lib/http/client.js b/lib/http/client.js index b8bb2664..ecc57104 100644 --- a/lib/http/client.js +++ b/lib/http/client.js @@ -624,8 +624,8 @@ HTTPClient.prototype.getWalletBlock = function getWalletBlock(id, height) { * @returns {Promise} */ -HTTPClient.prototype.getWalletCoin = function getWalletCoin(id, account, hash, index) { - return this._get(`/wallet/${id}/coin/${hash}/${index}`, { account }); +HTTPClient.prototype.getWalletCoin = function getWalletCoin(id, hash, index) { + return this._get(`/wallet/${id}/coin/${hash}/${index}`); }; /** @@ -823,8 +823,8 @@ HTTPClient.prototype.importAddress = function importAddress(id, account, address * @returns {Promise} */ -HTTPClient.prototype.lockCoin = function lockCoin(id, hash, index) { - return this._put(`/wallet/${id}/coin/locked`, { hash, index }); +HTTPClient.prototype.lockCoin = function lockCoin(id, hash, index, passphrase) { + return this._put(`/wallet/${id}/locked/${hash}/${index}`, { passphrase }); }; /** @@ -835,8 +835,8 @@ HTTPClient.prototype.lockCoin = function lockCoin(id, hash, index) { * @returns {Promise} */ -HTTPClient.prototype.unlockCoin = function unlockCoin(id, hash, index) { - return this._del(`/wallet/${id}/coin/locked`, { hash, index }); +HTTPClient.prototype.unlockCoin = function unlockCoin(id, hash, index, passphrase) { + return this._del(`/wallet/${id}/locked/${hash}/${index}`, { passphrase }); }; /** @@ -846,7 +846,7 @@ HTTPClient.prototype.unlockCoin = function unlockCoin(id, hash, index) { */ HTTPClient.prototype.getLocked = function getLocked(id) { - return this._get(`/wallet/${id}/coin/locked`); + return this._get(`/wallet/${id}/locked`); }; /** diff --git a/lib/http/wallet.js b/lib/http/wallet.js index 2b3174fc..5a48627f 100644 --- a/lib/http/wallet.js +++ b/lib/http/wallet.js @@ -232,8 +232,8 @@ HTTPWallet.prototype.getBlock = function getBlock(height) { * @see Wallet#getCoin */ -HTTPWallet.prototype.getCoin = function getCoin(account, hash, index) { - return this.client.getWalletCoin(this.id, account, hash, index); +HTTPWallet.prototype.getCoin = function getCoin(hash, index) { + return this.client.getWalletCoin(this.id, hash, index); }; /** diff --git a/lib/wallet/http.js b/lib/wallet/http.js index b74097af..a9f787e8 100644 --- a/lib/wallet/http.js +++ b/lib/wallet/http.js @@ -641,7 +641,7 @@ HTTPServer.prototype.initRouter = function initRouter() { // Locked coins this.get('/:id/locked', async (req, res) => { - const locked = this.wallet.getLocked(); + const locked = await req.wallet.getLocked(); const result = []; for (const outpoint of locked) @@ -660,8 +660,8 @@ HTTPServer.prototype.initRouter = function initRouter() { enforce(index != null, 'Index is required.'); const outpoint = new Outpoint(hash, index); - - this.wallet.lockCoin(outpoint); + await req.wallet.lockCoin(outpoint); + res.send(200, { success: true }); }); // Unlock coin @@ -675,7 +675,8 @@ HTTPServer.prototype.initRouter = function initRouter() { const outpoint = new Outpoint(hash, index); - this.wallet.unlockCoin(outpoint); + await req.wallet.unlockCoin(outpoint); + res.send(200, { success: true }); }); // Wallet Coin