@nockbox/iris-wasm 0.1.2 → 0.2.0-alpha.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.
- package/iris_wasm.d.ts +70 -23
- package/iris_wasm.js +175 -56
- package/iris_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/iris_wasm.d.ts
CHANGED
|
@@ -5,29 +5,29 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export function hashNoun(noun: Uint8Array): string;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Sign a message string with a private key
|
|
9
9
|
*/
|
|
10
|
-
export function
|
|
10
|
+
export function signMessage(private_key_bytes: Uint8Array, message: string): Signature;
|
|
11
11
|
/**
|
|
12
|
-
* Hash a
|
|
12
|
+
* Hash a u64 value
|
|
13
13
|
*/
|
|
14
|
-
export function
|
|
14
|
+
export function hashU64(value: bigint): string;
|
|
15
15
|
/**
|
|
16
16
|
* Derive master key from seed bytes
|
|
17
17
|
*/
|
|
18
18
|
export function deriveMasterKey(seed: Uint8Array): ExtendedKey;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Verify a signature with a public key
|
|
21
21
|
*/
|
|
22
|
-
export function
|
|
22
|
+
export function verifySignature(public_key_bytes: Uint8Array, signature: Signature, message: string): boolean;
|
|
23
23
|
/**
|
|
24
24
|
* Derive master key from BIP39 mnemonic phrase
|
|
25
25
|
*/
|
|
26
26
|
export function deriveMasterKeyFromMnemonic(mnemonic: string, passphrase?: string | null): ExtendedKey;
|
|
27
27
|
/**
|
|
28
|
-
* Hash a
|
|
28
|
+
* Hash a public key to get its digest (for use in PKH)
|
|
29
29
|
*/
|
|
30
|
-
export function
|
|
30
|
+
export function hashPublicKey(public_key_bytes: Uint8Array): string;
|
|
31
31
|
/**
|
|
32
32
|
* The `ReadableStreamType` enum.
|
|
33
33
|
*
|
|
@@ -172,12 +172,39 @@ export class Note {
|
|
|
172
172
|
* Expects response.notes[i].note (handles version internally)
|
|
173
173
|
*/
|
|
174
174
|
static fromProtobuf(pb_note: any): Note;
|
|
175
|
+
/**
|
|
176
|
+
* Create a new V1 note (the default for new notes)
|
|
177
|
+
*/
|
|
175
178
|
constructor(version: Version, origin_page: bigint, name: Name, note_data: NoteData, assets: bigint);
|
|
176
179
|
hash(): Digest;
|
|
180
|
+
/**
|
|
181
|
+
* Create a new V0 (legacy) note
|
|
182
|
+
*
|
|
183
|
+
* V0 notes are legacy notes that use public keys directly instead of spend conditions.
|
|
184
|
+
* - `origin_page`: Block height where the note originated
|
|
185
|
+
* - `sig_m`: Number of required signatures (m-of-n)
|
|
186
|
+
* - `sig_pubkeys`: Public keys as 97-byte arrays (big-endian format)
|
|
187
|
+
* - `source_hash`: Hash of the source (seeds that created this note)
|
|
188
|
+
* - `is_coinbase`: Whether this is a coinbase note
|
|
189
|
+
* - `timelock`: Optional timelock constraints (must have at least one constraint if provided)
|
|
190
|
+
* - `assets`: Amount of nicks in this note
|
|
191
|
+
*/
|
|
192
|
+
static newV0(origin_page: bigint, sig_m: bigint, sig_pubkeys: Uint8Array[], source_hash: Digest, is_coinbase: boolean, timelock: Timelock | null | undefined, assets: bigint): Note;
|
|
177
193
|
readonly originPage: bigint;
|
|
178
194
|
readonly name: Name;
|
|
195
|
+
/**
|
|
196
|
+
* Check if this is a V0 (legacy) note
|
|
197
|
+
*/
|
|
198
|
+
readonly isV0: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Check if this is a V1 note
|
|
201
|
+
*/
|
|
202
|
+
readonly isV1: boolean;
|
|
179
203
|
readonly assets: bigint;
|
|
180
204
|
readonly version: Version;
|
|
205
|
+
/**
|
|
206
|
+
* Returns note data. For V0 notes this returns empty NoteData since V0 doesn't have this field.
|
|
207
|
+
*/
|
|
181
208
|
readonly noteData: NoteData;
|
|
182
209
|
}
|
|
183
210
|
export class NoteData {
|
|
@@ -314,7 +341,7 @@ export class SpendBuilder {
|
|
|
314
341
|
/**
|
|
315
342
|
* Create a new `SpendBuilder` with a given note and spend condition
|
|
316
343
|
*/
|
|
317
|
-
constructor(note: Note, spend_condition
|
|
344
|
+
constructor(note: Note, spend_condition?: SpendCondition | null, refund_lock?: SpendCondition | null);
|
|
318
345
|
/**
|
|
319
346
|
* Add seed to this spend
|
|
320
347
|
*
|
|
@@ -339,6 +366,19 @@ export class SpendCondition {
|
|
|
339
366
|
hash(): Digest;
|
|
340
367
|
static newPkh(pkh: Pkh): SpendCondition;
|
|
341
368
|
}
|
|
369
|
+
/**
|
|
370
|
+
* Timelock for V0 (legacy) notes
|
|
371
|
+
*
|
|
372
|
+
* This is similar to LockTim but used for v0 notes' timelock constraints.
|
|
373
|
+
* At least one constraint (min or max in either rel or abs) must be set.
|
|
374
|
+
*/
|
|
375
|
+
export class Timelock {
|
|
376
|
+
free(): void;
|
|
377
|
+
[Symbol.dispose](): void;
|
|
378
|
+
constructor(rel: TimelockRange, abs: TimelockRange);
|
|
379
|
+
readonly abs: TimelockRange;
|
|
380
|
+
readonly rel: TimelockRange;
|
|
381
|
+
}
|
|
342
382
|
export class TimelockRange {
|
|
343
383
|
free(): void;
|
|
344
384
|
[Symbol.dispose](): void;
|
|
@@ -483,6 +523,7 @@ export interface InitOutput {
|
|
|
483
523
|
readonly __wbg_source_free: (a: number, b: number) => void;
|
|
484
524
|
readonly __wbg_spendbuilder_free: (a: number, b: number) => void;
|
|
485
525
|
readonly __wbg_spendcondition_free: (a: number, b: number) => void;
|
|
526
|
+
readonly __wbg_timelock_free: (a: number, b: number) => void;
|
|
486
527
|
readonly __wbg_timelockrange_free: (a: number, b: number) => void;
|
|
487
528
|
readonly __wbg_txbuilder_free: (a: number, b: number) => void;
|
|
488
529
|
readonly __wbg_txnotes_free: (a: number, b: number) => void;
|
|
@@ -523,9 +564,12 @@ export interface InitOutput {
|
|
|
523
564
|
readonly nockchaintx_version: (a: number) => number;
|
|
524
565
|
readonly note_assets: (a: number) => bigint;
|
|
525
566
|
readonly note_fromProtobuf: (a: any) => [number, number, number];
|
|
526
|
-
readonly note_hash: (a: number) =>
|
|
567
|
+
readonly note_hash: (a: number) => number;
|
|
568
|
+
readonly note_isV0: (a: number) => number;
|
|
569
|
+
readonly note_isV1: (a: number) => number;
|
|
527
570
|
readonly note_name: (a: number) => number;
|
|
528
|
-
readonly note_new: (a: number, b: bigint, c: number, d: number, e: bigint) => number;
|
|
571
|
+
readonly note_new: (a: number, b: bigint, c: number, d: number, e: bigint) => [number, number, number];
|
|
572
|
+
readonly note_newV0: (a: bigint, b: bigint, c: number, d: number, e: number, f: number, g: number, h: bigint) => [number, number, number];
|
|
529
573
|
readonly note_noteData: (a: number) => number;
|
|
530
574
|
readonly note_originPage: (a: number) => bigint;
|
|
531
575
|
readonly note_toProtobuf: (a: number) => [number, number, number];
|
|
@@ -553,7 +597,7 @@ export interface InitOutput {
|
|
|
553
597
|
readonly rawtx_name: (a: number) => [number, number];
|
|
554
598
|
readonly rawtx_outputs: (a: number) => [number, number];
|
|
555
599
|
readonly rawtx_toJam: (a: number) => any;
|
|
556
|
-
readonly rawtx_toNockchainTx: (a: number) => number;
|
|
600
|
+
readonly rawtx_toNockchainTx: (a: number) => [number, number, number];
|
|
557
601
|
readonly rawtx_toProtobuf: (a: number) => [number, number, number];
|
|
558
602
|
readonly rawtx_version: (a: number) => number;
|
|
559
603
|
readonly seed_gift: (a: number) => bigint;
|
|
@@ -586,11 +630,12 @@ export interface InitOutput {
|
|
|
586
630
|
readonly spendcondition_new: (a: number, b: number) => number;
|
|
587
631
|
readonly spendcondition_newPkh: (a: number) => number;
|
|
588
632
|
readonly spendcondition_toProtobuf: (a: number) => [number, number, number];
|
|
633
|
+
readonly timelock_new: (a: number, b: number) => [number, number, number];
|
|
589
634
|
readonly timelockrange_max: (a: number) => [number, bigint];
|
|
590
635
|
readonly timelockrange_min: (a: number) => [number, bigint];
|
|
591
636
|
readonly timelockrange_new: (a: number, b: bigint, c: number, d: bigint) => number;
|
|
592
637
|
readonly txbuilder_addPreimage: (a: number, b: number, c: number) => [number, number, number];
|
|
593
|
-
readonly txbuilder_allNotes: (a: number) => number;
|
|
638
|
+
readonly txbuilder_allNotes: (a: number) => [number, number, number];
|
|
594
639
|
readonly txbuilder_allSpends: (a: number) => [number, number];
|
|
595
640
|
readonly txbuilder_build: (a: number) => [number, number, number];
|
|
596
641
|
readonly txbuilder_calcFee: (a: number) => bigint;
|
|
@@ -611,18 +656,11 @@ export interface InitOutput {
|
|
|
611
656
|
readonly wasmseed_fromProtobuf: (a: any) => [number, number, number];
|
|
612
657
|
readonly wasmseed_toProtobuf: (a: number) => [number, number, number];
|
|
613
658
|
readonly version_new: (a: number) => number;
|
|
659
|
+
readonly timelock_abs: (a: number) => number;
|
|
660
|
+
readonly timelock_rel: (a: number) => number;
|
|
661
|
+
readonly __wbg_extendedkey_free: (a: number, b: number) => void;
|
|
614
662
|
readonly __wbg_grpcclient_free: (a: number, b: number) => void;
|
|
615
663
|
readonly __wbg_noun_free: (a: number, b: number) => void;
|
|
616
|
-
readonly grpcclient_getBalanceByAddress: (a: number, b: number, c: number) => any;
|
|
617
|
-
readonly grpcclient_getBalanceByFirstName: (a: number, b: number, c: number) => any;
|
|
618
|
-
readonly grpcclient_new: (a: number, b: number) => number;
|
|
619
|
-
readonly grpcclient_sendTransaction: (a: number, b: any) => any;
|
|
620
|
-
readonly grpcclient_transactionAccepted: (a: number, b: number, c: number) => any;
|
|
621
|
-
readonly noun_cue: (a: number, b: number) => [number, number, number];
|
|
622
|
-
readonly noun_fromJs: (a: any) => [number, number, number];
|
|
623
|
-
readonly noun_jam: (a: number) => [number, number, number, number];
|
|
624
|
-
readonly noun_toJs: (a: number) => [number, number, number];
|
|
625
|
-
readonly __wbg_extendedkey_free: (a: number, b: number) => void;
|
|
626
664
|
readonly __wbg_signature_free: (a: number, b: number) => void;
|
|
627
665
|
readonly deriveMasterKey: (a: number, b: number) => number;
|
|
628
666
|
readonly deriveMasterKeyFromMnemonic: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
@@ -630,9 +668,18 @@ export interface InitOutput {
|
|
|
630
668
|
readonly extendedkey_deriveChild: (a: number, b: number) => [number, number, number];
|
|
631
669
|
readonly extendedkey_privateKey: (a: number) => [number, number];
|
|
632
670
|
readonly extendedkey_publicKey: (a: number) => [number, number];
|
|
671
|
+
readonly grpcclient_getBalanceByAddress: (a: number, b: number, c: number) => any;
|
|
672
|
+
readonly grpcclient_getBalanceByFirstName: (a: number, b: number, c: number) => any;
|
|
673
|
+
readonly grpcclient_new: (a: number, b: number) => number;
|
|
674
|
+
readonly grpcclient_sendTransaction: (a: number, b: any) => any;
|
|
675
|
+
readonly grpcclient_transactionAccepted: (a: number, b: number, c: number) => any;
|
|
633
676
|
readonly hashNoun: (a: number, b: number) => [number, number, number, number];
|
|
634
677
|
readonly hashPublicKey: (a: number, b: number) => [number, number, number, number];
|
|
635
678
|
readonly hashU64: (a: bigint) => [number, number];
|
|
679
|
+
readonly noun_cue: (a: number, b: number) => [number, number, number];
|
|
680
|
+
readonly noun_fromJs: (a: any) => [number, number, number];
|
|
681
|
+
readonly noun_jam: (a: number) => [number, number, number, number];
|
|
682
|
+
readonly noun_toJs: (a: number) => [number, number, number];
|
|
636
683
|
readonly signMessage: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
637
684
|
readonly signature_c: (a: number) => [number, number];
|
|
638
685
|
readonly signature_new: (a: number, b: number, c: number, d: number) => number;
|
package/iris_wasm.js
CHANGED
|
@@ -280,48 +280,38 @@ export function hashNoun(noun) {
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
/**
|
|
283
|
-
*
|
|
284
|
-
* @param {Uint8Array}
|
|
285
|
-
* @param {Signature} signature
|
|
283
|
+
* Sign a message string with a private key
|
|
284
|
+
* @param {Uint8Array} private_key_bytes
|
|
286
285
|
* @param {string} message
|
|
287
|
-
* @returns {
|
|
286
|
+
* @returns {Signature}
|
|
288
287
|
*/
|
|
289
|
-
export function
|
|
290
|
-
const ptr0 = passArray8ToWasm0(
|
|
288
|
+
export function signMessage(private_key_bytes, message) {
|
|
289
|
+
const ptr0 = passArray8ToWasm0(private_key_bytes, wasm.__wbindgen_malloc);
|
|
291
290
|
const len0 = WASM_VECTOR_LEN;
|
|
292
|
-
_assertClass(signature, Signature);
|
|
293
291
|
const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
294
292
|
const len1 = WASM_VECTOR_LEN;
|
|
295
|
-
const ret = wasm.
|
|
293
|
+
const ret = wasm.signMessage(ptr0, len0, ptr1, len1);
|
|
296
294
|
if (ret[2]) {
|
|
297
295
|
throw takeFromExternrefTable0(ret[1]);
|
|
298
296
|
}
|
|
299
|
-
return ret[0]
|
|
297
|
+
return Signature.__wrap(ret[0]);
|
|
300
298
|
}
|
|
301
299
|
|
|
302
300
|
/**
|
|
303
|
-
* Hash a
|
|
304
|
-
* @param {
|
|
301
|
+
* Hash a u64 value
|
|
302
|
+
* @param {bigint} value
|
|
305
303
|
* @returns {string}
|
|
306
304
|
*/
|
|
307
|
-
export function
|
|
308
|
-
let
|
|
309
|
-
let
|
|
305
|
+
export function hashU64(value) {
|
|
306
|
+
let deferred1_0;
|
|
307
|
+
let deferred1_1;
|
|
310
308
|
try {
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
var len2 = ret[1];
|
|
316
|
-
if (ret[3]) {
|
|
317
|
-
ptr2 = 0; len2 = 0;
|
|
318
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
319
|
-
}
|
|
320
|
-
deferred3_0 = ptr2;
|
|
321
|
-
deferred3_1 = len2;
|
|
322
|
-
return getStringFromWasm0(ptr2, len2);
|
|
309
|
+
const ret = wasm.hashU64(value);
|
|
310
|
+
deferred1_0 = ret[0];
|
|
311
|
+
deferred1_1 = ret[1];
|
|
312
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
323
313
|
} finally {
|
|
324
|
-
wasm.__wbindgen_free(
|
|
314
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
325
315
|
}
|
|
326
316
|
}
|
|
327
317
|
|
|
@@ -338,21 +328,23 @@ export function deriveMasterKey(seed) {
|
|
|
338
328
|
}
|
|
339
329
|
|
|
340
330
|
/**
|
|
341
|
-
*
|
|
342
|
-
* @param {Uint8Array}
|
|
331
|
+
* Verify a signature with a public key
|
|
332
|
+
* @param {Uint8Array} public_key_bytes
|
|
333
|
+
* @param {Signature} signature
|
|
343
334
|
* @param {string} message
|
|
344
|
-
* @returns {
|
|
335
|
+
* @returns {boolean}
|
|
345
336
|
*/
|
|
346
|
-
export function
|
|
347
|
-
const ptr0 = passArray8ToWasm0(
|
|
337
|
+
export function verifySignature(public_key_bytes, signature, message) {
|
|
338
|
+
const ptr0 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc);
|
|
348
339
|
const len0 = WASM_VECTOR_LEN;
|
|
340
|
+
_assertClass(signature, Signature);
|
|
349
341
|
const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
350
342
|
const len1 = WASM_VECTOR_LEN;
|
|
351
|
-
const ret = wasm.
|
|
343
|
+
const ret = wasm.verifySignature(ptr0, len0, signature.__wbg_ptr, ptr1, len1);
|
|
352
344
|
if (ret[2]) {
|
|
353
345
|
throw takeFromExternrefTable0(ret[1]);
|
|
354
346
|
}
|
|
355
|
-
return
|
|
347
|
+
return ret[0] !== 0;
|
|
356
348
|
}
|
|
357
349
|
|
|
358
350
|
/**
|
|
@@ -374,20 +366,28 @@ export function deriveMasterKeyFromMnemonic(mnemonic, passphrase) {
|
|
|
374
366
|
}
|
|
375
367
|
|
|
376
368
|
/**
|
|
377
|
-
* Hash a
|
|
378
|
-
* @param {
|
|
369
|
+
* Hash a public key to get its digest (for use in PKH)
|
|
370
|
+
* @param {Uint8Array} public_key_bytes
|
|
379
371
|
* @returns {string}
|
|
380
372
|
*/
|
|
381
|
-
export function
|
|
382
|
-
let
|
|
383
|
-
let
|
|
373
|
+
export function hashPublicKey(public_key_bytes) {
|
|
374
|
+
let deferred3_0;
|
|
375
|
+
let deferred3_1;
|
|
384
376
|
try {
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
377
|
+
const ptr0 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc);
|
|
378
|
+
const len0 = WASM_VECTOR_LEN;
|
|
379
|
+
const ret = wasm.hashPublicKey(ptr0, len0);
|
|
380
|
+
var ptr2 = ret[0];
|
|
381
|
+
var len2 = ret[1];
|
|
382
|
+
if (ret[3]) {
|
|
383
|
+
ptr2 = 0; len2 = 0;
|
|
384
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
385
|
+
}
|
|
386
|
+
deferred3_0 = ptr2;
|
|
387
|
+
deferred3_1 = len2;
|
|
388
|
+
return getStringFromWasm0(ptr2, len2);
|
|
389
389
|
} finally {
|
|
390
|
-
wasm.__wbindgen_free(
|
|
390
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
|
|
@@ -1304,6 +1304,7 @@ export class Note {
|
|
|
1304
1304
|
return Note.__wrap(ret[0]);
|
|
1305
1305
|
}
|
|
1306
1306
|
/**
|
|
1307
|
+
* Create a new V1 note (the default for new notes)
|
|
1307
1308
|
* @param {Version} version
|
|
1308
1309
|
* @param {bigint} origin_page
|
|
1309
1310
|
* @param {Name} name
|
|
@@ -1318,7 +1319,10 @@ export class Note {
|
|
|
1318
1319
|
_assertClass(note_data, NoteData);
|
|
1319
1320
|
var ptr2 = note_data.__destroy_into_raw();
|
|
1320
1321
|
const ret = wasm.note_new(ptr0, origin_page, ptr1, ptr2, assets);
|
|
1321
|
-
|
|
1322
|
+
if (ret[2]) {
|
|
1323
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1324
|
+
}
|
|
1325
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
1322
1326
|
NoteFinalization.register(this, this.__wbg_ptr, this);
|
|
1323
1327
|
return this;
|
|
1324
1328
|
}
|
|
@@ -1327,10 +1331,7 @@ export class Note {
|
|
|
1327
1331
|
*/
|
|
1328
1332
|
hash() {
|
|
1329
1333
|
const ret = wasm.note_hash(this.__wbg_ptr);
|
|
1330
|
-
|
|
1331
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
1332
|
-
}
|
|
1333
|
-
return Digest.__wrap(ret[0]);
|
|
1334
|
+
return Digest.__wrap(ret);
|
|
1334
1335
|
}
|
|
1335
1336
|
/**
|
|
1336
1337
|
* @returns {Name}
|
|
@@ -1339,6 +1340,22 @@ export class Note {
|
|
|
1339
1340
|
const ret = wasm.note_name(this.__wbg_ptr);
|
|
1340
1341
|
return Name.__wrap(ret);
|
|
1341
1342
|
}
|
|
1343
|
+
/**
|
|
1344
|
+
* Check if this is a V0 (legacy) note
|
|
1345
|
+
* @returns {boolean}
|
|
1346
|
+
*/
|
|
1347
|
+
get isV0() {
|
|
1348
|
+
const ret = wasm.note_isV0(this.__wbg_ptr);
|
|
1349
|
+
return ret !== 0;
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Check if this is a V1 note
|
|
1353
|
+
* @returns {boolean}
|
|
1354
|
+
*/
|
|
1355
|
+
get isV1() {
|
|
1356
|
+
const ret = wasm.note_isV1(this.__wbg_ptr);
|
|
1357
|
+
return ret !== 0;
|
|
1358
|
+
}
|
|
1342
1359
|
/**
|
|
1343
1360
|
* @returns {bigint}
|
|
1344
1361
|
*/
|
|
@@ -1346,6 +1363,42 @@ export class Note {
|
|
|
1346
1363
|
const ret = wasm.note_assets(this.__wbg_ptr);
|
|
1347
1364
|
return BigInt.asUintN(64, ret);
|
|
1348
1365
|
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Create a new V0 (legacy) note
|
|
1368
|
+
*
|
|
1369
|
+
* V0 notes are legacy notes that use public keys directly instead of spend conditions.
|
|
1370
|
+
* - `origin_page`: Block height where the note originated
|
|
1371
|
+
* - `sig_m`: Number of required signatures (m-of-n)
|
|
1372
|
+
* - `sig_pubkeys`: Public keys as 97-byte arrays (big-endian format)
|
|
1373
|
+
* - `source_hash`: Hash of the source (seeds that created this note)
|
|
1374
|
+
* - `is_coinbase`: Whether this is a coinbase note
|
|
1375
|
+
* - `timelock`: Optional timelock constraints (must have at least one constraint if provided)
|
|
1376
|
+
* - `assets`: Amount of nicks in this note
|
|
1377
|
+
* @param {bigint} origin_page
|
|
1378
|
+
* @param {bigint} sig_m
|
|
1379
|
+
* @param {Uint8Array[]} sig_pubkeys
|
|
1380
|
+
* @param {Digest} source_hash
|
|
1381
|
+
* @param {boolean} is_coinbase
|
|
1382
|
+
* @param {Timelock | null | undefined} timelock
|
|
1383
|
+
* @param {bigint} assets
|
|
1384
|
+
* @returns {Note}
|
|
1385
|
+
*/
|
|
1386
|
+
static newV0(origin_page, sig_m, sig_pubkeys, source_hash, is_coinbase, timelock, assets) {
|
|
1387
|
+
const ptr0 = passArrayJsValueToWasm0(sig_pubkeys, wasm.__wbindgen_malloc);
|
|
1388
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1389
|
+
_assertClass(source_hash, Digest);
|
|
1390
|
+
var ptr1 = source_hash.__destroy_into_raw();
|
|
1391
|
+
let ptr2 = 0;
|
|
1392
|
+
if (!isLikeNone(timelock)) {
|
|
1393
|
+
_assertClass(timelock, Timelock);
|
|
1394
|
+
ptr2 = timelock.__destroy_into_raw();
|
|
1395
|
+
}
|
|
1396
|
+
const ret = wasm.note_newV0(origin_page, sig_m, ptr0, len0, ptr1, is_coinbase, ptr2, assets);
|
|
1397
|
+
if (ret[2]) {
|
|
1398
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1399
|
+
}
|
|
1400
|
+
return Note.__wrap(ret[0]);
|
|
1401
|
+
}
|
|
1349
1402
|
/**
|
|
1350
1403
|
* @returns {Version}
|
|
1351
1404
|
*/
|
|
@@ -1354,6 +1407,7 @@ export class Note {
|
|
|
1354
1407
|
return Version.__wrap(ret);
|
|
1355
1408
|
}
|
|
1356
1409
|
/**
|
|
1410
|
+
* Returns note data. For V0 notes this returns empty NoteData since V0 doesn't have this field.
|
|
1357
1411
|
* @returns {NoteData}
|
|
1358
1412
|
*/
|
|
1359
1413
|
get noteData() {
|
|
@@ -1759,7 +1813,10 @@ export class RawTx {
|
|
|
1759
1813
|
*/
|
|
1760
1814
|
toNockchainTx() {
|
|
1761
1815
|
const ret = wasm.rawtx_toNockchainTx(this.__wbg_ptr);
|
|
1762
|
-
|
|
1816
|
+
if (ret[2]) {
|
|
1817
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1818
|
+
}
|
|
1819
|
+
return NockchainTx.__wrap(ret[0]);
|
|
1763
1820
|
}
|
|
1764
1821
|
/**
|
|
1765
1822
|
* @returns {Digest}
|
|
@@ -2176,14 +2233,17 @@ export class SpendBuilder {
|
|
|
2176
2233
|
/**
|
|
2177
2234
|
* Create a new `SpendBuilder` with a given note and spend condition
|
|
2178
2235
|
* @param {Note} note
|
|
2179
|
-
* @param {SpendCondition} spend_condition
|
|
2236
|
+
* @param {SpendCondition | null} [spend_condition]
|
|
2180
2237
|
* @param {SpendCondition | null} [refund_lock]
|
|
2181
2238
|
*/
|
|
2182
2239
|
constructor(note, spend_condition, refund_lock) {
|
|
2183
2240
|
_assertClass(note, Note);
|
|
2184
2241
|
var ptr0 = note.__destroy_into_raw();
|
|
2185
|
-
|
|
2186
|
-
|
|
2242
|
+
let ptr1 = 0;
|
|
2243
|
+
if (!isLikeNone(spend_condition)) {
|
|
2244
|
+
_assertClass(spend_condition, SpendCondition);
|
|
2245
|
+
ptr1 = spend_condition.__destroy_into_raw();
|
|
2246
|
+
}
|
|
2187
2247
|
let ptr2 = 0;
|
|
2188
2248
|
if (!isLikeNone(refund_lock)) {
|
|
2189
2249
|
_assertClass(refund_lock, SpendCondition);
|
|
@@ -2328,6 +2388,62 @@ export class SpendCondition {
|
|
|
2328
2388
|
}
|
|
2329
2389
|
if (Symbol.dispose) SpendCondition.prototype[Symbol.dispose] = SpendCondition.prototype.free;
|
|
2330
2390
|
|
|
2391
|
+
const TimelockFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2392
|
+
? { register: () => {}, unregister: () => {} }
|
|
2393
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_timelock_free(ptr >>> 0, 1));
|
|
2394
|
+
/**
|
|
2395
|
+
* Timelock for V0 (legacy) notes
|
|
2396
|
+
*
|
|
2397
|
+
* This is similar to LockTim but used for v0 notes' timelock constraints.
|
|
2398
|
+
* At least one constraint (min or max in either rel or abs) must be set.
|
|
2399
|
+
*/
|
|
2400
|
+
export class Timelock {
|
|
2401
|
+
|
|
2402
|
+
__destroy_into_raw() {
|
|
2403
|
+
const ptr = this.__wbg_ptr;
|
|
2404
|
+
this.__wbg_ptr = 0;
|
|
2405
|
+
TimelockFinalization.unregister(this);
|
|
2406
|
+
return ptr;
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2409
|
+
free() {
|
|
2410
|
+
const ptr = this.__destroy_into_raw();
|
|
2411
|
+
wasm.__wbg_timelock_free(ptr, 0);
|
|
2412
|
+
}
|
|
2413
|
+
/**
|
|
2414
|
+
* @returns {TimelockRange}
|
|
2415
|
+
*/
|
|
2416
|
+
get abs() {
|
|
2417
|
+
const ret = wasm.locktim_abs(this.__wbg_ptr);
|
|
2418
|
+
return TimelockRange.__wrap(ret);
|
|
2419
|
+
}
|
|
2420
|
+
/**
|
|
2421
|
+
* @param {TimelockRange} rel
|
|
2422
|
+
* @param {TimelockRange} abs
|
|
2423
|
+
*/
|
|
2424
|
+
constructor(rel, abs) {
|
|
2425
|
+
_assertClass(rel, TimelockRange);
|
|
2426
|
+
var ptr0 = rel.__destroy_into_raw();
|
|
2427
|
+
_assertClass(abs, TimelockRange);
|
|
2428
|
+
var ptr1 = abs.__destroy_into_raw();
|
|
2429
|
+
const ret = wasm.timelock_new(ptr0, ptr1);
|
|
2430
|
+
if (ret[2]) {
|
|
2431
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2432
|
+
}
|
|
2433
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
2434
|
+
TimelockFinalization.register(this, this.__wbg_ptr, this);
|
|
2435
|
+
return this;
|
|
2436
|
+
}
|
|
2437
|
+
/**
|
|
2438
|
+
* @returns {TimelockRange}
|
|
2439
|
+
*/
|
|
2440
|
+
get rel() {
|
|
2441
|
+
const ret = wasm.locktim_rel(this.__wbg_ptr);
|
|
2442
|
+
return TimelockRange.__wrap(ret);
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
if (Symbol.dispose) Timelock.prototype[Symbol.dispose] = Timelock.prototype.free;
|
|
2446
|
+
|
|
2331
2447
|
const TimelockRangeFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2332
2448
|
? { register: () => {}, unregister: () => {} }
|
|
2333
2449
|
: new FinalizationRegistry(ptr => wasm.__wbg_timelockrange_free(ptr >>> 0, 1));
|
|
@@ -2617,7 +2733,10 @@ export class TxBuilder {
|
|
|
2617
2733
|
*/
|
|
2618
2734
|
allNotes() {
|
|
2619
2735
|
const ret = wasm.txbuilder_allNotes(this.__wbg_ptr);
|
|
2620
|
-
|
|
2736
|
+
if (ret[2]) {
|
|
2737
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2738
|
+
}
|
|
2739
|
+
return TxNotes.__wrap(ret[0]);
|
|
2621
2740
|
}
|
|
2622
2741
|
}
|
|
2623
2742
|
if (Symbol.dispose) TxBuilder.prototype[Symbol.dispose] = TxBuilder.prototype.free;
|
|
@@ -3252,8 +3371,8 @@ function __wbg_get_imports() {
|
|
|
3252
3371
|
const ret = BigInt.asUintN(64, arg0);
|
|
3253
3372
|
return ret;
|
|
3254
3373
|
};
|
|
3255
|
-
imports.wbg.
|
|
3256
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
3374
|
+
imports.wbg.__wbindgen_cast_8b855ba391b91225 = function(arg0, arg1) {
|
|
3375
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 285, function: Function { arguments: [Externref], shim_idx: 286, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3257
3376
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h20e54f17b0de8c43, wasm_bindgen__convert__closures_____invoke__hbf186e27576c509b);
|
|
3258
3377
|
return ret;
|
|
3259
3378
|
};
|
package/iris_wasm_bg.wasm
CHANGED
|
Binary file
|