@utexo/rgb-lib-linux-arm64 0.3.0-beta.8

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/wrapper.js ADDED
@@ -0,0 +1,838 @@
1
+ const Big = require("big.js");
2
+ const lib = require("./rgblib");
3
+
4
+ const u8Max = new Big(255);
5
+ const u16Max = new Big(65535);
6
+ const u32Max = new Big(4294967295);
7
+ const u64Max = new Big(Number.MAX_SAFE_INTEGER);
8
+
9
+ const i8Min = new Big(-128);
10
+ const i8Max = new Big(127);
11
+ const i16Min = new Big(-32768);
12
+ const i16Max = new Big(32767);
13
+ const i32Min = new Big(-2147483648);
14
+ const i32Max = new Big(2147483647);
15
+ const i64Min = new Big(Number.MIN_SAFE_INTEGER);
16
+ const i64Max = new Big(Number.MAX_SAFE_INTEGER);
17
+
18
+ const f32Min = new Big("1.17549435e-38");
19
+ const f32Max = new Big("3.4028235e38");
20
+
21
+ function isNumberType(type) {
22
+ const numberTypes = [
23
+ "u8",
24
+ "u16",
25
+ "u32",
26
+ "u64",
27
+ "i8",
28
+ "i16",
29
+ "i32",
30
+ "i64",
31
+ "f32",
32
+ "f64",
33
+ ];
34
+ return numberTypes.includes(type);
35
+ }
36
+
37
+ function isTypeSubset(actualType, expectedType) {
38
+ const typeHierarchy = {
39
+ u8: ["u8", "u16", "u32", "u64"],
40
+ u16: ["u16", "u32", "u64"],
41
+ u32: ["u32", "u64"],
42
+ u64: ["u64"],
43
+ i8: ["i8", "i16", "i32", "i64"],
44
+ i16: ["i16", "i32", "i64"],
45
+ i32: ["i32", "i64"],
46
+ i64: ["i64"],
47
+ f32: ["f32", "f64"],
48
+ f64: ["f64"],
49
+ string: ["string"],
50
+ boolean: ["boolean"],
51
+ array: ["array"],
52
+ object: ["object"],
53
+ };
54
+ return (
55
+ typeHierarchy[actualType] &&
56
+ typeHierarchy[actualType].includes(expectedType)
57
+ );
58
+ }
59
+
60
+ function trueTypeOfNumber(obj) {
61
+ let isInteger = true;
62
+ if (obj.includes(".")) {
63
+ isInteger = false;
64
+ }
65
+ let num = Big(obj);
66
+
67
+ if (isInteger) {
68
+ // Unsigned integers
69
+ if (num.gte(0) && num.lte(u8Max)) return "u8";
70
+ if (num.gte(0) && num.lte(u16Max)) return "u16";
71
+ if (num.gte(0) && num.lte(u32Max)) return "u32";
72
+ if (num.gte(0) && num.lte(u64Max)) return "u64";
73
+
74
+ // Signed integers
75
+ if (num.gte(i8Min) && num.lte(i8Max)) return "i8";
76
+ if (num.gte(i16Min) && num.lte(i16Max)) return "i16";
77
+ if (num.gte(i32Min) && num.lte(i32Max)) return "i32";
78
+ if (num.gte(i64Min) && num.lte(i64Max)) return "i64";
79
+ } else {
80
+ // Floating-point numbers
81
+ if (num.abs().gte(f32Min) && num.abs().lte(f32Max)) return "f32";
82
+ if (num.abs().lte(Number.MAX_VALUE)) return "f64";
83
+ }
84
+ return "number"; // Fallback for unusual numbers
85
+ }
86
+
87
+ function trueTypeOf(obj) {
88
+ return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();
89
+ }
90
+
91
+ function validateArrayElements(array, expectedElementType) {
92
+ array.forEach((item, index) => {
93
+ const actualType = trueTypeOf(item);
94
+ if (!isTypeSubset(actualType, expectedElementType)) {
95
+ throw new Error(
96
+ `Array element at index ${index} must be of type ${expectedElementType}, but got ${actualType}`,
97
+ );
98
+ }
99
+ });
100
+ }
101
+
102
+ function validateEnumValues(object, enumValidValues) {
103
+ Object.keys(enumValidValues).forEach((key) => {
104
+ const allowedValues = Object.values(enumValidValues[key]);
105
+ if (!allowedValues.includes(object[key])) {
106
+ throw new Error(
107
+ `${key} is invalid. Expected one of: ${allowedValues.join(", ")}`,
108
+ );
109
+ }
110
+ });
111
+ }
112
+
113
+ function validateTypes(values, expectedTypes) {
114
+ Object.keys(expectedTypes).forEach((key) => {
115
+ if (!(key in values)) {
116
+ throw new Error(`${key} must be defined`);
117
+ }
118
+ const type = expectedTypes[key];
119
+ const isOptional = type.endsWith("?");
120
+ let val = values[key];
121
+ let actualType = trueTypeOf(val);
122
+ const baseType = isOptional ? type.slice(0, -1) : type;
123
+
124
+ if (val !== null && isNumberType(baseType)) {
125
+ if (actualType != "string") {
126
+ throw new Error("numbers must be passed as strings");
127
+ }
128
+ actualType = trueTypeOfNumber(val);
129
+ }
130
+
131
+ const arrayMatch = baseType.match(/^array\[(.*)\]$/);
132
+ if (arrayMatch) {
133
+ if (actualType !== "array") {
134
+ throw new Error(`${key} must be an array`);
135
+ }
136
+ const elementType = arrayMatch[1];
137
+ validateArrayElements(val, elementType);
138
+ } else if (
139
+ !isTypeSubset(actualType, baseType) &&
140
+ !(isOptional && val === null)
141
+ ) {
142
+ throw new Error(
143
+ `${key} type must be ${baseType}${isOptional ? " or null" : ""}`,
144
+ );
145
+ }
146
+ });
147
+ }
148
+
149
+ exports.AssetSchema = AssetSchema = {
150
+ Nia: "Nia",
151
+ Cfa: "Cfa",
152
+ Uda: "Uda",
153
+ };
154
+
155
+ exports.BitcoinNetwork = BitcoinNetwork = {
156
+ Mainnet: "Mainnet",
157
+ Testnet: "Testnet",
158
+ Testnet4: "Testnet4",
159
+ Signet: "Signet",
160
+ Regtest: "Regtest",
161
+ };
162
+
163
+ exports.DatabaseType = DatabaseType = {
164
+ Sqlite: "Sqlite",
165
+ };
166
+
167
+ exports.dropOnline = function dropOnline(online) {
168
+ lib.free_online(online);
169
+ };
170
+
171
+ exports.generateKeys = function generateKeys(bitcoinNetwork) {
172
+ validateEnumValues(
173
+ { bitcoinNetwork },
174
+ {
175
+ bitcoinNetwork: BitcoinNetwork,
176
+ },
177
+ );
178
+ return JSON.parse(lib.rgblib_generate_keys(bitcoinNetwork));
179
+ };
180
+
181
+ exports.restoreBackup = function (backupPath, password, targetDir) {
182
+ const params = { backupPath, password, targetDir };
183
+ const expectedTypes = {
184
+ backupPath: "string",
185
+ password: "string",
186
+ targetDir: "string",
187
+ };
188
+ validateTypes(params, expectedTypes);
189
+ lib.rgblib_restore_backup(backupPath, password, targetDir);
190
+ };
191
+
192
+ exports.restoreKeys = function (bitcoinNetwork, mnemonic) {
193
+ validateEnumValues(
194
+ { bitcoinNetwork },
195
+ {
196
+ bitcoinNetwork: BitcoinNetwork,
197
+ },
198
+ );
199
+ validateTypes({ mnemonic }, { mnemonic: "string" });
200
+ return JSON.parse(lib.rgblib_restore_keys(bitcoinNetwork, mnemonic));
201
+ };
202
+
203
+ exports.WalletData = class WalletData {
204
+ constructor(walletData) {
205
+ const expectedTypes = {
206
+ dataDir: "string",
207
+ bitcoinNetwork: "string",
208
+ databaseType: "string",
209
+ accountXpubVanilla: "string",
210
+ accountXpubColored: "string",
211
+ maxAllocationsPerUtxo: "u32",
212
+ vanillaKeychain: "u8?",
213
+ };
214
+ validateTypes(walletData, expectedTypes);
215
+ validateEnumValues(walletData, {
216
+ bitcoinNetwork: BitcoinNetwork,
217
+ databaseType: DatabaseType,
218
+ });
219
+ return walletData;
220
+ }
221
+ };
222
+
223
+ exports.Wallet = class Wallet {
224
+ constructor(walletData) {
225
+ this.wallet = lib.rgblib_new_wallet(JSON.stringify(walletData));
226
+ }
227
+
228
+ drop() {
229
+ lib.free_wallet(this.wallet);
230
+ this.wallet = null;
231
+ }
232
+
233
+ backup(backupPath, password) {
234
+ const params = { backupPath, password };
235
+ const expectedTypes = {
236
+ backupPath: "string",
237
+ password: "string",
238
+ };
239
+ validateTypes(params, expectedTypes);
240
+ lib.rgblib_backup(this.wallet, backupPath, password);
241
+ }
242
+
243
+ backupInfo() {
244
+ return JSON.parse(lib.rgblib_backup_info(this.wallet));
245
+ }
246
+
247
+ blindReceive(
248
+ assetId,
249
+ assignment,
250
+ durationSeconds,
251
+ transportEndpoints,
252
+ minConfirmations,
253
+ ) {
254
+ const params = {
255
+ assetId,
256
+ assignment,
257
+ durationSeconds,
258
+ transportEndpoints,
259
+ minConfirmations,
260
+ };
261
+ const expectedTypes = {
262
+ assetId: "string?",
263
+ assignment: "string",
264
+ durationSeconds: "u32?",
265
+ transportEndpoints: "array[string]",
266
+ minConfirmations: "u8",
267
+ };
268
+ validateTypes(params, expectedTypes);
269
+ return JSON.parse(
270
+ lib.rgblib_blind_receive(
271
+ this.wallet,
272
+ assetId,
273
+ assignment,
274
+ durationSeconds,
275
+ JSON.stringify(transportEndpoints),
276
+ minConfirmations,
277
+ ),
278
+ );
279
+ }
280
+
281
+ createUtxos(online, upTo, num, size, feeRate, skipSync) {
282
+ const params = { online, upTo, num, size, feeRate, skipSync };
283
+ const expectedTypes = {
284
+ online: "object",
285
+ upTo: "boolean",
286
+ num: "u8?",
287
+ size: "u32?",
288
+ feeRate: "u64",
289
+ skipSync: "boolean",
290
+ };
291
+ validateTypes(params, expectedTypes);
292
+ return lib.rgblib_create_utxos(
293
+ this.wallet,
294
+ online,
295
+ upTo,
296
+ num,
297
+ size,
298
+ feeRate,
299
+ skipSync,
300
+ );
301
+ }
302
+
303
+ createUtxosBegin(online, upTo, num, size, feeRate, skipSync) {
304
+ const params = { online, upTo, num, size, feeRate, skipSync };
305
+ const expectedTypes = {
306
+ online: "object",
307
+ upTo: "boolean",
308
+ num: "u8?",
309
+ size: "u32?",
310
+ feeRate: "u64",
311
+ skipSync: "boolean",
312
+ };
313
+ validateTypes(params, expectedTypes);
314
+ return lib.rgblib_create_utxos_begin(
315
+ this.wallet,
316
+ online,
317
+ upTo,
318
+ num,
319
+ size,
320
+ feeRate,
321
+ skipSync,
322
+ );
323
+ }
324
+
325
+ createUtxosEnd(online, signedPsbt, skipSync) {
326
+ const params = { online, signedPsbt, skipSync };
327
+ const expectedTypes = {
328
+ online: "object",
329
+ signedPsbt: "string",
330
+ skipSync: "boolean",
331
+ };
332
+ validateTypes(params, expectedTypes);
333
+ return JSON.parse(
334
+ lib.rgblib_create_utxos_end(
335
+ this.wallet,
336
+ online,
337
+ signedPsbt,
338
+ skipSync,
339
+ ),
340
+ );
341
+ }
342
+
343
+ getAddress() {
344
+ return lib.rgblib_get_address(this.wallet);
345
+ }
346
+
347
+ getAssetBalance(assetId) {
348
+ const params = { assetId };
349
+ const expectedTypes = {
350
+ assetId: "string",
351
+ };
352
+ validateTypes(params, expectedTypes);
353
+ return JSON.parse(lib.rgblib_get_asset_balance(this.wallet, assetId));
354
+ }
355
+
356
+ getBtcBalance(online, skipSync) {
357
+ const params = { online, skipSync };
358
+ const expectedTypes = {
359
+ online: "object?",
360
+ skipSync: "boolean",
361
+ };
362
+ validateTypes(params, expectedTypes);
363
+ return JSON.parse(
364
+ lib.rgblib_get_btc_balance(this.wallet, online, skipSync),
365
+ );
366
+ }
367
+
368
+ getFeeEstimation(online, blocks) {
369
+ const params = { online, blocks };
370
+ const expectedTypes = {
371
+ online: "object",
372
+ blocks: "u16",
373
+ };
374
+ validateTypes(params, expectedTypes);
375
+ return lib.rgblib_get_fee_estimation(this.wallet, online, blocks);
376
+ }
377
+
378
+ goOnline(skipConsistencyCheck, electrumUrl) {
379
+ const params = { skipConsistencyCheck, electrumUrl };
380
+ const expectedTypes = {
381
+ skipConsistencyCheck: "boolean",
382
+ electrumUrl: "string",
383
+ };
384
+ validateTypes(params, expectedTypes);
385
+ return lib.rgblib_go_online(
386
+ this.wallet,
387
+ skipConsistencyCheck,
388
+ electrumUrl,
389
+ );
390
+ }
391
+
392
+ issueAssetCFA(name, details, precision, amounts, filePath) {
393
+ const params = {
394
+ name,
395
+ details,
396
+ precision,
397
+ amounts,
398
+ filePath,
399
+ };
400
+ const expectedTypes = {
401
+ name: "string",
402
+ details: "string?",
403
+ precision: "u8",
404
+ amounts: "array[string]",
405
+ filePath: "string?",
406
+ };
407
+ validateTypes(params, expectedTypes);
408
+ return JSON.parse(
409
+ lib.rgblib_issue_asset_cfa(
410
+ this.wallet,
411
+ name,
412
+ details,
413
+ precision,
414
+ JSON.stringify(amounts),
415
+ filePath,
416
+ ),
417
+ );
418
+ }
419
+
420
+ issueAssetNIA(ticker, name, precision, amounts) {
421
+ const params = {
422
+ ticker,
423
+ name,
424
+ precision,
425
+ amounts,
426
+ };
427
+ const expectedTypes = {
428
+ name: "string",
429
+ precision: "u8",
430
+ amounts: "array[string]",
431
+ };
432
+ validateTypes(params, expectedTypes);
433
+ return JSON.parse(
434
+ lib.rgblib_issue_asset_nia(
435
+ this.wallet,
436
+ ticker,
437
+ name,
438
+ precision,
439
+ JSON.stringify(amounts),
440
+ ),
441
+ );
442
+ }
443
+
444
+ issueAssetUDA(
445
+ ticker,
446
+ name,
447
+ details,
448
+ precision,
449
+ mediaFilePath,
450
+ attachmentsFilePaths,
451
+ ) {
452
+ const params = {
453
+ ticker,
454
+ name,
455
+ details,
456
+ precision,
457
+ mediaFilePath,
458
+ attachmentsFilePaths,
459
+ };
460
+ const expectedTypes = {
461
+ ticker: "string",
462
+ name: "string",
463
+ details: "string?",
464
+ precision: "u8",
465
+ mediaFilePath: "string?",
466
+ attachmentsFilePaths: "array[string]",
467
+ };
468
+ validateTypes(params, expectedTypes);
469
+ return JSON.parse(
470
+ lib.rgblib_issue_asset_uda(
471
+ this.wallet,
472
+ ticker,
473
+ name,
474
+ details,
475
+ precision,
476
+ mediaFilePath,
477
+ JSON.stringify(attachmentsFilePaths),
478
+ ),
479
+ );
480
+ }
481
+
482
+ listAssets(filterAssetSchemas) {
483
+ const params = {
484
+ filterAssetSchemas,
485
+ };
486
+ const expectedTypes = {
487
+ filterAssetSchemas: "array[string]",
488
+ };
489
+ validateTypes(params, expectedTypes);
490
+ return JSON.parse(
491
+ lib.rgblib_list_assets(
492
+ this.wallet,
493
+ JSON.stringify(filterAssetSchemas),
494
+ ),
495
+ );
496
+ }
497
+
498
+ listTransactions(online, skipSync) {
499
+ const params = { online, skipSync };
500
+ const expectedTypes = {
501
+ online: "object",
502
+ skipSync: "boolean",
503
+ };
504
+ validateTypes(params, expectedTypes);
505
+ return JSON.parse(
506
+ lib.rgblib_list_transactions(this.wallet, online, skipSync),
507
+ );
508
+ }
509
+
510
+ listTransfers(assetId) {
511
+ const params = {
512
+ assetId,
513
+ };
514
+ const expectedTypes = {
515
+ assetId: "string?",
516
+ };
517
+ validateTypes(params, expectedTypes);
518
+ return JSON.parse(lib.rgblib_list_transfers(this.wallet, assetId));
519
+ }
520
+
521
+ listUnspents(online, settledOnly, skipSync) {
522
+ const params = {
523
+ online,
524
+ settledOnly,
525
+ skipSync,
526
+ };
527
+ const expectedTypes = {
528
+ online: "object",
529
+ settledOnly: "boolean",
530
+ skipSync: "boolean",
531
+ };
532
+ validateTypes(params, expectedTypes);
533
+ return JSON.parse(
534
+ lib.rgblib_list_unspents(
535
+ this.wallet,
536
+ online,
537
+ settledOnly,
538
+ skipSync,
539
+ ),
540
+ );
541
+ }
542
+
543
+ refresh(online, assetId, filter, skipSync) {
544
+ const params = {
545
+ online,
546
+ assetId,
547
+ filter,
548
+ skipSync,
549
+ };
550
+ const expectedTypes = {
551
+ online: "object",
552
+ assetId: "string?",
553
+ filter: "array[string]",
554
+ skipSync: "boolean",
555
+ };
556
+ validateTypes(params, expectedTypes);
557
+ return JSON.parse(
558
+ lib.rgblib_refresh(
559
+ this.wallet,
560
+ online,
561
+ assetId,
562
+ JSON.stringify(filter),
563
+ skipSync,
564
+ ),
565
+ );
566
+ }
567
+
568
+ deleteTransfers(batchTransferIdx, noAssetOnly) {
569
+ const params = {
570
+ batchTransferIdx,
571
+ noAssetOnly,
572
+ };
573
+ const expectedTypes = {
574
+ batchTransferIdx: "i32?",
575
+ noAssetOnly: "boolean",
576
+ };
577
+ validateTypes(params, expectedTypes);
578
+ return JSON.parse(
579
+ lib.rgblib_delete_transfers(
580
+ this.wallet,
581
+ batchTransferIdx,
582
+ noAssetOnly,
583
+ ),
584
+ );
585
+ }
586
+
587
+ failTransfers(online, batchTransferIdx, noAssetOnly, skipSync) {
588
+ const params = {
589
+ online,
590
+ batchTransferIdx,
591
+ noAssetOnly,
592
+ skipSync,
593
+ };
594
+ const expectedTypes = {
595
+ online: "object",
596
+ batchTransferIdx: "i32?",
597
+ noAssetOnly: "boolean",
598
+ skipSync: "boolean",
599
+ };
600
+ validateTypes(params, expectedTypes);
601
+ return JSON.parse(
602
+ lib.rgblib_fail_transfers(
603
+ this.wallet,
604
+ online,
605
+ batchTransferIdx,
606
+ noAssetOnly,
607
+ skipSync,
608
+ ),
609
+ );
610
+ }
611
+
612
+ send(online, recipientMap, donation, feeRate, minConfirmations, skipSync) {
613
+ const params = {
614
+ online,
615
+ recipientMap,
616
+ donation,
617
+ feeRate,
618
+ minConfirmations,
619
+ skipSync,
620
+ };
621
+ const expectedTypes = {
622
+ online: "object",
623
+ recipientMap: "object",
624
+ donation: "boolean",
625
+ feeRate: "u64",
626
+ minConfirmations: "u8",
627
+ skipSync: "boolean",
628
+ };
629
+ validateTypes(params, expectedTypes);
630
+ return JSON.parse(
631
+ lib.rgblib_send(
632
+ this.wallet,
633
+ online,
634
+ JSON.stringify(recipientMap),
635
+ donation,
636
+ feeRate,
637
+ minConfirmations,
638
+ skipSync,
639
+ ),
640
+ );
641
+ }
642
+
643
+ sendBegin(online, recipientMap, donation, feeRate, minConfirmations) {
644
+ const params = {
645
+ online,
646
+ recipientMap,
647
+ donation,
648
+ feeRate,
649
+ minConfirmations,
650
+ };
651
+ const expectedTypes = {
652
+ online: "object",
653
+ recipientMap: "object",
654
+ donation: "boolean",
655
+ feeRate: "u64",
656
+ minConfirmations: "u8",
657
+ };
658
+ validateTypes(params, expectedTypes);
659
+ return lib.rgblib_send_begin(
660
+ this.wallet,
661
+ online,
662
+ JSON.stringify(recipientMap),
663
+ donation,
664
+ feeRate,
665
+ minConfirmations,
666
+ );
667
+ }
668
+
669
+ sendEnd(online, signedPsbt, skipSync) {
670
+ const params = {
671
+ online,
672
+ signedPsbt,
673
+ skipSync,
674
+ };
675
+ const expectedTypes = {
676
+ online: "object",
677
+ signedPsbt: "string",
678
+ skipSync: "boolean",
679
+ };
680
+ validateTypes(params, expectedTypes);
681
+ return JSON.parse(
682
+ lib.rgblib_send_end(
683
+ this.wallet,
684
+ online,
685
+ signedPsbt,
686
+ skipSync,
687
+ ),
688
+ );
689
+ }
690
+
691
+ sendBtc(online, address, amount, feeRate, skipSync) {
692
+ const params = {
693
+ online,
694
+ address,
695
+ amount,
696
+ feeRate,
697
+ skipSync,
698
+ };
699
+ const expectedTypes = {
700
+ online: "object",
701
+ address: "string",
702
+ amount: "u64",
703
+ feeRate: "u64",
704
+ skipSync: "boolean",
705
+ };
706
+ validateTypes(params, expectedTypes);
707
+ return lib.rgblib_send_btc(
708
+ this.wallet,
709
+ online,
710
+ address,
711
+ amount,
712
+ feeRate,
713
+ skipSync,
714
+ );
715
+ }
716
+
717
+ sendBtcBegin(online, address, amount, feeRate, skipSync) {
718
+ const params = {
719
+ online,
720
+ address,
721
+ amount,
722
+ feeRate,
723
+ skipSync,
724
+ };
725
+ const expectedTypes = {
726
+ online: "object",
727
+ address: "string",
728
+ amount: "u64",
729
+ feeRate: "u64",
730
+ skipSync: "boolean",
731
+ };
732
+ validateTypes(params, expectedTypes);
733
+ return lib.rgblib_send_btc_begin(
734
+ this.wallet,
735
+ online,
736
+ address,
737
+ amount,
738
+ feeRate,
739
+ skipSync,
740
+ );
741
+ }
742
+
743
+ sendBtcEnd(online, signedPsbt, skipSync) {
744
+ const params = {
745
+ online,
746
+ signedPsbt,
747
+ skipSync,
748
+ };
749
+ const expectedTypes = {
750
+ online: "object",
751
+ signedPsbt: "string",
752
+ skipSync: "boolean",
753
+ };
754
+ validateTypes(params, expectedTypes);
755
+ return lib.rgblib_send_btc_end(
756
+ this.wallet,
757
+ online,
758
+ signedPsbt,
759
+ skipSync,
760
+ );
761
+ }
762
+
763
+ signPsbt(psbt) {
764
+ const params = { psbt };
765
+ const expectedTypes = {
766
+ psbt: "string",
767
+ };
768
+ validateTypes(params, expectedTypes);
769
+ return lib.rgblib_sign_psbt(this.wallet, psbt);
770
+ }
771
+
772
+ sync(online) {
773
+ const params = { online };
774
+ const expectedTypes = {
775
+ online: "object",
776
+ };
777
+ validateTypes(params, expectedTypes);
778
+ lib.rgblib_sync(this.wallet, online);
779
+ }
780
+
781
+ witnessReceive(
782
+ assetId,
783
+ assignment,
784
+ durationSeconds,
785
+ transportEndpoints,
786
+ minConfirmations,
787
+ ) {
788
+ const params = {
789
+ assetId,
790
+ assignment,
791
+ durationSeconds,
792
+ transportEndpoints,
793
+ minConfirmations,
794
+ };
795
+ const expectedTypes = {
796
+ assetId: "string?",
797
+ assignment: "string",
798
+ durationSeconds: "u32?",
799
+ transportEndpoints: "array[string]",
800
+ minConfirmations: "u8",
801
+ };
802
+ validateTypes(params, expectedTypes);
803
+ return JSON.parse(
804
+ lib.rgblib_witness_receive(
805
+ this.wallet,
806
+ assetId,
807
+ assignment,
808
+ durationSeconds,
809
+ JSON.stringify(transportEndpoints),
810
+ minConfirmations,
811
+ ),
812
+ );
813
+ }
814
+ };
815
+
816
+ exports.Invoice = class Invoice {
817
+ constructor(invoiceString) {
818
+ const params = { invoiceString };
819
+ const expectedTypes = {
820
+ invoiceString: "string",
821
+ };
822
+ validateTypes(params, expectedTypes);
823
+ this.invoice = lib.rgblib_invoice_new(invoiceString);
824
+ }
825
+
826
+ drop() {
827
+ lib.free_invoice(this.invoice);
828
+ this.invoice = null;
829
+ }
830
+
831
+ invoiceData() {
832
+ return JSON.parse(lib.rgblib_invoice_data(this.invoice));
833
+ }
834
+
835
+ invoiceString() {
836
+ return lib.rgblib_invoice_string(this.invoice);
837
+ }
838
+ };