@exodus/bitcoin-api 4.10.0 → 4.11.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 +10 -0
- package/package.json +3 -3
- package/src/fee/fee-utils.js +2 -0
- package/src/fee/script-classifier.js +2 -0
- package/src/hash-utils.js +3 -0
- package/src/insight-api-client/index.js +2 -33
- package/src/move-funds.js +1 -1
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
|
+
## [4.11.0](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@4.10.0...@exodus/bitcoin-api@4.11.0) (2026-03-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* feat: update wif to 4.0.0 (#6195)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
6
16
|
## [4.10.0](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@4.9.6...@exodus/bitcoin-api@4.10.0) (2026-03-11)
|
|
7
17
|
|
|
8
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/bitcoin-api",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.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",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"socket.io-client": "^2.1.1",
|
|
49
49
|
"url-join": "^4.0.0",
|
|
50
50
|
"varuint-bitcoin": "^1.1.0",
|
|
51
|
-
"wif": "^
|
|
51
|
+
"wif": "^4.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@exodus/bitcoin-meta": "^2.0.0",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"type": "git",
|
|
63
63
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "e746a88ef78a0e7167587bfa14068ceb494d6fd7"
|
|
66
66
|
}
|
package/src/fee/fee-utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// eslint-disable-next-line @exodus/import/no-deprecated
|
|
1
2
|
import { isNumberUnit, UnitType } from '@exodus/currency'
|
|
2
3
|
import { UtxoCollection } from '@exodus/models'
|
|
3
4
|
import assert from 'minimalistic-assert'
|
|
@@ -53,6 +54,7 @@ export default function createDefaultFeeEstimator(getSize) {
|
|
|
53
54
|
export function parseCurrency(val, currency) {
|
|
54
55
|
assert(currency instanceof UnitType, 'Currency must be supples as a UnitType')
|
|
55
56
|
|
|
57
|
+
// eslint-disable-next-line @exodus/import/no-deprecated
|
|
56
58
|
if (isNumberUnit(val)) return val // TODO: consider checking if the unitType.equals(currency) (if currency is object)
|
|
57
59
|
|
|
58
60
|
if (typeof val === 'string') return currency.parse(val)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { memoizeLruCache } from '@exodus/asset-lib'
|
|
2
2
|
import { scriptClassify } from '@exodus/bitcoinjs'
|
|
3
|
+
// eslint-disable-next-line @exodus/import/no-deprecated
|
|
3
4
|
import { hashSync } from '@exodus/crypto/hash'
|
|
4
5
|
import assert from 'minimalistic-assert'
|
|
5
6
|
|
|
@@ -8,6 +9,7 @@ const { P2PKH, P2SH, P2WPKH, P2WSH, P2TR } = scriptClassify.types
|
|
|
8
9
|
const cacheSize = 1000
|
|
9
10
|
const maxSize = 30
|
|
10
11
|
const hashStringIfTooBig = (str) =>
|
|
12
|
+
// eslint-disable-next-line @exodus/import/no-deprecated
|
|
11
13
|
str.length > maxSize ? hashSync('sha256', str, 'hex').slice(0, maxSize) : str
|
|
12
14
|
|
|
13
15
|
export const scriptClassifierFactory = ({ addressApi }) => {
|
package/src/hash-utils.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
// eslint-disable-next-line @exodus/import/no-deprecated
|
|
1
2
|
import { hashSync } from '@exodus/crypto/hash'
|
|
2
3
|
|
|
3
4
|
export function hash160(buffer) {
|
|
5
|
+
// eslint-disable-next-line @exodus/import/no-deprecated
|
|
4
6
|
return hashSync('hash160', buffer)
|
|
5
7
|
}
|
|
6
8
|
|
|
7
9
|
export function sha256(buffer) {
|
|
10
|
+
// eslint-disable-next-line @exodus/import/no-deprecated
|
|
8
11
|
return hashSync('sha256', buffer)
|
|
9
12
|
}
|
|
@@ -12,7 +12,6 @@ const INSIGHT_JSON_ERROR_MESSAGE = safeString`insight-api-invalid-json`
|
|
|
12
12
|
const INSIGHT_MISSING_TXID_MESSAGE = safeString`insight-api-missing-txid`
|
|
13
13
|
const INSIGHT_HTTP_ERROR_BALANCE_MESSAGE = safeString`insight-api-http-error:balance`
|
|
14
14
|
const INSIGHT_HTTP_ERROR_STATUS_MESSAGE = safeString`insight-api-http-error:status`
|
|
15
|
-
const INSIGHT_HTTP_ERROR_ADDR_MESSAGE = safeString`insight-api-http-error:addr`
|
|
16
15
|
const INSIGHT_HTTP_ERROR_UTXO_MESSAGE = safeString`insight-api-http-error:utxo`
|
|
17
16
|
const INSIGHT_HTTP_ERROR_TX_MESSAGE = safeString`insight-api-http-error:tx`
|
|
18
17
|
const INSIGHT_HTTP_ERROR_FULLTX_MESSAGE = safeString`insight-api-http-error:fulltx`
|
|
@@ -21,8 +20,6 @@ const INSIGHT_HTTP_ERROR_ADDRS_TXS_MESSAGE = safeString`insight-api-http-error:a
|
|
|
21
20
|
const INSIGHT_HTTP_ERROR_UNCONFIRMED_ANCESTOR_MESSAGE = safeString`insight-api-http-error:unconfirmed-ancestor`
|
|
22
21
|
const INSIGHT_HTTP_ERROR_FEES_MESSAGE = safeString`insight-api-http-error:fees`
|
|
23
22
|
const INSIGHT_HTTP_ERROR_BROADCAST_MESSAGE = safeString`insight-api-http-error:broadcast`
|
|
24
|
-
const INSIGHT_HTTP_ERROR_CLAIMABLE_MESSAGE = safeString`insight-api-http-error:claimable`
|
|
25
|
-
const INSIGHT_HTTP_ERROR_UNCLAIMED_MESSAGE = safeString`insight-api-http-error:unclaimed`
|
|
26
23
|
|
|
27
24
|
const parseBroadcastErrorReason = (data) => {
|
|
28
25
|
if (!data) {
|
|
@@ -82,12 +79,6 @@ export default class InsightAPIClient {
|
|
|
82
79
|
this._baseURL = baseURL
|
|
83
80
|
}
|
|
84
81
|
|
|
85
|
-
async isNetworkConnected() {
|
|
86
|
-
const url = urlJoin(this._baseURL, '/peer')
|
|
87
|
-
const peerStatus = await fetchJson(url, { timeout: 10_000 })
|
|
88
|
-
return !!peerStatus.connected
|
|
89
|
-
}
|
|
90
|
-
|
|
91
82
|
async fetchBalance(address) {
|
|
92
83
|
const encodedAddress = encodeURIComponent(address)
|
|
93
84
|
const url = urlJoin(this._baseURL, `/balance/${encodedAddress}`)
|
|
@@ -105,24 +96,14 @@ export default class InsightAPIClient {
|
|
|
105
96
|
return status.info.blocks
|
|
106
97
|
}
|
|
107
98
|
|
|
108
|
-
async
|
|
99
|
+
async fetchUTXOs(address, { assetNames = [] } = {}) {
|
|
109
100
|
const encodedAddress = encodeURIComponent(address)
|
|
110
|
-
const url = urlJoin(
|
|
111
|
-
this._baseURL,
|
|
112
|
-
opts?.includeTxs ? `/addr/${encodedAddress}` : `/addr/${encodedAddress}?noTxList=1`
|
|
113
|
-
)
|
|
114
|
-
return fetchJson(url, undefined, false, INSIGHT_HTTP_ERROR_ADDR_MESSAGE)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async fetchUTXOs(addresses, { assetNames = [] } = {}) {
|
|
118
|
-
if (Array.isArray(addresses)) addresses = addresses.join(',')
|
|
119
101
|
const query = new URLSearchParams('noCache=1')
|
|
120
102
|
if (assetNames) {
|
|
121
103
|
query.set('assetNames', assetNames.join(','))
|
|
122
104
|
}
|
|
123
105
|
|
|
124
|
-
const
|
|
125
|
-
const url = urlJoin(this._baseURL, `/addrs/${encodedAddresses}/utxo?${query}`)
|
|
106
|
+
const url = urlJoin(this._baseURL, `/addrs/${encodedAddress}/utxo?${query}`)
|
|
126
107
|
const utxos = await fetchJson(url, undefined, false, INSIGHT_HTTP_ERROR_UTXO_MESSAGE)
|
|
127
108
|
|
|
128
109
|
return utxos.map((utxo) => ({
|
|
@@ -249,16 +230,4 @@ export default class InsightAPIClient {
|
|
|
249
230
|
throw error
|
|
250
231
|
}
|
|
251
232
|
}
|
|
252
|
-
|
|
253
|
-
async getClaimable(address) {
|
|
254
|
-
const encodedAddress = encodeURIComponent(address)
|
|
255
|
-
const url = urlJoin(this._baseURL, `/addr/${encodedAddress}/claimable`)
|
|
256
|
-
return fetchJson(url, undefined, false, INSIGHT_HTTP_ERROR_CLAIMABLE_MESSAGE)
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
async getUnclaimed(address) {
|
|
260
|
-
const encodedAddress = encodeURIComponent(address)
|
|
261
|
-
const url = urlJoin(this._baseURL, `/addr/${encodedAddress}/unclaimed`)
|
|
262
|
-
return fetchJson(url, undefined, false, INSIGHT_HTTP_ERROR_UNCLAIMED_MESSAGE)
|
|
263
|
-
}
|
|
264
233
|
}
|
package/src/move-funds.js
CHANGED
|
@@ -204,7 +204,7 @@ export const moveFundsFactory = ({
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
async function getUtxos({ asset, address }) {
|
|
207
|
-
const rawUtxos = await insightClient.fetchUTXOs(
|
|
207
|
+
const rawUtxos = await insightClient.fetchUTXOs(address)
|
|
208
208
|
return UtxoCollection.fromArray(
|
|
209
209
|
rawUtxos.map((utxo) => ({
|
|
210
210
|
txId: utxo.txId,
|