ecash-lib 4.5.2 → 4.7.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.
Files changed (84) hide show
  1. package/README.md +40 -38
  2. package/dist/address/address.d.ts +6 -10
  3. package/dist/address/address.d.ts.map +1 -1
  4. package/dist/address/address.js +17 -19
  5. package/dist/address/address.js.map +1 -1
  6. package/dist/address/legacyaddr.d.ts +1 -1
  7. package/dist/address/legacyaddr.d.ts.map +1 -1
  8. package/dist/ecc.js +2 -2
  9. package/dist/ecc.js.map +1 -1
  10. package/dist/ffi/ecash_lib_wasm_bg_browser.js +22118 -2600
  11. package/dist/ffi/ecash_lib_wasm_bg_browser.wasm +0 -0
  12. package/dist/ffi/ecash_lib_wasm_bg_nodejs.wasm +0 -0
  13. package/dist/hash.js +7 -8
  14. package/dist/hash.js.map +1 -1
  15. package/dist/hdwallet.d.ts +32 -0
  16. package/dist/hdwallet.d.ts.map +1 -1
  17. package/dist/hdwallet.js +94 -0
  18. package/dist/hdwallet.js.map +1 -1
  19. package/dist/hmac.js +3 -3
  20. package/dist/hmac.js.map +1 -1
  21. package/dist/index.js +17 -7
  22. package/dist/index.js.map +1 -1
  23. package/dist/initBrowser.js +17 -7
  24. package/dist/initBrowser.js.map +1 -1
  25. package/dist/initNodeJs.js +17 -7
  26. package/dist/initNodeJs.js.map +1 -1
  27. package/dist/io/bytes.js +2 -2
  28. package/dist/io/bytes.js.map +1 -1
  29. package/dist/io/hex.js +4 -5
  30. package/dist/io/hex.js.map +1 -1
  31. package/dist/io/str.js +2 -3
  32. package/dist/io/str.js.map +1 -1
  33. package/dist/io/varsize.js +2 -3
  34. package/dist/io/varsize.js.map +1 -1
  35. package/dist/messages.d.ts.map +1 -1
  36. package/dist/messages.js.map +1 -1
  37. package/dist/mnemonic.js +3 -4
  38. package/dist/mnemonic.js.map +1 -1
  39. package/dist/op.js +5 -6
  40. package/dist/op.js.map +1 -1
  41. package/dist/parse/opreturn.js +4 -5
  42. package/dist/parse/opreturn.js.map +1 -1
  43. package/dist/payment/asn1.js +2 -3
  44. package/dist/payment/asn1.js.map +1 -1
  45. package/dist/payment/index.js +17 -7
  46. package/dist/payment/index.js.map +1 -1
  47. package/dist/pbkdf2.js +1 -2
  48. package/dist/pbkdf2.js.map +1 -1
  49. package/dist/publicKeyCrypto.js +2 -2
  50. package/dist/publicKeyCrypto.js.map +1 -1
  51. package/dist/sigHashType.js.map +1 -1
  52. package/dist/test/testRunner.d.ts +0 -1
  53. package/dist/test/testRunner.d.ts.map +1 -1
  54. package/dist/test/testRunner.js +17 -7
  55. package/dist/test/testRunner.js.map +1 -1
  56. package/dist/token/alp.d.ts +1 -1
  57. package/dist/token/alp.d.ts.map +1 -1
  58. package/dist/token/alp.js +5 -5
  59. package/dist/token/alp.js.map +1 -1
  60. package/dist/token/alp.parse.js +1 -2
  61. package/dist/token/alp.parse.js.map +1 -1
  62. package/dist/token/common.d.ts +4 -4
  63. package/dist/token/common.d.ts.map +1 -1
  64. package/dist/token/empp.js +2 -3
  65. package/dist/token/empp.js.map +1 -1
  66. package/dist/token/slp.d.ts +1 -1
  67. package/dist/token/slp.d.ts.map +1 -1
  68. package/dist/token/slp.js +7 -7
  69. package/dist/token/slp.js.map +1 -1
  70. package/dist/token/slp.parse.js +1 -2
  71. package/dist/token/slp.parse.js.map +1 -1
  72. package/dist/tx.js +7 -7
  73. package/dist/tx.js.map +1 -1
  74. package/dist/txBuilder.d.ts.map +1 -1
  75. package/dist/txBuilder.js +4 -4
  76. package/dist/txBuilder.js.map +1 -1
  77. package/package.json +5 -5
  78. package/src/address/address.ts +27 -19
  79. package/src/ffi/ecash_lib_wasm_bg_browser.js +22118 -2600
  80. package/src/ffi/ecash_lib_wasm_bg_browser.wasm +0 -0
  81. package/src/ffi/ecash_lib_wasm_bg_nodejs.wasm +0 -0
  82. package/src/hdwallet.ts +122 -1
  83. package/src/messages.ts +4 -4
  84. package/src/sigHashType.ts +2 -2
