Socket
Socket
Sign inDemoInstall

bitcoinjs-lib

Package Overview
Dependencies
49
Maintainers
3
Versions
87
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.1.3 to 5.1.4

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# 5.1.4
__changed__
- `Psbt` inputs using segwit scripts can now work with nonWitnessUtxo as well as the original witnessUtxo. The reasoning for this is that nonWitnessUtxo has all the information contained in the witnessUtxo, so rejecting signing even though we have all the info we need is unnecessary. Trying to sign a non-segwit script with a witnessUtxo will still throw an Error as it should.
# 5.1.3

@@ -2,0 +6,0 @@ __changed__

4

package.json
{
"name": "bitcoinjs-lib",
"version": "5.1.3",
"version": "5.1.4",
"description": "Client-side Bitcoin JavaScript library",

@@ -50,3 +50,3 @@ "main": "./src/index.js",

"bech32": "^1.1.2",
"bip174": "^1.0.0",
"bip174": "^1.0.1",
"bip32": "^2.0.4",

@@ -53,0 +53,0 @@ "bip66": "^1.1.0",

@@ -818,9 +818,25 @@ 'use strict';

}
if (isP2WPKH(script) || isP2WSHScript(script)) {
throw new Error(
`Input #${inputIndex} has nonWitnessUtxo but segwit script: ` +
`${script.toString('hex')}`,
if (isP2WSHScript(script)) {
if (!input.witnessScript)
throw new Error('Segwit input needs witnessScript if not P2WPKH');
checkWitnessScript(inputIndex, script, input.witnessScript);
hash = unsignedTx.hashForWitnessV0(
inputIndex,
input.witnessScript,
prevout.value,
sighashType,
);
script = input.witnessScript;
} else if (isP2WPKH(script)) {
// P2WPKH uses the P2PKH template for prevoutScript when signing
const signingScript = payments.p2pkh({ hash: script.slice(2) }).output;
hash = unsignedTx.hashForWitnessV0(
inputIndex,
signingScript,
prevout.value,
sighashType,
);
} else {
hash = unsignedTx.hashForSignature(inputIndex, script, sighashType);
}
hash = unsignedTx.hashForSignature(inputIndex, script, sighashType);
} else if (input.witnessUtxo) {

@@ -931,7 +947,10 @@ let _script; // so we don't shadow the `let script` above

};
if (input.nonWitnessUtxo) {
if (input.redeemScript) {
res.isP2SH = true;
res.script = input.redeemScript;
} else {
res.isP2SH = !!input.redeemScript;
res.isP2WSH = !!input.witnessScript;
if (input.witnessScript) {
res.script = input.witnessScript;
} else if (input.redeemScript) {
res.script = input.redeemScript;
} else {
if (input.nonWitnessUtxo) {
const nonWitnessUtxoTx = nonWitnessUtxoTxFromCache(

@@ -944,18 +963,8 @@ cache,

res.script = nonWitnessUtxoTx.outs[prevoutIndex].script;
} else if (input.witnessUtxo) {
res.script = input.witnessUtxo.script;
}
} else if (input.witnessUtxo) {
}
if (input.witnessScript || isP2WPKH(res.script)) {
res.isSegwit = true;
res.isP2SH = !!input.redeemScript;
res.isP2WSH = !!input.witnessScript;
if (input.witnessScript) {
res.script = input.witnessScript;
} else if (input.redeemScript) {
res.script = payments.p2wpkh({
hash: input.redeemScript.slice(2),
}).output;
} else {
res.script = payments.p2wpkh({
hash: input.witnessUtxo.script.slice(2),
}).output;
}
}

@@ -962,0 +971,0 @@ return res;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc