wallet.outputs[0].output -> wallet.outputs[0].receive
output is overloaded. Considering we have output.spend, output.receive makes sense to me
This commit is contained in:
parent
dbb5681366
commit
e574693594
2 changed files with 8 additions and 8 deletions
|
@ -76,14 +76,14 @@ var Wallet = function (seed, options) {
|
||||||
utxo.forEach(function(uo){
|
utxo.forEach(function(uo){
|
||||||
validateUnspentOutput(uo)
|
validateUnspentOutput(uo)
|
||||||
var o = unspentOutputToOutput(uo)
|
var o = unspentOutputToOutput(uo)
|
||||||
outputs[o.output] = o
|
outputs[o.receive] = o
|
||||||
})
|
})
|
||||||
|
|
||||||
this.outputs = outputs
|
this.outputs = outputs
|
||||||
}
|
}
|
||||||
|
|
||||||
function outputToUnspentOutput(output){
|
function outputToUnspentOutput(output){
|
||||||
var hashAndIndex = output.output.split(":")
|
var hashAndIndex = output.receive.split(":")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hash: hashAndIndex[0],
|
hash: hashAndIndex[0],
|
||||||
|
@ -99,7 +99,7 @@ var Wallet = function (seed, options) {
|
||||||
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
|
||||||
return {
|
return {
|
||||||
output: key,
|
receive: key,
|
||||||
scriptPubKey: o.scriptPubKey,
|
scriptPubKey: o.scriptPubKey,
|
||||||
address: o.address,
|
address: o.address,
|
||||||
value: o.value
|
value: o.value
|
||||||
|
@ -143,7 +143,7 @@ var Wallet = function (seed, options) {
|
||||||
if (isMyAddress(address)) {
|
if (isMyAddress(address)) {
|
||||||
var output = txhash+':'+i
|
var output = txhash+':'+i
|
||||||
me.outputs[output] = {
|
me.outputs[output] = {
|
||||||
output: output,
|
receive: output,
|
||||||
value: txOut.value,
|
value: txOut.value,
|
||||||
address: address,
|
address: address,
|
||||||
scriptPubKey: convert.bytesToHex(txOut.script.buffer) //TODO: txOut.scriptPubKey()
|
scriptPubKey: convert.bytesToHex(txOut.script.buffer) //TODO: txOut.scriptPubKey()
|
||||||
|
@ -226,7 +226,7 @@ var Wallet = function (seed, options) {
|
||||||
: [toOut, halfChangeOut, halfChangeOut]
|
: [toOut, halfChangeOut, halfChangeOut]
|
||||||
|
|
||||||
var tx = new Bitcoin.Transaction({
|
var tx = new Bitcoin.Transaction({
|
||||||
ins: utxo.map(function(x) { return x.output }),
|
ins: utxo.map(function(x) { return x.receive }),
|
||||||
outs: outs
|
outs: outs
|
||||||
})
|
})
|
||||||
this.sign(tx)
|
this.sign(tx)
|
||||||
|
@ -239,7 +239,7 @@ var Wallet = function (seed, options) {
|
||||||
sum = utxo.reduce(function(t,p) { return t + o.value },0);
|
sum = utxo.reduce(function(t,p) { return t + o.value },0);
|
||||||
utxo[changeIndex].value += sum - value - fee;
|
utxo[changeIndex].value += sum - value - fee;
|
||||||
var tx = new Bitcoin.Transaction({
|
var tx = new Bitcoin.Transaction({
|
||||||
ins: utxo.map(function(x) { return x.output }),
|
ins: utxo.map(function(x) { return x.receive }),
|
||||||
outs: outputs
|
outs: outputs
|
||||||
})
|
})
|
||||||
this.sign(tx)
|
this.sign(tx)
|
||||||
|
|
|
@ -168,7 +168,7 @@ describe('Wallet', function() {
|
||||||
describe('getUnspentOutputs', function(){
|
describe('getUnspentOutputs', function(){
|
||||||
it('parses wallet outputs to the expect format', function(){
|
it('parses wallet outputs to the expect format', function(){
|
||||||
wallet.outputs[expectedOutputKey] = {
|
wallet.outputs[expectedOutputKey] = {
|
||||||
output: expectedOutputKey,
|
receive: expectedOutputKey,
|
||||||
scriptPubKey: expectedUtxo[0].scriptPubKey,
|
scriptPubKey: expectedUtxo[0].scriptPubKey,
|
||||||
address: expectedUtxo[0].address,
|
address: expectedUtxo[0].address,
|
||||||
value: expectedUtxo[0].value
|
value: expectedUtxo[0].value
|
||||||
|
@ -275,7 +275,7 @@ describe('Wallet', function() {
|
||||||
var txOut = tx.outs[index]
|
var txOut = tx.outs[index]
|
||||||
var key = convert.bytesToHex(tx.getHash()) + ":" + index
|
var key = convert.bytesToHex(tx.getHash()) + ":" + index
|
||||||
var output = wallet.outputs[key]
|
var output = wallet.outputs[key]
|
||||||
assert.equal(output.output, key)
|
assert.equal(output.receive, key)
|
||||||
assert.equal(output.value, txOut.value)
|
assert.equal(output.value, txOut.value)
|
||||||
assert.equal(output.address, txOut.address)
|
assert.equal(output.address, txOut.address)
|
||||||
assert.equal(output.scriptPubKey, convert.bytesToHex(txOut.script.buffer))
|
assert.equal(output.scriptPubKey, convert.bytesToHex(txOut.script.buffer))
|
||||||
|
|
Loading…
Reference in a new issue