package/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  Library for [eCash](https://e.cash) transaction building.
4
4
 
5
- - Compatible: Works on the browser using webpack, on NodeJS, jest etc.
6
- - Fast: Accelerated using the highly optimized secp256k1 library compiled to WebAssembly
7
- - Simple to use: Describe the tx to build in one TxBuilder object, and build the tx with just one `sign` call
8
- - SLP/ALP enabled: Functions to build the SLP/ALP eMPP scripts
9
- - Flexible: The "Signatory" mechanism can accommodate anything from simple wallet transfers to complex Script covenants, e.g. eCash Agora
10
- - Schnorr: eCash lib supports Schnorr and ECDSA signatures
11
- - Precise leftover ("change") computation: The tx size estimator will be exact for Schnorr signatures and very close for ECDSA signatures, even for complex scripts
5
+ - Compatible: Works on the browser using webpack, on NodeJS, jest etc.
6
+ - Fast: Accelerated using the highly optimized secp256k1 library compiled to WebAssembly
7
+ - Simple to use: Describe the tx to build in one TxBuilder object, and build the tx with just one `sign` call
8
+ - SLP/ALP enabled: Functions to build the SLP/ALP eMPP scripts
9
+ - Flexible: The "Signatory" mechanism can accommodate anything from simple wallet transfers to complex Script covenants, e.g. eCash Agora
10
+ - Schnorr: eCash lib supports Schnorr and ECDSA signatures
11
+ - Precise leftover ("change") computation: The tx size estimator will be exact for Schnorr signatures and very close for ECDSA signatures, even for complex scripts
12
12
 
13
13
  ## Usage
14
14
 
@@ -74,34 +74,36 @@ console.log(toHex(rawTx));
74
74
 
75
75
  ## Changelog
76
76
 
77
- - 0.1.1 - Validation that feePerKb is an integer
78
- - 0.1.2 - Upgrade dependencies [D16373](https://reviews.bitcoinabc.org/D16373)
79
- - 0.1.3 - Export `slpAmount` function [D16379](https://reviews.bitcoinabc.org/D16379)
80
- - 0.2.0 - Add `Script.fromAddress` method to convert cashaddr addresses to `Script`
81
- - 0.2.1 - Fix fee estimation for signatories that depend on tx outputs [D16673](https://reviews.bitcoinabc.org/D16673)
82
- - 1.0.0 - **(Breaking change)** Modify `GenesisInfo` so that `auth` and `data` types match [D17194](https://reviews.bitcoinabc.org/D17194)
83
- - 1.0.1 - Include `ecashaddrjs` and `chronik-client` installations from `npmjs` instead of local, to prevent need for peer dependencies [D17215](https://reviews.bitcoinabc.org/D17215)
84
- - 1.1.0 - Add support for the original pre-UAHF Bitcoin signatures, so we can sign transactions for other blockchains like BTC/DOGE/... [D17255](https://reviews.bitcoinabc.org/D17255)
85
- - 1.2.0 - Add `Address` class for cashaddr and legacy addresses. [D17269](https://reviews.bitcoinabc.org/D17269)
86
- - 1.2.1 - Patch type check causing txBuilder txs using change to fail in NodeJS environments [D17461](https://reviews.bitcoinabc.org/D17461)
87
- - 1.3.0 - Add `toHex()` method to `Script` to allow simple conversion to hex string [D17527](https://reviews.bitcoinabc.org/D17527)
88
- - 1.4.0 - Add `HdNode`, `entropyToMnemonic`, `mnemonicToEntropy` and `mnemonicToSeed` to complete wallet functionality [D17619](https://reviews.bitcoinabc.org/D17619)
89
- - 1.4.1 - Patch import in `mnemonic.ts` [D17621](https://reviews.bitcoinabc.org/D17621)
90
- - 1.5.0 - Support custom WASM URL and module [D17622](https://reviews.bitcoinabc.org/D17622)
91
- - 1.5.1 - `Address.withPrefix()` returns same prefix if unchanged (instead of throwing an error) [D17623](https://reviews.bitcoinabc.org/D17623)
92
- - 2.0.0 - Remove `initWasm`, auto-load the WebAssembly instead. Remove unneeded `ecc` parameters, esp. in `TxBuilder.sign` and `HdNode.fromSeed` [D17639](https://reviews.bitcoinabc.org/D17639) [D17640](https://reviews.bitcoinabc.org/D17640)
93
- - 2.1.0 - Add `signRecoverable` and `recoverSig` to `Ecc` [D17667](https://reviews.bitcoinabc.org/D17667)
94
- - 3.0.0 - Improve types and shapes in line with chronik proto updates [D17650](https://reviews.bitcoinabc.org/D17650)
95
- - 3.1.0 - Add methods for signing and verifying messages [D17778](https://reviews.bitcoinabc.org/D17778)
96
- - 3.2.0 - Add method for parsing pushes from an EMPP OP_RETURN [D18057](https://reviews.bitcoinabc.org/D18057)
97
- - 4.0.0 - Add constants and types to support `ecash-wallet` [D17822](https://reviews.bitcoinabc.org/D17822)
98
- - 4.1.0 - Add Tx deserialization methods [D18393](https://reviews.bitcoinabc.org/D18393)
99
- - 4.2.0 - Add Tx.txid() method to compute the TxId of a transaction [D18394](https://reviews.bitcoinabc.org/D18394)
100
- - 4.3.0 - Export a Tx.toHex() method [D18396](https://reviews.bitcoinabc.org/D18396)
101
- - 4.3.1 - Modify union type of payment outputs to include ecash-wallet template OP_RETURN [D18403](https://reviews.bitcoinabc.org/D18403)
102
- - 4.3.2 - Export additional token types [D18548](https://reviews.bitcoinabc.org/D18548)
103
- - 4.3.3 - Modify payment.GenesisAction to support minting NFTs (SLP_TOKEN_TYPE_NFT1_CHILD genesis txs) [D18557](https://reviews.bitcoinabc.org/D18557)
104
- - 4.4.0 - Add `parse` methods to support parsing of OP_RETURN outputScript strings as returned by chronik-client [D18659](https://reviews.bitcoinabc.org/D18659)
105
- - 4.5.0 - Add `fromTx` method to support creating a `TxBuilder` from a `Tx`, useful for creating a `TxBuilder` from a serialized partially-signed `Tx` in order to add postage and broadcast [D18838](https://reviews.bitcoinabc.org/D18838)
106
- - 4.5.1 - Add updated `testRunner` to support CI builds of monorepo apps that rely on this from the published version, e.g. `ecash-agora` [D18844](https://reviews.bitcoinabc.org/D18844)
107
- - 4.5.2 - Export constants used in `ecash-wallet` to calculate chained XEC-only txs for txs that would otherwise exceed `MAX_TX_SERSIZE`. There is no change in behavior. [D18918](https://reviews.bitcoinabc.org/D18918)
77
+ - 0.1.1 - Validation that feePerKb is an integer
78
+ - 0.1.2 - Upgrade dependencies [D16373](https://reviews.bitcoinabc.org/D16373)
79
+ - 0.1.3 - Export `slpAmount` function [D16379](https://reviews.bitcoinabc.org/D16379)
80
+ - 0.2.0 - Add `Script.fromAddress` method to convert cashaddr addresses to `Script`
81
+ - 0.2.1 - Fix fee estimation for signatories that depend on tx outputs [D16673](https://reviews.bitcoinabc.org/D16673)
82
+ - 1.0.0 - **(Breaking change)** Modify `GenesisInfo` so that `auth` and `data` types match [D17194](https://reviews.bitcoinabc.org/D17194)
83
+ - 1.0.1 - Include `ecashaddrjs` and `chronik-client` installations from `npmjs` instead of local, to prevent need for peer dependencies [D17215](https://reviews.bitcoinabc.org/D17215)
84
+ - 1.1.0 - Add support for the original pre-UAHF Bitcoin signatures, so we can sign transactions for other blockchains like BTC/DOGE/... [D17255](https://reviews.bitcoinabc.org/D17255)
85
+ - 1.2.0 - Add `Address` class for cashaddr and legacy addresses. [D17269](https://reviews.bitcoinabc.org/D17269)
86
+ - 1.2.1 - Patch type check causing txBuilder txs using change to fail in NodeJS environments [D17461](https://reviews.bitcoinabc.org/D17461)
87
+ - 1.3.0 - Add `toHex()` method to `Script` to allow simple conversion to hex string [D17527](https://reviews.bitcoinabc.org/D17527)
88
+ - 1.4.0 - Add `HdNode`, `entropyToMnemonic`, `mnemonicToEntropy` and `mnemonicToSeed` to complete wallet functionality [D17619](https://reviews.bitcoinabc.org/D17619)
89
+ - 1.4.1 - Patch import in `mnemonic.ts` [D17621](https://reviews.bitcoinabc.org/D17621)
90
+ - 1.5.0 - Support custom WASM URL and module [D17622](https://reviews.bitcoinabc.org/D17622)
91
+ - 1.5.1 - `Address.withPrefix()` returns same prefix if unchanged (instead of throwing an error) [D17623](https://reviews.bitcoinabc.org/D17623)
92
+ - 2.0.0 - Remove `initWasm`, auto-load the WebAssembly instead. Remove unneeded `ecc` parameters, esp. in `TxBuilder.sign` and `HdNode.fromSeed` [D17639](https://reviews.bitcoinabc.org/D17639) [D17640](https://reviews.bitcoinabc.org/D17640)
93
+ - 2.1.0 - Add `signRecoverable` and `recoverSig` to `Ecc` [D17667](https://reviews.bitcoinabc.org/D17667)
94
+ - 3.0.0 - Improve types and shapes in line with chronik proto updates [D17650](https://reviews.bitcoinabc.org/D17650)
95
+ - 3.1.0 - Add methods for signing and verifying messages [D17778](https://reviews.bitcoinabc.org/D17778)
96
+ - 3.2.0 - Add method for parsing pushes from an EMPP OP_RETURN [D18057](https://reviews.bitcoinabc.org/D18057)
97
+ - 4.0.0 - Add constants and types to support `ecash-wallet` [D17822](https://reviews.bitcoinabc.org/D17822)
98
+ - 4.1.0 - Add Tx deserialization methods [D18393](https://reviews.bitcoinabc.org/D18393)
99
+ - 4.2.0 - Add Tx.txid() method to compute the TxId of a transaction [D18394](https://reviews.bitcoinabc.org/D18394)
100
+ - 4.3.0 - Export a Tx.toHex() method [D18396](https://reviews.bitcoinabc.org/D18396)
101
+ - 4.3.1 - Modify union type of payment outputs to include ecash-wallet template OP_RETURN [D18403](https://reviews.bitcoinabc.org/D18403)
102
+ - 4.3.2 - Export additional token types [D18548](https://reviews.bitcoinabc.org/D18548)
103
+ - 4.3.3 - Modify payment.GenesisAction to support minting NFTs (SLP_TOKEN_TYPE_NFT1_CHILD genesis txs) [D18557](https://reviews.bitcoinabc.org/D18557)
104
+ - 4.4.0 - Add `parse` methods to support parsing of OP_RETURN outputScript strings as returned by chronik-client [D18659](https://reviews.bitcoinabc.org/D18659)
105
+ - 4.5.0 - Add `fromTx` method to support creating a `TxBuilder` from a `Tx`, useful for creating a `TxBuilder` from a serialized partially-signed `Tx` in order to add postage and broadcast [D18838](https://reviews.bitcoinabc.org/D18838)
106
+ - 4.5.1 - Add updated `testRunner` to support CI builds of monorepo apps that rely on this from the published version, e.g. `ecash-agora` [D18844](https://reviews.bitcoinabc.org/D18844)
107
+ - 4.5.2 - Export constants used in `ecash-wallet` to calculate chained XEC-only txs for txs that would otherwise exceed `MAX_TX_SERSIZE`. There is no change in behavior. [D18918](https://reviews.bitcoinabc.org/D18918)
108
+ - 4.6.0 - Support for `xpub` in `hdwallet.ts` [D19406](https://reviews.bitcoinabc.org/D19406)
109
+ - 4.7.0 - Support for custom prefix in all static Address constructors [D19441](https://reviews.bitcoinabc.org/D19441)
@@ -73,15 +73,14 @@ export declare class Address implements AddressInterface {
73
73
  private constructor();
74
74
  /**
75
75
  * Create a new p2pkh Address from hash
76
- * cashaddr encoding, ecash: prefix
76
+ * cashaddr encoding
77
77
  */
78
- static p2pkh: (hash: string | Uint8Array) => Address;
78
+ static p2pkh: (hash: string | Uint8Array, prefix?: string) => Address;
79
79
  /**
80
80
  * Create a new p2sh Address from hash
81
81
  * cashaddr encoding
82
- * ecash: prefix
83
82
  */
84
- static p2sh: (hash: string | Uint8Array) => Address;
83
+ static p2sh: (hash: string | Uint8Array, prefix?: string) => Address;
85
84
  /**
86
85
  * Create a new Address from a given address string
87
86
  * address must be valid legacy or cashaddr address
@@ -94,24 +93,21 @@ export declare class Address implements AddressInterface {
94
93
  static fromCashAddress: (address: string) => Address;
95
94
  /**
96
95
  * Create a new Address from legacy address
97
- * No prefix for Address created from legacy address
98
- * type and hash from legacy address
96
+ * prefix, type and hash from legacy address
99
97
  */
100
98
  static fromLegacyAddress: (legacy: string) => Address;
101
99
  /**
102
100
  * Create a new Address from an outputScript as Script
103
101
  * type and hash from outputScript
104
102
  * cashaddr encoding
105
- * ecash: prefix
106
103
  */
107
- static fromScript: (script: Script) => Address;
104
+ static fromScript: (script: Script, prefix?: string) => Address;
108
105
  /**
109
106
  * Create a new Address from an outputScript as hex string
110
107
  * type and hash from outputScript
111
108
  * cashaddr encoding
112
- * ecash: prefix
113
109
  */
114
- static fromScriptHex: (scriptHex: string) => Address;
110
+ static fromScriptHex: (scriptHex: string, prefix?: string) => Address;
115
111
  toString: () => string;
116
112
  legacy: () => Address;
117
113
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/address/address.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAC3C,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEpD,eAAO,MAAM,sBAAsB,UAA0B,CAAC;AAE9D;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,gBAAiB,MAAM,KAAG,MA4CrD,CAAC;AAEF,UAAU,gBAAgB;IACtB;;;;OAIG;I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AEF;;;;OAIG;IACH,MAAM,CAAC,aAAa,GAChB,WAAW,MAAM,EACjB,SAAQ,MAAuB,aAcjC;IAEF,QAAQ,eAEN;IAEF,MAAM,gBAMC;IAEP;;;OAGG;IACH,IAAI,gBAgBG;IAEP;;;OAGG;IACH,UAAU,GAAI,QAAQ,MAAM,aAgB1B;IAEF,QAAQ,QAAO,MAAM,CAInB;IAEF,WAAW,QAAO,MAAM,CAEtB;CACL"}
@@ -143,25 +143,24 @@ class Address {
143
143
  exports.Address = Address;
144
144
  /**
145
145
  * Create a new p2pkh Address from hash
146
- * cashaddr encoding, ecash: prefix
146
+ * cashaddr encoding
147
147
  */
148
- Address.p2pkh = (hash) => new Address({
148
+ Address.p2pkh = (hash, prefix = exports.DEFAULT_PREFIX) => new Address({
149
149
  type: 'p2pkh',
150
150
  hash: hash instanceof Uint8Array ? (0, hex_1.toHex)(hash) : hash,
151
- prefix: exports.DEFAULT_PREFIX,
152
- address: (0, ecashaddrjs_1.encodeCashAddress)(exports.DEFAULT_PREFIX, 'p2pkh', hash),
151
+ prefix: prefix,
152
+ address: (0, ecashaddrjs_1.encodeCashAddress)(prefix, 'p2pkh', hash),
153
153
  encoding: 'cashaddr',
154
154
  });
155
155
  /**
156
156
  * Create a new p2sh Address from hash
157
157
  * cashaddr encoding
158
- * ecash: prefix
159
158
  */
160
- Address.p2sh = (hash) => new Address({
159
+ Address.p2sh = (hash, prefix = exports.DEFAULT_PREFIX) => new Address({
161
160
  type: 'p2sh',
162
161
  hash: hash instanceof Uint8Array ? (0, hex_1.toHex)(hash) : hash,
163
- prefix: exports.DEFAULT_PREFIX,
164
- address: (0, ecashaddrjs_1.encodeCashAddress)(exports.DEFAULT_PREFIX, 'p2sh', hash),
162
+ prefix: prefix,
163
+ address: (0, ecashaddrjs_1.encodeCashAddress)(prefix, 'p2sh', hash),
165
164
  encoding: 'cashaddr',
166
165
  });
167
166
  /**
@@ -208,40 +207,39 @@ Address.fromCashAddress = (address) => {
208
207
  };
209
208
  /**
210
209
  * Create a new Address from legacy address
211
- * No prefix for Address created from legacy address
212
- * type and hash from legacy address
210
+ * prefix, type and hash from legacy address
213
211
  */
214
212
  Address.fromLegacyAddress = (legacy) => {
215
213
  // Determine addr params from legacy address
216
- const { type, hash } = (0, legacyaddr_1.decodeLegacyAddress)(legacy);
214
+ const { type, hash, network } = (0, legacyaddr_1.decodeLegacyAddress)(legacy);
217
215
  return new Address({
218
216
  type,
219
217
  hash,
220
218
  address: legacy,
221
219
  encoding: 'legacy',
220
+ prefix: network === 'testnet'
221
+ ? exports.ECASH_PREFIXES_TESTNET[0]
222
+ : exports.DEFAULT_PREFIX,
222
223
  });
223
224
  };
224
225
  /**
225
226
  * Create a new Address from an outputScript as Script
226
227
  * type and hash from outputScript
227
228
  * cashaddr encoding
228
- * ecash: prefix
229
229
  */
230
- Address.fromScript = (script) => {
230
+ Address.fromScript = (script, prefix = exports.DEFAULT_PREFIX) => {
231
231
  const scriptHex = (0, hex_1.toHex)(script.bytecode);
232
- return Address.fromScriptHex(scriptHex);
232
+ return Address.fromScriptHex(scriptHex, prefix);
233
233
  };
234
234
  /**
235
235
  * Create a new Address from an outputScript as hex string
236
236
  * type and hash from outputScript
237
237
  * cashaddr encoding
238
- * ecash: prefix
239
238
  */
240
- Address.fromScriptHex = (scriptHex) => {
239
+ Address.fromScriptHex = (scriptHex, prefix = exports.DEFAULT_PREFIX) => {
241
240
  const { type, hash } = (0, ecashaddrjs_1.getTypeAndHashFromOutputScript)(scriptHex);
242
- // Default cashaddr encoding with default prefix
243
- const address = (0, ecashaddrjs_1.encodeCashAddress)(exports.DEFAULT_PREFIX, type, hash);
244
- const prefix = exports.DEFAULT_PREFIX;
241
+ // Default cashaddr encoding
242
+ const address = (0, ecashaddrjs_1.encodeCashAddress)(prefix, type, hash);
245
243
  return new Address({
246
244
  type,
247
245
  hash,
@@ -1 +1 @@
1
- {"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/address/address.ts"],"names":[],"mappings":";;;AAA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P,CAAC,AAbuB,CAatB;AAEF;;;;GAIG;AACI,kBAAU,GAAG,CAAC,MAAc,EAAE,SAAiB,sBAAc,EAAE,EAAE;IACpE,MAAM,SAAS,GAAG,IAAA,WAAK,EAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACzC,OAAO,OAAO,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC,AAHgB,CAGf;AAEF;;;;GAIG;AACI,qBAAa,GAAG,CACnB,SAAiB,EACjB,SAAiB,sBAAc,EACjC,EAAE;IACA,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAA,4CAA8B,EAAC,SAAS,CAAC,CAAC;IAEjE,4BAA4B;IAC5B,MAAM,OAAO,GAAG,IAAA,+BAAiB,EAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAEtD,OAAO,IAAI,OAAO,CAAC;QACf,IAAI;QACJ,IAAI;QACJ,MAAM;QACN,OAAO;QACP,QAAQ,EAAE,UAAU;KACvB,CAAC,CAAC;AACP,CAAC,AAhBmB,CAgBlB"}
@@ -26,6 +26,6 @@ export declare const decodeLegacyAddress: (address: string) => DecodedLegacyAddr
26
26
  * Encode a legacy address given type and hash
27
27
  * For now, this is a stub method that supports only BTC p2pkh and p2sh
28
28
  */
29
- export declare const encodeLegacyAddress: (hash: Uint8Array, type: 'p2pkh' | 'p2sh', network?: NetworkType) => string;
29
+ export declare const encodeLegacyAddress: (hash: Uint8Array, type: "p2pkh" | "p2sh", network?: NetworkType) => string;
30
30
  export {};
31
31
  //# sourceMappingURL=legacyaddr.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"legacyaddr.d.ts","sourceRoot":"","sources":["../../src/address/legacyaddr.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC;;GAEG;AAEH,eAAO,MAAM,iBAAiB,SAAU,UAAU,KAAG,MAMpD,CAAC;AAEF,eAAO,MA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,OAAO,EAAE,mBAAmB,CAAC;KAChC,CAAC;CACL;AACD,eAAO,MAAM,oBAAoB,EAAE,oBAKlC,CAAC;AAGF,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,KAAG,oBA4CrD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAC5B,MAAM,UAAU,EAChB,MAAM,OAAO,GAAG,MAAM,EACtB,UAAS,WAAuB,WAOnC,CAAC"}
package/dist/ecc.js CHANGED
@@ -3,7 +3,8 @@
3
3
  // Distributed under the MIT software license, see the accompanying
4
4
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Ecc = exports.__setEcc = exports.EccDummy = void 0;
6
+ exports.Ecc = exports.EccDummy = void 0;
7
+ exports.__setEcc = __setEcc;
7
8
  /** Dummy Ecc impl that always returns 0, useful for measuring tx size */
8
9
  class EccDummy {
9
10
  derivePubkey(_seckey) {
@@ -41,7 +42,6 @@ const ECC = {};
41
42
  function __setEcc(ecc) {
42
43
  ECC.ecc = ecc;
43
44
  }
44
- exports.__setEcc = __setEcc;
45
45
  // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
46
46
  class Ecc {
47
47
  /** Derive a public key from secret key. */
package/dist/ecc.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ecc.js","sourceRoot":"","sources":["../src/ecc.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,mEAAmE;AACnE,sEAAsE;;;AAgDtE,yEAAyE;AACzE,MAAa,QAAQ;IACjB,YAAY,CAAC,OAAmB;QAC5B,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,SAAS,CAAC,OAAmB,EAAE,IAAgB;QAC3C,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,WAAW,CAAC,IAAgB,EAAE,IAAgB,EAAE,GAAe,IAAS,CAAC;IAEzE,W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