@exodus/bitcoin-api 3.1.0 → 3.2.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 +4 -2
- package/src/index.js +1 -0
- package/src/insight-api-client/index.js +1 -1
- package/src/send-validation.js +88 -0
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
|
+
## [3.2.0](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@3.1.1...@exodus/bitcoin-api@3.2.0) (2025-07-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* feat: move send validation to each asset plugin (#6076)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## [3.1.1](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@3.1.0...@exodus/bitcoin-api@3.1.1) (2025-07-16)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
* fix: fetchUTXOs now search input script in response script and scriptPubKey fields (#6097)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
6
26
|
## [3.1.0](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@3.0.0...@exodus/bitcoin-api@3.1.0) (2025-07-15)
|
|
7
27
|
|
|
8
28
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/bitcoin-api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.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",
|
|
@@ -29,8 +29,10 @@
|
|
|
29
29
|
"@exodus/bitcoinjs": "^1.1.0",
|
|
30
30
|
"@exodus/crypto": "^1.0.0-rc.13",
|
|
31
31
|
"@exodus/currency": "^6.0.1",
|
|
32
|
+
"@exodus/i18n-dummy": "^1.0.0",
|
|
32
33
|
"@exodus/key-identifier": "^1.3.0",
|
|
33
34
|
"@exodus/models": "^12.0.1",
|
|
35
|
+
"@exodus/send-validation-model": "^1.0.0",
|
|
34
36
|
"@exodus/simple-retry": "^0.0.6",
|
|
35
37
|
"bech32": "^1.1.3",
|
|
36
38
|
"bip32-path": "^0.4.2",
|
|
@@ -57,5 +59,5 @@
|
|
|
57
59
|
"type": "git",
|
|
58
60
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
59
61
|
},
|
|
60
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "c12ad495a49f457bc0941e6b568b608e2a6a4250"
|
|
61
63
|
}
|
package/src/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from './btc-like-keys.js'
|
|
|
9
9
|
export { default as InsightAPIClient } from './insight-api-client/index.js'
|
|
10
10
|
export { default as InsightWSClient } from './insight-api-client/ws.js'
|
|
11
11
|
export { default as bip44Constants } from './constants/bip44.js'
|
|
12
|
+
export { default as sendValidations } from './send-validation.js'
|
|
12
13
|
export * from './tx-send/index.js'
|
|
13
14
|
export * from './tx-sign/index.js'
|
|
14
15
|
export * from './fee/index.js'
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { t } from '@exodus/i18n-dummy'
|
|
2
|
+
import sendValidationModel from '@exodus/send-validation-model'
|
|
3
|
+
|
|
4
|
+
import { getSendDustValue as getDustValue } from './dust.js'
|
|
5
|
+
|
|
6
|
+
const { createValidator, FIELDS, PRIORITY_LEVELS, VALIDATION_TYPES } = sendValidationModel
|
|
7
|
+
|
|
8
|
+
const bip70Validator = createValidator({
|
|
9
|
+
id: 'BIP70',
|
|
10
|
+
type: VALIDATION_TYPES.ERROR,
|
|
11
|
+
priority: PRIORITY_LEVELS.MIDDLE,
|
|
12
|
+
field: FIELDS.ADDRESS,
|
|
13
|
+
shouldValidate: ({ bip70 }) => !!bip70,
|
|
14
|
+
isValid: async ({ bip70 }) => !bip70.isInvalid(),
|
|
15
|
+
getMessage: () => t(`The payment request is invalid.`),
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const bcnLegacyAddressValidator = createValidator({
|
|
19
|
+
type: VALIDATION_TYPES.WARN,
|
|
20
|
+
priority: PRIORITY_LEVELS.BASE,
|
|
21
|
+
field: FIELDS.ADDRESS,
|
|
22
|
+
id: 'BCN_LEGACY_ADDRESS',
|
|
23
|
+
shouldValidate: ({ asset }) => asset.ticker === 'BCH',
|
|
24
|
+
isValid: async ({ asset, destinationAddress }) => {
|
|
25
|
+
return (
|
|
26
|
+
!destinationAddress ||
|
|
27
|
+
(asset.address.validate(destinationAddress) &&
|
|
28
|
+
!asset.address.isLegacyAddress(destinationAddress))
|
|
29
|
+
)
|
|
30
|
+
},
|
|
31
|
+
getMessage: () =>
|
|
32
|
+
t(
|
|
33
|
+
'Are you sure you want to send Bitcoin Cash (BCH) using an old address format? Did you check to make sure you are not sending to a Bitcoin (BTC) address?\n\nMixing BCH and BTC addresses can result in a loss of funds.'
|
|
34
|
+
),
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const notEnoughOutputValidator = createValidator({
|
|
38
|
+
id: 'NOT_ENOUGH_OUTPUT',
|
|
39
|
+
type: VALIDATION_TYPES.ERROR,
|
|
40
|
+
priority: PRIORITY_LEVELS.MIDDLE,
|
|
41
|
+
field: FIELDS.AMOUNT,
|
|
42
|
+
shouldValidate: ({ asset }) => !!getDustValue(asset),
|
|
43
|
+
isValid: ({ sendAmount, asset }) =>
|
|
44
|
+
!sendAmount || sendAmount.isZero || sendAmount.gte(getDustValue(asset)),
|
|
45
|
+
getMessage: ({ asset, getFiatValue, formatPrice }) => {
|
|
46
|
+
const dust = getDustValue(asset)
|
|
47
|
+
const dustValue =
|
|
48
|
+
formatPrice(getFiatValue(dust)) + ' (' + dust.toBaseString({ unit: true }) + ')'
|
|
49
|
+
|
|
50
|
+
return t(`Sending ${dustValue} or less isn't supported on the ${asset.displayName} network`)
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const bitcoinCpfpWarning = createValidator({
|
|
55
|
+
id: 'BITCOIN_CPFP_WARNING',
|
|
56
|
+
type: VALIDATION_TYPES.WARN,
|
|
57
|
+
shouldValidate: ({ fees, getFiatValue, formatPrice, fiatCurrencies }) =>
|
|
58
|
+
fees && getFiatValue && formatPrice && fiatCurrencies,
|
|
59
|
+
isValid: ({ fees, getFiatValue, fiatCurrencies }) => {
|
|
60
|
+
const type = fees?.extraFeeData?.type
|
|
61
|
+
const extraFee = fees?.extraFeeData?.extraFee
|
|
62
|
+
|
|
63
|
+
if (!extraFee || extraFee?.isZero) {
|
|
64
|
+
return true
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const usdValue = getFiatValue(extraFee, fiatCurrencies.USD)
|
|
68
|
+
if (usdValue.toBaseNumber() < 1) {
|
|
69
|
+
return true
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return type !== 'cpfp' && type !== 'cpfpdust'
|
|
73
|
+
},
|
|
74
|
+
getMessage: ({ formatPrice, getFiatValue, fees }) => {
|
|
75
|
+
const extraFee = fees.extraFeeData.extraFee
|
|
76
|
+
const extraFeeDisplayValue = formatPrice(getFiatValue(extraFee))
|
|
77
|
+
return t(
|
|
78
|
+
`You're paying ${extraFeeDisplayValue} in extra fees for spending unconfirmed transactions (CPFP).`
|
|
79
|
+
)
|
|
80
|
+
},
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
export default [
|
|
84
|
+
bitcoinCpfpWarning,
|
|
85
|
+
bip70Validator,
|
|
86
|
+
bcnLegacyAddressValidator,
|
|
87
|
+
notEnoughOutputValidator,
|
|
88
|
+
]
|