Skip to content

Commit e087b89

Browse files
author
Mark Tyneway
committed
wallet: create cancel lock
1 parent 82861f1 commit e087b89

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

lib/wallet/wallet.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,32 +2763,52 @@ class Wallet extends EventEmitter {
27632763
}
27642764

27652765
/**
2766-
* Create and finalize a cancel MTX.
2766+
* Create and finalize a cancel
2767+
* MTX without a lock.
27672768
* @param {String} name
27682769
* @param {Object} options
27692770
* @returns {MTX}
27702771
*/
27712772

2772-
async createCancel(name, options) {
2773+
async _createCancel(name, options) {
27732774
const mtx = await this.makeCancel(name);
27742775
await this.fill(mtx, options);
27752776
return this.finalize(mtx, options);
27762777
}
27772778

27782779
/**
2779-
* Create and send a cancel MTX.
2780+
* Create and finalize a cancel
2781+
* MTX with a lock.
2782+
* @param {String} name
2783+
* @param {Object} options
2784+
* @returns {MTX}
2785+
*/
2786+
2787+
async createCancel(name, options) {
2788+
const unlock = await this.fundLock.lock();
2789+
try {
2790+
return await this._createCancel(name, options);
2791+
} finally {
2792+
unlock();
2793+
}
2794+
}
2795+
2796+
/**
2797+
* Create and send a cancel
2798+
* MTX without a lock.
27802799
* @param {String} name
27812800
* @param {Object} options
27822801
*/
27832802

27842803
async _sendCancel(name, options) {
27852804
const passphrase = options ? options.passphrase : null;
2786-
const mtx = await this.createCancel(name, options);
2805+
const mtx = await this._createCancel(name, options);
27872806
return this.sendMTX(mtx, passphrase);
27882807
}
27892808

27902809
/**
2791-
* Create and send a cancel MTX.
2810+
* Create and send a cancel
2811+
* MTX with a lock.
27922812
* @param {String} name
27932813
* @param {Object} options
27942814
*/

0 commit comments

Comments
 (0)