@exodus/bitcoin-api 2.22.1 → 2.24.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 +33 -0
- package/package.json +15 -20
- package/src/balances.js +1 -1
- package/src/bitcoinjs-lib/ec-pair.js +2 -2
- package/src/bitcoinjs-lib/index.js +3 -3
- package/src/btc-like-address.js +3 -1
- package/src/btc-like-keys.js +6 -4
- package/src/constants/bip44.js +1 -1
- package/src/fee/can-bump-tx.js +4 -4
- package/src/fee/fee-estimator.js +3 -3
- package/src/fee/fee-utils.js +1 -1
- package/src/fee/get-fee-resolver.js +5 -5
- package/src/fee/index.js +2 -2
- package/src/fee/script-classifier.js +1 -1
- package/src/fee/utxo-selector.js +5 -3
- package/src/index.js +25 -25
- package/src/insight-api-client/index.js +3 -2
- package/src/insight-api-client/util.js +3 -1
- package/src/move-funds.js +1 -1
- package/src/multisig-address.js +14 -7
- package/src/tx-log/bitcoin-monitor-scanner.js +8 -6
- package/src/tx-log/bitcoin-monitor.js +7 -5
- package/src/tx-log/index.js +2 -2
- package/src/tx-log/ordinals-indexer-utils.js +3 -1
- package/src/tx-send/batch-tx.js +6 -8
- package/src/tx-send/index.js +6 -6
- package/src/tx-sign/create-get-key-and-purpose.js +1 -1
- package/src/tx-sign/create-sign-with-wallet.js +4 -4
- package/src/tx-sign/default-create-tx.js +3 -3
- package/src/tx-sign/default-sign-hardware.js +42 -12
- package/src/tx-sign/index.js +4 -4
- package/src/tx-sign/taproot.js +2 -2
- package/src/tx-utils.js +1 -1
- package/src/utxos-utils.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,39 @@
|
|
|
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.24.0](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.23.0...@exodus/bitcoin-api@2.24.0) (2024-09-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **BTC:** add multisig data to hardware wallet signing ([#3633](https://github.com/ExodusMovement/assets/issues/3633)) ([90293e9](https://github.com/ExodusMovement/assets/commit/90293e9b80799556df1c595558b1544c5a081d7b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **BTC:** allow internal pubkey and sort xonly for multisig ([#3634](https://github.com/ExodusMovement/assets/issues/3634)) ([808bf65](https://github.com/ExodusMovement/assets/commit/808bf65f05576e2758bb32ad5654143577db7c38))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## [2.23.0](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.22.1...@exodus/bitcoin-api@2.23.0) (2024-09-11)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* switch bitcoin to ESM ([#3433](https://github.com/ExodusMovement/assets/issues/3433)) ([8a2740f](https://github.com/ExodusMovement/assets/commit/8a2740f19401777e3333b89a2b7ac15febcb6bb8)), closes [#3286](https://github.com/ExodusMovement/assets/issues/3286)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **bitcoin-api:** add a missing exodus/bip32 dep ([#3457](https://github.com/ExodusMovement/assets/issues/3457)) ([d8b3499](https://github.com/ExodusMovement/assets/commit/d8b34998c78a55d56cdf787c4805e363336efd2d))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Reverts
|
|
34
|
+
|
|
35
|
+
* Revert "test(bitcoin-api): use dynamic import( instead of dynamic require( in createSignTestCases (#3286)" (#3300) ([92065cc](https://github.com/ExodusMovement/assets/commit/92065cc44a1ad02fe2330742810679f3594300bf)), closes [#3286](https://github.com/ExodusMovement/assets/issues/3286) [#3300](https://github.com/ExodusMovement/assets/issues/3300)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
6
39
|
## [2.22.1](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.22.0...@exodus/bitcoin-api@2.22.1) (2024-08-18)
|
|
7
40
|
|
|
8
41
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/bitcoin-api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.24.0",
|
|
4
4
|
"description": "Exodus bitcoin-api",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "src/index.js",
|
|
6
7
|
"files": [
|
|
7
8
|
"src",
|
|
@@ -14,23 +15,22 @@
|
|
|
14
15
|
"access": "restricted"
|
|
15
16
|
},
|
|
16
17
|
"scripts": {
|
|
17
|
-
"test": "run -T exodus-test --jest
|
|
18
|
-
"lint": "run -T
|
|
18
|
+
"test": "run -T exodus-test --jest",
|
|
19
|
+
"lint": "run -T eslintc .",
|
|
19
20
|
"lint:fix": "yarn lint --fix"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@exodus/asset-lib": "^
|
|
23
|
-
"@exodus/basic-utils": "^
|
|
24
|
-
"@exodus/
|
|
23
|
+
"@exodus/asset-lib": "^5.0.0",
|
|
24
|
+
"@exodus/basic-utils": "^3.0.1",
|
|
25
|
+
"@exodus/bip32": "^3.1.0",
|
|
26
|
+
"@exodus/bip322-js": "^1.1.0",
|
|
25
27
|
"@exodus/bip44-constants": "^195.0.0",
|
|
26
|
-
"@exodus/bitcoin-lib": "^2.4.
|
|
27
|
-
"@exodus/bitcoinjs-lib": "^6.1.
|
|
28
|
-
"@exodus/currency": "^
|
|
29
|
-
"@exodus/fetch": "^1.3.0",
|
|
28
|
+
"@exodus/bitcoin-lib": "^2.4.2",
|
|
29
|
+
"@exodus/bitcoinjs-lib": "^6.1.6",
|
|
30
|
+
"@exodus/currency": "^5.0.2",
|
|
30
31
|
"@exodus/key-identifier": "^1.1.1",
|
|
31
|
-
"@exodus/models": "^
|
|
32
|
+
"@exodus/models": "^12.0.1",
|
|
32
33
|
"@exodus/simple-retry": "^0.0.6",
|
|
33
|
-
"@exodus/timer": "^1.1.1",
|
|
34
34
|
"bech32": "^1.1.3",
|
|
35
35
|
"bip32-path": "^0.4.2",
|
|
36
36
|
"bn.js": "^4.12.0",
|
|
@@ -44,19 +44,14 @@
|
|
|
44
44
|
"ms": "^2.1.1",
|
|
45
45
|
"secp256k1": "^3.0.1",
|
|
46
46
|
"socket.io-client": "^2.1.1",
|
|
47
|
-
"tiny-secp256k1": "^1.1.3",
|
|
48
47
|
"url-join": "^4.0.0",
|
|
49
48
|
"varuint-bitcoin": "^1.1.0",
|
|
50
49
|
"wif": "^2.0.6"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
53
52
|
"@exodus/assets-testing": "^1.0.0",
|
|
54
|
-
"@exodus/bitcoin-meta": "^
|
|
55
|
-
"
|
|
56
|
-
"@scure/btc-signer": "^1.1.0",
|
|
57
|
-
"bigi": "^1.4.2",
|
|
58
|
-
"jest-when": "^3.5.1",
|
|
59
|
-
"safe-buffer": "^5.2.1"
|
|
53
|
+
"@exodus/bitcoin-meta": "^2.0.0",
|
|
54
|
+
"jest-when": "^3.5.1"
|
|
60
55
|
},
|
|
61
56
|
"bugs": {
|
|
62
57
|
"url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Abitcoin-api"
|
|
@@ -66,5 +61,5 @@
|
|
|
66
61
|
"type": "git",
|
|
67
62
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
68
63
|
},
|
|
69
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "ba34f68e632d17fdd80cc50358792f449e92180a"
|
|
70
65
|
}
|
package/src/balances.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './ecc'
|
|
2
|
-
export { scriptClassify } from './script-classify'
|
|
3
|
-
export * from './ec-pair'
|
|
1
|
+
export * from './ecc/index.js'
|
|
2
|
+
export { scriptClassify } from './script-classify/index.js'
|
|
3
|
+
export * from './ec-pair.js'
|
package/src/btc-like-address.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as bitcoinjsOriginal from '@exodus/bitcoinjs-lib'
|
|
2
2
|
import * as bech32 from 'bech32'
|
|
3
3
|
import bs58check from 'bs58check'
|
|
4
|
-
import
|
|
4
|
+
import lodash from 'lodash'
|
|
5
5
|
import assert from 'minimalistic-assert'
|
|
6
6
|
|
|
7
|
+
const { identity, pickBy } = lodash
|
|
8
|
+
|
|
7
9
|
export const createBtcLikeAddress = ({
|
|
8
10
|
versions,
|
|
9
11
|
coinInfo,
|
package/src/btc-like-keys.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import * as defaultBitcoinjsLib from '@exodus/bitcoinjs-lib'
|
|
2
2
|
import * as bech32 from 'bech32'
|
|
3
3
|
import bs58check from 'bs58check'
|
|
4
|
-
import
|
|
4
|
+
import lodash from 'lodash'
|
|
5
5
|
import assert from 'minimalistic-assert'
|
|
6
6
|
import secp256k1 from 'secp256k1'
|
|
7
7
|
import wif from 'wif'
|
|
8
8
|
|
|
9
|
-
import { ecc } from './bitcoinjs-lib/ecc'
|
|
10
|
-
import { toXOnly } from './bitcoinjs-lib/ecc-utils'
|
|
11
|
-
import { hash160 } from './hash-utils'
|
|
9
|
+
import { ecc } from './bitcoinjs-lib/ecc/index.js'
|
|
10
|
+
import { toXOnly } from './bitcoinjs-lib/ecc-utils.js'
|
|
11
|
+
import { hash160 } from './hash-utils.js'
|
|
12
|
+
|
|
13
|
+
const { identity, pickBy } = lodash
|
|
12
14
|
|
|
13
15
|
export const publicKeyToHashFactory = (p2pkh) => (publicKey) => {
|
|
14
16
|
const payload = Buffer.concat([Buffer.from([p2pkh]), hash160(publicKey)])
|
package/src/constants/bip44.js
CHANGED
package/src/fee/can-bump-tx.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BumpType } from '@exodus/bitcoin-lib'
|
|
2
2
|
import assert from 'minimalistic-assert'
|
|
3
3
|
|
|
4
|
-
import { findUnconfirmedSentRbfTxs } from '../tx-utils'
|
|
5
|
-
import { getUnconfirmedTxAncestorMap } from '../unconfirmed-ancestor-data'
|
|
6
|
-
import { getUsableUtxos, getUtxos } from '../utxos-utils'
|
|
7
|
-
import { selectUtxos } from './utxo-selector'
|
|
4
|
+
import { findUnconfirmedSentRbfTxs } from '../tx-utils.js'
|
|
5
|
+
import { getUnconfirmedTxAncestorMap } from '../unconfirmed-ancestor-data.js'
|
|
6
|
+
import { getUsableUtxos, getUtxos } from '../utxos-utils.js'
|
|
7
|
+
import { selectUtxos } from './utxo-selector.js'
|
|
8
8
|
|
|
9
9
|
export const ASSET_NAMES = ['bitcoin', 'bitcoinregtest', 'bitcointestnet']
|
|
10
10
|
|
package/src/fee/fee-estimator.js
CHANGED
|
@@ -2,9 +2,9 @@ import { UtxoCollection } from '@exodus/models'
|
|
|
2
2
|
import assert from 'minimalistic-assert'
|
|
3
3
|
import * as varuint from 'varuint-bitcoin'
|
|
4
4
|
|
|
5
|
-
import { scriptClassify } from '../bitcoinjs-lib'
|
|
6
|
-
import createDefaultFeeEstimator, { isHex } from './fee-utils'
|
|
7
|
-
import { scriptClassifierFactory } from './script-classifier'
|
|
5
|
+
import { scriptClassify } from '../bitcoinjs-lib/index.js'
|
|
6
|
+
import createDefaultFeeEstimator, { isHex } from './fee-utils.js'
|
|
7
|
+
import { scriptClassifierFactory } from './script-classifier.js'
|
|
8
8
|
|
|
9
9
|
const { P2PKH, P2SH, P2WPKH, P2WSH, P2TR } = scriptClassify.types
|
|
10
10
|
|
package/src/fee/fee-utils.js
CHANGED
|
@@ -2,7 +2,7 @@ import { isNumberUnit, UnitType } from '@exodus/currency'
|
|
|
2
2
|
import { UtxoCollection } from '@exodus/models'
|
|
3
3
|
import assert from 'minimalistic-assert'
|
|
4
4
|
|
|
5
|
-
import { resolveExtraFeeOfTx } from '../unconfirmed-ancestor-data'
|
|
5
|
+
import { resolveExtraFeeOfTx } from '../unconfirmed-ancestor-data.js'
|
|
6
6
|
|
|
7
7
|
export const isHex = (s) => typeof s === 'string' && /[\da-f]*/.test(s.toLowerCase())
|
|
8
8
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import assert from 'minimalistic-assert'
|
|
2
2
|
|
|
3
|
-
import { findUnconfirmedSentRbfTxs } from '../tx-utils'
|
|
4
|
-
import { getUnconfirmedTxAncestorMap } from '../unconfirmed-ancestor-data'
|
|
3
|
+
import { findUnconfirmedSentRbfTxs } from '../tx-utils.js'
|
|
4
|
+
import { getUnconfirmedTxAncestorMap } from '../unconfirmed-ancestor-data.js'
|
|
5
5
|
import {
|
|
6
6
|
getInscriptionIds,
|
|
7
7
|
getOrdinalsUtxos,
|
|
8
8
|
getTransferOrdinalsUtxos,
|
|
9
9
|
getUsableUtxos,
|
|
10
10
|
getUtxos,
|
|
11
|
-
} from '../utxos-utils'
|
|
12
|
-
import { canBumpTx } from './can-bump-tx'
|
|
13
|
-
import { getUtxosData } from './utxo-selector'
|
|
11
|
+
} from '../utxos-utils.js'
|
|
12
|
+
import { canBumpTx } from './can-bump-tx.js'
|
|
13
|
+
import { getUtxosData } from './utxo-selector.js'
|
|
14
14
|
|
|
15
15
|
export class GetFeeResolver {
|
|
16
16
|
#getFeeEstimator
|
package/src/fee/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './get-fee-resolver'
|
|
2
|
-
export { default as getFeeEstimatorFactory } from './fee-estimator'
|
|
1
|
+
export * from './get-fee-resolver.js'
|
|
2
|
+
export { default as getFeeEstimatorFactory } from './fee-estimator.js'
|
|
@@ -2,7 +2,7 @@ import { memoizeLruCache } from '@exodus/asset-lib'
|
|
|
2
2
|
import createHash from 'create-hash'
|
|
3
3
|
import assert from 'minimalistic-assert'
|
|
4
4
|
|
|
5
|
-
import { scriptClassify } from '../bitcoinjs-lib'
|
|
5
|
+
import { scriptClassify } from '../bitcoinjs-lib/index.js'
|
|
6
6
|
|
|
7
7
|
const { P2PKH, P2SH, P2WPKH, P2WSH, P2TR } = scriptClassify.types
|
|
8
8
|
|
package/src/fee/utxo-selector.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import NumberUnit from '@exodus/currency'
|
|
2
2
|
import { UtxoCollection } from '@exodus/models'
|
|
3
|
-
import
|
|
3
|
+
import lodash from 'lodash'
|
|
4
4
|
import assert from 'minimalistic-assert'
|
|
5
5
|
|
|
6
|
-
import { getConfirmedOrRfbDisabledUtxos, getConfirmedUtxos } from '../utxos-utils'
|
|
7
|
-
import { getExtraFee } from './fee-utils'
|
|
6
|
+
import { getConfirmedOrRfbDisabledUtxos, getConfirmedUtxos } from '../utxos-utils.js'
|
|
7
|
+
import { getExtraFee } from './fee-utils.js'
|
|
8
|
+
|
|
9
|
+
const { sortBy } = lodash
|
|
8
10
|
|
|
9
11
|
const MIN_RELAY_FEE = 1000
|
|
10
12
|
|
package/src/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export * from './account-state'
|
|
2
|
-
export * from './balances'
|
|
3
|
-
export * from './btc-address'
|
|
4
|
-
export * from './btc-like-address'
|
|
5
|
-
export * from './btc-like-keys'
|
|
6
|
-
export * from './bitcoinjs-lib'
|
|
7
|
-
export { default as InsightAPIClient } from './insight-api-client'
|
|
8
|
-
export { default as InsightWSClient } from './insight-api-client/ws'
|
|
9
|
-
export { default as bip44Constants } from './constants/bip44'
|
|
10
|
-
export * from './tx-send'
|
|
11
|
-
export * from './tx-sign'
|
|
12
|
-
export * from './fee'
|
|
13
|
-
export * from './utxos-utils'
|
|
14
|
-
export * from './tx-log'
|
|
15
|
-
export * from './unconfirmed-ancestor-data'
|
|
16
|
-
export * from './parse-unsigned-tx'
|
|
17
|
-
export { getCreateBatchTransaction } from './tx-send/batch-tx'
|
|
18
|
-
export { createPsbtToUnsignedTx } from './psbt-utils'
|
|
19
|
-
export * from './insight-api-client/util'
|
|
20
|
-
export * from './move-funds'
|
|
21
|
-
export { createEncodeMultisigContract } from './multisig-address'
|
|
22
|
-
export { toAsyncSigner } from './tx-sign/taproot'
|
|
23
|
-
export { toXOnly } from './bitcoinjs-lib/ecc-utils'
|
|
24
|
-
export * from './ordinals-utils'
|
|
25
|
-
export { signMessage } from './sign-message'
|
|
1
|
+
export * from './account-state.js'
|
|
2
|
+
export * from './balances.js'
|
|
3
|
+
export * from './btc-address.js'
|
|
4
|
+
export * from './btc-like-address.js'
|
|
5
|
+
export * from './btc-like-keys.js'
|
|
6
|
+
export * from './bitcoinjs-lib/index.js'
|
|
7
|
+
export { default as InsightAPIClient } from './insight-api-client/index.js'
|
|
8
|
+
export { default as InsightWSClient } from './insight-api-client/ws.js'
|
|
9
|
+
export { default as bip44Constants } from './constants/bip44.js'
|
|
10
|
+
export * from './tx-send/index.js'
|
|
11
|
+
export * from './tx-sign/index.js'
|
|
12
|
+
export * from './fee/index.js'
|
|
13
|
+
export * from './utxos-utils.js'
|
|
14
|
+
export * from './tx-log/index.js'
|
|
15
|
+
export * from './unconfirmed-ancestor-data.js'
|
|
16
|
+
export * from './parse-unsigned-tx.js'
|
|
17
|
+
export { getCreateBatchTransaction } from './tx-send/batch-tx.js'
|
|
18
|
+
export { createPsbtToUnsignedTx } from './psbt-utils.js'
|
|
19
|
+
export * from './insight-api-client/util.js'
|
|
20
|
+
export * from './move-funds.js'
|
|
21
|
+
export { createEncodeMultisigContract } from './multisig-address.js'
|
|
22
|
+
export { toAsyncSigner } from './tx-sign/taproot.js'
|
|
23
|
+
export { toXOnly } from './bitcoinjs-lib/ecc-utils.js'
|
|
24
|
+
export * from './ordinals-utils.js'
|
|
25
|
+
export { signMessage } from './sign-message.js'
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { fetch } from '@exodus/fetch'
|
|
2
1
|
import { retry } from '@exodus/simple-retry'
|
|
3
2
|
import delay from 'delay'
|
|
4
|
-
import
|
|
3
|
+
import lodash from 'lodash'
|
|
5
4
|
import urlJoin from 'url-join'
|
|
6
5
|
|
|
6
|
+
const { isEmpty } = lodash
|
|
7
|
+
|
|
7
8
|
const getTextFromResponse = async (response) => {
|
|
8
9
|
try {
|
|
9
10
|
const responseBody = await response.text()
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import lodash from 'lodash'
|
|
2
2
|
import assert from 'minimalistic-assert'
|
|
3
3
|
|
|
4
|
+
const { groupBy, sortBy } = lodash
|
|
5
|
+
|
|
4
6
|
// return first to last (ALSO FILTERS)
|
|
5
7
|
// we need to do this because Insight often returns the blocktime as time and many
|
|
6
8
|
// txs may fall inside the same block, but if one is an input to other, it should preceed
|
package/src/move-funds.js
CHANGED
|
@@ -3,7 +3,7 @@ import assert from 'minimalistic-assert'
|
|
|
3
3
|
import secp256k1 from 'secp256k1'
|
|
4
4
|
import wif from 'wif'
|
|
5
5
|
|
|
6
|
-
import { createInputs, createOutput, getNonWitnessTxs } from './tx-send'
|
|
6
|
+
import { createInputs, createOutput, getNonWitnessTxs } from './tx-send/index.js'
|
|
7
7
|
|
|
8
8
|
const isValidPrivateKey = (privateKey) => {
|
|
9
9
|
try {
|
package/src/multisig-address.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import * as defaultBitcoinjsLib from '@exodus/bitcoinjs-lib'
|
|
2
2
|
|
|
3
|
-
import { ecc as defaultEcc } from './bitcoinjs-lib/ecc'
|
|
4
|
-
import { toXOnly } from './bitcoinjs-lib/ecc-utils'
|
|
3
|
+
import { ecc as defaultEcc } from './bitcoinjs-lib/ecc/index.js'
|
|
4
|
+
import { toXOnly } from './bitcoinjs-lib/ecc-utils.js'
|
|
5
5
|
|
|
6
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
|
|
7
7
|
const DUMMY_TAPROOT_PUBKEY = Buffer.from(
|
|
8
|
-
'
|
|
8
|
+
'0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0',
|
|
9
9
|
'hex'
|
|
10
10
|
)
|
|
11
11
|
|
|
12
12
|
// Leaf version for BIP342 is 0xc0 or 192 https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki#specification
|
|
13
13
|
const LEAF_VERSION_TAPSCRIPT = 192
|
|
14
14
|
|
|
15
|
-
// Limit multisig keys to
|
|
15
|
+
// Limit multisig keys to 16 for now
|
|
16
16
|
const MAX_PUBKEYS = 20
|
|
17
17
|
|
|
18
18
|
export const createEncodeMultisigContract =
|
|
@@ -21,7 +21,14 @@ export const createEncodeMultisigContract =
|
|
|
21
21
|
network = bitcoinjsLib.Network.bitcoin,
|
|
22
22
|
ecc = defaultEcc,
|
|
23
23
|
}) =>
|
|
24
|
-
(
|
|
24
|
+
(
|
|
25
|
+
publicKeys,
|
|
26
|
+
{
|
|
27
|
+
threshold = publicKeys.length,
|
|
28
|
+
version = 0,
|
|
29
|
+
internalPubkey = DUMMY_TAPROOT_PUBKEY,
|
|
30
|
+
} = Object.create(null)
|
|
31
|
+
) => {
|
|
25
32
|
if (
|
|
26
33
|
!Array.isArray(publicKeys) ||
|
|
27
34
|
publicKeys.some((k) => !Buffer.isBuffer(k) || !ecc.isPointCompressed(k))
|
|
@@ -57,7 +64,7 @@ export const createEncodeMultisigContract =
|
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
// Sort according to BIP67 https://github.com/bitcoin/bips/blob/master/bip-0067.mediawiki
|
|
60
|
-
publicKeys.sort((a, b) => Buffer.compare(a, b))
|
|
67
|
+
publicKeys.sort((a, b) => Buffer.compare(toXOnly(a), toXOnly(b)))
|
|
61
68
|
|
|
62
69
|
// Create multisig redeem script https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki#cite_note-5
|
|
63
70
|
const OPS = bitcoinjsLib.script.OPS
|
|
@@ -74,7 +81,7 @@ export const createEncodeMultisigContract =
|
|
|
74
81
|
const output = bitcoinjsLib.script.compile(chunks)
|
|
75
82
|
|
|
76
83
|
return bitcoinjsLib.payments.p2tr({
|
|
77
|
-
internalPubkey:
|
|
84
|
+
internalPubkey: toXOnly(internalPubkey),
|
|
78
85
|
scriptTree: { output },
|
|
79
86
|
redeem: { output, redeemVersion: LEAF_VERSION_TAPSCRIPT },
|
|
80
87
|
network,
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Address, UtxoCollection } from '@exodus/models'
|
|
2
|
-
import
|
|
2
|
+
import lodash from 'lodash'
|
|
3
3
|
import assert from 'minimalistic-assert'
|
|
4
4
|
import ms from 'ms'
|
|
5
5
|
|
|
6
|
-
import { isChangeAddress, isReceiveAddress } from '../address-utils'
|
|
7
|
-
import { orderTxs } from '../insight-api-client/util'
|
|
8
|
-
import { getOrdinalAddress } from '../ordinals-utils'
|
|
9
|
-
import { getOrdinalsUtxos, getUtxos, partitionUtxos } from '../utxos-utils'
|
|
10
|
-
import { indexOrdinalUnconfirmedTx } from './ordinals-indexer-utils'
|
|
6
|
+
import { isChangeAddress, isReceiveAddress } from '../address-utils.js'
|
|
7
|
+
import { orderTxs } from '../insight-api-client/util.js'
|
|
8
|
+
import { getOrdinalAddress } from '../ordinals-utils.js'
|
|
9
|
+
import { getOrdinalsUtxos, getUtxos, partitionUtxos } from '../utxos-utils.js'
|
|
10
|
+
import { indexOrdinalUnconfirmedTx } from './ordinals-indexer-utils.js'
|
|
11
|
+
|
|
12
|
+
const { compact, isEqual, uniq } = lodash
|
|
11
13
|
|
|
12
14
|
// Time to check whether to drop a sent tx
|
|
13
15
|
const SENT_TIME_TO_DROP = ms('2m')
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { BaseMonitor } from '@exodus/asset-lib'
|
|
2
2
|
import delay from 'delay'
|
|
3
|
-
import
|
|
3
|
+
import lodash from 'lodash'
|
|
4
4
|
import assert from 'minimalistic-assert'
|
|
5
5
|
import ms from 'ms'
|
|
6
6
|
|
|
7
|
-
import { normalizeInsightConfig, toWSUrl } from '../insight-api-client/util'
|
|
8
|
-
import InsightWSClient from '../insight-api-client/ws'
|
|
9
|
-
import { resolveUnconfirmedAncestorData } from '../unconfirmed-ancestor-data'
|
|
10
|
-
import { BitcoinMonitorScanner } from './bitcoin-monitor-scanner'
|
|
7
|
+
import { normalizeInsightConfig, toWSUrl } from '../insight-api-client/util.js'
|
|
8
|
+
import InsightWSClient from '../insight-api-client/ws.js'
|
|
9
|
+
import { resolveUnconfirmedAncestorData } from '../unconfirmed-ancestor-data.js'
|
|
10
|
+
import { BitcoinMonitorScanner } from './bitcoin-monitor-scanner.js'
|
|
11
|
+
|
|
12
|
+
const { isEmpty, isEqual, pickBy } = lodash
|
|
11
13
|
|
|
12
14
|
// NOTE: this is a frankenstein mashup of Exodus desktop
|
|
13
15
|
// assets-refresh/insight action + Neo monitor
|
package/src/tx-log/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './bitcoin-monitor'
|
|
2
|
-
export * from './bitcoin-monitor-scanner'
|
|
1
|
+
export * from './bitcoin-monitor.js'
|
|
2
|
+
export * from './bitcoin-monitor-scanner.js'
|
package/src/tx-send/batch-tx.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
// eslint-disable-next-line @exodus/import/no-extraneous-dependencies
|
|
2
1
|
import BIP32 from '@exodus/bip32'
|
|
3
2
|
import { Psbt } from '@exodus/bitcoinjs-lib'
|
|
4
3
|
import BipPath from 'bip32-path'
|
|
5
|
-
|
|
6
|
-
import doShuffle from 'lodash/shuffle'
|
|
4
|
+
import lodash from 'lodash' // mockable in tests
|
|
7
5
|
import assert from 'minimalistic-assert'
|
|
8
6
|
|
|
9
|
-
import { selectUtxos } from '../fee/utxo-selector'
|
|
10
|
-
import { getUnconfirmedTxAncestorMap } from '../unconfirmed-ancestor-data'
|
|
11
|
-
import { getUsableUtxos, getUtxos } from '../utxos-utils'
|
|
7
|
+
import { selectUtxos } from '../fee/utxo-selector.js'
|
|
8
|
+
import { getUnconfirmedTxAncestorMap } from '../unconfirmed-ancestor-data.js'
|
|
9
|
+
import { getUsableUtxos, getUtxos } from '../utxos-utils.js'
|
|
12
10
|
|
|
13
11
|
const DUST_VALUES = {
|
|
14
12
|
P2WPKH: 294,
|
|
@@ -65,7 +63,7 @@ export const getCreateBatchTransaction = ({
|
|
|
65
63
|
|
|
66
64
|
const psbt = new Psbt({ network: asset.coinInfo.toBitcoinJS() })
|
|
67
65
|
|
|
68
|
-
for (const utxo of
|
|
66
|
+
for (const utxo of lodash.shuffle(selectedUtxos.toArray())) {
|
|
69
67
|
const path = addressPathsMap[utxo.address]
|
|
70
68
|
if (!path) {
|
|
71
69
|
throw new Error(`Path missing for input address ${utxo.address}`)
|
|
@@ -153,7 +151,7 @@ export const getCreateBatchTransaction = ({
|
|
|
153
151
|
recipients.push(output)
|
|
154
152
|
}
|
|
155
153
|
|
|
156
|
-
for (const recipient of
|
|
154
|
+
for (const recipient of lodash.shuffle(recipients)) {
|
|
157
155
|
psbt.addOutput({
|
|
158
156
|
address: recipient.address,
|
|
159
157
|
value: parseInt(recipient.amount.toBaseString(), 10),
|
package/src/tx-send/index.js
CHANGED
|
@@ -5,21 +5,21 @@ import { retry } from '@exodus/simple-retry'
|
|
|
5
5
|
import lodash from 'lodash'
|
|
6
6
|
import assert from 'minimalistic-assert'
|
|
7
7
|
|
|
8
|
-
import { parseCurrency } from '../fee/fee-utils'
|
|
9
|
-
import { selectUtxos } from '../fee/utxo-selector'
|
|
10
|
-
import { findUnconfirmedSentRbfTxs } from '../tx-utils'
|
|
11
|
-
import { getUnconfirmedTxAncestorMap } from '../unconfirmed-ancestor-data'
|
|
8
|
+
import { parseCurrency } from '../fee/fee-utils.js'
|
|
9
|
+
import { selectUtxos } from '../fee/utxo-selector.js'
|
|
10
|
+
import { findUnconfirmedSentRbfTxs } from '../tx-utils.js'
|
|
11
|
+
import { getUnconfirmedTxAncestorMap } from '../unconfirmed-ancestor-data.js'
|
|
12
12
|
import {
|
|
13
13
|
getInscriptionIds,
|
|
14
14
|
getOrdinalsUtxos,
|
|
15
15
|
getTransferOrdinalsUtxos,
|
|
16
16
|
getUsableUtxos,
|
|
17
17
|
getUtxos,
|
|
18
|
-
} from '../utxos-utils'
|
|
18
|
+
} from '../utxos-utils.js'
|
|
19
19
|
import {
|
|
20
20
|
createInputs as dogecoinCreateInputs,
|
|
21
21
|
createOutput as dogecoinCreateOutput,
|
|
22
|
-
} from './dogecoin'
|
|
22
|
+
} from './dogecoin.js'
|
|
23
23
|
|
|
24
24
|
const ASSETS_SUPPORTED_BIP_174 = new Set([
|
|
25
25
|
'bitcoin',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { payments, Transaction } from '@exodus/bitcoinjs-lib'
|
|
2
|
-
import * as bip371 from '@exodus/bitcoinjs-lib/src/psbt/bip371'
|
|
2
|
+
import * as bip371 from '@exodus/bitcoinjs-lib/src/psbt/bip371.js'
|
|
3
3
|
|
|
4
|
-
import { toXOnly } from '../bitcoinjs-lib/ecc-utils'
|
|
5
|
-
import { createGetKeyWithMetadata } from './create-get-key-and-purpose'
|
|
6
|
-
import { toAsyncBufferSigner, toAsyncSigner } from './taproot'
|
|
4
|
+
import { toXOnly } from '../bitcoinjs-lib/ecc-utils.js'
|
|
5
|
+
import { createGetKeyWithMetadata } from './create-get-key-and-purpose.js'
|
|
6
|
+
import { toAsyncBufferSigner, toAsyncSigner } from './taproot.js'
|
|
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 { extractTransaction } from './common'
|
|
4
|
-
import { createSignWithWallet } from './create-sign-with-wallet'
|
|
5
|
-
import { createPrepareForSigning } from './default-prepare-for-signing'
|
|
3
|
+
import { extractTransaction } from './common.js'
|
|
4
|
+
import { createSignWithWallet } from './create-sign-with-wallet.js'
|
|
5
|
+
import { createPrepareForSigning } from './default-prepare-for-signing.js'
|
|
6
6
|
|
|
7
7
|
export const signTxFactory = ({
|
|
8
8
|
assetName,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from 'minimalistic-assert'
|
|
2
2
|
|
|
3
|
-
import { extractTransaction } from './common'
|
|
4
|
-
import { createPrepareForSigning } from './default-prepare-for-signing'
|
|
3
|
+
import { extractTransaction } from './common.js'
|
|
4
|
+
import { createPrepareForSigning } from './default-prepare-for-signing.js'
|
|
5
5
|
|
|
6
6
|
export const signHardwareFactory = ({ assetName, resolvePurpose, keys, coinInfo }) => {
|
|
7
7
|
assert(assetName, 'assetName is required')
|
|
@@ -20,7 +20,7 @@ export const signHardwareFactory = ({ assetName, resolvePurpose, keys, coinInfo
|
|
|
20
20
|
resolvePurpose,
|
|
21
21
|
})
|
|
22
22
|
|
|
23
|
-
return async ({ unsignedTx, hardwareDevice, accountIndex }) => {
|
|
23
|
+
return async ({ unsignedTx, hardwareDevice, accountIndex, multisigData }) => {
|
|
24
24
|
assert(unsignedTx, 'unsignedTx is required')
|
|
25
25
|
assert(hardwareDevice, 'hardwareDevice is required')
|
|
26
26
|
assert(Number.isInteger(accountIndex), 'accountIndex must be integer')
|
|
@@ -37,35 +37,65 @@ export const signHardwareFactory = ({ assetName, resolvePurpose, keys, coinInfo
|
|
|
37
37
|
addressPathsMap,
|
|
38
38
|
hardwareDevice,
|
|
39
39
|
accountIndex,
|
|
40
|
+
multisigData,
|
|
40
41
|
})
|
|
41
42
|
|
|
42
|
-
const skipFinalize = !!unsignedTx.txData.psbtBuffer
|
|
43
|
+
const skipFinalize = !!unsignedTx.txData.psbtBuffer || unsignedTx.txMeta.returnPsbt
|
|
43
44
|
return extractTransaction({ psbt, skipFinalize })
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
function createSignWithHardwareWallet({ assetName, resolvePurpose }) {
|
|
48
|
-
return async ({
|
|
49
|
-
|
|
49
|
+
return async ({
|
|
50
|
+
psbt,
|
|
51
|
+
inputsToSign,
|
|
52
|
+
addressPathsMap,
|
|
53
|
+
accountIndex,
|
|
54
|
+
hardwareDevice,
|
|
55
|
+
multisigData,
|
|
56
|
+
}) => {
|
|
57
|
+
const derivationPathsMap = getDerivationPathsMap({
|
|
58
|
+
resolvePurpose,
|
|
59
|
+
addressPathsMap,
|
|
60
|
+
accountIndex,
|
|
61
|
+
})
|
|
50
62
|
const signatures = await hardwareDevice.signTransaction({
|
|
51
63
|
assetName,
|
|
52
64
|
signableTransaction: psbt.toBuffer(),
|
|
53
|
-
derivationPaths,
|
|
65
|
+
derivationPaths: Object.values(derivationPathsMap),
|
|
66
|
+
derivationPathsMap,
|
|
67
|
+
multisigData,
|
|
54
68
|
})
|
|
55
69
|
|
|
56
|
-
|
|
70
|
+
if (multisigData) {
|
|
71
|
+
applyMultisigSignatures(psbt, signatures)
|
|
72
|
+
} else {
|
|
73
|
+
applySignatures(psbt, signatures, inputsToSign)
|
|
74
|
+
}
|
|
57
75
|
}
|
|
58
76
|
}
|
|
59
77
|
|
|
60
|
-
function
|
|
61
|
-
const
|
|
78
|
+
function getDerivationPathsMap({ resolvePurpose, accountIndex, addressPathsMap }) {
|
|
79
|
+
const derivationPathsMap = {}
|
|
62
80
|
for (const [address, path] of Object.entries(addressPathsMap)) {
|
|
63
81
|
const purpose = resolvePurpose(address)
|
|
64
82
|
const derivationPath = `m/${purpose}'/0'/${accountIndex}'/${path.slice(2)}` // TODO: coinindex
|
|
65
|
-
|
|
83
|
+
derivationPathsMap[address] = derivationPath
|
|
66
84
|
}
|
|
67
85
|
|
|
68
|
-
return
|
|
86
|
+
return derivationPathsMap
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function applyMultisigSignatures(psbt, signatures) {
|
|
90
|
+
for (const signature of signatures) {
|
|
91
|
+
const input = psbt.data.inputs[signature.inputIndex]
|
|
92
|
+
if (!input.tapScriptSig) input.tapScriptSig = []
|
|
93
|
+
input.tapScriptSig.push({
|
|
94
|
+
pubkey: signature.publicKey,
|
|
95
|
+
signature: signature.signature,
|
|
96
|
+
leafHash: signature.tapleafHash,
|
|
97
|
+
})
|
|
98
|
+
}
|
|
69
99
|
}
|
|
70
100
|
|
|
71
101
|
export function applySignatures(psbt, signatures, inputsToSign) {
|
package/src/tx-sign/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { signTxFactory } from './default-create-tx'
|
|
2
|
-
export { serializeTx } from './common'
|
|
3
|
-
export { signHardwareFactory } from './default-sign-hardware'
|
|
4
|
-
export { createPrepareForSigning } from './default-prepare-for-signing'
|
|
1
|
+
export { signTxFactory } from './default-create-tx.js'
|
|
2
|
+
export { serializeTx } from './common.js'
|
|
3
|
+
export { signHardwareFactory } from './default-sign-hardware.js'
|
|
4
|
+
export { createPrepareForSigning } from './default-prepare-for-signing.js'
|
package/src/tx-sign/taproot.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { crypto } from '@exodus/bitcoinjs-lib'
|
|
2
2
|
import assert from 'minimalistic-assert'
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { ecc } from '../bitcoinjs-lib/ecc/index.js'
|
|
5
|
+
import { getECPair } from '../bitcoinjs-lib/index.js'
|
|
6
6
|
import defaultEntropy from './default-entropy.cjs'
|
|
7
7
|
|
|
8
8
|
const ECPair = getECPair()
|
package/src/tx-utils.js
CHANGED
package/src/utxos-utils.js
CHANGED