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 = []
|
var utxo = []
|
||||||
|
|
||||||
for(var key in this.outputs){
|
for(var key in this.outputs){
|
||||||
var hashAndIndex = key.split(":")
|
utxo.push(outputToUnspentOutput(this.outputs[key]))
|
||||||
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
|
return utxo
|
||||||
|
@ -92,6 +82,19 @@ var Wallet = function (seed, options) {
|
||||||
this.outputs = outputs
|
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) {
|
function unspentOutputToOutput(o) {
|
||||||
var hash = o.hash || convert.reverseEndian(o.hashLittleEndian)
|
var hash = o.hash || convert.reverseEndian(o.hashLittleEndian)
|
||||||
var key = hash + ":" + o.outputIndex
|
var key = hash + ":" + o.outputIndex
|
||||||
|
|
Loading…
Add table
Reference in a new issue