Merge pull request #316 from Bucko13/lock-coin-bug
use req.wallet for lock coin endpoints
This commit is contained in:
commit
5ba79e4729
@ -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`);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user