@exodus/bitcoin-api 4.15.4 → 4.15.5

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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.15.5](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@4.15.4...@exodus/bitcoin-api@4.15.5) (2026-06-02)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+
12
+ * fix: restrict unsafe non-segwit signing to internal LTC PSBTs (#8172)
13
+
14
+
15
+
6
16
  ## [4.15.4](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@4.15.3...@exodus/bitcoin-api@4.15.4) (2026-05-28)
7
17
 
8
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/bitcoin-api",
3
- "version": "4.15.4",
3
+ "version": "4.15.5",
4
4
  "description": "Bitcoin transaction and fee monitors, RPC with the blockchain node, other networking code.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -63,5 +63,5 @@
63
63
  "type": "git",
64
64
  "url": "git+https://github.com/ExodusMovement/assets.git"
65
65
  },
66
- "gitHead": "a2a294de9468382e1c3bbdebf6db6eea2bea4b1c"
66
+ "gitHead": "58cae1e2c4b158a7eb55b8817ea23f26583ae1f1"
67
67
  }
package/src/move-funds.js CHANGED
@@ -162,6 +162,7 @@ export const moveFundsFactory = ({
162
162
  },
163
163
  txMeta: {
164
164
  addressPathsMap: utxos.getAddressPathsMap(),
165
+ psbtOrigin: 'internal',
165
166
  },
166
167
  }
167
168
  const nonWitnessTxs = await getNonWitnessTxs(
package/src/psbt-utils.js CHANGED
@@ -118,10 +118,9 @@ export const createPsbtToUnsignedTx =
118
118
  }
119
119
 
120
120
  /**
121
- * Temporarily turns on __UNSAFE_SIGN_NONSEGWIT so we can sign or validate PSBTs
122
- * whose legacy inputs are missing nonWitnessUtxo.
121
+ * Temporarily sets __UNSAFE_SIGN_NONSEGWIT for explicitly allowed internal fallbacks.
123
122
  */
124
- export async function withUnsafeNonSegwit({ psbt, fn, unsafe = true }) {
123
+ export async function withUnsafeNonSegwit({ psbt, fn, unsafe = false }) {
125
124
  const cache = psbt.__CACHE
126
125
  const prevValue = cache.__UNSAFE_SIGN_NONSEGWIT
127
126
  cache.__UNSAFE_SIGN_NONSEGWIT = unsafe
@@ -339,6 +339,7 @@ async function createUnsignedTx({
339
339
  Transaction,
340
340
  })
341
341
 
342
+ result.txMeta.psbtOrigin = 'internal'
342
343
  result.txData.psbtBuffer = psbt.toBuffer()
343
344
  }
344
345
 
@@ -14,6 +14,7 @@ export function createSignWithWallet({
14
14
  coinInfo,
15
15
  getKeyIdentifier,
16
16
  getPrivateKeyFromMap,
17
+ allowUnsafeNonSegwit = false,
17
18
  }) {
18
19
  const getKeyWithMetadata = createGetKeyWithMetadata({
19
20
  signer,
@@ -90,6 +91,7 @@ export function createSignWithWallet({
90
91
  await withUnsafeNonSegwit({
91
92
  psbt,
92
93
  fn: () => Promise.all(signingPromises.map((sign) => sign())),
94
+ unsafe: allowUnsafeNonSegwit,
93
95
  })
94
96
  }
95
97
  }
@@ -12,6 +12,7 @@ export const signTxFactory = ({
12
12
  network,
13
13
  getKeyIdentifier,
14
14
  getPrivateKeyFromMap,
15
+ allowUnsafeNonSegwitSigning = false,
15
16
  Psbt = DefaultPsbt,
16
17
  Transaction = DefaultTransaction,
17
18
  }) => {
@@ -39,6 +40,8 @@ export const signTxFactory = ({
39
40
  const psbt = prepareForSigning({ unsignedTx })
40
41
 
41
42
  const inputsToSign = unsignedTx.txMeta.inputsToSign || unsignedTx.txData.inputs
43
+ const allowUnsafeNonSegwit =
44
+ allowUnsafeNonSegwitSigning && unsignedTx.txMeta.psbtOrigin === 'internal'
42
45
  const signWithWallet = createSignWithWallet({
43
46
  signer,
44
47
  hdkeys,
@@ -48,6 +51,7 @@ export const signTxFactory = ({
48
51
  addressPathsMap,
49
52
  coinInfo,
50
53
  network,
54
+ allowUnsafeNonSegwit,
51
55
  getKeyIdentifier: (args) => {
52
56
  assert(
53
57
  !('accountIndex' in args) || args.accountIndex === accountIndex,
@@ -130,9 +130,7 @@ function createPsbtFromTxData({
130
130
  if (canParseTx(Transaction, rawTxBuffer)) {
131
131
  txIn.nonWitnessUtxo = rawTxBuffer
132
132
  } else {
133
- // temp fix for https://exodusio.slack.com/archives/CP202D90Q/p1671014704829939 until bitcoinjs could parse a mweb tx without failing
134
- console.warn(`Setting psbt.__CACHE.__UNSAFE_SIGN_NONSEGWIT = true for asset ${assetName}`)
135
- psbt.__CACHE.__UNSAFE_SIGN_NONSEGWIT = true
133
+ console.warn(`Falling back to witnessUtxo for unparseable previous tx on ${assetName}`)
136
134
  txIn.witnessUtxo = {
137
135
  value: normalizeWitnessUtxoValue(value),
138
136
  script: Buffer.from(script, 'hex'),