@xchainjs/xchain-bitcoin 2.0.0 → 2.0.2
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/lib/index.esm.js +12 -13
- package/lib/index.js +12 -13
- package/package.json +12 -12
package/lib/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ecc from '@bitcoin-js/tiny-secp256k1-asmjs';
|
|
2
2
|
import { ExplorerProvider, Network, FeeOption, checkFeeBounds } from '@xchainjs/xchain-client';
|
|
3
3
|
import { getSeed } from '@xchainjs/xchain-crypto';
|
|
4
|
-
import {
|
|
4
|
+
import { HDKey } from '@scure/bip32';
|
|
5
5
|
import * as Bitcoin from 'bitcoinjs-lib';
|
|
6
6
|
import { ECPairFactory } from 'ecpair';
|
|
7
7
|
import { Client as Client$1 } from '@xchainjs/xchain-utxo';
|
|
@@ -113,9 +113,9 @@ const BitgoProviders = {
|
|
|
113
113
|
[Network.Mainnet]: mainnetBitgoProvider,
|
|
114
114
|
};
|
|
115
115
|
const tapRootDerivationPaths = {
|
|
116
|
-
[Network.Mainnet]: `86'/0'/0'/0/`,
|
|
117
|
-
[Network.Testnet]: `86'/1'/0'/0/`,
|
|
118
|
-
[Network.Stagenet]: `86'/0'/0'/0/`,
|
|
116
|
+
[Network.Mainnet]: `m/86'/0'/0'/0/`,
|
|
117
|
+
[Network.Testnet]: `m/86'/1'/0'/0/`,
|
|
118
|
+
[Network.Stagenet]: `m/86'/0'/0'/0/`,
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
// Import statements for necessary modules and types
|
|
@@ -192,9 +192,9 @@ const defaultBTCParams = {
|
|
|
192
192
|
explorerProviders: blockstreamExplorerProviders,
|
|
193
193
|
dataProviders: [BitgoProviders, BlockcypherDataProviders],
|
|
194
194
|
rootDerivationPaths: {
|
|
195
|
-
[Network.Mainnet]: `84'/0'/0'/0/`,
|
|
196
|
-
[Network.Testnet]: `84'/1'/0'/0/`,
|
|
197
|
-
[Network.Stagenet]: `84'/0'/0'/0/`,
|
|
195
|
+
[Network.Mainnet]: `m/84'/0'/0'/0/`,
|
|
196
|
+
[Network.Testnet]: `m/84'/1'/0'/0/`,
|
|
197
|
+
[Network.Stagenet]: `m/84'/0'/0'/0/`,
|
|
198
198
|
},
|
|
199
199
|
feeBounds: {
|
|
200
200
|
lower: LOWER_FEE_BOUND,
|
|
@@ -222,9 +222,9 @@ class Client extends Client$1 {
|
|
|
222
222
|
});
|
|
223
223
|
this.addressFormat = params.addressFormat || AddressFormat.P2WPKH;
|
|
224
224
|
if (this.addressFormat === AddressFormat.P2TR) {
|
|
225
|
-
if (!((_a = this.rootDerivationPaths) === null || _a === void 0 ? void 0 : _a.mainnet.startsWith(`86'`)) ||
|
|
226
|
-
!((_b = this.rootDerivationPaths) === null || _b === void 0 ? void 0 : _b.testnet.startsWith(`86'`)) ||
|
|
227
|
-
!((_c = this.rootDerivationPaths) === null || _c === void 0 ? void 0 : _c.stagenet.startsWith(`86'`))) {
|
|
225
|
+
if (!((_a = this.rootDerivationPaths) === null || _a === void 0 ? void 0 : _a.mainnet.startsWith(`m/86'`)) ||
|
|
226
|
+
!((_b = this.rootDerivationPaths) === null || _b === void 0 ? void 0 : _b.testnet.startsWith(`m/86'`)) ||
|
|
227
|
+
!((_c = this.rootDerivationPaths) === null || _c === void 0 ? void 0 : _c.stagenet.startsWith(`m/86'`))) {
|
|
228
228
|
throw Error(`Unsupported derivation paths for Taproot client. Use 86' paths`);
|
|
229
229
|
}
|
|
230
230
|
}
|
|
@@ -461,12 +461,11 @@ class ClientKeystore extends Client {
|
|
|
461
461
|
getBtcKeys(phrase, index = 0) {
|
|
462
462
|
const btcNetwork$1 = btcNetwork(this.network);
|
|
463
463
|
const seed = getSeed(phrase);
|
|
464
|
-
const
|
|
465
|
-
const master = bip32.fromSeed(seed, btcNetwork$1).derivePath(this.getFullDerivationPath(index));
|
|
464
|
+
const master = HDKey.fromMasterSeed(Uint8Array.from(seed)).derive(this.getFullDerivationPath(index));
|
|
466
465
|
if (!master.privateKey) {
|
|
467
466
|
throw new Error('Could not get private key from phrase');
|
|
468
467
|
}
|
|
469
|
-
return ECPair.fromPrivateKey(master.privateKey, { network: btcNetwork$1 });
|
|
468
|
+
return ECPair.fromPrivateKey(Buffer.from(master.privateKey), { network: btcNetwork$1 });
|
|
470
469
|
}
|
|
471
470
|
/**
|
|
472
471
|
* Transfer BTC.
|
package/lib/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var ecc = require('@bitcoin-js/tiny-secp256k1-asmjs');
|
|
4
4
|
var xchainClient = require('@xchainjs/xchain-client');
|
|
5
5
|
var xchainCrypto = require('@xchainjs/xchain-crypto');
|
|
6
|
-
var bip32 = require('bip32');
|
|
6
|
+
var bip32 = require('@scure/bip32');
|
|
7
7
|
var Bitcoin = require('bitcoinjs-lib');
|
|
8
8
|
var ecpair = require('ecpair');
|
|
9
9
|
var xchainUtxo = require('@xchainjs/xchain-utxo');
|
|
@@ -140,9 +140,9 @@ const BitgoProviders = {
|
|
|
140
140
|
[xchainClient.Network.Mainnet]: mainnetBitgoProvider,
|
|
141
141
|
};
|
|
142
142
|
const tapRootDerivationPaths = {
|
|
143
|
-
[xchainClient.Network.Mainnet]: `86'/0'/0'/0/`,
|
|
144
|
-
[xchainClient.Network.Testnet]: `86'/1'/0'/0/`,
|
|
145
|
-
[xchainClient.Network.Stagenet]: `86'/0'/0'/0/`,
|
|
143
|
+
[xchainClient.Network.Mainnet]: `m/86'/0'/0'/0/`,
|
|
144
|
+
[xchainClient.Network.Testnet]: `m/86'/1'/0'/0/`,
|
|
145
|
+
[xchainClient.Network.Stagenet]: `m/86'/0'/0'/0/`,
|
|
146
146
|
};
|
|
147
147
|
|
|
148
148
|
// Import statements for necessary modules and types
|
|
@@ -219,9 +219,9 @@ const defaultBTCParams = {
|
|
|
219
219
|
explorerProviders: blockstreamExplorerProviders,
|
|
220
220
|
dataProviders: [BitgoProviders, BlockcypherDataProviders],
|
|
221
221
|
rootDerivationPaths: {
|
|
222
|
-
[xchainClient.Network.Mainnet]: `84'/0'/0'/0/`,
|
|
223
|
-
[xchainClient.Network.Testnet]: `84'/1'/0'/0/`,
|
|
224
|
-
[xchainClient.Network.Stagenet]: `84'/0'/0'/0/`,
|
|
222
|
+
[xchainClient.Network.Mainnet]: `m/84'/0'/0'/0/`,
|
|
223
|
+
[xchainClient.Network.Testnet]: `m/84'/1'/0'/0/`,
|
|
224
|
+
[xchainClient.Network.Stagenet]: `m/84'/0'/0'/0/`,
|
|
225
225
|
},
|
|
226
226
|
feeBounds: {
|
|
227
227
|
lower: LOWER_FEE_BOUND,
|
|
@@ -249,9 +249,9 @@ class Client extends xchainUtxo.Client {
|
|
|
249
249
|
});
|
|
250
250
|
this.addressFormat = params.addressFormat || exports.AddressFormat.P2WPKH;
|
|
251
251
|
if (this.addressFormat === exports.AddressFormat.P2TR) {
|
|
252
|
-
if (!((_a = this.rootDerivationPaths) === null || _a === void 0 ? void 0 : _a.mainnet.startsWith(`86'`)) ||
|
|
253
|
-
!((_b = this.rootDerivationPaths) === null || _b === void 0 ? void 0 : _b.testnet.startsWith(`86'`)) ||
|
|
254
|
-
!((_c = this.rootDerivationPaths) === null || _c === void 0 ? void 0 : _c.stagenet.startsWith(`86'`))) {
|
|
252
|
+
if (!((_a = this.rootDerivationPaths) === null || _a === void 0 ? void 0 : _a.mainnet.startsWith(`m/86'`)) ||
|
|
253
|
+
!((_b = this.rootDerivationPaths) === null || _b === void 0 ? void 0 : _b.testnet.startsWith(`m/86'`)) ||
|
|
254
|
+
!((_c = this.rootDerivationPaths) === null || _c === void 0 ? void 0 : _c.stagenet.startsWith(`m/86'`))) {
|
|
255
255
|
throw Error(`Unsupported derivation paths for Taproot client. Use 86' paths`);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
@@ -488,12 +488,11 @@ class ClientKeystore extends Client {
|
|
|
488
488
|
getBtcKeys(phrase, index = 0) {
|
|
489
489
|
const btcNetwork$1 = btcNetwork(this.network);
|
|
490
490
|
const seed = xchainCrypto.getSeed(phrase);
|
|
491
|
-
const
|
|
492
|
-
const master = bip32$1.fromSeed(seed, btcNetwork$1).derivePath(this.getFullDerivationPath(index));
|
|
491
|
+
const master = bip32.HDKey.fromMasterSeed(Uint8Array.from(seed)).derive(this.getFullDerivationPath(index));
|
|
493
492
|
if (!master.privateKey) {
|
|
494
493
|
throw new Error('Could not get private key from phrase');
|
|
495
494
|
}
|
|
496
|
-
return ECPair.fromPrivateKey(master.privateKey, { network: btcNetwork$1 });
|
|
495
|
+
return ECPair.fromPrivateKey(Buffer.from(master.privateKey), { network: btcNetwork$1 });
|
|
497
496
|
}
|
|
498
497
|
/**
|
|
499
498
|
* Transfer BTC.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-bitcoin",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Custom Bitcoin client and utilities used by XChainJS clients",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"XChain",
|
|
@@ -33,23 +33,23 @@
|
|
|
33
33
|
"postversion": "git push --follow-tags"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@bitcoin-js/tiny-secp256k1-asmjs": "2.2.3",
|
|
37
|
-
"@ledgerhq/hw-app-btc": "10.
|
|
38
|
-
"@
|
|
39
|
-
"@xchainjs/xchain-
|
|
40
|
-
"@xchainjs/xchain-
|
|
41
|
-
"@xchainjs/xchain-
|
|
42
|
-
"@xchainjs/xchain-utxo
|
|
43
|
-
"
|
|
44
|
-
"bitcoinjs-lib": "6.1.
|
|
45
|
-
"coininfo": "5.1.0",
|
|
36
|
+
"@bitcoin-js/tiny-secp256k1-asmjs": "^2.2.3",
|
|
37
|
+
"@ledgerhq/hw-app-btc": "10.9.0",
|
|
38
|
+
"@scure/bip32": "^1.7.0",
|
|
39
|
+
"@xchainjs/xchain-client": "2.0.2",
|
|
40
|
+
"@xchainjs/xchain-crypto": "1.0.1",
|
|
41
|
+
"@xchainjs/xchain-util": "2.0.1",
|
|
42
|
+
"@xchainjs/xchain-utxo": "2.0.2",
|
|
43
|
+
"@xchainjs/xchain-utxo-providers": "2.0.2",
|
|
44
|
+
"bitcoinjs-lib": "^6.1.7",
|
|
46
45
|
"coinselect": "3.1.12",
|
|
47
46
|
"ecpair": "2.1.0"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
49
|
"@ledgerhq/hw-transport-node-hid": "6.28.6",
|
|
50
|
+
"@types/bitcoinjs-lib": "^5.0.4",
|
|
51
51
|
"axios": "1.8.4",
|
|
52
|
-
"axios-mock-adapter": "1.
|
|
52
|
+
"axios-mock-adapter": "2.1.0"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public",
|