minor refactoring
This commit is contained in:
parent
01dc34d720
commit
c39aa6cb07
1 changed files with 14 additions and 11 deletions
|
@ -64,17 +64,7 @@ var Wallet = function (seed, options) {
|
|||
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
|
||||
})
|
||||
utxo.push(outputToUnspentOutput(this.outputs[key]))
|
||||
}
|
||||
|
||||
return utxo
|
||||
|
@ -92,6 +82,19 @@ var Wallet = function (seed, options) {
|
|||
this.outputs = outputs
|
||||
}
|
||||
|
||||
function outputToUnspentOutput(output){
|
||||
var hashAndIndex = output.output.split(":")
|
||||
|
||||
return {
|
||||
hash: hashAndIndex[0],
|
||||
hashLittleEndian: convert.reverseEndian(hashAndIndex[0]),
|
||||
outputIndex: parseInt(hashAndIndex[1]),
|
||||
scriptPubKey: output.scriptPubKey,
|
||||
address: output.address,
|
||||
value: output.value
|
||||
}
|
||||
}
|
||||
|
||||
function unspentOutputToOutput(o) {
|
||||
var hash = o.hash || convert.reverseEndian(o.hashLittleEndian)
|
||||
var key = hash + ":" + o.outputIndex
|
||||
|
|
Loading…
Add table
Reference in a new issue