wallet exposes unspent outputs via a getter
also add reverseEndian method to convert
This commit is contained in:
parent
68e8834c66
commit
16dc68cbaa
4 changed files with 67 additions and 8 deletions
src
|
@ -60,6 +60,26 @@ var Wallet = function (seed, options) {
|
|||
return this.changeAddresses[this.changeAddresses.length - 1]
|
||||
}
|
||||
|
||||
this.getUnspentOutputs = function() {
|
||||
var utxo = []
|
||||
|
||||
for(var key in this.outputs){
|
||||
var hashAndIndex = key.split(":")
|
||||
var output = this.outputs[key]
|
||||
|
||||
utxo.push({
|
||||
hash: hashAndIndex[0],
|
||||
hashLittleEndian: convert.reverseEndian(hashAndIndex[0]),
|
||||
outputIndex: parseInt(hashAndIndex[1]),
|
||||
scriptPubKey: output.scriptPubKey,
|
||||
address: output.address,
|
||||
value: output.value
|
||||
})
|
||||
}
|
||||
|
||||
return utxo
|
||||
}
|
||||
|
||||
// Processes a transaction object
|
||||
// If "verified" is true, then we trust the transaction as "final"
|
||||
this.processTx = function(tx, verified) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue