diff --git a/README.md b/README.md index b0f0de94..c934fe63 100644 --- a/README.md +++ b/README.md @@ -497,7 +497,7 @@ tx.addOutput({ // Select coins from our array and add inputs. // Calculate fee and add a change output. -tx.fill(coins, { +tx.fund(coins, { // Use a rate of 10,000 satoshis per kb. // With the `fullnode` object, you can // use the fee estimator for this instead diff --git a/lib/bcoin/mtx.js b/lib/bcoin/mtx.js index ba8ec03a..fd07a46b 100644 --- a/lib/bcoin/mtx.js +++ b/lib/bcoin/mtx.js @@ -1164,7 +1164,7 @@ MTX.prototype.subtractFee = function subtractFee(fee, index) { * @returns {Object} See {@link MTX#selectCoins} return value. */ -MTX.prototype.fill = function fill(coins, options) { +MTX.prototype.fund = function fund(coins, options) { var result, i, change, changeAddress; assert(this.inputs.length === 0, 'TX is already filled.'); diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index 37c1924b..3a5c610c 100644 --- a/lib/bcoin/wallet.js +++ b/lib/bcoin/wallet.js @@ -685,7 +685,7 @@ Wallet.prototype.getPath = function getPath(address, callback) { * fee from existing outputs rather than adding more inputs. */ -Wallet.prototype.fill = function fill(tx, options, callback) { +Wallet.prototype.fund = function fund(tx, options, callback) { var self = this; var unlock, rate; @@ -699,7 +699,7 @@ Wallet.prototype.fill = function fill(tx, options, callback) { // We use a lock here to ensure we // don't end up double spending coins. - unlock = this.fillLock.lock(fill, [tx, options, callback]); + unlock = this.fillLock.lock(fund, [tx, options, callback]); if (!unlock) return; @@ -736,7 +736,7 @@ Wallet.prototype.fill = function fill(tx, options, callback) { } try { - tx.fill(coins, { + tx.fund(coins, { selection: options.selection || 'age', round: options.round, confirmed: options.confirmed, @@ -790,7 +790,7 @@ Wallet.prototype.createTX = function createTX(options, callback) { } // Fill the inputs with unspents - this.fill(tx, options, function(err) { + this.fund(tx, options, function(err) { if (err) return callback(err); diff --git a/test/wallet-test.js b/test/wallet-test.js index a0d6798b..c684fbac 100644 --- a/test/wallet-test.js +++ b/test/wallet-test.js @@ -359,7 +359,7 @@ describe('Wallet', function() { // Create new transaction var t2 = bcoin.mtx().addOutput(w2, 5460); - w1.fill(t2, { rate: 10000, round: true }, function(err) { + w1.fund(t2, { rate: 10000, round: true }, function(err) { assert.ifError(err); w1.sign(t2, function(err) { assert.ifError(err); @@ -375,7 +375,7 @@ describe('Wallet', function() { // Create new transaction var t3 = bcoin.mtx().addOutput(w2, 15000); - w1.fill(t3, { rate: 10000, round: true }, function(err) { + w1.fund(t3, { rate: 10000, round: true }, function(err) { assert(err); assert.equal(err.requiredFunds, 25000); cb(); @@ -407,7 +407,7 @@ describe('Wallet', function() { // Create new transaction var t2 = bcoin.mtx().addOutput(w2, 5460); - w1.fill(t2, { rate: 10000 }, function(err) { + w1.fund(t2, { rate: 10000 }, function(err) { assert.ifError(err); w1.sign(t2, function(err) { assert.ifError(err); @@ -434,7 +434,7 @@ describe('Wallet', function() { walletdb.addTX(t2, function(err) { assert.ifError(err); var t3 = bcoin.mtx().addOutput(w2, 15000); - w1.fill(t3, { rate: 10000 }, function(err) { + w1.fund(t3, { rate: 10000 }, function(err) { assert(err); assert(balance); assert(balance.total === 5460); @@ -664,7 +664,7 @@ describe('Wallet', function() { var send = bcoin.mtx(); send.addOutput({ address: receive.getAddress(), value: 5460 }); assert(!send.verify(flags)); - w1.fill(send, { rate: 10000, round: true }, function(err) { + w1.fund(send, { rate: 10000, round: true }, function(err) { assert.ifError(err); w1.sign(send, function(err) { @@ -774,7 +774,7 @@ describe('Wallet', function() { // Create new transaction var t2 = bcoin.mtx().addOutput(w2, 5460); - w1.fill(t2, { rate: 10000, round: true }, function(err) { + w1.fund(t2, { rate: 10000, round: true }, function(err) { assert.ifError(err); w1.sign(t2, function(err) { assert.ifError(err); @@ -790,7 +790,7 @@ describe('Wallet', function() { // Create new transaction var t3 = bcoin.mtx().addOutput(w2, 15000); - w1.fill(t3, { rate: 10000, round: true }, function(err) { + w1.fund(t3, { rate: 10000, round: true }, function(err) { assert(err); assert.equal(err.requiredFunds, 25000); w1.getAccounts(function(err, accounts) { @@ -840,11 +840,11 @@ describe('Wallet', function() { // Should fill from `foo` and fail var t2 = bcoin.mtx().addOutput(w1, 5460); - w1.fill(t2, { rate: 10000, round: true, account: 'foo' }, function(err) { + w1.fund(t2, { rate: 10000, round: true, account: 'foo' }, function(err) { assert(err); // Should fill from whole wallet and succeed var t2 = bcoin.mtx().addOutput(w1, 5460); - w1.fill(t2, { rate: 10000, round: true }, function(err) { + w1.fund(t2, { rate: 10000, round: true }, function(err) { assert.ifError(err); // Coinbase @@ -859,7 +859,7 @@ describe('Wallet', function() { assert.ifError(err); var t2 = bcoin.mtx().addOutput(w1, 5460); // Should fill from `foo` and succeed - w1.fill(t2, { rate: 10000, round: true, account: 'foo' }, function(err) { + w1.fund(t2, { rate: 10000, round: true, account: 'foo' }, function(err) { assert.ifError(err); cb(); }); @@ -892,7 +892,7 @@ describe('Wallet', function() { // Create new transaction var t2 = bcoin.mtx().addOutput(w1, 5460); - w1.fill(t2, { rate: 10000, round: true }, function(err) { + w1.fund(t2, { rate: 10000, round: true }, function(err) { assert.ifError(err); // Should fail w1.sign(t2, 'bar', function(err) { @@ -930,7 +930,7 @@ describe('Wallet', function() { // Create new transaction var t2 = bcoin.mtx().addOutput(w2, 21840); - w1.fill(t2, { rate: 10000, round: true, subtractFee: true }, function(err) { + w1.fund(t2, { rate: 10000, round: true, subtractFee: true }, function(err) { assert.ifError(err); w1.sign(t2, function(err) { assert.ifError(err);