diff --git a/src/wallet.js b/src/wallet.js index b144206..5e04b74 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -136,7 +136,7 @@ function Wallet(seed, network) { return value == undefined } - this.processTx = function(tx) { + this.processTx = function(tx, isPending) { var txhash = tx.getHash() tx.outs.forEach(function(txOut, i){ @@ -155,6 +155,7 @@ function Wallet(seed, network) { receive: output, value: txOut.value, address: address, + pending: isPending } } }) diff --git a/test/wallet.js b/test/wallet.js index 955eba1..00fea42 100644 --- a/test/wallet.js +++ b/test/wallet.js @@ -302,16 +302,26 @@ describe('Wallet', function() { verifyOutputAdded(1) }) + describe("when the pending flag is set", function(){ + it("sets the pending flag on output", function(){ + wallet.addresses = [addresses[0]] + wallet.processTx(tx, true) + + verifyOutputAdded(0, true) + }) + }) + function outputCount(){ return Object.keys(wallet.outputs).length } - function verifyOutputAdded(index) { + function verifyOutputAdded(index, pending) { var txOut = tx.outs[index] var key = tx.getHash() + ":" + index var output = wallet.outputs[key] assert.equal(output.receive, key) assert.equal(output.value, txOut.value) + assert.equal(output.pending, pending) var txOutAddress = Address.fromScriptPubKey(txOut.script).toString() assert.equal(output.address, txOutAddress)