diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index 6f1eb0f6..8d623e22 100644 --- a/lib/bcoin/wallet.js +++ b/lib/bcoin/wallet.js @@ -373,17 +373,9 @@ Wallet.prototype.balance = function balance() { return this.tx.balance(); }; -Wallet.prototype.fill = function fill(tx, options, cb) { - if ((cb && typeof cb === 'object') || options == null) { - cb = options; - options = {}; - } +Wallet.prototype.fill = function fill(tx, cb) { cb = utils.asyncify(cb); - if (options._getChange) { - tx = tx.clone(); - } - // NOTE: tx should be prefilled with all outputs var cost = tx.funds('out'); @@ -434,10 +426,6 @@ Wallet.prototype.fill = function fill(tx, options, cb) { // How much money is left after sending outputs var left = tx.funds('in').sub(total); - if (options._getChange) { - return left; - } - // Not enough money, transfer everything to owner if (left.cmpn(this.dust) < 0) { // NOTE: that this output is either `postCost` or one of the `dust` values @@ -452,21 +440,14 @@ Wallet.prototype.fill = function fill(tx, options, cb) { tx.outputs[tx.outputs.length - 1].value = left; // Sign transaction - if (options.sign === false) { - this.signEmpty(tx); - } else { - this.sign(tx); - } + // XXX Do not necessarily call this here + this.sign(tx); cb(null, tx); return tx; }; -Wallet.prototype.getChange = function fill(tx) { - return this.fill(tx, { _getChange: true }); -}; - /** * P2SH+Multisig Redemption */