ecash-lib 0.1.0-rc2 → 0.1.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 (91) hide show
  1. package/README.md +73 -15
  2. package/dist/ecc.d.ts +6 -2
  3. package/dist/ecc.d.ts.map +1 -1
  4. package/dist/ecc.js +9 -6
  5. package/dist/ecc.js.map +1 -1
  6. package/dist/ffi/ecash_lib_wasm_bg.wasm +0 -0
  7. package/dist/ffi/ecash_lib_wasm_bg_browser.wasm +0 -0
  8. package/dist/ffi/ecash_lib_wasm_bg_browser.wasm.d.ts +16 -0
  9. package/dist/ffi/ecash_lib_wasm_bg_nodejs.wasm +0 -0
  10. package/dist/ffi/ecash_lib_wasm_bg_nodejs.wasm.d.ts +16 -0
  11. package/dist/ffi/ecash_lib_wasm_browser.d.ts +90 -0
  12. package/dist/ffi/ecash_lib_wasm_browser.js +340 -0
  13. package/dist/ffi/ecash_lib_wasm_nodejs.d.ts +50 -0
  14. package/dist/ffi/ecash_lib_wasm_nodejs.js +265 -0
  15. package/dist/hash.d.ts +10 -4
  16. package/dist/hash.d.ts.map +1 -1
  17. package/dist/hash.js +20 -4
  18. package/dist/hash.js.map +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +37 -21
  22. package/dist/index.js.map +1 -1
  23. package/dist/indexBrowser.d.ts +3 -0
  24. package/dist/indexBrowser.d.ts.map +1 -0
  25. package/dist/indexBrowser.js +22 -0
  26. package/dist/indexBrowser.js.map +1 -0
  27. package/dist/indexNodeJs.d.ts +3 -0
  28. package/dist/indexNodeJs.d.ts.map +1 -0
  29. package/dist/indexNodeJs.js +22 -0
  30. package/dist/indexNodeJs.js.map +1 -0
  31. package/dist/initBrowser.d.ts +3 -0
  32. package/dist/initBrowser.d.ts.map +1 -0
  33. package/dist/initBrowser.js +44 -0
  34. package/dist/initBrowser.js.map +1 -0
  35. package/dist/initNodeJs.d.ts +3 -0
  36. package/dist/initNodeJs.d.ts.map +1 -0
  37. package/dist/initNodeJs.js +43 -0
  38. package/dist/initNodeJs.js.map +1 -0
  39. package/dist/io/bytes.js +5 -1
  40. package/dist/io/bytes.js.map +1 -1
  41. package/dist/io/hex.js +11 -4
  42. package/dist/io/hex.js.map +1 -1
  43. package/dist/io/int.js +2 -1
  44. package/dist/io/int.js.map +1 -1
  45. package/dist/io/str.d.ts +2 -0
  46. package/dist/io/str.d.ts.map +1 -1
  47. package/dist/io/str.js +11 -1
  48. package/dist/io/str.js.map +1 -1
  49. package/dist/io/varsize.js +7 -2
  50. package/dist/io/varsize.js.map +1 -1
  51. package/dist/io/writer.js +2 -1
  52. package/dist/io/writer.js.map +1 -1
  53. package/dist/io/writerbytes.js +5 -1
  54. package/dist/io/writerbytes.js.map +1 -1
  55. package/dist/io/writerlength.js +5 -1
  56. package/dist/io/writerlength.js.map +1 -1
  57. package/dist/op.js +23 -16
  58. package/dist/op.js.map +1 -1
  59. package/dist/opcode.js +126 -121
  60. package/dist/opcode.js.map +1 -1
  61. package/dist/script.d.ts +1 -0
  62. package/dist/script.d.ts.map +1 -1
  63. package/dist/script.js +34 -25
  64. package/dist/script.js.map +1 -1
  65. package/dist/sigHashType.js +23 -19
  66. package/dist/sigHashType.js.map +1 -1
  67. package/dist/test/testRunner.d.ts +1 -1
  68. package/dist/test/testRunner.d.ts.map +1 -1
  69. package/dist/test/testRunner.js +51 -26
  70. package/dist/test/testRunner.js.map +1 -1
  71. package/dist/token/alp.js +43 -36
  72. package/dist/token/alp.js.map +1 -1
  73. package/dist/token/common.js +8 -5
  74. package/dist/token/common.js.map +1 -1
  75. package/dist/token/empp.js +13 -9
  76. package/dist/token/empp.js.map +1 -1
  77. package/dist/token/slp.js +61 -53
  78. package/dist/token/slp.js.map +1 -1
  79. package/dist/tx.d.ts +2 -0
  80. package/dist/tx.d.ts.map +1 -1
  81. package/dist/tx.js +39 -21
  82. package/dist/tx.js.map +1 -1
  83. package/dist/txBuilder.js +33 -25
  84. package/dist/txBuilder.js.map +1 -1
  85. package/dist/unsignedTx.js +34 -29
  86. package/dist/unsignedTx.js.map +1 -1
  87. package/package.json +3 -3
  88. package/tsconfig.json +1 -2
  89. package/tests/alp.test.ts +0 -383
  90. package/tests/slp.test.ts +0 -1124
  91. package/tests/txBuilder.test.ts +0 -562
