@exodus/bitcoin-api 2.21.1 → 2.21.3
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 +19 -0
- package/package.json +2 -2
- package/src/balances.js +1 -0
- package/src/bitcoinjs-lib/ec-pair.js +1 -0
- package/src/btc-like-address.js +3 -3
- package/src/btc-like-keys.js +7 -6
- package/src/fee/can-bump-tx.js +4 -4
- package/src/fee/fee-estimator.js +3 -4
- package/src/fee/fee-utils.js +2 -1
- package/src/fee/get-fee-resolver.js +3 -2
- package/src/fee/script-classifier.js +3 -3
- package/src/fee/utxo-selector.js +3 -2
- package/src/insight-api-client/index.js +3 -4
- package/src/insight-api-client/util.js +1 -1
- package/src/move-funds.js +6 -5
- package/src/multisig-address.js +2 -1
- package/src/parse-unsigned-tx.js +2 -2
- package/src/tx-log/bitcoin-monitor-scanner.js +86 -63
- package/src/tx-log/bitcoin-monitor.js +7 -7
- package/src/tx-send/index.js +13 -16
- package/src/tx-sign/create-get-key-and-purpose.js +4 -5
- package/src/tx-sign/create-sign-with-wallet.js +2 -2
- package/src/tx-sign/default-create-tx.js +4 -4
- package/src/tx-sign/default-prepare-for-signing.js +1 -1
- package/src/tx-sign/default-sign-hardware.js +1 -1
- package/src/tx-sign/taproot.js +2 -2
- package/src/utxos-utils.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
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.21.3](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.21.2...@exodus/bitcoin-api@2.21.3) (2024-07-31)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* pass compatibility mode to getKeyIdentifier ([#3048](https://github.com/ExodusMovement/assets/issues/3048)) ([61066f9](https://github.com/ExodusMovement/assets/commit/61066f958cafb59ab3b9be9234e9c8360ea51841))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [2.21.2](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.21.1...@exodus/bitcoin-api@2.21.2) (2024-07-26)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **bitcoin:** make asset config function optional on ACI ([#2983](https://github.com/ExodusMovement/assets/issues/2983)) ([0b45695](https://github.com/ExodusMovement/assets/commit/0b4569522c5a65da8109ae70e74ee75ba8111ce9))
|
|
21
|
+
* disable multi address scanning in `multiAddressMode` is false ([#2984](https://github.com/ExodusMovement/assets/issues/2984)) ([37bab79](https://github.com/ExodusMovement/assets/commit/37bab79ec9bcb8e08850402dd5f71df823eddd3b))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [2.21.1](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.21.0...@exodus/bitcoin-api@2.21.1) (2024-07-24)
|
|
7
26
|
|
|
8
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/bitcoin-api",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.3",
|
|
4
4
|
"description": "Exodus bitcoin-api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"type": "git",
|
|
67
67
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "a9a07ce549e5e911d65a75e2d768a6ff5a1d854e"
|
|
70
70
|
}
|
package/src/balances.js
CHANGED
package/src/btc-like-address.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as bitcoinjsOriginal from '@exodus/bitcoinjs-lib'
|
|
2
2
|
import * as bech32 from 'bech32'
|
|
3
|
-
import
|
|
3
|
+
import bs58check from 'bs58check'
|
|
4
4
|
import { identity, pickBy } from 'lodash'
|
|
5
|
-
import
|
|
5
|
+
import assert from 'minimalistic-assert'
|
|
6
6
|
|
|
7
7
|
export const createBtcLikeAddress = ({
|
|
8
8
|
versions,
|
package/src/btc-like-keys.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import wif from 'wif'
|
|
1
|
+
import * as defaultBitcoinjsLib from '@exodus/bitcoinjs-lib'
|
|
3
2
|
import * as bech32 from 'bech32'
|
|
4
|
-
import
|
|
3
|
+
import bs58check from 'bs58check'
|
|
5
4
|
import { identity, pickBy } from 'lodash'
|
|
6
|
-
import
|
|
5
|
+
import assert from 'minimalistic-assert'
|
|
7
6
|
import secp256k1 from 'secp256k1'
|
|
8
|
-
import
|
|
9
|
-
|
|
7
|
+
import wif from 'wif'
|
|
8
|
+
|
|
10
9
|
import { ecc } from './bitcoinjs-lib/ecc'
|
|
10
|
+
import { toXOnly } from './bitcoinjs-lib/ecc-utils'
|
|
11
|
+
import { hash160 } from './hash-utils'
|
|
11
12
|
|
|
12
13
|
export const publicKeyToHashFactory = (p2pkh) => (publicKey) => {
|
|
13
14
|
const payload = Buffer.concat([Buffer.from([p2pkh]), hash160(publicKey)])
|
package/src/fee/can-bump-tx.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BumpType } from '@exodus/bitcoin-lib'
|
|
2
2
|
import assert from 'minimalistic-assert'
|
|
3
|
-
import { findUnconfirmedSentRbfTxs } from '../tx-utils'
|
|
4
|
-
import { getUsableUtxos, getUtxos } from '../utxos-utils'
|
|
5
3
|
|
|
6
|
-
import {
|
|
4
|
+
import { findUnconfirmedSentRbfTxs } from '../tx-utils'
|
|
7
5
|
import { getUnconfirmedTxAncestorMap } from '../unconfirmed-ancestor-data'
|
|
6
|
+
import { getUsableUtxos, getUtxos } from '../utxos-utils'
|
|
7
|
+
import { selectUtxos } from './utxo-selector'
|
|
8
8
|
|
|
9
9
|
export const ASSET_NAMES = ['bitcoin', 'bitcoinregtest', 'bitcointestnet']
|
|
10
10
|
|
package/src/fee/fee-estimator.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { UtxoCollection } from '@exodus/models'
|
|
1
2
|
import assert from 'minimalistic-assert'
|
|
2
3
|
import * as varuint from 'varuint-bitcoin'
|
|
3
|
-
import { UtxoCollection } from '@exodus/models'
|
|
4
|
-
import { scriptClassify } from '../bitcoinjs-lib'
|
|
5
|
-
|
|
6
|
-
import { scriptClassifierFactory } from './script-classifier'
|
|
7
4
|
|
|
5
|
+
import { scriptClassify } from '../bitcoinjs-lib'
|
|
8
6
|
import createDefaultFeeEstimator, { isHex } from './fee-utils'
|
|
7
|
+
import { scriptClassifierFactory } from './script-classifier'
|
|
9
8
|
|
|
10
9
|
const { P2PKH, P2SH, P2WPKH, P2WSH, P2TR } = scriptClassify.types
|
|
11
10
|
|
package/src/fee/fee-utils.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { isNumberUnit, UnitType } from '@exodus/currency'
|
|
2
|
-
import { resolveExtraFeeOfTx } from '../unconfirmed-ancestor-data'
|
|
3
2
|
import { UtxoCollection } from '@exodus/models'
|
|
4
3
|
import assert from 'minimalistic-assert'
|
|
5
4
|
|
|
5
|
+
import { resolveExtraFeeOfTx } from '../unconfirmed-ancestor-data'
|
|
6
|
+
|
|
6
7
|
export const isHex = (s) => typeof s === 'string' && /[\da-f]*/.test(s.toLowerCase())
|
|
7
8
|
|
|
8
9
|
export function getExtraFee({ asset, inputs, feePerKB, unconfirmedTxAncestor }) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import assert from 'minimalistic-assert'
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { findUnconfirmedSentRbfTxs } from '../tx-utils'
|
|
4
|
+
import { getUnconfirmedTxAncestorMap } from '../unconfirmed-ancestor-data'
|
|
4
5
|
import {
|
|
5
6
|
getInscriptionIds,
|
|
6
7
|
getOrdinalsUtxos,
|
|
@@ -9,7 +10,7 @@ import {
|
|
|
9
10
|
getUtxos,
|
|
10
11
|
} from '../utxos-utils'
|
|
11
12
|
import { canBumpTx } from './can-bump-tx'
|
|
12
|
-
import {
|
|
13
|
+
import { getUtxosData } from './utxo-selector'
|
|
13
14
|
|
|
14
15
|
export class GetFeeResolver {
|
|
15
16
|
#getFeeEstimator
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { scriptClassify } from '../bitcoinjs-lib'
|
|
2
|
-
import createHash from 'create-hash'
|
|
3
|
-
|
|
4
1
|
import { memoizeLruCache } from '@exodus/asset-lib'
|
|
2
|
+
import createHash from 'create-hash'
|
|
5
3
|
import assert from 'minimalistic-assert'
|
|
6
4
|
|
|
5
|
+
import { scriptClassify } from '../bitcoinjs-lib'
|
|
6
|
+
|
|
7
7
|
const { P2PKH, P2SH, P2WPKH, P2WSH, P2TR } = scriptClassify.types
|
|
8
8
|
|
|
9
9
|
const cacheSize = 1000
|
package/src/fee/utxo-selector.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { UtxoCollection } from '@exodus/models'
|
|
2
1
|
import NumberUnit from '@exodus/currency'
|
|
2
|
+
import { UtxoCollection } from '@exodus/models'
|
|
3
3
|
import { sortBy } from 'lodash'
|
|
4
4
|
import assert from 'minimalistic-assert'
|
|
5
|
+
|
|
6
|
+
import { getConfirmedOrRfbDisabledUtxos, getConfirmedUtxos } from '../utxos-utils'
|
|
5
7
|
import { getExtraFee } from './fee-utils'
|
|
6
|
-
import { getConfirmedUtxos, getConfirmedOrRfbDisabledUtxos } from '../utxos-utils'
|
|
7
8
|
|
|
8
9
|
const MIN_RELAY_FEE = 1000
|
|
9
10
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import urlJoin from 'url-join'
|
|
2
|
-
import delay from 'delay'
|
|
3
|
-
import { isEmpty } from 'lodash'
|
|
4
|
-
|
|
5
1
|
import { fetch } from '@exodus/fetch'
|
|
6
2
|
import { retry } from '@exodus/simple-retry'
|
|
3
|
+
import delay from 'delay'
|
|
4
|
+
import { isEmpty } from 'lodash'
|
|
5
|
+
import urlJoin from 'url-join'
|
|
7
6
|
|
|
8
7
|
const getTextFromResponse = async (response) => {
|
|
9
8
|
try {
|
package/src/move-funds.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { UtxoCollection, Address } from '@exodus/models'
|
|
3
|
-
import { createInputs, createOutput, getNonWitnessTxs } from './tx-send'
|
|
1
|
+
import { Address, UtxoCollection } from '@exodus/models'
|
|
4
2
|
import assert from 'minimalistic-assert'
|
|
5
3
|
import secp256k1 from 'secp256k1'
|
|
4
|
+
import wif from 'wif'
|
|
5
|
+
|
|
6
|
+
import { createInputs, createOutput, getNonWitnessTxs } from './tx-send'
|
|
6
7
|
|
|
7
8
|
const isValidPrivateKey = (privateKey) => {
|
|
8
9
|
try {
|
|
@@ -97,14 +98,14 @@ export const moveFundsFactory = ({
|
|
|
97
98
|
throw new MoveFundsError('private-key-invalid', formatProps)
|
|
98
99
|
}
|
|
99
100
|
|
|
100
|
-
const config = await assetClientInterface.getAssetConfig({
|
|
101
|
+
const config = await assetClientInterface.getAssetConfig?.({
|
|
101
102
|
assetName,
|
|
102
103
|
walletAccount,
|
|
103
104
|
})
|
|
104
105
|
const recieveAddressesObjects = await assetClientInterface.getReceiveAddresses({
|
|
105
106
|
walletAccount,
|
|
106
107
|
assetName,
|
|
107
|
-
multiAddressMode: config
|
|
108
|
+
multiAddressMode: config?.multiAddressMode ?? true,
|
|
108
109
|
})
|
|
109
110
|
|
|
110
111
|
const receiveAddresses = recieveAddressesObjects.map(
|
package/src/multisig-address.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as defaultBitcoinjsLib from '@exodus/bitcoinjs-lib'
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { ecc as defaultEcc } from './bitcoinjs-lib/ecc'
|
|
4
|
+
import { toXOnly } from './bitcoinjs-lib/ecc-utils'
|
|
4
5
|
|
|
5
6
|
// Key to use when key path spending is disabled https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#constructing-and-spending-taproot-outputs
|
|
6
7
|
const DUMMY_TAPROOT_PUBKEY = Buffer.from(
|
package/src/parse-unsigned-tx.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Transaction as BitcoinTransactionClass } from '@exodus/bitcoinjs-lib'
|
|
2
2
|
import BIPPath from 'bip32-path'
|
|
3
3
|
import BN from 'bn.js'
|
|
4
4
|
import lodash from 'lodash'
|
|
5
|
-
import
|
|
5
|
+
import assert from 'minimalistic-assert'
|
|
6
6
|
|
|
7
7
|
export const parseUnsignedTxFactory =
|
|
8
8
|
({ Transaction = BitcoinTransactionClass } = {}) =>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { orderTxs } from '../insight-api-client/util'
|
|
2
1
|
import { Address, UtxoCollection } from '@exodus/models'
|
|
3
2
|
import { compact, isEqual, uniq } from 'lodash'
|
|
4
|
-
import ms from 'ms'
|
|
5
3
|
import assert from 'minimalistic-assert'
|
|
4
|
+
import ms from 'ms'
|
|
5
|
+
|
|
6
6
|
import { isChangeAddress, isReceiveAddress } from '../address-utils'
|
|
7
|
-
import {
|
|
7
|
+
import { orderTxs } from '../insight-api-client/util'
|
|
8
8
|
import { getOrdinalAddress } from '../ordinals-utils'
|
|
9
|
+
import { getOrdinalsUtxos, getUtxos, partitionUtxos } from '../utxos-utils'
|
|
9
10
|
import { indexOrdinalUnconfirmedTx } from './ordinals-indexer-utils'
|
|
10
11
|
|
|
11
12
|
// Time to check whether to drop a sent tx
|
|
@@ -54,12 +55,8 @@ export class BitcoinMonitorScanner {
|
|
|
54
55
|
this.#refreshGapLimit = refreshGapLimit
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
async #getGapLimit({
|
|
58
|
-
|
|
59
|
-
assetName,
|
|
60
|
-
walletAccount,
|
|
61
|
-
})
|
|
62
|
-
if (typeof assetConfig?.gapLimit === 'number') return assetConfig.gapLimit
|
|
58
|
+
async #getGapLimit({ assetConfig, refresh }) {
|
|
59
|
+
if (typeof assetConfig.gapLimit === 'number') return assetConfig.gapLimit
|
|
63
60
|
return refresh ? this.#refreshGapLimit : this.#gapLimit
|
|
64
61
|
}
|
|
65
62
|
|
|
@@ -74,6 +71,12 @@ export class BitcoinMonitorScanner {
|
|
|
74
71
|
const accountState = await assetClientInterface.getAccountState({ assetName, walletAccount })
|
|
75
72
|
const currency = asset.currency
|
|
76
73
|
const currentTxs = await assetClientInterface.getTxLog({ assetName, walletAccount })
|
|
74
|
+
const assetConfig = await this.#assetClientInterface.getAssetConfig({
|
|
75
|
+
assetName,
|
|
76
|
+
walletAccount,
|
|
77
|
+
})
|
|
78
|
+
// multiAddressMode may be null, in which case it is enabled.
|
|
79
|
+
const multiAddressMode = assetConfig.multiAddressMode ?? true
|
|
77
80
|
|
|
78
81
|
const storedUtxos = getUtxos({ asset, accountState })
|
|
79
82
|
const storedOrdinalUtxos = getOrdinalsUtxos({ asset, accountState })
|
|
@@ -110,7 +113,7 @@ export class BitcoinMonitorScanner {
|
|
|
110
113
|
walletAccount,
|
|
111
114
|
})
|
|
112
115
|
|
|
113
|
-
const resolvedGapLimit = await this.#getGapLimit({
|
|
116
|
+
const resolvedGapLimit = await this.#getGapLimit({ assetConfig, refresh })
|
|
114
117
|
/*
|
|
115
118
|
* The chain fields/variables are number arrays of size 2
|
|
116
119
|
*
|
|
@@ -136,10 +139,22 @@ export class BitcoinMonitorScanner {
|
|
|
136
139
|
* - for bip/purpose 84 and chainIndex 1 (change), 10 is the greatest unused addressIndex
|
|
137
140
|
*/
|
|
138
141
|
|
|
139
|
-
const chains = purposes.map((purpose) =>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
const chains = purposes.map((purpose) => {
|
|
143
|
+
if (multiAddressMode) {
|
|
144
|
+
return {
|
|
145
|
+
purpose,
|
|
146
|
+
chain: unusedAddressIndexes.find((indexes) => indexes.purpose === purpose)?.chain || [
|
|
147
|
+
0, 0,
|
|
148
|
+
],
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// If not in multi address mode then stick chains to 0
|
|
153
|
+
return {
|
|
154
|
+
purpose,
|
|
155
|
+
chain: [0, 0],
|
|
156
|
+
}
|
|
157
|
+
})
|
|
143
158
|
|
|
144
159
|
// cloning
|
|
145
160
|
const newChains = chains.map(({ purpose, chain }) => ({ purpose, chain: [...chain] }))
|
|
@@ -153,7 +168,11 @@ export class BitcoinMonitorScanner {
|
|
|
153
168
|
const promises = []
|
|
154
169
|
for (const chainObject of chainObjects) {
|
|
155
170
|
const { purpose, chainIndex, startAddressIndex, endAddressIndex } = chainObject
|
|
156
|
-
for (
|
|
171
|
+
for (
|
|
172
|
+
let addressIndex = startAddressIndex;
|
|
173
|
+
addressIndex <= endAddressIndex;
|
|
174
|
+
addressIndex++
|
|
175
|
+
) {
|
|
157
176
|
promises.push(
|
|
158
177
|
assetClientInterface
|
|
159
178
|
.getAddress({
|
|
@@ -246,14 +265,14 @@ export class BitcoinMonitorScanner {
|
|
|
246
265
|
purpose,
|
|
247
266
|
chain,
|
|
248
267
|
startAddressIndexes: chain.map(() => 0),
|
|
249
|
-
endAddressIndexes: chain.map((addressIndex) =>
|
|
250
|
-
refresh
|
|
251
|
-
|
|
268
|
+
endAddressIndexes: chain.map((addressIndex) => {
|
|
269
|
+
if (refresh) return resolvedGapLimit
|
|
270
|
+
return addressIndex + resolvedGapLimit
|
|
271
|
+
}),
|
|
252
272
|
}
|
|
253
273
|
})
|
|
254
274
|
|
|
255
275
|
let allTxs = []
|
|
256
|
-
|
|
257
276
|
for (let fetchCount = 0; ; fetchCount++) {
|
|
258
277
|
const chainObjects = gapSearchParameters.flatMap(
|
|
259
278
|
({ purpose, chain, startAddressIndexes, endAddressIndexes }) => {
|
|
@@ -303,55 +322,59 @@ export class BitcoinMonitorScanner {
|
|
|
303
322
|
allTxs = [...allTxs, ...txs]
|
|
304
323
|
|
|
305
324
|
// Update chains to see if we need to fetch more
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
325
|
+
if (multiAddressMode) {
|
|
326
|
+
txs.forEach((tx) =>
|
|
327
|
+
tx.vout.forEach((vout) => {
|
|
328
|
+
if (!vout.scriptPubKey) return
|
|
329
|
+
// this is an array because legacy multisig has multiple addresses
|
|
330
|
+
if (!Array.isArray(vout.scriptPubKey.addresses)) return
|
|
331
|
+
if (vout.scriptPubKey.addresses.length === 0) return
|
|
332
|
+
if (!addrMap[vout.scriptPubKey.addresses[0]]) return
|
|
333
|
+
|
|
334
|
+
const address = addrMap[vout.scriptPubKey.addresses[0]]
|
|
335
|
+
// this is a used address, we need to update the chain
|
|
336
|
+
const pd = address.meta.path.split('/')
|
|
337
|
+
const metaChainIndex = parseInt(pd[1])
|
|
338
|
+
const metaAddressIndex = pd[2] ? parseInt(pd[2]) : undefined // compatibility, it could shorter eg. m/0, not m/0/0
|
|
339
|
+
const addressString = String(address)
|
|
340
|
+
const purposeToUpdate = purposeMap[addressString]
|
|
341
|
+
|
|
342
|
+
if (
|
|
343
|
+
metaAddressIndex === undefined ||
|
|
344
|
+
(metaChainIndex === this.#ordinalChainIndex && this.#ordinalChainIndex > 1)
|
|
345
|
+
) {
|
|
346
|
+
return
|
|
347
|
+
}
|
|
328
348
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
349
|
+
if (!purposeToUpdate) {
|
|
350
|
+
console.warn(`${assetName}: Cannot resolve purpose from address ${addressString}`)
|
|
351
|
+
return
|
|
352
|
+
}
|
|
333
353
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
console.log(
|
|
337
|
-
`${assetName}: There is no chain info for purpose ${purposeToUpdate} and address ${addressString}`
|
|
354
|
+
const chainToUpgrade = newChains.find(
|
|
355
|
+
(newChain) => newChain.purpose === purposeToUpdate
|
|
338
356
|
)
|
|
339
|
-
|
|
340
|
-
|
|
357
|
+
if (!chainToUpgrade) {
|
|
358
|
+
console.log(
|
|
359
|
+
`${assetName}: There is no chain info for purpose ${purposeToUpdate} and address ${addressString}`
|
|
360
|
+
)
|
|
361
|
+
return
|
|
362
|
+
}
|
|
341
363
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
364
|
+
if (chainToUpgrade.chain[metaChainIndex] === undefined) {
|
|
365
|
+
console.log(
|
|
366
|
+
`${assetName}: There is no chain info for purpose ${purposeToUpdate}, address ${addressString} and chain index ${metaChainIndex}`
|
|
367
|
+
)
|
|
368
|
+
return
|
|
369
|
+
}
|
|
348
370
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
371
|
+
chainToUpgrade.chain[metaChainIndex] = Math.max(
|
|
372
|
+
metaAddressIndex + 1,
|
|
373
|
+
chainToUpgrade.chain[metaChainIndex]
|
|
374
|
+
)
|
|
375
|
+
})
|
|
376
|
+
)
|
|
377
|
+
}
|
|
355
378
|
|
|
356
379
|
gapSearchParameters.forEach((indexData) => {
|
|
357
380
|
// eslint-disable-next-line @exodus/mutable/no-param-reassign-prop-only
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BaseMonitor } from '@exodus/asset-lib'
|
|
2
|
+
import delay from 'delay'
|
|
2
3
|
import { isEmpty, isEqual, pickBy } from 'lodash'
|
|
4
|
+
import assert from 'minimalistic-assert'
|
|
5
|
+
import ms from 'ms'
|
|
3
6
|
|
|
4
|
-
import {
|
|
7
|
+
import { normalizeInsightConfig, toWSUrl } from '../insight-api-client/util'
|
|
5
8
|
import InsightWSClient from '../insight-api-client/ws'
|
|
6
9
|
import { resolveUnconfirmedAncestorData } from '../unconfirmed-ancestor-data'
|
|
7
10
|
import { BitcoinMonitorScanner } from './bitcoin-monitor-scanner'
|
|
8
|
-
import { normalizeInsightConfig, toWSUrl } from '../insight-api-client/util'
|
|
9
|
-
import ms from 'ms'
|
|
10
|
-
import delay from 'delay'
|
|
11
11
|
|
|
12
12
|
// NOTE: this is a frankenstein mashup of Exodus desktop
|
|
13
13
|
// assets-refresh/insight action + Neo monitor
|
|
@@ -91,14 +91,14 @@ export class Monitor extends BaseMonitor {
|
|
|
91
91
|
Object.fromEntries(
|
|
92
92
|
await Promise.all(
|
|
93
93
|
walletAccounts.map(async (walletAccount) => {
|
|
94
|
-
const config = await this.aci.getAssetConfig({
|
|
94
|
+
const config = await this.aci.getAssetConfig?.({
|
|
95
95
|
assetName: this.asset.name,
|
|
96
96
|
walletAccount,
|
|
97
97
|
})
|
|
98
98
|
return [
|
|
99
99
|
walletAccount,
|
|
100
100
|
await this.aci.getReceiveAddresses({
|
|
101
|
-
multiAddressMode: config
|
|
101
|
+
multiAddressMode: config?.multiAddressMode ?? true,
|
|
102
102
|
assetName: this.asset.name,
|
|
103
103
|
walletAccount,
|
|
104
104
|
useCache: true,
|
package/src/tx-send/index.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import assert from 'minimalistic-assert'
|
|
2
|
-
import lodash from 'lodash'
|
|
3
|
-
|
|
4
|
-
import { UtxoCollection, Address } from '@exodus/models'
|
|
5
|
-
import { retry } from '@exodus/simple-retry'
|
|
6
|
-
import { selectUtxos } from '../fee/utxo-selector'
|
|
7
1
|
import { getTxSequence } from '@exodus/bitcoin-lib'
|
|
2
|
+
import * as defaultBitcoinjsLib from '@exodus/bitcoinjs-lib'
|
|
3
|
+
import { Address, UtxoCollection } from '@exodus/models'
|
|
4
|
+
import { retry } from '@exodus/simple-retry'
|
|
5
|
+
import lodash from 'lodash'
|
|
6
|
+
import assert from 'minimalistic-assert'
|
|
8
7
|
|
|
9
8
|
import { parseCurrency } from '../fee/fee-utils'
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
createInputs as dogecoinCreateInputs,
|
|
13
|
-
createOutput as dogecoinCreateOutput,
|
|
14
|
-
} from './dogecoin'
|
|
9
|
+
import { selectUtxos } from '../fee/utxo-selector'
|
|
15
10
|
import { findUnconfirmedSentRbfTxs } from '../tx-utils'
|
|
11
|
+
import { getUnconfirmedTxAncestorMap } from '../unconfirmed-ancestor-data'
|
|
16
12
|
import {
|
|
17
13
|
getInscriptionIds,
|
|
18
14
|
getOrdinalsUtxos,
|
|
@@ -20,9 +16,10 @@ import {
|
|
|
20
16
|
getUsableUtxos,
|
|
21
17
|
getUtxos,
|
|
22
18
|
} from '../utxos-utils'
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
import {
|
|
20
|
+
createInputs as dogecoinCreateInputs,
|
|
21
|
+
createOutput as dogecoinCreateOutput,
|
|
22
|
+
} from './dogecoin'
|
|
26
23
|
|
|
27
24
|
const ASSETS_SUPPORTED_BIP_174 = new Set([
|
|
28
25
|
'bitcoin',
|
|
@@ -635,14 +632,14 @@ export const createAndBroadcastTXFactory =
|
|
|
635
632
|
},
|
|
636
633
|
})
|
|
637
634
|
|
|
638
|
-
const config = await assetClientInterface.getAssetConfig({
|
|
635
|
+
const config = await assetClientInterface.getAssetConfig?.({
|
|
639
636
|
assetName,
|
|
640
637
|
walletAccount,
|
|
641
638
|
})
|
|
642
639
|
const walletAddressObjects = await assetClientInterface.getReceiveAddresses({
|
|
643
640
|
walletAccount,
|
|
644
641
|
assetName,
|
|
645
|
-
multiAddressMode: config
|
|
642
|
+
multiAddressMode: config?.multiAddressMode ?? true,
|
|
646
643
|
})
|
|
647
644
|
// There are two cases of bumping, replacing or chaining a self-send.
|
|
648
645
|
// If we have a bumpTxId, but we aren't replacing, then it is a self-send.
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import lodash from 'lodash'
|
|
2
|
-
import BipPath from 'bip32-path'
|
|
3
|
-
import assert from 'minimalistic-assert'
|
|
4
1
|
import { getOwnProperty } from '@exodus/basic-utils'
|
|
5
2
|
import KeyIdentifier from '@exodus/key-identifier'
|
|
3
|
+
import BipPath from 'bip32-path'
|
|
4
|
+
import lodash from 'lodash'
|
|
5
|
+
import assert from 'minimalistic-assert'
|
|
6
|
+
import secp256k1 from 'secp256k1'
|
|
6
7
|
|
|
7
8
|
import { getECPair } from '../bitcoinjs-lib'
|
|
8
9
|
|
|
9
|
-
import secp256k1 from 'secp256k1'
|
|
10
|
-
|
|
11
10
|
const ECPair = getECPair()
|
|
12
11
|
|
|
13
12
|
export const createGetKeyWithMetadata = ({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { payments, Transaction } from '@exodus/bitcoinjs-lib'
|
|
2
2
|
import * as bip371 from '@exodus/bitcoinjs-lib/src/psbt/bip371'
|
|
3
3
|
|
|
4
4
|
import { toXOnly } from '../bitcoinjs-lib/ecc-utils'
|
|
5
5
|
import { createGetKeyWithMetadata } from './create-get-key-and-purpose'
|
|
6
|
-
import {
|
|
6
|
+
import { toAsyncBufferSigner, toAsyncSigner } from './taproot'
|
|
7
7
|
|
|
8
8
|
export function createSignWithWallet({
|
|
9
9
|
signer,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import assert from 'minimalistic-assert'
|
|
2
2
|
|
|
3
|
-
import { createPrepareForSigning } from './default-prepare-for-signing'
|
|
4
|
-
import { createSignWithWallet } from './create-sign-with-wallet'
|
|
5
3
|
import { extractTransaction } from './common'
|
|
4
|
+
import { createSignWithWallet } from './create-sign-with-wallet'
|
|
5
|
+
import { createPrepareForSigning } from './default-prepare-for-signing'
|
|
6
6
|
|
|
7
7
|
export const signTxFactory = ({
|
|
8
8
|
assetName,
|
|
@@ -28,7 +28,7 @@ export const signTxFactory = ({
|
|
|
28
28
|
'hdkeys or privateKeysAddressMap or signer is required'
|
|
29
29
|
)
|
|
30
30
|
|
|
31
|
-
const { addressPathsMap, accountIndex } = unsignedTx.txMeta
|
|
31
|
+
const { addressPathsMap, accountIndex, compatibilityMode } = unsignedTx.txMeta
|
|
32
32
|
|
|
33
33
|
const psbt = prepareForSigning({ unsignedTx })
|
|
34
34
|
|
|
@@ -46,7 +46,7 @@ export const signTxFactory = ({
|
|
|
46
46
|
!('accountIndex' in args) || args.accountIndex === accountIndex,
|
|
47
47
|
'`accountIndex` mismatch'
|
|
48
48
|
)
|
|
49
|
-
return getKeyIdentifier({ ...args, accountIndex })
|
|
49
|
+
return getKeyIdentifier({ compatibilityMode, ...args, accountIndex })
|
|
50
50
|
},
|
|
51
51
|
})
|
|
52
52
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from 'minimalistic-assert'
|
|
2
2
|
|
|
3
|
-
import { createPrepareForSigning } from './default-prepare-for-signing'
|
|
4
3
|
import { extractTransaction } from './common'
|
|
4
|
+
import { createPrepareForSigning } from './default-prepare-for-signing'
|
|
5
5
|
|
|
6
6
|
export const signHardwareFactory = ({ assetName, resolvePurpose, keys, coinInfo }) => {
|
|
7
7
|
assert(assetName, 'assetName is required')
|
package/src/tx-sign/taproot.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { crypto } from '@exodus/bitcoinjs-lib'
|
|
2
2
|
import assert from 'minimalistic-assert'
|
|
3
3
|
|
|
4
|
-
import defaultEntropy from './default-entropy.cjs'
|
|
5
|
-
import { ecc } from '../bitcoinjs-lib/ecc'
|
|
6
4
|
import { getECPair } from '../bitcoinjs-lib'
|
|
5
|
+
import { ecc } from '../bitcoinjs-lib/ecc'
|
|
6
|
+
import defaultEntropy from './default-entropy.cjs'
|
|
7
7
|
|
|
8
8
|
const ECPair = getECPair()
|
|
9
9
|
|
package/src/utxos-utils.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Move to shared utils...
|
|
2
2
|
import { UtxoCollection } from '@exodus/models'
|
|
3
|
-
import { findLargeUnconfirmedTxs } from './tx-utils'
|
|
4
3
|
import assert from 'minimalistic-assert'
|
|
5
4
|
|
|
5
|
+
import { findLargeUnconfirmedTxs } from './tx-utils'
|
|
6
|
+
|
|
6
7
|
const MAX_ORDINAL_VALUE_POSTAGE = 10_000
|
|
7
8
|
|
|
8
9
|
export const getInscriptionTxId = (inscriptionId) => {
|