TransactionBuilder: less exits
This commit is contained in:
parent
83b2bb5d6a
commit
6826aa312d
1 changed files with 14 additions and 13 deletions
|
@ -144,29 +144,30 @@ function extractFromOutputScript (outputScript, kpPubKey) {
|
||||||
var scriptType = bscript.classifyOutput(outputScript)
|
var scriptType = bscript.classifyOutput(outputScript)
|
||||||
var outputScriptChunks = bscript.decompile(outputScript)
|
var outputScriptChunks = bscript.decompile(outputScript)
|
||||||
|
|
||||||
|
var pubKeys
|
||||||
switch (scriptType) {
|
switch (scriptType) {
|
||||||
case 'pubkeyhash':
|
case 'pubkeyhash':
|
||||||
var pkh1 = outputScriptChunks[2]
|
var pkh1 = outputScriptChunks[2]
|
||||||
var pkh2 = bcrypto.hash160(kpPubKey)
|
var pkh2 = bcrypto.hash160(kpPubKey)
|
||||||
|
|
||||||
if (!bufferEquals(pkh1, pkh2)) throw new Error('privateKey cannot sign for this input')
|
if (!bufferEquals(pkh1, pkh2)) throw new Error('privateKey cannot sign for this input')
|
||||||
|
pubKeys = [kpPubKey]
|
||||||
return {
|
break
|
||||||
pubKeys: [kpPubKey],
|
|
||||||
scriptType: scriptType
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'pubkey':
|
case 'pubkey':
|
||||||
return {
|
pubKeys = outputScriptChunks.slice(0, 1)
|
||||||
pubKeys: outputScriptChunks.slice(0, 1),
|
break
|
||||||
scriptType: scriptType
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'multisig':
|
case 'multisig':
|
||||||
return {
|
pubKeys = outputScriptChunks.slice(1, -2)
|
||||||
pubKeys: outputScriptChunks.slice(1, -2),
|
break
|
||||||
scriptType: scriptType
|
|
||||||
}
|
default: return
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
pubKeys: pubKeys,
|
||||||
|
scriptType: scriptType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue