@exodus/bitcoin-api 2.29.6 → 2.29.7

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
+ ## [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
+
8
+
9
+ ### Bug Fixes
10
+
11
+
12
+ * fix: reduce btc send dust (#4780)
13
+
14
+
15
+
6
16
  ## [2.29.6](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.29.5...@exodus/bitcoin-api@2.29.6) (2025-01-01)
7
17
 
8
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/bitcoin-api",
3
- "version": "2.29.6",
3
+ "version": "2.29.7",
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": "1f23b2168c83db6ae6ed864cd2baaa7cc70e0213"
59
+ "gitHead": "ee5817abc555d84d79887f3191aa8f3f28705f25"
60
60
  }
package/src/dust.js ADDED
@@ -0,0 +1,41 @@
1
+ const CHANGE_DUST_VALUES = {
2
+ bitcoin: 6000,
3
+ bitcoinregtest: 6000,
4
+ bitcointestnet: 6000,
5
+ bitcoinsv: 5000,
6
+ bcash: 6000,
7
+ bgold: 6000,
8
+ litecoin: 60_000,
9
+ dash: 5500,
10
+ dogecoin: 99_999_999,
11
+ decred: 70_000,
12
+ digibyte: 60_000,
13
+ zcash: 1500,
14
+ qtumignition: 400_000,
15
+ ravencoin: 545,
16
+ lightningnetwork: 20_000,
17
+ }
18
+
19
+ const SEND_DUST_VALUES = {
20
+ bitcoin: 546,
21
+ bitcoinregtest: 546,
22
+ bitcointestnet: 546,
23
+ }
24
+
25
+ export const getChangeDustValue = (asset) => {
26
+ const value = CHANGE_DUST_VALUES[asset.name]
27
+ if (!value) {
28
+ return
29
+ }
30
+
31
+ return asset.currency.baseUnit(value)
32
+ }
33
+
34
+ export const getSendDustValue = (asset) => {
35
+ const value = SEND_DUST_VALUES[asset.name] ?? CHANGE_DUST_VALUES[asset.name]
36
+ if (!value) {
37
+ return
38
+ }
39
+
40
+ return asset.currency.baseUnit(value)
41
+ }
@@ -5,6 +5,7 @@ import { retry } from '@exodus/simple-retry'
5
5
  import lodash from 'lodash'
6
6
  import assert from 'minimalistic-assert'
7
7
 
8
+ import { getChangeDustValue } from '../dust.js'
8
9
  import { parseCurrency, serializeCurrency } from '../fee/fee-utils.js'
9
10
  import { selectUtxos } from '../fee/utxo-selector.js'
10
11
  import { findUnconfirmedSentRbfTxs } from '../tx-utils.js'
@@ -34,34 +35,6 @@ const ASSETS_SUPPORTED_BIP_174 = new Set([
34
35
  'vertcoin', // is not available on mobile!
35
36
  ])
36
37
 
37
- const DUST_VALUES = {
38
- bitcoin: 6000,
39
- bitcoinregtest: 6000,
40
- bitcointestnet: 6000,
41
- bitcoinsv: 5000,
42
- bcash: 6000,
43
- bgold: 6000,
44
- litecoin: 60_000,
45
- dash: 5500,
46
- dogecoin: 99_999_999,
47
- decred: 70_000,
48
- digibyte: 60_000,
49
- zcash: 1500,
50
- qtumignition: 400_000,
51
- ravencoin: 545,
52
- lightningnetwork: 20_000,
53
- vertcoin: 20_000,
54
- }
55
-
56
- export const getDustValue = (asset) => {
57
- const value = DUST_VALUES[asset.name]
58
- if (!value) {
59
- return
60
- }
61
-
62
- return asset.currency.baseUnit(value)
63
- }
64
-
65
38
  export async function getNonWitnessTxs(asset, utxos, insightClient) {
66
39
  const rawTxs = []
67
40
 
@@ -427,7 +400,7 @@ export const getPrepareSendTransaction =
427
400
  .sub(totalAmount)
428
401
  .sub(transferOrdinalsUtxos?.value || currency.ZERO)
429
402
  .sub(fee)
430
- const dust = getDustValue(asset)
403
+ const dust = getChangeDustValue(asset)
431
404
  let ourAddress = replaceTx?.data?.changeAddress || changeAddress
432
405
  if (asset.address.toLegacyAddress) {
433
406
  const legacyAddress = asset.address.toLegacyAddress(ourAddress.address)
@@ -781,3 +754,6 @@ export function createOutput(assetName, ...rest) {
781
754
  function defaultCreateOutput(address, sendAmount) {
782
755
  return [address, parseInt(sendAmount.toBaseString(), 10)]
783
756
  }
757
+
758
+ // back compatibiliy
759
+ export { getSendDustValue as getDustValue } from '../dust.js'