wallet: do not delete pending incoming tx from outputs
This commit is contained in:
parent
79a17d67ec
commit
82b1d8fbdc
2 changed files with 31 additions and 2 deletions
|
@ -175,7 +175,13 @@ function Wallet(seed, network) {
|
||||||
|
|
||||||
var output = txinId + ':' + txIn.index
|
var output = txinId + ':' + txIn.index
|
||||||
|
|
||||||
if(me.outputs[output]) delete me.outputs[output]
|
if (!(output in me.outputs)) return
|
||||||
|
|
||||||
|
if (isPending) {
|
||||||
|
return me.outputs[output].pending = true
|
||||||
|
}
|
||||||
|
|
||||||
|
delete me.outputs[output]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,12 +264,35 @@ describe('Wallet', function() {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("processPendingTx", function(){
|
describe("processPendingTx", function(){
|
||||||
it("sets the pending flag on output", function(){
|
it("incoming: sets the pending flag on output", function(){
|
||||||
wallet.addresses = [addresses[0]]
|
wallet.addresses = [addresses[0]]
|
||||||
wallet.processPendingTx(tx)
|
wallet.processPendingTx(tx)
|
||||||
|
|
||||||
verifyOutputAdded(0, true)
|
verifyOutputAdded(0, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("when tx ins outpoint contains a known txhash:i", function(){
|
||||||
|
var spendTx
|
||||||
|
beforeEach(function(){
|
||||||
|
wallet.addresses = [addresses[0]]
|
||||||
|
wallet.processConfirmedTx(tx)
|
||||||
|
|
||||||
|
spendTx = Transaction.fromHex(fixtureTx2Hex)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("outgoing: sets the pending flag on output instead of deleting it", function(){
|
||||||
|
var txIn = spendTx.ins[0]
|
||||||
|
var txInId = new Buffer(txIn.hash)
|
||||||
|
Array.prototype.reverse.call(txInId)
|
||||||
|
txInId = txInId.toString('hex')
|
||||||
|
|
||||||
|
var key = txInId + ':' + txIn.index
|
||||||
|
assert(!wallet.outputs[key].pending)
|
||||||
|
|
||||||
|
wallet.processPendingTx(spendTx)
|
||||||
|
assert(wallet.outputs[key].pending)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('processConfirmedTx', function(){
|
describe('processConfirmedTx', function(){
|
||||||
|
|
Loading…
Add table
Reference in a new issue