@xchainjs/xchain-dash 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.
@@ -1,7 +1,7 @@
1
1
  import { FeeRate, TxHash } from '@xchainjs/xchain-client';
2
2
  import { Address } from '@xchainjs/xchain-util';
3
3
  import { TxParams } from '@xchainjs/xchain-utxo';
4
- import * as Dash from 'bitcoinjs-lib';
4
+ import { ECPairInterface } from 'ecpair';
5
5
  import { Client } from './client';
6
6
  export declare class ClientKeystore extends Client {
7
7
  /**
@@ -27,7 +27,7 @@ export declare class ClientKeystore extends Client {
27
27
  * @returns {Dash.ECPairInterface} The DASH ECPairInterface object.
28
28
  * @throws {"Could not get private key from phrase"} Thrown if private key cannot be obtained from the phrase.
29
29
  */
30
- getDashKeys(phrase: string, index?: number): Dash.ECPairInterface;
30
+ getDashKeys(phrase: string, index?: number): ECPairInterface;
31
31
  /**
32
32
  * Asynchronously transfers assets between addresses.
33
33
  * @param {TxParams & { feeRate?: FeeRate }} params - Parameters for the transfer.
package/lib/index.esm.js CHANGED
@@ -2,11 +2,13 @@ import { ExplorerProvider, Network, TxType, FeeOption, checkFeeBounds } from '@x
2
2
  import { AssetType, baseAmount, assetToBase, assetAmount } from '@xchainjs/xchain-util';
3
3
  import { BlockcypherProvider, BlockcypherNetwork, BitgoProvider } from '@xchainjs/xchain-utxo-providers';
4
4
  import * as dashcore from '@dashevo/dashcore-lib';
5
- import { Client as Client$1 } from '@xchainjs/xchain-utxo';
5
+ import { toBitcoinJS, Client as Client$1 } from '@xchainjs/xchain-utxo';
6
6
  import * as Dash from 'bitcoinjs-lib';
7
- import * as coininfo from 'coininfo';
8
7
  import accumulative from 'coinselect/accumulative';
8
+ import * as ecc from '@bitcoin-js/tiny-secp256k1-asmjs';
9
9
  import { getSeed } from '@xchainjs/xchain-crypto';
10
+ import { HDKey } from '@scure/bip32';
11
+ import { ECPairFactory } from 'ecpair';
10
12
  import AppBtc from '@ledgerhq/hw-app-btc';
11
13
 
12
14
  /**
@@ -3908,9 +3910,9 @@ const dashNetwork = (network) => {
3908
3910
  switch (network) {
3909
3911
  case Network.Mainnet:
3910
3912
  case Network.Stagenet:
3911
- return coininfo.dash.main.toBitcoinJS(); // Convert Dash mainnet to BitcoinJS format
3913
+ return toBitcoinJS('dash', 'main'); // Convert Dash mainnet to BitcoinJS format
3912
3914
  case Network.Testnet:
3913
- return coininfo.dash.test.toBitcoinJS(); // Convert Dash testnet to BitcoinJS format
3915
+ return toBitcoinJS('dash', 'test'); // Convert Dash testnet to BitcoinJS format
3914
3916
  }
3915
3917
  };
3916
3918
  /**
@@ -4276,6 +4278,7 @@ const broadcastTx = (params) => __awaiter(void 0, void 0, void 0, function* () {
4276
4278
  }
4277
4279
  });
4278
4280
 
4281
+ const ECPair = ECPairFactory(ecc);
4279
4282
  class ClientKeystore extends Client {
4280
4283
  /**
4281
4284
  * Get the DASH address corresponding to the given index.
@@ -4324,11 +4327,11 @@ class ClientKeystore extends Client {
4324
4327
  getDashKeys(phrase, index = 0) {
4325
4328
  const dashNetwork$1 = dashNetwork(this.network);
4326
4329
  const seed = getSeed(phrase);
4327
- const master = Dash.bip32.fromSeed(seed, dashNetwork$1).derivePath(this.getFullDerivationPath(index));
4330
+ const master = HDKey.fromMasterSeed(Uint8Array.from(seed), dashNetwork$1.bip32).derive(this.getFullDerivationPath(index));
4328
4331
  if (!master.privateKey) {
4329
4332
  throw new Error('Could not get private key from phrase');
4330
4333
  }
4331
- return Dash.ECPair.fromPrivateKey(master.privateKey, { network: dashNetwork$1 });
4334
+ return ECPair.fromPrivateKey(Buffer.from(master.privateKey), { network: dashNetwork$1 });
4332
4335
  }
4333
4336
  /**
4334
4337
  * Asynchronously transfers assets between addresses.
package/lib/index.js CHANGED
@@ -6,9 +6,11 @@ var xchainUtxoProviders = require('@xchainjs/xchain-utxo-providers');
6
6
  var dashcore = require('@dashevo/dashcore-lib');
7
7
  var xchainUtxo = require('@xchainjs/xchain-utxo');
8
8
  var Dash = require('bitcoinjs-lib');
9
- var coininfo = require('coininfo');
10
9
  var accumulative = require('coinselect/accumulative');
10
+ var ecc = require('@bitcoin-js/tiny-secp256k1-asmjs');
11
11
  var xchainCrypto = require('@xchainjs/xchain-crypto');
12
+ var bip32 = require('@scure/bip32');
13
+ var ecpair = require('ecpair');
12
14
  var AppBtc = require('@ledgerhq/hw-app-btc');
13
15
 
14
16
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -33,8 +35,8 @@ function _interopNamespace(e) {
33
35
 
34
36
  var dashcore__namespace = /*#__PURE__*/_interopNamespace(dashcore);
35
37
  var Dash__namespace = /*#__PURE__*/_interopNamespace(Dash);
36
- var coininfo__namespace = /*#__PURE__*/_interopNamespace(coininfo);
37
38
  var accumulative__default = /*#__PURE__*/_interopDefault(accumulative);
39
+ var ecc__namespace = /*#__PURE__*/_interopNamespace(ecc);
38
40
  var AppBtc__default = /*#__PURE__*/_interopDefault(AppBtc);
39
41
 
40
42
  /**
@@ -3936,9 +3938,9 @@ const dashNetwork = (network) => {
3936
3938
  switch (network) {
3937
3939
  case xchainClient.Network.Mainnet:
3938
3940
  case xchainClient.Network.Stagenet:
3939
- return coininfo__namespace.dash.main.toBitcoinJS(); // Convert Dash mainnet to BitcoinJS format
3941
+ return xchainUtxo.toBitcoinJS('dash', 'main'); // Convert Dash mainnet to BitcoinJS format
3940
3942
  case xchainClient.Network.Testnet:
3941
- return coininfo__namespace.dash.test.toBitcoinJS(); // Convert Dash testnet to BitcoinJS format
3943
+ return xchainUtxo.toBitcoinJS('dash', 'test'); // Convert Dash testnet to BitcoinJS format
3942
3944
  }
3943
3945
  };
3944
3946
  /**
@@ -4304,6 +4306,7 @@ const broadcastTx = (params) => __awaiter(void 0, void 0, void 0, function* () {
4304
4306
  }
4305
4307
  });
4306
4308
 
4309
+ const ECPair = ecpair.ECPairFactory(ecc__namespace);
4307
4310
  class ClientKeystore extends Client {
4308
4311
  /**
4309
4312
  * Get the DASH address corresponding to the given index.
@@ -4352,11 +4355,11 @@ class ClientKeystore extends Client {
4352
4355
  getDashKeys(phrase, index = 0) {
4353
4356
  const dashNetwork$1 = dashNetwork(this.network);
4354
4357
  const seed = xchainCrypto.getSeed(phrase);
4355
- const master = Dash__namespace.bip32.fromSeed(seed, dashNetwork$1).derivePath(this.getFullDerivationPath(index));
4358
+ const master = bip32.HDKey.fromMasterSeed(Uint8Array.from(seed), dashNetwork$1.bip32).derive(this.getFullDerivationPath(index));
4356
4359
  if (!master.privateKey) {
4357
4360
  throw new Error('Could not get private key from phrase');
4358
4361
  }
4359
- return Dash__namespace.ECPair.fromPrivateKey(master.privateKey, { network: dashNetwork$1 });
4362
+ return ECPair.fromPrivateKey(Buffer.from(master.privateKey), { network: dashNetwork$1 });
4360
4363
  }
4361
4364
  /**
4362
4365
  * Asynchronously transfers assets between addresses.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-dash",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Custom Dash client and utilities used by XChainJS clients",
5
5
  "keywords": [
6
6
  "XChain",
@@ -33,22 +33,24 @@
33
33
  "postversion": "git push --follow-tags"
34
34
  },
35
35
  "dependencies": {
36
- "@dashevo/dashcore-lib": "0.19.41",
37
- "@ledgerhq/hw-app-btc": "10.1.0",
38
- "@xchainjs/xchain-client": "2.0.0",
39
- "@xchainjs/xchain-crypto": "1.0.0",
40
- "@xchainjs/xchain-util": "2.0.0",
41
- "@xchainjs/xchain-utxo": "2.0.0",
42
- "@xchainjs/xchain-utxo-providers": "2.0.0",
43
- "bitcoinjs-lib": "5.2.0",
44
- "coininfo": "5.1.0",
45
- "coinselect": "3.1.12"
36
+ "@bitcoin-js/tiny-secp256k1-asmjs": "^2.2.3",
37
+ "@dashevo/dashcore-lib": "^0.25.0",
38
+ "@ledgerhq/hw-app-btc": "10.9.0",
39
+ "@scure/bip32": "^1.7.0",
40
+ "@xchainjs/xchain-client": "2.0.2",
41
+ "@xchainjs/xchain-crypto": "1.0.1",
42
+ "@xchainjs/xchain-util": "2.0.1",
43
+ "@xchainjs/xchain-utxo": "2.0.2",
44
+ "@xchainjs/xchain-utxo-providers": "2.0.2",
45
+ "bitcoinjs-lib": "^6.1.7",
46
+ "coinselect": "3.1.12",
47
+ "ecpair": "2.1.0"
46
48
  },
47
49
  "devDependencies": {
48
50
  "@ledgerhq/hw-transport-node-hid": "6.28.6",
49
- "@types/bitcoinjs-lib": "5.0.0",
51
+ "@types/bitcoinjs-lib": "^5.0.4",
50
52
  "axios": "1.8.4",
51
- "axios-mock-adapter": "1.20.0"
53
+ "axios-mock-adapter": "2.1.0"
52
54
  },
53
55
  "publishConfig": {
54
56
  "access": "public",