@exodus/bitcoin-api 5.2.2 → 5.2.3

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,15 @@
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
+ ## [5.2.3](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@5.2.2...@exodus/bitcoin-api@5.2.3) (2026-11-27)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **bitcoin-api:** require ancestor fee data before chaining ([#9453](https://github.com/ExodusMovement/assets/issues/9453)) ([cb00b1e](https://github.com/ExodusMovement/assets/commit/cb00b1e65e07b19817e795aac329afff696a7dca))
12
+
13
+
14
+
6
15
  ## [5.2.2](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@5.2.1...@exodus/bitcoin-api@5.2.2) (2026-11-26)
7
16
 
8
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/bitcoin-api",
3
- "version": "5.2.2",
3
+ "version": "5.2.3",
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",
@@ -60,5 +60,5 @@
60
60
  "type": "git",
61
61
  "url": "git+https://github.com/ExodusMovement/assets.git"
62
62
  },
63
- "gitHead": "ee68ceadf6392aa8c2ff2a8ae2c6a7d7600e9ad7"
63
+ "gitHead": "de6c00cd6c874087f5998f1ea2970017dbe4c640"
64
64
  }
package/src/errors.js CHANGED
@@ -110,6 +110,11 @@ export const BTC_ERRORS = createSendErrorTable(3100, {
110
110
  hint: safeString`The transaction was sent but could not be saved, check your history before sending again`,
111
111
  action: 'check-history',
112
112
  },
113
+ ANCESTOR_DATA_UNAVAILABLE: {
114
+ code: 'EXOD-3167',
115
+ hint: safeString`Transaction fee data is not ready yet, please try again shortly`,
116
+ action: 'retry-later',
117
+ },
113
118
  UNKNOWN_SEND_FAILURE: {
114
119
  code: 'EXOD-3199',
115
120
  hint: safeString`Transaction failed, try again or contact support`,
@@ -4,6 +4,7 @@ import assert from 'minimalistic-assert'
4
4
  import { findUnconfirmedSentRbfTxs } from '../tx-utils.js'
5
5
  import { getUnconfirmedTxAncestorMap } from '../unconfirmed-ancestor-data.js'
6
6
  import { getUsableUtxos, getUtxos, isUtxoConfirmed } from '../utxos-utils.js'
7
+ import { hasUnconfirmedAncestorData } from './fee-utils.js'
7
8
  import { selectUtxos } from './utxo-selector.js'
8
9
 
9
10
  export const ASSET_NAMES = ['bitcoin', 'bitcoinregtest', 'bitcointestnet']
@@ -126,9 +127,12 @@ const _canBumpTx = ({
126
127
  isBumpTx: true,
127
128
  })
128
129
 
129
- return selectedUtxos?.size
130
- ? { bumpType: BumpType.CPFP, bumpFee: fee }
131
- : { errorMessage: 'insufficient funds' }
130
+ if (!selectedUtxos?.size) return { errorMessage: 'insufficient funds' }
131
+ if (!hasUnconfirmedAncestorData({ asset, utxos: selectedUtxos, unconfirmedTxAncestor })) {
132
+ return { errorMessage: 'ancestor data not loaded' }
133
+ }
134
+
135
+ return { bumpType: BumpType.CPFP, bumpFee: fee }
132
136
  }
133
137
 
134
138
  const validateIsNumber = (number, name) => {
@@ -5,13 +5,23 @@ import assert from 'minimalistic-assert'
5
5
  import { resolveExtraFeeOfTx } from '../unconfirmed-ancestor-data.js'
6
6
  import { isUtxoConfirmed } from '../utxos-utils.js'
7
7
 
8
+ const ancestorFeeAssets = new Set(['bitcoin', 'bitcointestnet', 'bitcoinregtest'])
9
+
10
+ // The monitor rebuilds this in-memory cache, so data can be missing after a restart or failed fetch.
11
+ export function hasUnconfirmedAncestorData({ asset, utxos, unconfirmedTxAncestor }) {
12
+ return (
13
+ !ancestorFeeAssets.has(asset.name) ||
14
+ utxos.toArray().every((utxo) => isUtxoConfirmed(utxo) || unconfirmedTxAncestor[utxo.txId])
15
+ )
16
+ }
17
+
8
18
  export const isHex = (s) => typeof s === 'string' && /^[\da-f]+$/.test(s.toLowerCase())
9
19
 
10
20
  export function getExtraFee({ asset, inputs, feePerKB, unconfirmedTxAncestor }) {
11
21
  let extraFee = 0
12
22
  // Add extra fee to unconfirmed bitcoin utxos to allow transaction to CPFP ancestors
13
23
  if (
14
- ['bitcoin', 'bitcointestnet', 'bitcoinregtest'].includes(asset.name) &&
24
+ ancestorFeeAssets.has(asset.name) &&
15
25
  (inputs instanceof UtxoCollection || !Array.isArray(inputs))
16
26
  ) {
17
27
  const feeRate = feePerKB.toBaseNumber() / 1000
@@ -5,7 +5,7 @@ import assert from 'minimalistic-assert'
5
5
 
6
6
  import { getChangeDustValue } from '../dust.js'
7
7
  import { setBtcErrorCode, toBtcSendError } from '../errors.js'
8
- import { parseCurrency, serializeCurrency } from '../fee/fee-utils.js'
8
+ import { hasUnconfirmedAncestorData, parseCurrency, serializeCurrency } from '../fee/fee-utils.js'
9
9
  import { selectUtxos } from '../fee/utxo-selector.js'
10
10
  import { createPsbtWithMetadata } from '../psbt-builder.js'
11
11
  import { findUnconfirmedSentRbfTxs } from '../tx-utils.js'
@@ -496,6 +496,17 @@ const transferHandler = {
496
496
  selectedUtxos = selectedUtxos.union(replaceTxInputUtxos)
497
497
  }
498
498
 
499
+ if (
500
+ !replaceTx &&
501
+ !hasUnconfirmedAncestorData({
502
+ asset,
503
+ utxos: selectedUtxos,
504
+ unconfirmedTxAncestor: context.unconfirmedTxAncestor,
505
+ })
506
+ ) {
507
+ throw setBtcErrorCode(new Error('Ancestor data not loaded'), 'ANCESTOR_DATA_UNAVAILABLE')
508
+ }
509
+
499
510
  const addressPathsMap = selectedUtxos.getAddressPathsMap()
500
511
 
501
512
  // Create inputs
@@ -4,6 +4,7 @@ import lodash from 'lodash'
4
4
  import assert from 'minimalistic-assert'
5
5
  import ms from 'ms'
6
6
 
7
+ import { hasUnconfirmedAncestorData } from '../fee/fee-utils.js'
7
8
  import MempoolWSClient from '../insight-api-client/mempool-ws-client.js'
8
9
  import {
9
10
  normalizeInsightConfig,
@@ -11,7 +12,11 @@ import {
11
12
  toWSUrl,
12
13
  } from '../insight-api-client/util.js'
13
14
  import InsightWSClient from '../insight-api-client/ws.js'
14
- import { resolveUnconfirmedAncestorData } from '../unconfirmed-ancestor-data.js'
15
+ import {
16
+ getUnconfirmedTxAncestorMap,
17
+ resolveUnconfirmedAncestorData,
18
+ } from '../unconfirmed-ancestor-data.js'
19
+ import { getUtxos } from '../utxos-utils.js'
15
20
  import { BitcoinMonitorScanner } from './bitcoin-monitor-scanner.js'
16
21
 
17
22
  const { isEmpty, isEqual } = lodash
@@ -305,13 +310,24 @@ export class Monitor extends BaseMonitor {
305
310
  })
306
311
  }
307
312
 
308
- // Move to after tick
309
- if (utxos && ['bitcoin', 'bitcoinregtest', 'bitcointestnet'].includes(assetName)) {
310
- const unconfirmedTxAncestor = await resolveUnconfirmedAncestorData({
311
- utxos,
312
- insightClient: this.#insightClient,
313
- })
314
- newData.mem = { unconfirmedTxAncestor }
313
+ if (['bitcoin', 'bitcoinregtest', 'bitcointestnet'].includes(assetName)) {
314
+ const accountState = await aci.getAccountState({ assetName, walletAccount })
315
+ const currentUtxos = utxos || getUtxos({ asset: this.asset, accountState })
316
+ // Retry missing ancestor data even when the scanner reports no UTXO changes.
317
+ if (
318
+ utxos ||
319
+ !hasUnconfirmedAncestorData({
320
+ asset: this.asset,
321
+ utxos: currentUtxos,
322
+ unconfirmedTxAncestor: getUnconfirmedTxAncestorMap({ accountState }),
323
+ })
324
+ ) {
325
+ const unconfirmedTxAncestor = await resolveUnconfirmedAncestorData({
326
+ utxos: currentUtxos,
327
+ insightClient: this.#insightClient,
328
+ })
329
+ newData.mem = { unconfirmedTxAncestor }
330
+ }
315
331
  }
316
332
 
317
333
  await aci.updateAccountState({
@@ -5,6 +5,7 @@ import lodash from 'lodash' // mockable in tests
5
5
  import assert from 'minimalistic-assert'
6
6
 
7
7
  import { setBtcErrorCode, toBtcSendError } from '../errors.js'
8
+ import { hasUnconfirmedAncestorData } from '../fee/fee-utils.js'
8
9
  import { selectUtxos } from '../fee/utxo-selector.js'
9
10
  import { findUnconfirmedSentRbfTxs } from '../tx-utils.js'
10
11
  import { getUnconfirmedTxAncestorMap } from '../unconfirmed-ancestor-data.js'
@@ -70,6 +71,10 @@ export const getCreateBatchTransaction = ({
70
71
  throw setBtcErrorCode(new Error('Not enough funds.'), 'INSUFFICIENT_FUNDS')
71
72
  }
72
73
 
74
+ if (!hasUnconfirmedAncestorData({ asset, utxos: selectedUtxos, unconfirmedTxAncestor })) {
75
+ throw setBtcErrorCode(new Error('Ancestor data not loaded'), 'ANCESTOR_DATA_UNAVAILABLE')
76
+ }
77
+
73
78
  const addressPathsMap = selectedUtxos.getAddressPathsMap()
74
79
 
75
80
  const psbt = new Psbt({ network: asset.coinInfo.toBitcoinJS() })