@caravan/psbt 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -94024,11 +94024,6 @@ var getHashForSignature = (psbt, inputIndex, inputAmount, sigHashFlag = import_b
94024
94024
  throw new Error("No redeem or witness script found for input.");
94025
94025
  };
94026
94026
  function translatePSBT(network, addressType, psbt, signingKeyDetails) {
94027
- if (addressType !== import_bitcoin4.P2SH) {
94028
- throw new Error(
94029
- "Unsupported addressType -- only P2SH is supported right now"
94030
- );
94031
- }
94032
94027
  const localPSBT = autoLoadPSBT(psbt, { network: (0, import_bitcoin4.networkData)(network) });
94033
94028
  if (localPSBT === null)
94034
94029
  return null;
@@ -94051,12 +94046,17 @@ function translatePSBT(network, addressType, psbt, signingKeyDetails) {
94051
94046
  function getUnchainedInputsFromPSBT(network, addressType, psbt) {
94052
94047
  return psbt.txInputs.map((input, index) => {
94053
94048
  const dataInput = psbt.data.inputs[index];
94049
+ const spendingScript = dataInput.witnessScript || dataInput.redeemScript;
94050
+ if (!dataInput?.nonWitnessUtxo && addressType === import_bitcoin4.P2WSH) {
94051
+ throw new Error(`Non-witness UTXO now required for P2WSH
94052
+ inputs to protect against large fee attack`);
94053
+ }
94054
94054
  const fundingTxHex = dataInput.nonWitnessUtxo.toString("hex");
94055
94055
  const fundingTx = import_bitcoinjs_lib_v63.Transaction.fromHex(fundingTxHex);
94056
94056
  const multisig = (0, import_bitcoin4.generateMultisigFromHex)(
94057
94057
  network,
94058
94058
  addressType,
94059
- dataInput.redeemScript.toString("hex")
94059
+ spendingScript.toString("hex")
94060
94060
  );
94061
94061
  return {
94062
94062
  amountSats: fundingTx.outs[input.index].value,
package/dist/index.mjs CHANGED
@@ -1241,6 +1241,7 @@ import {
1241
1241
  multisigSignatureBuffer,
1242
1242
  networkData,
1243
1243
  P2SH as P2SH2,
1244
+ P2WSH as P2WSH2,
1244
1245
  signatureNoSighashType
1245
1246
  } from "@caravan/bitcoin";
1246
1247
  import { Psbt as Psbt3, Transaction } from "bitcoinjs-lib-v6";
@@ -94002,11 +94003,6 @@ var getHashForSignature = (psbt, inputIndex, inputAmount, sigHashFlag = Transact
94002
94003
  throw new Error("No redeem or witness script found for input.");
94003
94004
  };
94004
94005
  function translatePSBT(network, addressType, psbt, signingKeyDetails) {
94005
- if (addressType !== P2SH2) {
94006
- throw new Error(
94007
- "Unsupported addressType -- only P2SH is supported right now"
94008
- );
94009
- }
94010
94006
  const localPSBT = autoLoadPSBT(psbt, { network: networkData(network) });
94011
94007
  if (localPSBT === null)
94012
94008
  return null;
@@ -94029,12 +94025,17 @@ function translatePSBT(network, addressType, psbt, signingKeyDetails) {
94029
94025
  function getUnchainedInputsFromPSBT(network, addressType, psbt) {
94030
94026
  return psbt.txInputs.map((input, index) => {
94031
94027
  const dataInput = psbt.data.inputs[index];
94028
+ const spendingScript = dataInput.witnessScript || dataInput.redeemScript;
94029
+ if (!dataInput?.nonWitnessUtxo && addressType === P2WSH2) {
94030
+ throw new Error(`Non-witness UTXO now required for P2WSH
94031
+ inputs to protect against large fee attack`);
94032
+ }
94032
94033
  const fundingTxHex = dataInput.nonWitnessUtxo.toString("hex");
94033
94034
  const fundingTx = Transaction.fromHex(fundingTxHex);
94034
94035
  const multisig = generateMultisigFromHex(
94035
94036
  network,
94036
94037
  addressType,
94037
- dataInput.redeemScript.toString("hex")
94038
+ spendingScript.toString("hex")
94038
94039
  );
94039
94040
  return {
94040
94041
  amountSats: fundingTx.outs[input.index].value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caravan/psbt",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "typescript library for working with PSBTs",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -51,6 +51,7 @@
51
51
  "author": "unchained capital",
52
52
  "license": "ISC",
53
53
  "devDependencies": {
54
+ "@caravan/bip32": "*",
54
55
  "@caravan/eslint-config": "*",
55
56
  "@caravan/multisig": "*",
56
57
  "@caravan/typescript-config": "*",