@bitpay-labs/crypto-wallet-core 11.11.4 → 11.11.6

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.
Files changed (91) hide show
  1. package/package.json +9 -3
  2. package/ts_build/src/constants/index.d.ts +18 -1
  3. package/ts_build/src/constants/index.d.ts.map +1 -1
  4. package/ts_build/src/constants/tokens.d.ts +14 -2
  5. package/ts_build/src/constants/tokens.d.ts.map +1 -1
  6. package/ts_build/src/constants/tokens.js +8 -2
  7. package/ts_build/src/constants/tokens.js.map +1 -1
  8. package/ts_build/src/constants/units.d.ts +11 -0
  9. package/ts_build/src/constants/units.d.ts.map +1 -1
  10. package/ts_build/src/constants/units.js +11 -0
  11. package/ts_build/src/constants/units.js.map +1 -1
  12. package/ts_build/src/transactions/index.d.ts +1 -1
  13. package/ts_build/src/transactions/index.d.ts.map +1 -1
  14. package/ts_build/src/transactions/index.js.map +1 -1
  15. package/ts_build/src/types/derivation.d.ts +1 -0
  16. package/ts_build/src/types/derivation.d.ts.map +1 -1
  17. package/.mocharc.json +0 -6
  18. package/LICENSE +0 -21
  19. package/mcr.config.js +0 -17
  20. package/src/constants/address.ts +0 -7
  21. package/src/constants/algorithms.ts +0 -9
  22. package/src/constants/arc.ts +0 -4
  23. package/src/constants/chains.ts +0 -68
  24. package/src/constants/feeMinimums.ts +0 -23
  25. package/src/constants/index.ts +0 -40
  26. package/src/constants/tokens.ts +0 -227
  27. package/src/constants/units.ts +0 -300
  28. package/src/derivation/arb/index.ts +0 -3
  29. package/src/derivation/base/index.ts +0 -3
  30. package/src/derivation/bch/index.ts +0 -11
  31. package/src/derivation/btc/index.ts +0 -68
  32. package/src/derivation/doge/index.ts +0 -6
  33. package/src/derivation/eth/index.ts +0 -86
  34. package/src/derivation/index.ts +0 -140
  35. package/src/derivation/ltc/index.ts +0 -6
  36. package/src/derivation/matic/index.ts +0 -3
  37. package/src/derivation/op/index.ts +0 -3
  38. package/src/derivation/paths.ts +0 -45
  39. package/src/derivation/sol/index.ts +0 -81
  40. package/src/derivation/xrp/index.ts +0 -63
  41. package/src/index.ts +0 -48
  42. package/src/message/btc.ts +0 -28
  43. package/src/message/eth.ts +0 -47
  44. package/src/message/index.ts +0 -71
  45. package/src/message/sol.ts +0 -3
  46. package/src/message/xrp.ts +0 -4
  47. package/src/transactions/arb/index.ts +0 -14
  48. package/src/transactions/base/index.ts +0 -13
  49. package/src/transactions/bch/index.ts +0 -25
  50. package/src/transactions/btc/index.ts +0 -316
  51. package/src/transactions/doge/index.ts +0 -31
  52. package/src/transactions/erc20/abi.ts +0 -418
  53. package/src/transactions/erc20/index.ts +0 -57
  54. package/src/transactions/eth/index.ts +0 -192
  55. package/src/transactions/eth-multisig/abi.ts +0 -724
  56. package/src/transactions/eth-multisig/index.ts +0 -172
  57. package/src/transactions/index.ts +0 -85
  58. package/src/transactions/ltc/index.ts +0 -31
  59. package/src/transactions/matic/index.ts +0 -14
  60. package/src/transactions/matic-multisig/index.ts +0 -172
  61. package/src/transactions/op/index.ts +0 -14
  62. package/src/transactions/sol/index.ts +0 -306
  63. package/src/transactions/spl/index.ts +0 -192
  64. package/src/transactions/xrp/index.ts +0 -167
  65. package/src/types/derivation.ts +0 -34
  66. package/src/types/index.ts +0 -3
  67. package/src/types/message.ts +0 -15
  68. package/src/types/utils.ts +0 -1
  69. package/src/types/validation.ts +0 -4
  70. package/src/utils/bigint.ts +0 -238
  71. package/src/utils/index.ts +0 -188
  72. package/src/validation/arb/index.ts +0 -8
  73. package/src/validation/arc/index.ts +0 -8
  74. package/src/validation/base/index.ts +0 -8
  75. package/src/validation/bch/index.ts +0 -17
  76. package/src/validation/btc/index.ts +0 -17
  77. package/src/validation/doge/index.ts +0 -16
  78. package/src/validation/eth/index.ts +0 -29
  79. package/src/validation/index.ts +0 -45
  80. package/src/validation/ltc/index.ts +0 -16
  81. package/src/validation/matic/index.ts +0 -8
  82. package/src/validation/op/index.ts +0 -8
  83. package/src/validation/sol/index.ts +0 -34
  84. package/src/validation/xrp/index.ts +0 -50
  85. package/test/address.test.ts +0 -190
  86. package/test/bigint.test.ts +0 -373
  87. package/test/deriver.test.ts +0 -126
  88. package/test/transactions.test.ts +0 -2103
  89. package/test/utils.test.ts +0 -446
  90. package/test/validation.test.ts +0 -282
  91. package/tsconfig.json +0 -29
