Move comments to main check logic
This commit is contained in:
parent
f961724c73
commit
18e7c9de80
2 changed files with 5 additions and 2 deletions
|
@ -7,7 +7,6 @@ const checkRedeemScript = (inputIndex, scriptPubKey, redeemScript) => {
|
||||||
const redeemScriptOutput = payments.p2sh({
|
const redeemScriptOutput = payments.p2sh({
|
||||||
redeem: { output: redeemScript },
|
redeem: { output: redeemScript },
|
||||||
}).output;
|
}).output;
|
||||||
// If a redeemScript is provided, the scriptPubKey must be for that redeemScript
|
|
||||||
if (!scriptPubKey.equals(redeemScriptOutput)) {
|
if (!scriptPubKey.equals(redeemScriptOutput)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Redeem script for input #${inputIndex} doesn't match the scriptPubKey in the prevout`,
|
`Redeem script for input #${inputIndex} doesn't match the scriptPubKey in the prevout`,
|
||||||
|
@ -62,10 +61,12 @@ class Psbt extends bip174_1.Psbt {
|
||||||
if (input.redeemScript) {
|
if (input.redeemScript) {
|
||||||
const prevoutIndex = unsignedTx.ins[inputIndex].index;
|
const prevoutIndex = unsignedTx.ins[inputIndex].index;
|
||||||
const prevout = nonWitnessUtxoTx.outs[prevoutIndex];
|
const prevout = nonWitnessUtxoTx.outs[prevoutIndex];
|
||||||
|
// If a redeemScript is provided, the scriptPubKey must be for that redeemScript
|
||||||
checkRedeemScript(inputIndex, prevout.script, input.redeemScript);
|
checkRedeemScript(inputIndex, prevout.script, input.redeemScript);
|
||||||
}
|
}
|
||||||
} else if (input.witnessUtxo) {
|
} else if (input.witnessUtxo) {
|
||||||
if (input.redeemScript) {
|
if (input.redeemScript) {
|
||||||
|
// If a redeemScript is provided, the scriptPubKey must be for that redeemScript
|
||||||
checkRedeemScript(
|
checkRedeemScript(
|
||||||
inputIndex,
|
inputIndex,
|
||||||
input.witnessUtxo.script,
|
input.witnessUtxo.script,
|
||||||
|
|
|
@ -12,7 +12,6 @@ const checkRedeemScript = (
|
||||||
redeem: { output: redeemScript },
|
redeem: { output: redeemScript },
|
||||||
}).output as Buffer;
|
}).output as Buffer;
|
||||||
|
|
||||||
// If a redeemScript is provided, the scriptPubKey must be for that redeemScript
|
|
||||||
if (!scriptPubKey.equals(redeemScriptOutput)) {
|
if (!scriptPubKey.equals(redeemScriptOutput)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Redeem script for input #${inputIndex} doesn't match the scriptPubKey in the prevout`,
|
`Redeem script for input #${inputIndex} doesn't match the scriptPubKey in the prevout`,
|
||||||
|
@ -70,10 +69,13 @@ export class Psbt extends PsbtBase {
|
||||||
if (input.redeemScript) {
|
if (input.redeemScript) {
|
||||||
const prevoutIndex = unsignedTx.ins[inputIndex].index;
|
const prevoutIndex = unsignedTx.ins[inputIndex].index;
|
||||||
const prevout = nonWitnessUtxoTx.outs[prevoutIndex];
|
const prevout = nonWitnessUtxoTx.outs[prevoutIndex];
|
||||||
|
|
||||||
|
// If a redeemScript is provided, the scriptPubKey must be for that redeemScript
|
||||||
checkRedeemScript(inputIndex, prevout.script, input.redeemScript);
|
checkRedeemScript(inputIndex, prevout.script, input.redeemScript);
|
||||||
}
|
}
|
||||||
} else if (input.witnessUtxo) {
|
} else if (input.witnessUtxo) {
|
||||||
if (input.redeemScript) {
|
if (input.redeemScript) {
|
||||||
|
// If a redeemScript is provided, the scriptPubKey must be for that redeemScript
|
||||||
checkRedeemScript(
|
checkRedeemScript(
|
||||||
inputIndex,
|
inputIndex,
|
||||||
input.witnessUtxo.script,
|
input.witnessUtxo.script,
|
||||||
|
|
Loading…
Reference in a new issue