@@ -0,0 +1,50 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Calculate SHA256(SHA256(data)).
5
+ * @param {Uint8Array} data
6
+ * @returns {Uint8Array}
7
+ */
8
+ export function sha256d(data: Uint8Array): Uint8Array;
9
+ /**
10
+ * Calculate SHA256(data).
11
+ * @param {Uint8Array} data
12
+ * @returns {Uint8Array}
13
+ */
14
+ export function sha256(data: Uint8Array): Uint8Array;
15
+ /**
16
+ * Calculate RIPEMD160(SHA256(data)), commonly used as address hash.
17
+ * @param {Uint8Array} data
18
+ * @returns {Uint8Array}
19
+ */
20
+ export function shaRmd160(data: Uint8Array): Uint8Array;
21
+ /**
22
+ * ECC signatures with libsecp256k1.
23
+ */
24
+ export class Ecc {
25
+ free(): void;
26
+ /**
27
+ * Create a new Ecc instance.
28
+ */
29
+ constructor();
30
+ /**
31
+ * Derive a public key from secret key.
32
+ * @param {Uint8Array} seckey
33
+ * @returns {Uint8Array}
34
+ */
35
+ derivePubkey(seckey: Uint8Array): Uint8Array;
36
+ /**
37
+ * Sign an ECDSA signature.
38
+ * @param {Uint8Array} seckey
39
+ * @param {Uint8Array} msg
40
+ * @returns {Uint8Array}
41
+ */
42
+ ecdsaSign(seckey: Uint8Array, msg: Uint8Array): Uint8Array;
43
+ /**
44
+ * Sign a Schnorr signature.
45
+ * @param {Uint8Array} seckey
46
+ * @param {Uint8Array} msg
47
+ * @returns {Uint8Array}
48
+ */
49
+ schnorrSign(seckey: Uint8Array, msg: Uint8Array): Uint8Array;
50
+ }
@@ -0,0 +1,265 @@
1
+ let imports = {};
2
+ imports['__wbindgen_placeholder__'] = module.exports;
3
+ let wasm;
4
+ const { TextDecoder } = require(`util`);
5
+
6
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
7
+
8
+ cachedTextDecoder.decode();
9
+
10
+ let cachedUint8Memory0 = null;
11
+
12
+ function getUint8Memory0() {
13
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
14
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
15
+ }
16
+ return cachedUint8Memory0;
17
+ }
18
+
19
+ function getStringFromWasm0(ptr, len) {
20
+ ptr = ptr >>> 0;
21
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
22
+ }
23
+
24
+ const heap = new Array(128).fill(undefined);
25
+
26
+ heap.push(undefined, null, true, false);
27
+
28
+ let heap_next = heap.length;
29
+
30
+ function addHeapObject(obj) {
31
+ if (heap_next === heap.length) heap.push(heap.length + 1);
32
+ const idx = heap_next;
33
+ heap_next = heap[idx];
34
+
35
+ heap[idx] = obj;
36
+ return idx;
37
+ }
38
+
39
+ let WASM_VECTOR_LEN = 0;
40
+
41
+ function passArray8ToWasm0(arg, malloc) {
42
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
43
+ getUint8Memory0().set(arg, ptr / 1);
44
+ WASM_VECTOR_LEN = arg.length;
45
+ return ptr;
46
+ }
47
+
48
+ let cachedInt32Memory0 = null;
49
+
50
+ function getInt32Memory0() {
51
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
52
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
53
+ }
54
+ return cachedInt32Memory0;
55
+ }
56
+
57
+ function getObject(idx) { return heap[idx]; }
58
+
59
+ function dropObject(idx) {
60
+ if (idx < 132) return;
61
+ heap[idx] = heap_next;
62
+ heap_next = idx;
63
+ }
64
+
65
+ function takeObject(idx) {
66
+ const ret = getObject(idx);
67
+ dropObject(idx);
68
+ return ret;
69
+ }
70
+
71
+ function getArrayU8FromWasm0(ptr, len) {
72
+ ptr = ptr >>> 0;
73
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
74
+ }
75
+ /**
76
+ * Calculate SHA256(SHA256(data)).
77
+ * @param {Uint8Array} data
78
+ * @returns {Uint8Array}
79
+ */
80
+ module.exports.sha256d = function(data) {
81
+ try {
82
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
83
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
84
+ const len0 = WASM_VECTOR_LEN;
85
+ wasm.sha256d(retptr, ptr0, len0);
86
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
87
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
88
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
89
+ wasm.__wbindgen_export_1(r0, r1 * 1, 1);
90
+ return v2;
91
+ } finally {
92
+ wasm.__wbindgen_add_to_stack_pointer(16);
93
+ }
94
+ };
95
+
96
+ /**
97
+ * Calculate SHA256(data).
98
+ * @param {Uint8Array} data
99
+ * @returns {Uint8Array}
100
+ */
101
+ module.exports.sha256 = function(data) {
102
+ try {
103
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
104
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
105
+ const len0 = WASM_VECTOR_LEN;
106
+ wasm.sha256(retptr, ptr0, len0);
107
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
108
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
109
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
110
+ wasm.__wbindgen_export_1(r0, r1 * 1, 1);
111
+ return v2;
112
+ } finally {
113
+ wasm.__wbindgen_add_to_stack_pointer(16);
114
+ }
115
+ };
116
+
117
+ /**
118
+ * Calculate RIPEMD160(SHA256(data)), commonly used as address hash.
119
+ * @param {Uint8Array} data
120
+ * @returns {Uint8Array}
121
+ */
122
+ module.exports.shaRmd160 = function(data) {
123
+ try {
124
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
125
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
126
+ const len0 = WASM_VECTOR_LEN;
127
+ wasm.shaRmd160(retptr, ptr0, len0);
128
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
129
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
130
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
131
+ wasm.__wbindgen_export_1(r0, r1 * 1, 1);
132
+ return v2;
133
+ } finally {
134
+ wasm.__wbindgen_add_to_stack_pointer(16);
135
+ }
136
+ };
137
+
138
+ const EccFinalization = (typeof FinalizationRegistry === 'undefined')
139
+ ? { register: () => {}, unregister: () => {} }
140
+ : new FinalizationRegistry(ptr => wasm.__wbg_ecc_free(ptr >>> 0));
141
+ /**
142
+ * ECC signatures with libsecp256k1.
143
+ */
144
+ class Ecc {
145
+
146
+ __destroy_into_raw() {
147
+ const ptr = this.__wbg_ptr;
148
+ this.__wbg_ptr = 0;
149
+ EccFinalization.unregister(this);
150
+ return ptr;
151
+ }
152
+
153
+ free() {
154
+ const ptr = this.__destroy_into_raw();
155
+ wasm.__wbg_ecc_free(ptr);
156
+ }
157
+ /**
158
+ * Create a new Ecc instance.
159
+ */
160
+ constructor() {
161
+ const ret = wasm.ecc_new();
162
+ this.__wbg_ptr = ret >>> 0;
163
+ return this;
164
+ }
165
+ /**
166
+ * Derive a public key from secret key.
167
+ * @param {Uint8Array} seckey
168
+ * @returns {Uint8Array}
169
+ */
170
+ derivePubkey(seckey) {
171
+ try {
172
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
173
+ const ptr0 = passArray8ToWasm0(seckey, wasm.__wbindgen_export_0);
174
+ const len0 = WASM_VECTOR_LEN;
175
+ wasm.ecc_derivePubkey(retptr, this.__wbg_ptr, ptr0, len0);
176
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
177
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
178
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
179
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
180
+ if (r3) {
181
+ throw takeObject(r2);
182
+ }
183
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
184
+ wasm.__wbindgen_export_1(r0, r1 * 1, 1);
185
+ return v2;
186
+ } finally {
187
+ wasm.__wbindgen_add_to_stack_pointer(16);
188
+ }
189
+ }
190
+ /**
191
+ * Sign an ECDSA signature.
192
+ * @param {Uint8Array} seckey
193
+ * @param {Uint8Array} msg
194
+ * @returns {Uint8Array}
195
+ */
196
+ ecdsaSign(seckey, msg) {
197
+ try {
198
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
199
+ const ptr0 = passArray8ToWasm0(seckey, wasm.__wbindgen_export_0);
200
+ const len0 = WASM_VECTOR_LEN;
201
+ const ptr1 = passArray8ToWasm0(msg, wasm.__wbindgen_export_0);
202
+ const len1 = WASM_VECTOR_LEN;
203
+ wasm.ecc_ecdsaSign(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
204
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
205
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
206
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
207
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
208
+ if (r3) {
209
+ throw takeObject(r2);
210
+ }
211
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
212
+ wasm.__wbindgen_export_1(r0, r1 * 1, 1);
213
+ return v3;
214
+ } finally {
215
+ wasm.__wbindgen_add_to_stack_pointer(16);
216
+ }
217
+ }
218
+ /**
219
+ * Sign a Schnorr signature.
220
+ * @param {Uint8Array} seckey
221
+ * @param {Uint8Array} msg
222
+ * @returns {Uint8Array}
223
+ */
224
+ schnorrSign(seckey, msg) {
225
+ try {
226
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
227
+ const ptr0 = passArray8ToWasm0(seckey, wasm.__wbindgen_export_0);
228
+ const len0 = WASM_VECTOR_LEN;
229
+ const ptr1 = passArray8ToWasm0(msg, wasm.__wbindgen_export_0);
230
+ const len1 = WASM_VECTOR_LEN;
231
+ wasm.ecc_schnorrSign(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
232
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
233
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
234
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
235
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
236
+ if (r3) {
237
+ throw takeObject(r2);
238
+ }
239
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
240
+ wasm.__wbindgen_export_1(r0, r1 * 1, 1);
241
+ return v3;
242
+ } finally {
243
+ wasm.__wbindgen_add_to_stack_pointer(16);
244
+ }
245
+ }
246
+ }
247
+ module.exports.Ecc = Ecc;
248
+
249
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
250
+ const ret = getStringFromWasm0(arg0, arg1);
251
+ return addHeapObject(ret);
252
+ };
253
+
254
+ module.exports.__wbindgen_throw = function(arg0, arg1) {
255
+ throw new Error(getStringFromWasm0(arg0, arg1));
256
+ };
257
+
258
+ const path = require('path').join(__dirname, 'ecash_lib_wasm_bg_nodejs.wasm');
259
+ const bytes = require('fs').readFileSync(path);
260
+
261
+ const wasmModule = new WebAssembly.Module(bytes);
262
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
263
+ wasm = wasmInstance.exports;
264
+ module.exports.__wasm = wasm;
265
+
package/dist/hash.d.ts CHANGED
@@ -1,5 +1,11 @@
1
- import * as ffi from './ffi/ecash_lib_wasm.js';
2
- export declare const sha256: typeof ffi.sha256;
3
- export declare const sha256d: typeof ffi.sha256d;
4
- export declare const shaRmd160: typeof ffi.shaRmd160;
1
+ interface EcashLibHashes {
2
+ sha256: (data: Uint8Array) => Uint8Array;
3
+ sha256d: (data: Uint8Array) => Uint8Array;
4
+ shaRmd160: (data: Uint8Array) => Uint8Array;
5
+ }
6
+ export declare function sha256(data: Uint8Array): Uint8Array;
7
+ export declare function sha256d(data: Uint8Array): Uint8Array;
8
+ export declare function shaRmd160(data: Uint8Array): Uint8Array;
9
+ export declare function __setHashes(hashes: EcashLibHashes): void;
10
+ export {};
5
11
  //# sourceMappingURL=hash.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,GAAG,MAAM,yBAAyB,CAAC;AAE/C,eAAO,MAAM,MAAM,mBAAa,CAAC;AACjC,eAAO,MAAM,OAAO,oBAAc,CAAC;AACnC,eAAO,MAAM,SAAS,sBAAgB,CAAC"}
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAIA,UAAU,cAAc;IACpB,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,CAAC;IACzC,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,CAAC;IAC1C,SAAS,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,CAAC;CAC/C;AAID,wBAAgB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAEnD;AACD,wBAAgB,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAEpD;AACD,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAEtD;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,QAEjD"}
package/dist/hash.js CHANGED
@@ -1,8 +1,24 @@
1
+ "use strict";
1
2
  // Copyright (c) 2024 The Bitcoin developers
2
3
  // Distributed under the MIT software license, see the accompanying
3
4
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
- import * as ffi from './ffi/ecash_lib_wasm.js';
5
- export const sha256 = ffi.sha256;
6
- export const sha256d = ffi.sha256d;
7
- export const shaRmd160 = ffi.shaRmd160;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.__setHashes = exports.shaRmd160 = exports.sha256d = exports.sha256 = void 0;
7
+ let HASHES;
8
+ function sha256(data) {
9
+ return HASHES.sha256(data);
10
+ }
11
+ exports.sha256 = sha256;
12
+ function sha256d(data) {
13
+ return HASHES.sha256d(data);
14
+ }
15
+ exports.sha256d = sha256d;
16
+ function shaRmd160(data) {
17
+ return HASHES.shaRmd160(data);
18
+ }
19
+ exports.shaRmd160 = shaRmd160;
20
+ function __setHashes(hashes) {
21
+ HASHES = hashes;
22
+ }
23
+ exports.__setHashes = __setHashes;
8
24
  //# sourceMappingURL=hash.js.map
package/dist/hash.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,mEAAmE;AACnE,sEAAsE;AAEtE,OAAO,KAAK,GAAG,MAAM,yBAAyB,CAAC;AAE/C,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;AACjC,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;AACnC,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC"}
1
+ {"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,mEAAmE;AACnE,sEAAsE;;;AAQtE,IAAI,MAAsB,CAAC;AAE3B,SAAgB,MAAM,CAAC,IAAgB;IACnC,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC;AAFD,wBAEC;AACD,SAAgB,OAAO,CAAC,IAAgB;IACpC,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAFD,0BAEC;AACD,SAAgB,SAAS,CAAC,IAAgB;IACtC,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAFD,8BAEC;AAED,SAAgB,WAAW,CAAC,MAAsB;IAC9C,MAAM,GAAG,MAAM,CAAC;AACpB,CAAC;AAFD,kCAEC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export * from './ecc.js';
2
2
  export * from './hash.js';
3
- export * from './init.js';
4
3
  export * from './op.js';
5
4
  export * from './opcode.js';
6
5
  export * from './script.js';
@@ -11,6 +10,7 @@ export * from './unsignedTx.js';
11
10
  export * from './io/bytes.js';
12
11
  export * from './io/hex.js';
13
12
  export * from './io/int.js';
13
+ export * from './io/str.js';
14
14
  export * from './io/varsize.js';
15
15
  export * from './io/writer.js';
16
16
  export * from './io/writerbytes.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -1,25 +1,41 @@
1
+ "use strict";
1
2
  // Copyright (c) 2024 The Bitcoin developers
2
3
  // Distributed under the MIT software license, see the accompanying
3
4
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
- export * from './ecc.js';
5
- export * from './hash.js';
6
- export * from './init.js';
7
- export * from './op.js';
8
- export * from './opcode.js';
9
- export * from './script.js';
10
- export * from './sigHashType.js';
11
- export * from './tx.js';
12
- export * from './txBuilder.js';
13
- export * from './unsignedTx.js';
14
- export * from './io/bytes.js';
15
- export * from './io/hex.js';
16
- export * from './io/int.js';
17
- export * from './io/varsize.js';
18
- export * from './io/writer.js';
19
- export * from './io/writerbytes.js';
20
- export * from './io/writerlength.js';
21
- export * from './token/alp.js';
22
- export * from './token/common.js';
23
- export * from './token/empp.js';
24
- export * from './token/slp.js';
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./ecc.js"), exports);
21
+ __exportStar(require("./hash.js"), exports);
22
+ __exportStar(require("./op.js"), exports);
23
+ __exportStar(require("./opcode.js"), exports);
24
+ __exportStar(require("./script.js"), exports);
25
+ __exportStar(require("./sigHashType.js"), exports);
26
+ __exportStar(require("./tx.js"), exports);
27
+ __exportStar(require("./txBuilder.js"), exports);
28
+ __exportStar(require("./unsignedTx.js"), exports);
29
+ __exportStar(require("./io/bytes.js"), exports);
30
+ __exportStar(require("./io/hex.js"), exports);
31
+ __exportStar(require("./io/int.js"), exports);
32
+ __exportStar(require("./io/str.js"), exports);
33
+ __exportStar(require("./io/varsize.js"), exports);
34
+ __exportStar(require("./io/writer.js"), exports);
35
+ __exportStar(require("./io/writerbytes.js"), exports);
36
+ __exportStar(require("./io/writerlength.js"), exports);
37
+ __exportStar(require("./token/alp.js"), exports);
38
+ __exportStar(require("./token/common.js"), exports);
39
+ __exportStar(require("./token/empp.js"), exports);
40
+ __exportStar(require("./token/slp.js"), exports);
25
41
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,mEAAmE;AACnE,sEAAsE;AAEtE,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,mEAAmE;AACnE,sEAAsE;;;;;;;;;;;;;;;;AAEtE,2CAAyB;AACzB,4CAA0B;AAC1B,0CAAwB;AACxB,8CAA4B;AAC5B,8CAA4B;AAC5B,mDAAiC;AACjC,0CAAwB;AACxB,iDAA+B;AAC/B,kDAAgC;AAChC,gDAA8B;AAC9B,8CAA4B;AAC5B,8CAA4B;AAC5B,8CAA4B;AAC5B,kDAAgC;AAChC,iDAA+B;AAC/B,sDAAoC;AACpC,uDAAqC;AACrC,iDAA+B;AAC/B,oDAAkC;AAClC,kDAAgC;AAChC,iDAA+B"}
@@ -0,0 +1,3 @@
1
+ export * from './index.js';
2
+ export * from './initBrowser.js';
3
+ //# sourceMappingURL=indexBrowser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexBrowser.d.ts","sourceRoot":"","sources":["../src/indexBrowser.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ // Copyright (c) 2024 The Bitcoin developers
3
+ // Distributed under the MIT software license, see the accompanying
4
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./index.js"), exports);
21
+ __exportStar(require("./initBrowser.js"), exports);
22
+ //# sourceMappingURL=indexBrowser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexBrowser.js","sourceRoot":"","sources":["../src/indexBrowser.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,mEAAmE;AACnE,sEAAsE;;;;;;;;;;;;;;;;AAEtE,6CAA2B;AAC3B,mDAAiC"}
@@ -0,0 +1,3 @@
1
+ export * from './index.js';
2
+ export * from './initNodeJs.js';
3
+ //# sourceMappingURL=indexNodeJs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexNodeJs.d.ts","sourceRoot":"","sources":["../src/indexNodeJs.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ // Copyright (c) 2024 The Bitcoin developers
3
+ // Distributed under the MIT software license, see the accompanying
4
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./index.js"), exports);
21
+ __exportStar(require("./initNodeJs.js"), exports);
22
+ //# sourceMappingURL=indexNodeJs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexNodeJs.js","sourceRoot":"","sources":["../src/indexNodeJs.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,mEAAmE;AACnE,sEAAsE;;;;;;;;;;;;;;;;AAEtE,6CAA2B;AAC3B,kDAAgC"}
@@ -0,0 +1,3 @@
1
+ /** Load and initialize the WASM module for Web */
2
+ export declare function initWasm(): Promise<void>;
3
+ //# sourceMappingURL=initBrowser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initBrowser.d.ts","sourceRoot":"","sources":["../src/initBrowser.ts"],"names":[],"mappings":"AAQA,kDAAkD;AAClD,wBAAsB,QAAQ,kBAQ7B"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ // Copyright (c) 2024 The Bitcoin developers
3
+ // Distributed under the MIT software license, see the accompanying
4
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.initWasm = void 0;
30
+ const ecc_js_1 = require("./ecc.js");
31
+ const ecash_lib_wasm_browser_js_1 = __importStar(require("./ffi/ecash_lib_wasm_browser.js")), ffi = ecash_lib_wasm_browser_js_1;
32
+ const hash_js_1 = require("./hash.js");
33
+ /** Load and initialize the WASM module for Web */
34
+ async function initWasm() {
35
+ await (0, ecash_lib_wasm_browser_js_1.default)();
36
+ (0, ecc_js_1.__setEcc)(ffi.Ecc);
37
+ (0, hash_js_1.__setHashes)({
38
+ sha256: ffi.sha256,
39
+ sha256d: ffi.sha256d,
40
+ shaRmd160: ffi.shaRmd160,
41
+ });
42
+ }
43
+ exports.initWasm = initWasm;
44
+ //# sourceMappingURL=initBrowser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initBrowser.js","sourceRoot":"","sources":["../src/initBrowser.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,mEAAmE;AACnE,sEAAsE;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtE,qCAAoC;AACpC,gIAAmE;AACnE,uCAAwC;AAExC,kDAAkD;AAC3C,KAAK,UAAU,QAAQ;IAC1B,MAAM,IAAA,mCAAU,GAAE,CAAC;IACnB,IAAA,iBAAQ,EAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClB,IAAA,qBAAW,EAAC;QACR,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,SAAS,EAAE,GAAG,CAAC,SAAS;KAC3B,CAAC,CAAC;AACP,CAAC;AARD,4BAQC"}
@@ -0,0 +1,3 @@
1
+ /** Load and initialize the WASM module for NodeJS */
2
+ export declare function initWasm(): Promise<void>;
3
+ //# sourceMappingURL=initNodeJs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initNodeJs.d.ts","sourceRoot":"","sources":["../src/initNodeJs.ts"],"names":[],"mappings":"AAQA,qDAAqD;AACrD,wBAAsB,QAAQ,kBAO7B"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ // Copyright (c) 2024 The Bitcoin developers
3
+ // Distributed under the MIT software license, see the accompanying
4
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.initWasm = void 0;
30
+ const ecc_js_1 = require("./ecc.js");
31
+ const ffi = __importStar(require("./ffi/ecash_lib_wasm_nodejs.js"));
32
+ const hash_js_1 = require("./hash.js");
33
+ /** Load and initialize the WASM module for NodeJS */
34
+ async function initWasm() {
35
+ (0, ecc_js_1.__setEcc)(ffi.Ecc);
36
+ (0, hash_js_1.__setHashes)({
37
+ sha256: ffi.sha256,
38
+ sha256d: ffi.sha256d,
39
+ shaRmd160: ffi.shaRmd160,
40
+ });
41
+ }
42
+ exports.initWasm = initWasm;
43
+ //# sourceMappingURL=initNodeJs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initNodeJs.js","sourceRoot":"","sources":["../src/initNodeJs.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,mEAAmE;AACnE,sEAAsE;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtE,qCAAoC;AACpC,oEAAsD;AACtD,uCAAwC;AAExC,qDAAqD;AAC9C,KAAK,UAAU,QAAQ;IAC1B,IAAA,iBAAQ,EAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClB,IAAA,qBAAW,EAAC;QACR,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,SAAS,EAAE,GAAG,CAAC,SAAS;KAC3B,CAAC,CAAC;AACP,CAAC;AAPD,4BAOC"}