Browse Source

minor refactoring

hk-custom-address
Wei Lu 11 years ago
parent
commit
c39aa6cb07
  1. 25
      src/wallet.js

25
src/wallet.js

@ -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…
Cancel
Save