minor.
This commit is contained in:
parent
018ce13815
commit
dda07e8eab
@ -127,10 +127,12 @@ MTX.prototype.addInput = function addInput(options, index) {
|
|||||||
|
|
||||||
assert(this.ts === 0, 'Cannot modify a confirmed tx.');
|
assert(this.ts === 0, 'Cannot modify a confirmed tx.');
|
||||||
|
|
||||||
if (options instanceof MTX)
|
if (options instanceof bcoin.tx)
|
||||||
options = bcoin.coin(options, index);
|
options = bcoin.coin(options, index);
|
||||||
|
|
||||||
if (options instanceof bcoin.coin) {
|
if (options instanceof bcoin.coin) {
|
||||||
|
assert(typeof options.hash === 'string');
|
||||||
|
assert(typeof options.index === 'number');
|
||||||
options = {
|
options = {
|
||||||
prevout: { hash: options.hash, index: options.index },
|
prevout: { hash: options.hash, index: options.index },
|
||||||
coin: options
|
coin: options
|
||||||
@ -901,7 +903,7 @@ MTX.prototype.selectCoins = function selectCoins(coins, options) {
|
|||||||
var i, index;
|
var i, index;
|
||||||
|
|
||||||
for (i = lastAdded; i < coins.length; i++) {
|
for (i = lastAdded; i < coins.length; i++) {
|
||||||
// Add new inputs until MTX will have enough
|
// Add new inputs until TX will have enough
|
||||||
// funds to cover both minimum post cost
|
// funds to cover both minimum post cost
|
||||||
// and fee.
|
// and fee.
|
||||||
tx.addInput(coins[i]);
|
tx.addInput(coins[i]);
|
||||||
@ -929,7 +931,7 @@ MTX.prototype.selectCoins = function selectCoins(coins, options) {
|
|||||||
addCoins();
|
addCoins();
|
||||||
|
|
||||||
// Add dummy output (for `change`) to
|
// Add dummy output (for `change`) to
|
||||||
// calculate maximum MTX size.
|
// calculate maximum TX size.
|
||||||
tx.addOutput({
|
tx.addOutput({
|
||||||
address: options.changeAddress,
|
address: options.changeAddress,
|
||||||
value: new bn(0)
|
value: new bn(0)
|
||||||
|
|||||||
@ -601,9 +601,12 @@ TX.prototype.fillCoins = function fillCoins(coins) {
|
|||||||
coins = coins.reduce(function(out, coin) {
|
coins = coins.reduce(function(out, coin) {
|
||||||
if (coin instanceof TX) {
|
if (coin instanceof TX) {
|
||||||
out[coin.hash('hex')] = coin;
|
out[coin.hash('hex')] = coin;
|
||||||
} else {
|
} else if (coin instanceof bcoin.coin) {
|
||||||
assert(typeof coin.hash === 'string');
|
assert(typeof coin.hash === 'string');
|
||||||
|
assert(typeof coin.index === 'number');
|
||||||
out[coin.hash + '/' + coin.index] = coin;
|
out[coin.hash + '/' + coin.index] = coin;
|
||||||
|
} else {
|
||||||
|
assert(false, 'Non-coin object passed to fillCoins.');
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}, {});
|
}, {});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user