@@ -1,126 +0,0 @@
1
- import { expect } from 'chai';
2
- import crypto from 'crypto';
3
- import { Deriver } from '../src';
4
-
5
- describe('IDeriver', function () {
6
- describe('getPublicKey (Buffer-first)', () => {
7
- it('BTC: should derive the compressed secp256k1 public key', () => {
8
- // Well-known secp256k1 test vector: private key 1 maps to generator point G.
9
- const privHex = '0000000000000000000000000000000000000000000000000000000000000001';
10
- const expectedPubKey = '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798';
11
- const privBuf = Deriver.privateKeyToBuffer('BTC', privHex);
12
- try {
13
- const pubKey = Deriver.getPublicKey('BTC', 'testnet', privBuf);
14
-
15
- expect(pubKey).to.equal(expectedPubKey);
16
- expect(pubKey).to.match(/^(02|03)/);
17
- expect(pubKey).to.have.length(66);
18
- } finally {
19
- privBuf.fill(0);
20
- }
21
- });
22
-
23
- it('ETH: should derive the compressed pubKey used by wallet imports', () => {
24
- // Vetted fixture from `test/address.test.ts`.
25
- const privHex = '62b8311c71f355c5c07f6bffe9b1ae60aa20d90e2e2ec93ec11b6014b2ae6340';
26
- const expectedPubKey = '0386d153aad9395924631dbc78fa560107123a759eaa3e105958248c60cd4472ad';
27
- const expectedAddress = '0xb497281830dE4F19a3482AbF3D5C35c514e6fB36';
28
- const privBuf = Deriver.privateKeyToBuffer('ETH', privHex);
29
- try {
30
- const pubKey = Deriver.getPublicKey('ETH', 'mainnet', privBuf);
31
-
32
- expect(pubKey).to.equal(expectedPubKey);
33
- expect(pubKey).to.match(/^(02|03)/);
34
- expect(pubKey).to.have.length(66);
35
- expect(Deriver.getAddress('ETH', 'mainnet', pubKey)).to.equal(expectedAddress);
36
- } finally {
37
- privBuf.fill(0);
38
- }
39
- });
40
-
41
- it('XRP: should derive the compressed pubKey used by wallet imports', () => {
42
- // Vetted fixture from `test/address.test.ts`.
43
- const privHex = 'D02C6801D8F328FF2EAD51D01F9580AF36C8D74E2BD463963AC4ADBE51AE5F2C';
44
- const expectedPubKey = '03DBEEC5E9E76DA09C5B502A67136BC2D73423E8902A7C35A8CBC0C5A6AC0469E8';
45
- const expectedAddress = 'r9dmAJBfBe7JL2RRLiFWGJ8kM4CHEeTpgN';
46
- const privBuf = Deriver.privateKeyToBuffer('XRP', privHex);
47
- try {
48
- const pubKey = Deriver.getPublicKey('XRP', 'mainnet', privBuf);
49
-
50
- expect(pubKey).to.equal(expectedPubKey);
51
- expect(pubKey).to.match(/^(02|03)/);
52
- expect(pubKey).to.have.length(66);
53
- expect(Deriver.getAddress('XRP', 'mainnet', pubKey)).to.equal(expectedAddress);
54
- } finally {
55
- privBuf.fill(0);
56
- }
57
- });
58
-
59
- it('SOL: should derive the public key used by wallet imports', () => {
60
- // Vetted fixture from `test/address.test.ts`.
61
- const privKey = 'E4Tp4nTgMCa5dtGwqvkWoMGrJC7FKRNjcpeFFXi4nNb9';
62
- const expectedPubKey = '5c9c85b20525ee81d3cc56da1f8307ec169086ae41458c5458519aced7683b66';
63
- const expectedAddress = '7EWwMxKQa5Gru7oTcS1Wi3AaEgTfA6MU3z7MaLUT6hnD';
64
- const privBuf = Deriver.privateKeyToBuffer('SOL', privKey);
65
- try {
66
- const pubKey = Deriver.getPublicKey('SOL', 'mainnet', privBuf);
67
-
68
- expect(pubKey).to.equal(expectedPubKey);
69
- expect(pubKey).to.have.length(64);
70
- expect(Deriver.getAddress('SOL', 'mainnet', pubKey)).to.equal(expectedAddress);
71
- } finally {
72
- privBuf.fill(0);
73
- }
74
- });
75
- });
76
-
77
- describe('privateKeyToBuffer', function () {
78
- it('ETH: should accept with/without 0x', () => {
79
- const privHex = crypto.randomBytes(32).toString('hex');
80
- const privBufNo0x = Deriver.privateKeyToBuffer('ETH', privHex);
81
- const privBuf0x = Deriver.privateKeyToBuffer('ETH', `0x${privHex}`);
82
- try {
83
- expect(privBuf0x.equals(privBufNo0x)).to.be.true;
84
- } finally {
85
- privBufNo0x.fill(0);
86
- privBuf0x.fill(0);
87
- }
88
- });
89
- it('ETH: hex-stringified buffer output equals input', () => {
90
- const privHex = crypto.randomBytes(32).toString('hex');
91
- const privBuf = Deriver.privateKeyToBuffer('ETH', privHex);
92
- try {
93
- expect(privBuf.toString('hex')).to.equal(privHex);
94
- } finally {
95
- privBuf.fill(0);
96
- }
97
- });
98
-
99
- it('XRP: should accept uppercase/lowercase hex', () => {
100
- // Vetted fixture from `test/address.test.ts`.
101
- const privHexUpper = 'D02C6801D8F328FF2EAD51D01F9580AF36C8D74E2BD463963AC4ADBE51AE5F2C';
102
- const privHexLower = privHexUpper.toLowerCase();
103
- const privBufUpper = Deriver.privateKeyToBuffer('XRP', privHexUpper);
104
- const privBufLower = Deriver.privateKeyToBuffer('XRP', privHexLower);
105
- try {
106
- expect(privBufUpper.equals(privBufLower)).to.be.true;
107
- } finally {
108
- privBufUpper.fill(0);
109
- privBufLower.fill(0);
110
- }
111
- });
112
-
113
- it('XRP: hex-stringified buffer output equals fixture bytes', () => {
114
- // Vetted fixture from `test/address.test.ts`.
115
- const privHexUpper = 'D02C6801D8F328FF2EAD51D01F9580AF36C8D74E2BD463963AC4ADBE51AE5F2C';
116
- const privBuf = Deriver.privateKeyToBuffer('XRP', privHexUpper);
117
- try {
118
- expect(privBuf.toString('hex')).to.equal(privHexUpper.toLowerCase());
119
- } finally {
120
- privBuf.fill(0);
121
- }
122
- });
123
- });
124
- });
125
-
126
-