SerializeSigData: operations on arrays before final pushAll (scriptSig)
This commit is contained in:
parent
c60a6418b5
commit
09bdc1deee
@ -408,13 +408,11 @@ function serializeStandard (outputType, signatures, publicKeys) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function serializeSigData (signatures, publicKeys, scriptPubKey, redeemScript, witnessScript) {
|
function serializeSigData (signatures, publicKeys, scriptPubKey, redeemScript, witnessScript) {
|
||||||
var sigData = {
|
var scriptChunks = []
|
||||||
scriptSig: EMPTY_SCRIPT,
|
var witnessChunks = []
|
||||||
witness: []
|
|
||||||
}
|
|
||||||
var type = scriptPubKey.type
|
var type = scriptPubKey.type
|
||||||
if (scriptPubKey.canSign) {
|
if (scriptPubKey.canSign) {
|
||||||
sigData.scriptSig = pushAll(serializeStandard(type, signatures, publicKeys))
|
scriptChunks = serializeStandard(type, signatures, publicKeys)
|
||||||
}
|
}
|
||||||
|
|
||||||
var p2sh = false
|
var p2sh = false
|
||||||
@ -425,29 +423,32 @@ function serializeSigData (signatures, publicKeys, scriptPubKey, redeemScript, w
|
|||||||
p2sh = true
|
p2sh = true
|
||||||
type = redeemScript.type
|
type = redeemScript.type
|
||||||
if (redeemScript.canSign) {
|
if (redeemScript.canSign) {
|
||||||
sigData.scriptSig = pushAll(serializeStandard(type, signatures, publicKeys))
|
scriptChunks = serializeStandard(type, signatures, publicKeys)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === bscript.types.P2WPKH) {
|
if (type === bscript.types.P2WPKH) {
|
||||||
sigData.witness = serializeStandard(bscript.types.P2PKH, signatures, publicKeys)
|
witnessChunks = serializeStandard(bscript.types.P2PKH, signatures, publicKeys)
|
||||||
} else if (type === bscript.types.P2WSH) {
|
} else if (type === bscript.types.P2WSH) {
|
||||||
if (witnessScript === undefined) {
|
if (witnessScript === undefined) {
|
||||||
throw new Error('Witness script not provided')
|
throw new Error('Witness script not provided')
|
||||||
}
|
}
|
||||||
type = witnessScript.type
|
type = witnessScript.type
|
||||||
if (witnessScript.canSign) {
|
if (witnessScript.canSign) {
|
||||||
sigData.scriptSig = EMPTY_SCRIPT
|
scriptChunks = []
|
||||||
sigData.witness = serializeStandard(type, signatures, publicKeys)
|
witnessChunks = serializeStandard(type, signatures, publicKeys)
|
||||||
sigData.witness.push(witnessScript.script)
|
witnessChunks.push(witnessScript.script);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p2sh) {
|
if (p2sh) {
|
||||||
sigData.scriptSig = bscript.scriptHash.input.encode(sigData.scriptSig, redeemScript.script)
|
scriptChunks.push(redeemScript.script)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sigData
|
return {
|
||||||
|
scriptSig: pushAll(scriptChunks),
|
||||||
|
witness: witnessChunks
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InSigner.prototype.serializeSigData = function () {
|
InSigner.prototype.serializeSigData = function () {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user