Browse Source

wallet: rename utxo.receive to utxo.from

hk-custom-address
Wei Lu 11 years ago
parent
commit
7e31668b69
  1. 10
      src/wallet.js
  2. 4
      test/wallet.js

10
src/wallet.js

@ -77,14 +77,14 @@ function Wallet(seed, network) {
utxo.forEach(function(uo){ utxo.forEach(function(uo){
validateUnspentOutput(uo) validateUnspentOutput(uo)
var o = unspentOutputToOutput(uo) var o = unspentOutputToOutput(uo)
outputs[o.receive] = o outputs[o.from] = o
}) })
this.outputs = outputs this.outputs = outputs
} }
function outputToUnspentOutput(output){ function outputToUnspentOutput(output){
var hashAndIndex = output.receive.split(":") var hashAndIndex = output.from.split(":")
return { return {
hash: hashAndIndex[0], hash: hashAndIndex[0],
@ -99,7 +99,7 @@ function Wallet(seed, network) {
var hash = o.hash var hash = o.hash
var key = hash + ":" + o.outputIndex var key = hash + ":" + o.outputIndex
return { return {
receive: key, from: key,
address: o.address, address: o.address,
value: o.value, value: o.value,
pending: o.pending pending: o.pending
@ -159,7 +159,7 @@ function Wallet(seed, network) {
var output = txid + ':' + i var output = txid + ':' + i
me.outputs[output] = { me.outputs[output] = {
receive: output, from: output,
value: txOut.value, value: txOut.value,
address: address, address: address,
pending: isPending pending: isPending
@ -194,7 +194,7 @@ function Wallet(seed, network) {
var utxo = utxos[i] var utxo = utxos[i]
addresses.push(utxo.address) addresses.push(utxo.address)
var outpoint = utxo.receive.split(':') var outpoint = utxo.from.split(':')
tx.addInput(outpoint[0], parseInt(outpoint[1])) tx.addInput(outpoint[0], parseInt(outpoint[1]))
var fee = fixedFee == undefined ? estimateFeePadChangeOutput(tx) : fixedFee var fee = fixedFee == undefined ? estimateFeePadChangeOutput(tx) : fixedFee

4
test/wallet.js

@ -184,7 +184,7 @@ describe('Wallet', function() {
function addUtxoToOutput(utxo){ function addUtxoToOutput(utxo){
var key = utxo.hash + ":" + utxo.outputIndex var key = utxo.hash + ":" + utxo.outputIndex
wallet.outputs[key] = { wallet.outputs[key] = {
receive: key, from: key,
address: utxo.address, address: utxo.address,
value: utxo.value, value: utxo.value,
pending: utxo.pending pending: utxo.pending
@ -352,7 +352,7 @@ describe('Wallet', function() {
var txOut = tx.outs[index] var txOut = tx.outs[index]
var key = tx.getId() + ":" + index var key = tx.getId() + ":" + index
var output = wallet.outputs[key] var output = wallet.outputs[key]
assert.equal(output.receive, key) assert.equal(output.from, key)
assert.equal(output.value, txOut.value) assert.equal(output.value, txOut.value)
assert.equal(output.pending, pending) assert.equal(output.pending, pending)

Loading…
Cancel
Save