@exodus/bitcoin-api 2.29.7 → 2.30.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 +20 -0
- package/package.json +2 -2
- package/src/dust.js +3 -3
- package/src/fee/get-fee-resolver.js +2 -2
- package/src/fee/utxo-selector.js +38 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
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
|
+
## [2.30.0](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.29.8...@exodus/bitcoin-api@2.30.0) (2025-01-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* feat: bitcoin dust fee display (#4789)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## [2.29.8](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.29.7...@exodus/bitcoin-api@2.29.8) (2025-01-08)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
* fix: reduce bitcoin change dust to 1500 (#4795)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
6
26
|
## [2.29.7](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.29.6...@exodus/bitcoin-api@2.29.7) (2025-01-03)
|
|
7
27
|
|
|
8
28
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/bitcoin-api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.30.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": "
|
|
59
|
+
"gitHead": "94e7e3c3c61802ff79891bf67e66e9f2b87b80a6"
|
|
60
60
|
}
|
package/src/dust.js
CHANGED
|
@@ -59,7 +59,7 @@ export class GetFeeResolver {
|
|
|
59
59
|
|
|
60
60
|
const inscriptionIds = getInscriptionIds({ nft, brc20 })
|
|
61
61
|
|
|
62
|
-
const {
|
|
62
|
+
const { fee, unspendableFee, extraFeeData } = this.#getUtxosData({
|
|
63
63
|
asset,
|
|
64
64
|
accountState,
|
|
65
65
|
txSet,
|
|
@@ -71,7 +71,7 @@ export class GetFeeResolver {
|
|
|
71
71
|
inscriptionIds,
|
|
72
72
|
taprootInputWitnessSize,
|
|
73
73
|
})
|
|
74
|
-
return { fee
|
|
74
|
+
return { fee, unspendableFee, extraFeeData }
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
getAvailableBalance = ({
|
package/src/fee/utxo-selector.js
CHANGED
|
@@ -3,6 +3,7 @@ import { UtxoCollection } from '@exodus/models'
|
|
|
3
3
|
import lodash from 'lodash'
|
|
4
4
|
import assert from 'minimalistic-assert'
|
|
5
5
|
|
|
6
|
+
import { getChangeDustValue } from '../dust.js'
|
|
6
7
|
import { getConfirmedOrRfbDisabledUtxos, getConfirmedUtxos } from '../utxos-utils.js'
|
|
7
8
|
import { getExtraFee } from './fee-utils.js'
|
|
8
9
|
|
|
@@ -265,7 +266,11 @@ export const getUtxosData = ({
|
|
|
265
266
|
taprootInputWitnessSize,
|
|
266
267
|
changeAddressType,
|
|
267
268
|
}) => {
|
|
268
|
-
const {
|
|
269
|
+
const {
|
|
270
|
+
selectedUtxos,
|
|
271
|
+
replaceTx,
|
|
272
|
+
fee: unspendableFee,
|
|
273
|
+
} = selectUtxos({
|
|
269
274
|
asset,
|
|
270
275
|
usableUtxos,
|
|
271
276
|
replaceableTxs,
|
|
@@ -285,18 +290,20 @@ export const getUtxosData = ({
|
|
|
285
290
|
changeAddressType,
|
|
286
291
|
})
|
|
287
292
|
|
|
288
|
-
|
|
293
|
+
let fee = replaceTx ? unspendableFee.sub(replaceTx.feeAmount) : unspendableFee
|
|
289
294
|
const empty = UtxoCollection.createEmpty({ currency: asset.currency })
|
|
295
|
+
|
|
296
|
+
const replaceUtxos = replaceTx ? usableUtxos.getTxIdUtxos(replaceTx.txId) : empty
|
|
297
|
+
|
|
290
298
|
const spendableUtxos = getConfirmedOrRfbDisabledUtxos({
|
|
291
299
|
asset,
|
|
292
300
|
utxos: usableUtxos,
|
|
293
301
|
allowUnconfirmedRbfEnabledUtxos,
|
|
294
|
-
}).union(
|
|
295
|
-
// .union(selectedUtxos || empty)
|
|
302
|
+
}).union(replaceUtxos)
|
|
296
303
|
|
|
297
304
|
const spendableBalance = spendableUtxos.value
|
|
298
305
|
|
|
299
|
-
const
|
|
306
|
+
const extraFeeCpfp = selectedUtxos
|
|
300
307
|
? asset.currency.baseUnit(
|
|
301
308
|
getExtraFee({
|
|
302
309
|
asset,
|
|
@@ -307,15 +314,38 @@ export const getUtxosData = ({
|
|
|
307
314
|
)
|
|
308
315
|
: asset.currency.ZERO
|
|
309
316
|
|
|
310
|
-
const availableBalance = spendableBalance.sub(
|
|
317
|
+
const availableBalance = spendableBalance.sub(fee).clampLowerZero()
|
|
318
|
+
|
|
319
|
+
const change =
|
|
320
|
+
selectedUtxos?.size && amount
|
|
321
|
+
? selectedUtxos.union(replaceUtxos).value.sub(amount).sub(fee)
|
|
322
|
+
: undefined
|
|
323
|
+
|
|
324
|
+
const dust = getChangeDustValue(asset)
|
|
325
|
+
|
|
326
|
+
let extraFeeDust = asset.currency.ZERO
|
|
327
|
+
if (change && !change.isZero && change.lt(dust)) {
|
|
328
|
+
fee = fee.add(change)
|
|
329
|
+
extraFeeDust = change
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
let extraFeeData
|
|
333
|
+
if (!extraFeeCpfp.isZero && !extraFeeDust.isZero) {
|
|
334
|
+
extraFeeData = { type: 'cpfpdust', extraFee: extraFeeCpfp.add(extraFeeDust) }
|
|
335
|
+
} else if (!extraFeeDust.isZero) {
|
|
336
|
+
extraFeeData = { type: 'dust', extraFee: extraFeeDust }
|
|
337
|
+
} else if (!extraFeeCpfp.isZero) {
|
|
338
|
+
extraFeeData = { type: 'cpfp', extraFee: extraFeeCpfp }
|
|
339
|
+
}
|
|
340
|
+
|
|
311
341
|
return {
|
|
312
342
|
spendableBalance,
|
|
313
343
|
availableBalance,
|
|
314
344
|
selectedUtxos,
|
|
345
|
+
unspendableFee,
|
|
315
346
|
fee,
|
|
316
|
-
resolvedFee,
|
|
317
347
|
replaceTx,
|
|
318
|
-
|
|
348
|
+
extraFeeData,
|
|
319
349
|
}
|
|
320
350
|
}
|
|
321
351
|
|