@exodus/bitcoin-api 2.24.0 → 2.25.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 +16 -0
- package/package.json +5 -5
- package/src/btc-like-address.js +1 -1
- package/src/btc-like-keys.js +3 -3
- package/src/fee/fee-estimator.js +1 -1
- package/src/fee/script-classifier.js +3 -4
- package/src/hash-utils.js +3 -8
- package/src/index.js +9 -2
- package/src/multisig-address.js +3 -3
- package/src/parse-unsigned-tx.js +1 -1
- package/src/tx-log/bitcoin-monitor-scanner.js +2 -1
- package/src/tx-send/batch-tx.js +1 -1
- package/src/tx-send/index.js +1 -1
- package/src/tx-sign/create-get-key-and-purpose.js +3 -7
- package/src/tx-sign/create-sign-with-wallet.js +2 -3
- package/src/tx-sign/default-prepare-for-signing.js +1 -1
- package/src/tx-sign/taproot.js +2 -5
- package/src/bitcoinjs-lib/ec-pair.js +0 -10
- package/src/bitcoinjs-lib/ecc/index.js +0 -4
- package/src/bitcoinjs-lib/ecc-utils.js +0 -3
- package/src/bitcoinjs-lib/index.js +0 -3
- package/src/bitcoinjs-lib/script-classify/index.js +0 -48
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.25.0](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.24.0...@exodus/bitcoin-api@2.25.0) (2024-09-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* import secp256k1 impl directly in bitcoin-api ([#3980](https://github.com/ExodusMovement/assets/issues/3980)) ([5e7f014](https://github.com/ExodusMovement/assets/commit/5e7f014b957fe27e96548277c4ec6e3038045fd0))
|
|
12
|
+
* move ec-pair and script-classify to bitcoinjs ([#4001](https://github.com/ExodusMovement/assets/issues/4001)) ([adb759b](https://github.com/ExodusMovement/assets/commit/adb759be5b264194f216b6a8f65d370f63555d81))
|
|
13
|
+
* unfork bitcoinjs-lib ([#3968](https://github.com/ExodusMovement/assets/issues/3968)) ([287ba8f](https://github.com/ExodusMovement/assets/commit/287ba8f4e7dacb0f4eb91f31090b74a67eb78733))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* bitcoin monitor unused addresses ([#3973](https://github.com/ExodusMovement/assets/issues/3973)) ([e133efc](https://github.com/ExodusMovement/assets/commit/e133efc5c9f472b9611e1b7b9ead78c7c366ba89))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [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
23
|
|
|
8
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/bitcoin-api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.25.0",
|
|
4
4
|
"description": "Exodus bitcoin-api",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -26,7 +26,9 @@
|
|
|
26
26
|
"@exodus/bip322-js": "^1.1.0",
|
|
27
27
|
"@exodus/bip44-constants": "^195.0.0",
|
|
28
28
|
"@exodus/bitcoin-lib": "^2.4.2",
|
|
29
|
-
"@exodus/
|
|
29
|
+
"@exodus/bitcoinerlab-secp256k1": "^1.0.5-exodus.1",
|
|
30
|
+
"@exodus/bitcoinjs": "^1.1.0",
|
|
31
|
+
"@exodus/crypto": "^1.0.0-rc.7",
|
|
30
32
|
"@exodus/currency": "^5.0.2",
|
|
31
33
|
"@exodus/key-identifier": "^1.1.1",
|
|
32
34
|
"@exodus/models": "^12.0.1",
|
|
@@ -36,9 +38,7 @@
|
|
|
36
38
|
"bn.js": "^4.12.0",
|
|
37
39
|
"bs58check": "^2.1.2",
|
|
38
40
|
"coininfo": "^5.1.0",
|
|
39
|
-
"create-hash": "^1.2.0",
|
|
40
41
|
"delay": "^4.0.1",
|
|
41
|
-
"ecpair": "^2.0.1",
|
|
42
42
|
"lodash": "^4.17.21",
|
|
43
43
|
"minimalistic-assert": "^1.0.1",
|
|
44
44
|
"ms": "^2.1.1",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"type": "git",
|
|
62
62
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "823ab98b35624d4cc58dc75fa5d081e09fdc1ee6"
|
|
65
65
|
}
|
package/src/btc-like-address.js
CHANGED
package/src/btc-like-keys.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ecc from '@exodus/bitcoinerlab-secp256k1'
|
|
2
|
+
import * as defaultBitcoinjsLib from '@exodus/bitcoinjs'
|
|
2
3
|
import * as bech32 from 'bech32'
|
|
3
4
|
import bs58check from 'bs58check'
|
|
4
5
|
import lodash from 'lodash'
|
|
@@ -6,11 +7,10 @@ import assert from 'minimalistic-assert'
|
|
|
6
7
|
import secp256k1 from 'secp256k1'
|
|
7
8
|
import wif from 'wif'
|
|
8
9
|
|
|
9
|
-
import { ecc } from './bitcoinjs-lib/ecc/index.js'
|
|
10
|
-
import { toXOnly } from './bitcoinjs-lib/ecc-utils.js'
|
|
11
10
|
import { hash160 } from './hash-utils.js'
|
|
12
11
|
|
|
13
12
|
const { identity, pickBy } = lodash
|
|
13
|
+
const toXOnly = ecc.xOnlyPointFromPoint
|
|
14
14
|
|
|
15
15
|
export const publicKeyToHashFactory = (p2pkh) => (publicKey) => {
|
|
16
16
|
const payload = Buffer.concat([Buffer.from([p2pkh]), hash160(publicKey)])
|
package/src/fee/fee-estimator.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { scriptClassify } from '@exodus/bitcoinjs'
|
|
1
2
|
import { UtxoCollection } from '@exodus/models'
|
|
2
3
|
import assert from 'minimalistic-assert'
|
|
3
4
|
import * as varuint from 'varuint-bitcoin'
|
|
4
5
|
|
|
5
|
-
import { scriptClassify } from '../bitcoinjs-lib/index.js'
|
|
6
6
|
import createDefaultFeeEstimator, { isHex } from './fee-utils.js'
|
|
7
7
|
import { scriptClassifierFactory } from './script-classifier.js'
|
|
8
8
|
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { memoizeLruCache } from '@exodus/asset-lib'
|
|
2
|
-
import
|
|
2
|
+
import { scriptClassify } from '@exodus/bitcoinjs'
|
|
3
|
+
import { hashSync } from '@exodus/crypto/hash'
|
|
3
4
|
import assert from 'minimalistic-assert'
|
|
4
5
|
|
|
5
|
-
import { scriptClassify } from '../bitcoinjs-lib/index.js'
|
|
6
|
-
|
|
7
6
|
const { P2PKH, P2SH, P2WPKH, P2WSH, P2TR } = scriptClassify.types
|
|
8
7
|
|
|
9
8
|
const cacheSize = 1000
|
|
10
9
|
const maxSize = 30
|
|
11
10
|
const hashStringIfTooBig = (str) =>
|
|
12
|
-
str.length > maxSize ?
|
|
11
|
+
str.length > maxSize ? hashSync('sha256', str, 'hex').slice(0, maxSize) : str
|
|
13
12
|
|
|
14
13
|
export const scriptClassifierFactory = ({ addressApi }) => {
|
|
15
14
|
assert(addressApi, 'addressApi is required')
|
package/src/hash-utils.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { hashSync } from '@exodus/crypto/hash'
|
|
2
2
|
|
|
3
3
|
export function hash160(buffer) {
|
|
4
|
-
|
|
5
|
-
try {
|
|
6
|
-
return createHash('ripemd160').update(sha256Hash).digest()
|
|
7
|
-
} catch {
|
|
8
|
-
return createHash('rmd160').update(sha256Hash).digest()
|
|
9
|
-
}
|
|
4
|
+
return hashSync('hash160', buffer)
|
|
10
5
|
}
|
|
11
6
|
|
|
12
7
|
export function sha256(buffer) {
|
|
13
|
-
return
|
|
8
|
+
return hashSync('sha256', buffer)
|
|
14
9
|
}
|
package/src/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import ecc from '@exodus/bitcoinerlab-secp256k1'
|
|
2
|
+
import { ECPair } from '@exodus/bitcoinjs'
|
|
3
|
+
|
|
1
4
|
export * from './account-state.js'
|
|
2
5
|
export * from './balances.js'
|
|
3
6
|
export * from './btc-address.js'
|
|
4
7
|
export * from './btc-like-address.js'
|
|
5
8
|
export * from './btc-like-keys.js'
|
|
6
|
-
export * from './bitcoinjs-lib/index.js'
|
|
7
9
|
export { default as InsightAPIClient } from './insight-api-client/index.js'
|
|
8
10
|
export { default as InsightWSClient } from './insight-api-client/ws.js'
|
|
9
11
|
export { default as bip44Constants } from './constants/bip44.js'
|
|
@@ -20,6 +22,11 @@ export * from './insight-api-client/util.js'
|
|
|
20
22
|
export * from './move-funds.js'
|
|
21
23
|
export { createEncodeMultisigContract } from './multisig-address.js'
|
|
22
24
|
export { toAsyncSigner } from './tx-sign/taproot.js'
|
|
23
|
-
export { toXOnly } from './bitcoinjs-lib/ecc-utils.js'
|
|
24
25
|
export * from './ordinals-utils.js'
|
|
25
26
|
export { signMessage } from './sign-message.js'
|
|
27
|
+
|
|
28
|
+
// TODO: remove these, kept for compat
|
|
29
|
+
export { scriptClassify } from '@exodus/bitcoinjs'
|
|
30
|
+
export { default as ecc, xOnlyPointFromPoint as toXOnly } from '@exodus/bitcoinerlab-secp256k1'
|
|
31
|
+
export const eccFactory = () => ecc
|
|
32
|
+
export const getECPair = () => ECPair
|
package/src/multisig-address.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import defaultEcc from '@exodus/bitcoinerlab-secp256k1'
|
|
2
|
+
import * as defaultBitcoinjsLib from '@exodus/bitcoinjs'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
import { toXOnly } from './bitcoinjs-lib/ecc-utils.js'
|
|
4
|
+
const toXOnly = defaultEcc.xOnlyPointFromPoint
|
|
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(
|
package/src/parse-unsigned-tx.js
CHANGED
|
@@ -113,6 +113,7 @@ export class BitcoinMonitorScanner {
|
|
|
113
113
|
const unusedAddressIndexes = await assetClientInterface.getUnusedAddressIndexes({
|
|
114
114
|
assetName,
|
|
115
115
|
walletAccount,
|
|
116
|
+
highestUnusedIndexes: true,
|
|
116
117
|
})
|
|
117
118
|
|
|
118
119
|
const resolvedGapLimit = await this.#getGapLimit({ assetConfig, refresh })
|
|
@@ -579,7 +580,7 @@ export class BitcoinMonitorScanner {
|
|
|
579
580
|
txLogItem.from = from
|
|
580
581
|
}
|
|
581
582
|
|
|
582
|
-
if (currentTxs.has(txLogItem.txId)) {
|
|
583
|
+
if (currentTxs.has(txLogItem.txId) && !refresh) {
|
|
583
584
|
const existingItem = currentTxs.get(txLogItem.txId)
|
|
584
585
|
// we only want to detect changes when it matters - when a tx confirms
|
|
585
586
|
if (
|
package/src/tx-send/batch-tx.js
CHANGED
package/src/tx-send/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getTxSequence } from '@exodus/bitcoin-lib'
|
|
2
|
-
import * as defaultBitcoinjsLib from '@exodus/bitcoinjs
|
|
2
|
+
import * as defaultBitcoinjsLib from '@exodus/bitcoinjs'
|
|
3
3
|
import { Address, UtxoCollection } from '@exodus/models'
|
|
4
4
|
import { retry } from '@exodus/simple-retry'
|
|
5
5
|
import lodash from 'lodash'
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { getOwnProperty } from '@exodus/basic-utils'
|
|
1
|
+
import { getOwnProperty, memoize } from '@exodus/basic-utils'
|
|
2
|
+
import { ECPair } from '@exodus/bitcoinjs'
|
|
2
3
|
import KeyIdentifier from '@exodus/key-identifier'
|
|
3
4
|
import BipPath from 'bip32-path'
|
|
4
|
-
import lodash from 'lodash'
|
|
5
5
|
import assert from 'minimalistic-assert'
|
|
6
6
|
import secp256k1 from 'secp256k1'
|
|
7
7
|
|
|
8
|
-
import { getECPair } from '../bitcoinjs-lib/index.js'
|
|
9
|
-
|
|
10
|
-
const ECPair = getECPair()
|
|
11
|
-
|
|
12
8
|
export const createGetKeyWithMetadata = ({
|
|
13
9
|
signer,
|
|
14
10
|
hdkeys,
|
|
@@ -18,7 +14,7 @@ export const createGetKeyWithMetadata = ({
|
|
|
18
14
|
coinInfo,
|
|
19
15
|
getKeyIdentifier,
|
|
20
16
|
}) =>
|
|
21
|
-
|
|
17
|
+
memoize((address) => {
|
|
22
18
|
const purpose = resolvePurpose(address)
|
|
23
19
|
const networkInfo = coinInfo.toBitcoinJS()
|
|
24
20
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { xOnlyPointFromPoint as toXOnly } from '@exodus/bitcoinerlab-secp256k1'
|
|
2
|
+
import { bip371, payments, Transaction } from '@exodus/bitcoinjs'
|
|
3
3
|
|
|
4
|
-
import { toXOnly } from '../bitcoinjs-lib/ecc-utils.js'
|
|
5
4
|
import { createGetKeyWithMetadata } from './create-get-key-and-purpose.js'
|
|
6
5
|
import { toAsyncBufferSigner, toAsyncSigner } from './taproot.js'
|
|
7
6
|
|
package/src/tx-sign/taproot.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ecc from '@exodus/bitcoinerlab-secp256k1'
|
|
2
|
+
import { crypto, ECPair } from '@exodus/bitcoinjs'
|
|
2
3
|
import assert from 'minimalistic-assert'
|
|
3
4
|
|
|
4
|
-
import { ecc } from '../bitcoinjs-lib/ecc/index.js'
|
|
5
|
-
import { getECPair } from '../bitcoinjs-lib/index.js'
|
|
6
5
|
import defaultEntropy from './default-entropy.cjs'
|
|
7
6
|
|
|
8
|
-
const ECPair = getECPair()
|
|
9
|
-
|
|
10
7
|
function tweakSigner({ signer, tweakHash, network }) {
|
|
11
8
|
assert(signer, 'signer is required')
|
|
12
9
|
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { payments } from '@exodus/bitcoinjs-lib'
|
|
2
|
-
|
|
3
|
-
function isPaymentFactory(payment) {
|
|
4
|
-
return (script, eccLib) => {
|
|
5
|
-
try {
|
|
6
|
-
payment({ output: script }, { eccLib })
|
|
7
|
-
return true
|
|
8
|
-
} catch {
|
|
9
|
-
return false
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const isP2WPKH = isPaymentFactory(payments.p2wpkh)
|
|
15
|
-
const isP2TR = isPaymentFactory(payments.p2tr)
|
|
16
|
-
const isP2PKH = isPaymentFactory(payments.p2pkh)
|
|
17
|
-
const isP2MS = isPaymentFactory(payments.p2ms)
|
|
18
|
-
const isP2PK = isPaymentFactory(payments.p2pk)
|
|
19
|
-
const isP2WSHScript = isPaymentFactory(payments.p2wsh)
|
|
20
|
-
const isP2SHScript = isPaymentFactory(payments.p2sh)
|
|
21
|
-
|
|
22
|
-
const types = {
|
|
23
|
-
P2WPKH: 'witnesspubkeyhash',
|
|
24
|
-
P2PKH: 'pubkeyhash',
|
|
25
|
-
P2MS: 'multisig',
|
|
26
|
-
P2PK: 'pubkey',
|
|
27
|
-
P2WSH: 'witnessscripthash',
|
|
28
|
-
P2SH: 'scripthash',
|
|
29
|
-
P2TR: 'taproot',
|
|
30
|
-
NONSTANDARD: 'nonstandard',
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const outputFactory = () => (script) => {
|
|
34
|
-
if (isP2WPKH(script)) return types.P2WPKH
|
|
35
|
-
if (isP2TR(script)) return types.P2TR
|
|
36
|
-
if (isP2PKH(script)) return types.P2PKH
|
|
37
|
-
if (isP2MS(script)) return types.P2MS
|
|
38
|
-
if (isP2PK(script)) return types.P2PK
|
|
39
|
-
if (isP2WSHScript(script)) return types.P2WSH
|
|
40
|
-
if (isP2SHScript(script)) return types.P2SH
|
|
41
|
-
|
|
42
|
-
return types.NONSTANDARD
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const scriptClassify = {
|
|
46
|
-
types,
|
|
47
|
-
outputFactory,
|
|
48
|
-
}
|