diff --git a/lib/bcoin/node.js b/lib/bcoin/node.js index 375c57a4..805c104a 100644 --- a/lib/bcoin/node.js +++ b/lib/bcoin/node.js @@ -139,6 +139,10 @@ Node.prototype._init = function _init() { }); }; +Node.prototype.scanWallet = function scanWallet(callback) { + this.wallet.scan(this.getTXByAddress.bind(this), callback); +}; + Node.prototype.getBlock = function getBlock(hash, callback) { var self = this; var coin; diff --git a/lib/bcoin/tx-pool.js b/lib/bcoin/tx-pool.js index 6db4b0c5..e036703d 100644 --- a/lib/bcoin/tx-pool.js +++ b/lib/bcoin/tx-pool.js @@ -83,6 +83,7 @@ TXPool.prototype.add = function add(tx, noWrite) { this._all[hash].ts = tx.ts; this._all[hash].block = tx.block; this._all[hash].height = tx.height; + this._all[hash].index = tx.index; this._all[hash].outputs.forEach(function(output, i) { var key = hash + '/' + i; if (this._unspent[key]) @@ -294,6 +295,7 @@ TXPool.prototype.unconfirm = function unconfirm(hash) { tx.ts = 0; tx.block = null; tx.height = -1; + tx.index = -1; tx.outputs.forEach(function(output, i) { var key = hash + '/' + i; if (this._unspent[key]) diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index 555f4f2d..07854511 100644 --- a/lib/bcoin/wallet.js +++ b/lib/bcoin/wallet.js @@ -535,10 +535,11 @@ Wallet.prototype.fill = function fill(tx, options) { assert(this._initialized); tx.fill(this.getUnspent(), { - // wallet: this, + selection: options.selection || 'age', fee: options.fee, subtractFee: options.subtractFee, changeAddress: this.changeAddress.getAddress(), + wallet: this, m: this.m, n: this.n }); @@ -546,21 +547,19 @@ Wallet.prototype.fill = function fill(tx, options) { return true; }; -// Legacy -Wallet.prototype.fillUnspent = Wallet.prototype.fill; -Wallet.prototype.fillInputs = Wallet.prototype.fill; - Wallet.prototype.fillPrevout = function fillPrevout(tx) { return tx.fillPrevout(this); }; -// Legacy -Wallet.prototype.fillTX = Wallet.prototype.fillPrevout; - -Wallet.prototype.createTX = function createTX(outputs, options) { - var tx = bcoin.tx(); +Wallet.prototype.createTX = function createTX(options, outputs) { + var tx = bcoin.mtx(); var target; + if (!outputs) { + outputs = options; + options = {}; + } + if (!Array.isArray(outputs)) outputs = [outputs]; @@ -841,9 +840,9 @@ Wallet.prototype.__defineGetter__('scriptAddress', function() { return this.getScriptAddress(); }); -// Wallet.prototype.__defineGetter__('program', function() { -// return this.getProgram(); -// }); +Wallet.prototype.__defineGetter__('program', function() { + return this.getProgram(); +}); Wallet.prototype.__defineGetter__('programHash', function() { return this.getProgramHash();