Prefer buf1.equals(buf2) over Buffer.compare(buf1, buf2) !== 0
This commit is contained in:
parent
95b4a2806d
commit
f961724c73
2 changed files with 4 additions and 4 deletions
|
@ -8,7 +8,7 @@ const checkRedeemScript = (inputIndex, scriptPubKey, redeemScript) => {
|
||||||
redeem: { output: redeemScript },
|
redeem: { output: redeemScript },
|
||||||
}).output;
|
}).output;
|
||||||
// If a redeemScript is provided, the scriptPubKey must be for that redeemScript
|
// If a redeemScript is provided, the scriptPubKey must be for that redeemScript
|
||||||
if (Buffer.compare(scriptPubKey, redeemScriptOutput) !== 0) {
|
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`,
|
||||||
);
|
);
|
||||||
|
@ -54,7 +54,7 @@ class Psbt extends bip174_1.Psbt {
|
||||||
const prevoutHash = unsignedTx.ins[inputIndex].hash;
|
const prevoutHash = unsignedTx.ins[inputIndex].hash;
|
||||||
const utxoHash = nonWitnessUtxoTx.getHash();
|
const utxoHash = nonWitnessUtxoTx.getHash();
|
||||||
// If a non-witness UTXO is provided, its hash must match the hash specified in the prevout
|
// If a non-witness UTXO is provided, its hash must match the hash specified in the prevout
|
||||||
if (Buffer.compare(prevoutHash, utxoHash) !== 0) {
|
if (!prevoutHash.equals(utxoHash)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Non-witness UTXO hash for input #${inputIndex} doesn't match the hash specified in the prevout`,
|
`Non-witness UTXO hash for input #${inputIndex} doesn't match the hash specified in the prevout`,
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,7 +13,7 @@ const checkRedeemScript = (
|
||||||
}).output as Buffer;
|
}).output as Buffer;
|
||||||
|
|
||||||
// If a redeemScript is provided, the scriptPubKey must be for that redeemScript
|
// If a redeemScript is provided, the scriptPubKey must be for that redeemScript
|
||||||
if (Buffer.compare(scriptPubKey, redeemScriptOutput) !== 0) {
|
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`,
|
||||||
);
|
);
|
||||||
|
@ -61,7 +61,7 @@ export class Psbt extends PsbtBase {
|
||||||
const utxoHash = nonWitnessUtxoTx.getHash();
|
const utxoHash = nonWitnessUtxoTx.getHash();
|
||||||
|
|
||||||
// If a non-witness UTXO is provided, its hash must match the hash specified in the prevout
|
// If a non-witness UTXO is provided, its hash must match the hash specified in the prevout
|
||||||
if (Buffer.compare(prevoutHash, utxoHash) !== 0) {
|
if (!prevoutHash.equals(utxoHash)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Non-witness UTXO hash for input #${inputIndex} doesn't match the hash specified in the prevout`,
|
`Non-witness UTXO hash for input #${inputIndex} doesn't match the hash specified in the prevout`,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue