@exodus/bitcoin-api 2.34.1 → 3.0.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/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
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
+ ## [3.0.0](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.34.1...@exodus/bitcoin-api@3.0.0) (2025-07-11)
7
+
8
+
9
+ ### ⚠ BREAKING CHANGES
10
+
11
+ * remove deprecated asset.getSpendableBalance and asset.getAvailableBalance (#6013)
12
+
13
+
14
+ * refactor!: remove deprecated asset.getSpendableBalance and asset.getAvailableBalance (#6013)
15
+
16
+
17
+
6
18
  ## [2.34.1](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.34.0...@exodus/bitcoin-api@2.34.1) (2025-07-04)
7
19
 
8
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/bitcoin-api",
3
- "version": "2.34.1",
3
+ "version": "3.0.0",
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",
@@ -56,5 +56,5 @@
56
56
  "type": "git",
57
57
  "url": "git+https://github.com/ExodusMovement/assets.git"
58
58
  },
59
- "gitHead": "5257fdf0f08e1c8f22849ed6c190f083f4393efb"
59
+ "gitHead": "00006973d63f0ea79d60c2f2023805e5b412c321"
60
60
  }
package/src/balances.js CHANGED
@@ -1,11 +1,24 @@
1
1
  import { getUnconfirmedSentBalance } from '@exodus/asset-lib'
2
2
  import assert from 'minimalistic-assert'
3
3
 
4
- import { getUnconfirmedUtxos, getUtxos } from './utxos-utils.js'
4
+ import { getUnconfirmedTxAncestorMap } from './unconfirmed-ancestor-data.js'
5
+ import {
6
+ getConfirmedOrRfbDisabledUtxos,
7
+ getUnconfirmedUtxos,
8
+ getUsableUtxos,
9
+ getUtxos,
10
+ } from './utxos-utils.js'
5
11
 
6
- export const getBalancesFactory = ({ feeData: defaultFeeData, getSpendableBalance }) => {
12
+ export const getBalancesFactory = ({
13
+ feeData: defaultFeeData,
14
+ allowUnconfirmedRbfEnabledUtxos,
15
+ }) => {
7
16
  assert(defaultFeeData, 'default feeData is required')
8
- assert(getSpendableBalance, 'getSpendableBalance is required')
17
+ assert(
18
+ typeof allowUnconfirmedRbfEnabledUtxos === 'boolean',
19
+ 'allowUnconfirmedRbfEnabledUtxos is required'
20
+ )
21
+
9
22
  return ({ asset, accountState, txLog, feeData = defaultFeeData }) => {
10
23
  assert(asset, 'asset is required')
11
24
  assert(accountState, 'accountState is required')
@@ -14,13 +27,25 @@ export const getBalancesFactory = ({ feeData: defaultFeeData, getSpendableBalanc
14
27
 
15
28
  const utxos = getUtxos({ asset, accountState })
16
29
  const balance = utxos.value
17
- const spendableBalance = getSpendableBalance({
30
+
31
+ const unconfirmedTxAncestor = getUnconfirmedTxAncestorMap({ accountState })
32
+
33
+ const usableUtxos = getUsableUtxos({
18
34
  asset,
19
- accountState,
20
- txSet: txLog,
35
+ utxos,
21
36
  feeData,
37
+ txSet: txLog,
38
+ unconfirmedTxAncestor,
22
39
  })
23
40
 
41
+ const spendableUtxos = getConfirmedOrRfbDisabledUtxos({
42
+ asset,
43
+ utxos: usableUtxos,
44
+ allowUnconfirmedRbfEnabledUtxos,
45
+ })
46
+
47
+ const spendableBalance = spendableUtxos.value
48
+
24
49
  const unconfirmedUtxos = getUnconfirmedUtxos({ utxos })
25
50
  const unconfirmedSent = getUnconfirmedSentBalance({ asset, txLog })
26
51
  return {
@@ -66,39 +66,6 @@ export class GetFeeResolver {
66
66
  return { fee, unspendableFee, extraFeeData }
67
67
  }
68
68
 
69
- getAvailableBalance = ({
70
- asset,
71
- accountState,
72
- txSet,
73
- feeData,
74
- amount,
75
- customFee,
76
- isSendAll,
77
- taprootInputWitnessSize,
78
- }) => {
79
- return this.#getUtxosData({
80
- asset,
81
- accountState,
82
- txSet,
83
- feeData,
84
- customFee,
85
- isSendAll,
86
- amount,
87
- taprootInputWitnessSize,
88
- }).availableBalance
89
- }
90
-
91
- getSpendableBalance = ({ asset, accountState, txSet, feeData, taprootInputWitnessSize }) => {
92
- return this.#getUtxosData({
93
- asset,
94
- accountState,
95
- txSet,
96
- feeData,
97
- isSendAll: true,
98
- taprootInputWitnessSize,
99
- }).spendableBalance
100
- }
101
-
102
69
  #getUtxosData = ({
103
70
  asset,
104
71
  accountState,