transaction/builder: s/txin/txIn/g
This commit is contained in:
parent
42f2a34b8a
commit
6ed8e15b63
2 changed files with 30 additions and 30 deletions
|
@ -83,7 +83,7 @@ Transaction.fromHex = function(hex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new txin.
|
* Create a new txIn.
|
||||||
*
|
*
|
||||||
* Can be called with any of:
|
* Can be called with any of:
|
||||||
*
|
*
|
||||||
|
@ -122,7 +122,7 @@ Transaction.prototype.addInput = function(hash, index, sequence, script) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new txout.
|
* Create a new txOut.
|
||||||
*
|
*
|
||||||
* Can be called with:
|
* Can be called with:
|
||||||
*
|
*
|
||||||
|
@ -156,19 +156,19 @@ Transaction.prototype.clone = function () {
|
||||||
newTx.version = this.version
|
newTx.version = this.version
|
||||||
newTx.locktime = this.locktime
|
newTx.locktime = this.locktime
|
||||||
|
|
||||||
newTx.ins = this.ins.map(function(txin) {
|
newTx.ins = this.ins.map(function(txIn) {
|
||||||
return {
|
return {
|
||||||
hash: txin.hash,
|
hash: txIn.hash,
|
||||||
index: txin.index,
|
index: txIn.index,
|
||||||
script: txin.script,
|
script: txIn.script,
|
||||||
sequence: txin.sequence
|
sequence: txIn.sequence
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
newTx.outs = this.outs.map(function(txout) {
|
newTx.outs = this.outs.map(function(txOut) {
|
||||||
return {
|
return {
|
||||||
script: txout.script,
|
script: txOut.script,
|
||||||
value: txout.value
|
value: txOut.value
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -205,8 +205,8 @@ Transaction.prototype.hashForSignature = function(inIndex, prevOutScript, hashTy
|
||||||
var hashScript = prevOutScript.without(opcodes.OP_CODESEPARATOR)
|
var hashScript = prevOutScript.without(opcodes.OP_CODESEPARATOR)
|
||||||
|
|
||||||
// Blank out other inputs' signatures
|
// Blank out other inputs' signatures
|
||||||
txTmp.ins.forEach(function(txin) {
|
txTmp.ins.forEach(function(txIn) {
|
||||||
txin.script = Script.EMPTY
|
txIn.script = Script.EMPTY
|
||||||
})
|
})
|
||||||
txTmp.ins[inIndex].script = hashScript
|
txTmp.ins[inIndex].script = hashScript
|
||||||
|
|
||||||
|
@ -280,19 +280,19 @@ Transaction.prototype.toBuffer = function () {
|
||||||
writeUInt32(this.version)
|
writeUInt32(this.version)
|
||||||
writeVarInt(this.ins.length)
|
writeVarInt(this.ins.length)
|
||||||
|
|
||||||
this.ins.forEach(function(txin) {
|
this.ins.forEach(function(txIn) {
|
||||||
writeSlice(txin.hash)
|
writeSlice(txIn.hash)
|
||||||
writeUInt32(txin.index)
|
writeUInt32(txIn.index)
|
||||||
writeVarInt(txin.script.buffer.length)
|
writeVarInt(txIn.script.buffer.length)
|
||||||
writeSlice(txin.script.buffer)
|
writeSlice(txIn.script.buffer)
|
||||||
writeUInt32(txin.sequence)
|
writeUInt32(txIn.sequence)
|
||||||
})
|
})
|
||||||
|
|
||||||
writeVarInt(this.outs.length)
|
writeVarInt(this.outs.length)
|
||||||
this.outs.forEach(function(txout) {
|
this.outs.forEach(function(txOut) {
|
||||||
writeUInt64(txout.value)
|
writeUInt64(txOut.value)
|
||||||
writeVarInt(txout.script.buffer.length)
|
writeVarInt(txOut.script.buffer.length)
|
||||||
writeSlice(txout.script.buffer)
|
writeSlice(txOut.script.buffer)
|
||||||
})
|
})
|
||||||
|
|
||||||
writeUInt32(this.locktime)
|
writeUInt32(this.locktime)
|
||||||
|
|
|
@ -20,26 +20,26 @@ TransactionBuilder.fromTransaction = function(transaction) {
|
||||||
var txb = new TransactionBuilder()
|
var txb = new TransactionBuilder()
|
||||||
|
|
||||||
// Extract/add inputs
|
// Extract/add inputs
|
||||||
transaction.ins.forEach(function(txin) {
|
transaction.ins.forEach(function(txIn) {
|
||||||
txb.addInput(txin.hash, txin.index, txin.sequence)
|
txb.addInput(txIn.hash, txIn.index, txIn.sequence)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Extract/add outputs
|
// Extract/add outputs
|
||||||
transaction.outs.forEach(function(txout) {
|
transaction.outs.forEach(function(txOut) {
|
||||||
txb.addOutput(txout.script, txout.value)
|
txb.addOutput(txOut.script, txOut.value)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Extract/add signatures
|
// Extract/add signatures
|
||||||
transaction.ins.forEach(function(txin, i) {
|
transaction.ins.forEach(function(txIn, i) {
|
||||||
// Ignore empty scripts
|
// Ignore empty scripts
|
||||||
if (txin.script.buffer.length === 0) return
|
if (txIn.script.buffer.length === 0) return
|
||||||
|
|
||||||
assert(!Array.prototype.every.call(txin.hash, function(x) {
|
assert(!Array.prototype.every.call(txIn.hash, function(x) {
|
||||||
return x === 0
|
return x === 0
|
||||||
}), 'coinbase inputs not supported')
|
}), 'coinbase inputs not supported')
|
||||||
|
|
||||||
var redeemScript
|
var redeemScript
|
||||||
var scriptSig = txin.script
|
var scriptSig = txIn.script
|
||||||
var scriptType = scripts.classifyInput(scriptSig)
|
var scriptType = scripts.classifyInput(scriptSig)
|
||||||
|
|
||||||
// Re-classify if P2SH
|
// Re-classify if P2SH
|
||||||
|
|
Loading…
Reference in a new issue