wallet.createTx ignores pending utxo
This commit is contained in:
parent
660c95483d
commit
e064e9d29d
2 changed files with 22 additions and 2 deletions
|
@ -103,7 +103,8 @@ function Wallet(seed, network) {
|
|||
return {
|
||||
receive: key,
|
||||
address: o.address,
|
||||
value: o.value
|
||||
value: o.value,
|
||||
pending: o.pending
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,7 +212,7 @@ function Wallet(seed, network) {
|
|||
|
||||
for (var key in me.outputs) {
|
||||
var output = me.outputs[key]
|
||||
if (!output.spend) unspent.push(output)
|
||||
if (!output.spend && !output.pending) unspent.push(output)
|
||||
}
|
||||
|
||||
var sortByValueDesc = unspent.sort(function(o1, o2){
|
||||
|
|
|
@ -439,6 +439,25 @@ describe('Wallet', function() {
|
|||
assert.equal(tx.ins.length, 1)
|
||||
assert.deepEqual(tx.ins[0].outpoint, { hash: fakeTxHash(3), index: 0 })
|
||||
})
|
||||
|
||||
it('ignores pending outputs', function(){
|
||||
utxo.push(
|
||||
{
|
||||
"hash": fakeTxHash(4),
|
||||
"outputIndex": 0,
|
||||
"address" : address2,
|
||||
"value": 530000,
|
||||
"pending": true
|
||||
}
|
||||
)
|
||||
wallet.setUnspentOutputs(utxo)
|
||||
|
||||
var tx = wallet.createTx(to, value)
|
||||
|
||||
assert.equal(tx.ins.length, 1)
|
||||
assert.deepEqual(tx.ins[0].outpoint, { hash: fakeTxHash(3), index: 0 })
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
describe(networks.testnet, function(){
|
||||
|
|
Loading…
Add table
Reference in a new issue