@utexo/rgb-lib-linux-x64 0.3.0-beta.16-rc1 → 0.3.0-beta.16.dev

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utexo/rgb-lib-linux-x64",
3
- "version": "0.3.0-beta.16-rc1",
3
+ "version": "0.3.0-beta.16.dev",
4
4
  "description": "Node.js bindings for rgb-lib on linux-x64",
5
5
  "main": "wrapper.js",
6
6
  "os": [
@@ -178,6 +178,10 @@ CResultString rgblib_restore_from_vss(const char *config_json, const char *targe
178
178
 
179
179
  CResultString rgblib_restore_keys(const char *bitcoin_network, const char *mnemonic);
180
180
 
181
+ CResultString rgblib_rotate_colored_address(const COpaqueStruct *wallet);
182
+
183
+ CResultString rgblib_rotate_vanilla_address(const COpaqueStruct *wallet);
184
+
181
185
  CResultString rgblib_send(const COpaqueStruct *wallet,
182
186
  const COpaqueStruct *online,
183
187
  const char *recipient_map,
package/swig_wrap.cxx CHANGED
@@ -2329,9 +2329,6 @@ static SwigV8ReturnValue _wrap_rgblib_blind_receive(const SwigV8Arguments &args)
2329
2329
  int res3 ;
2330
2330
  char *buf3 = 0 ;
2331
2331
  int alloc3 = 0 ;
2332
- int res4 ;
2333
- char *buf4 = 0 ;
2334
- int alloc4 = 0 ;
2335
2332
  int res5 ;
2336
2333
  char *buf5 = 0 ;
2337
2334
  int alloc5 = 0 ;
@@ -2362,11 +2359,19 @@ static SwigV8ReturnValue _wrap_rgblib_blind_receive(const SwigV8Arguments &args)
2362
2359
  if (!SWIG_IsOK(res3)) {
2363
2360
  SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "rgblib_blind_receive" "', argument " "3"" of type '" "char const *""'");
2364
2361
  }
2365
- arg3 = reinterpret_cast< char * >(buf3);res4 = SWIG_AsCharPtrAndSize(args[3], &buf4, NULL, &alloc4);
2366
- if (!SWIG_IsOK(res4)) {
2367
- SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "rgblib_blind_receive" "', argument " "4"" of type '" "char const *""'");
2362
+ arg3 = reinterpret_cast< char * >(buf3);{
2363
+ {
2364
+ if (args[3] == v8::Null(v8::Isolate::GetCurrent())) {
2365
+ arg4 = nullptr;
2366
+ } else {
2367
+ int res = SWIG_AsCharPtrAndSize(args[3], (char**)&arg4, NULL, NULL);
2368
+ if (!SWIG_IsOK(res)) {
2369
+ SWIG_exception_fail(SWIG_ArgError(res), "in method '" "rgblib_blind_receive" "', argument '" "4""' of type '" "char const *""'");
2370
+ }
2371
+ }
2372
+ }
2368
2373
  }
2369
- arg4 = reinterpret_cast< char * >(buf4);res5 = SWIG_AsCharPtrAndSize(args[4], &buf5, NULL, &alloc5);
2374
+ res5 = SWIG_AsCharPtrAndSize(args[4], &buf5, NULL, &alloc5);
2370
2375
  if (!SWIG_IsOK(res5)) {
2371
2376
  SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "rgblib_blind_receive" "', argument " "5"" of type '" "char const *""'");
2372
2377
  }
@@ -2392,7 +2397,6 @@ static SwigV8ReturnValue _wrap_rgblib_blind_receive(const SwigV8Arguments &args)
2392
2397
 
2393
2398
 
2394
2399
  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
2395
- if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
2396
2400
  if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
2397
2401
  if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
2398
2402
 
@@ -2729,9 +2733,6 @@ static SwigV8ReturnValue _wrap_rgblib_delete_transfers(const SwigV8Arguments &ar
2729
2733
  bool arg3 ;
2730
2734
  void *argp1 = 0 ;
2731
2735
  int res1 = 0 ;
2732
- int res2 ;
2733
- char *buf2 = 0 ;
2734
- int alloc2 = 0 ;
2735
2736
  bool val3 ;
2736
2737
  int ecode3 = 0 ;
2737
2738
  CResultString result;
@@ -2742,11 +2743,19 @@ static SwigV8ReturnValue _wrap_rgblib_delete_transfers(const SwigV8Arguments &ar
2742
2743
  if (!SWIG_IsOK(res1)) {
2743
2744
  SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rgblib_delete_transfers" "', argument " "1"" of type '" "COpaqueStruct const *""'");
2744
2745
  }
2745
- arg1 = reinterpret_cast< COpaqueStruct * >(argp1);res2 = SWIG_AsCharPtrAndSize(args[1], &buf2, NULL, &alloc2);
2746
- if (!SWIG_IsOK(res2)) {
2747
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "rgblib_delete_transfers" "', argument " "2"" of type '" "char const *""'");
2746
+ arg1 = reinterpret_cast< COpaqueStruct * >(argp1);{
2747
+ {
2748
+ if (args[1] == v8::Null(v8::Isolate::GetCurrent())) {
2749
+ arg2 = nullptr;
2750
+ } else {
2751
+ int res = SWIG_AsCharPtrAndSize(args[1], (char**)&arg2, NULL, NULL);
2752
+ if (!SWIG_IsOK(res)) {
2753
+ SWIG_exception_fail(SWIG_ArgError(res), "in method '" "rgblib_delete_transfers" "', argument '" "2""' of type '" "char const *""'");
2754
+ }
2755
+ }
2756
+ }
2748
2757
  }
2749
- arg2 = reinterpret_cast< char * >(buf2);ecode3 = SWIG_AsVal_bool(args[2], &val3);
2758
+ ecode3 = SWIG_AsVal_bool(args[2], &val3);
2750
2759
  if (!SWIG_IsOK(ecode3)) {
2751
2760
  SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "rgblib_delete_transfers" "', argument " "3"" of type '" "bool""'");
2752
2761
  }
@@ -2767,7 +2776,6 @@ static SwigV8ReturnValue _wrap_rgblib_delete_transfers(const SwigV8Arguments &ar
2767
2776
  }
2768
2777
 
2769
2778
 
2770
- if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
2771
2779
 
2772
2780
 
2773
2781
  SWIGV8_RETURN(jsresult);
@@ -2832,9 +2840,6 @@ static SwigV8ReturnValue _wrap_rgblib_fail_transfers(const SwigV8Arguments &args
2832
2840
  int res1 = 0 ;
2833
2841
  void *argp2 = 0 ;
2834
2842
  int res2 = 0 ;
2835
- int res3 ;
2836
- char *buf3 = 0 ;
2837
- int alloc3 = 0 ;
2838
2843
  bool val4 ;
2839
2844
  int ecode4 = 0 ;
2840
2845
  bool val5 ;
@@ -2851,11 +2856,19 @@ static SwigV8ReturnValue _wrap_rgblib_fail_transfers(const SwigV8Arguments &args
2851
2856
  if (!SWIG_IsOK(res2)) {
2852
2857
  SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "rgblib_fail_transfers" "', argument " "2"" of type '" "COpaqueStruct const *""'");
2853
2858
  }
2854
- arg2 = reinterpret_cast< COpaqueStruct * >(argp2);res3 = SWIG_AsCharPtrAndSize(args[2], &buf3, NULL, &alloc3);
2855
- if (!SWIG_IsOK(res3)) {
2856
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "rgblib_fail_transfers" "', argument " "3"" of type '" "char const *""'");
2859
+ arg2 = reinterpret_cast< COpaqueStruct * >(argp2);{
2860
+ {
2861
+ if (args[2] == v8::Null(v8::Isolate::GetCurrent())) {
2862
+ arg3 = nullptr;
2863
+ } else {
2864
+ int res = SWIG_AsCharPtrAndSize(args[2], (char**)&arg3, NULL, NULL);
2865
+ if (!SWIG_IsOK(res)) {
2866
+ SWIG_exception_fail(SWIG_ArgError(res), "in method '" "rgblib_fail_transfers" "', argument '" "3""' of type '" "char const *""'");
2867
+ }
2868
+ }
2869
+ }
2857
2870
  }
2858
- arg3 = reinterpret_cast< char * >(buf3);ecode4 = SWIG_AsVal_bool(args[3], &val4);
2871
+ ecode4 = SWIG_AsVal_bool(args[3], &val4);
2859
2872
  if (!SWIG_IsOK(ecode4)) {
2860
2873
  SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "rgblib_fail_transfers" "', argument " "4"" of type '" "bool""'");
2861
2874
  }
@@ -2881,7 +2894,6 @@ static SwigV8ReturnValue _wrap_rgblib_fail_transfers(const SwigV8Arguments &args
2881
2894
 
2882
2895
 
2883
2896
 
2884
- if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
2885
2897
 
2886
2898
 
2887
2899
 
@@ -4416,6 +4428,88 @@ fail:
4416
4428
  }
4417
4429
 
4418
4430
 
4431
+ static SwigV8ReturnValue _wrap_rgblib_rotate_colored_address(const SwigV8Arguments &args) {
4432
+ SWIGV8_HANDLESCOPE();
4433
+
4434
+ SWIGV8_VALUE jsresult;
4435
+ COpaqueStruct *arg1 = (COpaqueStruct *) 0 ;
4436
+ void *argp1 = 0 ;
4437
+ int res1 = 0 ;
4438
+ CResultString result;
4439
+
4440
+ if (args.Length() < 1 || args.Length() > 1) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for _wrap_rgblib_rotate_colored_address.");
4441
+
4442
+ res1 = SWIG_ConvertPtr(args[0], &argp1,SWIGTYPE_p_COpaqueStruct, 0 | 0 );
4443
+ if (!SWIG_IsOK(res1)) {
4444
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rgblib_rotate_colored_address" "', argument " "1"" of type '" "COpaqueStruct const *""'");
4445
+ }
4446
+ arg1 = reinterpret_cast< COpaqueStruct * >(argp1);result = rgblib_rotate_colored_address((COpaqueStruct const *)arg1);
4447
+
4448
+ switch ((&result)->result) {
4449
+ case CResultValue::Ok:
4450
+ if ((&result)->inner == nullptr) {
4451
+ jsresult = v8::Null(v8::Isolate::GetCurrent());
4452
+ } else {
4453
+ jsresult = v8::String::NewFromUtf8(args.GetIsolate(), (const char*) (&result)->inner).ToLocalChecked();
4454
+ delete ((&result)->inner);
4455
+ }
4456
+ break;
4457
+ case CResultValue::Err:
4458
+ SWIG_V8_Raise((const char*) (&result)->inner);
4459
+ break;
4460
+ }
4461
+
4462
+
4463
+
4464
+ SWIGV8_RETURN(jsresult);
4465
+
4466
+ goto fail;
4467
+ fail:
4468
+ SWIGV8_RETURN(SWIGV8_UNDEFINED());
4469
+ }
4470
+
4471
+
4472
+ static SwigV8ReturnValue _wrap_rgblib_rotate_vanilla_address(const SwigV8Arguments &args) {
4473
+ SWIGV8_HANDLESCOPE();
4474
+
4475
+ SWIGV8_VALUE jsresult;
4476
+ COpaqueStruct *arg1 = (COpaqueStruct *) 0 ;
4477
+ void *argp1 = 0 ;
4478
+ int res1 = 0 ;
4479
+ CResultString result;
4480
+
4481
+ if (args.Length() < 1 || args.Length() > 1) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for _wrap_rgblib_rotate_vanilla_address.");
4482
+
4483
+ res1 = SWIG_ConvertPtr(args[0], &argp1,SWIGTYPE_p_COpaqueStruct, 0 | 0 );
4484
+ if (!SWIG_IsOK(res1)) {
4485
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rgblib_rotate_vanilla_address" "', argument " "1"" of type '" "COpaqueStruct const *""'");
4486
+ }
4487
+ arg1 = reinterpret_cast< COpaqueStruct * >(argp1);result = rgblib_rotate_vanilla_address((COpaqueStruct const *)arg1);
4488
+
4489
+ switch ((&result)->result) {
4490
+ case CResultValue::Ok:
4491
+ if ((&result)->inner == nullptr) {
4492
+ jsresult = v8::Null(v8::Isolate::GetCurrent());
4493
+ } else {
4494
+ jsresult = v8::String::NewFromUtf8(args.GetIsolate(), (const char*) (&result)->inner).ToLocalChecked();
4495
+ delete ((&result)->inner);
4496
+ }
4497
+ break;
4498
+ case CResultValue::Err:
4499
+ SWIG_V8_Raise((const char*) (&result)->inner);
4500
+ break;
4501
+ }
4502
+
4503
+
4504
+
4505
+ SWIGV8_RETURN(jsresult);
4506
+
4507
+ goto fail;
4508
+ fail:
4509
+ SWIGV8_RETURN(SWIGV8_UNDEFINED());
4510
+ }
4511
+
4512
+
4419
4513
  static SwigV8ReturnValue _wrap_rgblib_send(const SwigV8Arguments &args) {
4420
4514
  SWIGV8_HANDLESCOPE();
4421
4515
 
@@ -4443,9 +4537,6 @@ static SwigV8ReturnValue _wrap_rgblib_send(const SwigV8Arguments &args) {
4443
4537
  int res6 ;
4444
4538
  char *buf6 = 0 ;
4445
4539
  int alloc6 = 0 ;
4446
- int res7 ;
4447
- char *buf7 = 0 ;
4448
- int alloc7 = 0 ;
4449
4540
  bool val8 ;
4450
4541
  int ecode8 = 0 ;
4451
4542
  CResultString result;
@@ -4476,11 +4567,19 @@ static SwigV8ReturnValue _wrap_rgblib_send(const SwigV8Arguments &args) {
4476
4567
  if (!SWIG_IsOK(res6)) {
4477
4568
  SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "rgblib_send" "', argument " "6"" of type '" "char const *""'");
4478
4569
  }
4479
- arg6 = reinterpret_cast< char * >(buf6);res7 = SWIG_AsCharPtrAndSize(args[6], &buf7, NULL, &alloc7);
4480
- if (!SWIG_IsOK(res7)) {
4481
- SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "rgblib_send" "', argument " "7"" of type '" "char const *""'");
4570
+ arg6 = reinterpret_cast< char * >(buf6);{
4571
+ {
4572
+ if (args[6] == v8::Null(v8::Isolate::GetCurrent())) {
4573
+ arg7 = nullptr;
4574
+ } else {
4575
+ int res = SWIG_AsCharPtrAndSize(args[6], (char**)&arg7, NULL, NULL);
4576
+ if (!SWIG_IsOK(res)) {
4577
+ SWIG_exception_fail(SWIG_ArgError(res), "in method '" "rgblib_send" "', argument '" "7""' of type '" "char const *""'");
4578
+ }
4579
+ }
4580
+ }
4482
4581
  }
4483
- arg7 = reinterpret_cast< char * >(buf7);ecode8 = SWIG_AsVal_bool(args[7], &val8);
4582
+ ecode8 = SWIG_AsVal_bool(args[7], &val8);
4484
4583
  if (!SWIG_IsOK(ecode8)) {
4485
4584
  SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "rgblib_send" "', argument " "8"" of type '" "bool""'");
4486
4585
  }
@@ -4506,7 +4605,6 @@ static SwigV8ReturnValue _wrap_rgblib_send(const SwigV8Arguments &args) {
4506
4605
 
4507
4606
  if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
4508
4607
  if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
4509
- if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
4510
4608
 
4511
4609
 
4512
4610
  SWIGV8_RETURN(jsresult);
@@ -4544,9 +4642,6 @@ static SwigV8ReturnValue _wrap_rgblib_send_begin(const SwigV8Arguments &args) {
4544
4642
  int res6 ;
4545
4643
  char *buf6 = 0 ;
4546
4644
  int alloc6 = 0 ;
4547
- int res7 ;
4548
- char *buf7 = 0 ;
4549
- int alloc7 = 0 ;
4550
4645
  bool val8 ;
4551
4646
  int ecode8 = 0 ;
4552
4647
  CResultString result;
@@ -4577,11 +4672,19 @@ static SwigV8ReturnValue _wrap_rgblib_send_begin(const SwigV8Arguments &args) {
4577
4672
  if (!SWIG_IsOK(res6)) {
4578
4673
  SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "rgblib_send_begin" "', argument " "6"" of type '" "char const *""'");
4579
4674
  }
4580
- arg6 = reinterpret_cast< char * >(buf6);res7 = SWIG_AsCharPtrAndSize(args[6], &buf7, NULL, &alloc7);
4581
- if (!SWIG_IsOK(res7)) {
4582
- SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "rgblib_send_begin" "', argument " "7"" of type '" "char const *""'");
4675
+ arg6 = reinterpret_cast< char * >(buf6);{
4676
+ {
4677
+ if (args[6] == v8::Null(v8::Isolate::GetCurrent())) {
4678
+ arg7 = nullptr;
4679
+ } else {
4680
+ int res = SWIG_AsCharPtrAndSize(args[6], (char**)&arg7, NULL, NULL);
4681
+ if (!SWIG_IsOK(res)) {
4682
+ SWIG_exception_fail(SWIG_ArgError(res), "in method '" "rgblib_send_begin" "', argument '" "7""' of type '" "char const *""'");
4683
+ }
4684
+ }
4685
+ }
4583
4686
  }
4584
- arg7 = reinterpret_cast< char * >(buf7);ecode8 = SWIG_AsVal_bool(args[7], &val8);
4687
+ ecode8 = SWIG_AsVal_bool(args[7], &val8);
4585
4688
  if (!SWIG_IsOK(ecode8)) {
4586
4689
  SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "rgblib_send_begin" "', argument " "8"" of type '" "bool""'");
4587
4690
  }
@@ -4607,7 +4710,6 @@ static SwigV8ReturnValue _wrap_rgblib_send_begin(const SwigV8Arguments &args) {
4607
4710
 
4608
4711
  if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
4609
4712
  if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
4610
- if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
4611
4713
 
4612
4714
 
4613
4715
  SWIGV8_RETURN(jsresult);
@@ -5191,9 +5293,6 @@ static SwigV8ReturnValue _wrap_rgblib_witness_receive(const SwigV8Arguments &arg
5191
5293
  int res3 ;
5192
5294
  char *buf3 = 0 ;
5193
5295
  int alloc3 = 0 ;
5194
- int res4 ;
5195
- char *buf4 = 0 ;
5196
- int alloc4 = 0 ;
5197
5296
  int res5 ;
5198
5297
  char *buf5 = 0 ;
5199
5298
  int alloc5 = 0 ;
@@ -5224,11 +5323,19 @@ static SwigV8ReturnValue _wrap_rgblib_witness_receive(const SwigV8Arguments &arg
5224
5323
  if (!SWIG_IsOK(res3)) {
5225
5324
  SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "rgblib_witness_receive" "', argument " "3"" of type '" "char const *""'");
5226
5325
  }
5227
- arg3 = reinterpret_cast< char * >(buf3);res4 = SWIG_AsCharPtrAndSize(args[3], &buf4, NULL, &alloc4);
5228
- if (!SWIG_IsOK(res4)) {
5229
- SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "rgblib_witness_receive" "', argument " "4"" of type '" "char const *""'");
5326
+ arg3 = reinterpret_cast< char * >(buf3);{
5327
+ {
5328
+ if (args[3] == v8::Null(v8::Isolate::GetCurrent())) {
5329
+ arg4 = nullptr;
5330
+ } else {
5331
+ int res = SWIG_AsCharPtrAndSize(args[3], (char**)&arg4, NULL, NULL);
5332
+ if (!SWIG_IsOK(res)) {
5333
+ SWIG_exception_fail(SWIG_ArgError(res), "in method '" "rgblib_witness_receive" "', argument '" "4""' of type '" "char const *""'");
5334
+ }
5335
+ }
5336
+ }
5230
5337
  }
5231
- arg4 = reinterpret_cast< char * >(buf4);res5 = SWIG_AsCharPtrAndSize(args[4], &buf5, NULL, &alloc5);
5338
+ res5 = SWIG_AsCharPtrAndSize(args[4], &buf5, NULL, &alloc5);
5232
5339
  if (!SWIG_IsOK(res5)) {
5233
5340
  SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "rgblib_witness_receive" "', argument " "5"" of type '" "char const *""'");
5234
5341
  }
@@ -5254,7 +5361,6 @@ static SwigV8ReturnValue _wrap_rgblib_witness_receive(const SwigV8Arguments &arg
5254
5361
 
5255
5362
 
5256
5363
  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
5257
- if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
5258
5364
  if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
5259
5365
  if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
5260
5366
 
@@ -5718,6 +5824,8 @@ SWIGV8_AddStaticFunction(exports_obj, "rgblib_refresh", _wrap_rgblib_refresh, co
5718
5824
  SWIGV8_AddStaticFunction(exports_obj, "rgblib_restore_backup", _wrap_rgblib_restore_backup, context);
5719
5825
  SWIGV8_AddStaticFunction(exports_obj, "rgblib_restore_from_vss", _wrap_rgblib_restore_from_vss, context);
5720
5826
  SWIGV8_AddStaticFunction(exports_obj, "rgblib_restore_keys", _wrap_rgblib_restore_keys, context);
5827
+ SWIGV8_AddStaticFunction(exports_obj, "rgblib_rotate_colored_address", _wrap_rgblib_rotate_colored_address, context);
5828
+ SWIGV8_AddStaticFunction(exports_obj, "rgblib_rotate_vanilla_address", _wrap_rgblib_rotate_vanilla_address, context);
5721
5829
  SWIGV8_AddStaticFunction(exports_obj, "rgblib_send", _wrap_rgblib_send, context);
5722
5830
  SWIGV8_AddStaticFunction(exports_obj, "rgblib_send_begin", _wrap_rgblib_send_begin, context);
5723
5831
  SWIGV8_AddStaticFunction(exports_obj, "rgblib_send_btc", _wrap_rgblib_send_btc, context);
package/wrapper.js CHANGED
@@ -102,7 +102,16 @@ function validateArrayElements(array, expectedElementType) {
102
102
  function validateEnumValues(object, enumValidValues) {
103
103
  Object.keys(enumValidValues).forEach((key) => {
104
104
  const allowedValues = Object.values(enumValidValues[key]);
105
- if (!allowedValues.includes(object[key])) {
105
+ const value = object[key];
106
+ if (Array.isArray(value)) {
107
+ value.forEach((item, index) => {
108
+ if (!allowedValues.includes(item)) {
109
+ throw new Error(
110
+ `${key}[${index}] is invalid. Expected one of: ${allowedValues.join(", ")}`,
111
+ );
112
+ }
113
+ });
114
+ } else if (!allowedValues.includes(value)) {
106
115
  throw new Error(
107
116
  `${key} is invalid. Expected one of: ${allowedValues.join(", ")}`,
108
117
  );
@@ -112,14 +121,24 @@ function validateEnumValues(object, enumValidValues) {
112
121
 
113
122
  function validateTypes(values, expectedTypes) {
114
123
  Object.keys(expectedTypes).forEach((key) => {
115
- if (!(key in values)) {
116
- throw new Error(`${key} must be defined`);
117
- }
118
124
  const type = expectedTypes[key];
119
125
  const isOptional = type.endsWith("?");
126
+ const baseType = isOptional ? type.slice(0, -1) : type;
127
+
128
+ if (isOptional) {
129
+ if (
130
+ !(key in values) ||
131
+ values[key] === undefined ||
132
+ values[key] === null
133
+ ) {
134
+ return;
135
+ }
136
+ } else if (!(key in values) || values[key] === undefined) {
137
+ throw new Error(`${key} must be defined`);
138
+ }
139
+
120
140
  let val = values[key];
121
141
  let actualType = trueTypeOf(val);
122
- const baseType = isOptional ? type.slice(0, -1) : type;
123
142
 
124
143
  if (val !== null && isNumberType(baseType)) {
125
144
  if (actualType != "string") {
@@ -135,13 +154,8 @@ function validateTypes(values, expectedTypes) {
135
154
  }
136
155
  const elementType = arrayMatch[1];
137
156
  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
- );
157
+ } else if (!isTypeSubset(actualType, baseType)) {
158
+ throw new Error(`${key} type must be ${baseType}`);
145
159
  }
146
160
  });
147
161
  }
@@ -157,6 +171,7 @@ exports.BitcoinNetwork = BitcoinNetwork = {
157
171
  Testnet: "Testnet",
158
172
  Testnet4: "Testnet4",
159
173
  Signet: "Signet",
174
+ SignetCustom: "SignetCustom",
160
175
  Regtest: "Regtest",
161
176
  };
162
177
 
@@ -200,6 +215,20 @@ exports.restoreKeys = function (bitcoinNetwork, mnemonic) {
200
215
  return JSON.parse(lib.rgblib_restore_keys(bitcoinNetwork, mnemonic));
201
216
  };
202
217
 
218
+ exports.SinglesigKeys = class SinglesigKeys {
219
+ constructor(singlesigKeys) {
220
+ const expectedTypes = {
221
+ accountXpubVanilla: "string",
222
+ accountXpubColored: "string",
223
+ vanillaKeychain: "u8?",
224
+ masterFingerprint: "string",
225
+ mnemonic: "string?",
226
+ };
227
+ validateTypes(singlesigKeys, expectedTypes);
228
+ return singlesigKeys;
229
+ }
230
+ };
231
+
203
232
  exports.restoreFromVss = function (config, targetDir) {
204
233
  const expectedTypes = {
205
234
  server_url: "string",
@@ -242,23 +271,26 @@ exports.WalletData = class WalletData {
242
271
  dataDir: "string",
243
272
  bitcoinNetwork: "string",
244
273
  databaseType: "string",
245
- accountXpubVanilla: "string",
246
- accountXpubColored: "string",
247
274
  maxAllocationsPerUtxo: "u32",
248
- vanillaKeychain: "u8?",
275
+ supportedSchemas: "array[string]",
276
+ reuseAddresses: "boolean?",
249
277
  };
250
278
  validateTypes(walletData, expectedTypes);
251
279
  validateEnumValues(walletData, {
252
280
  bitcoinNetwork: BitcoinNetwork,
253
281
  databaseType: DatabaseType,
282
+ supportedSchemas: AssetSchema,
254
283
  });
255
284
  return walletData;
256
285
  }
257
286
  };
258
287
 
259
288
  exports.Wallet = class Wallet {
260
- constructor(walletData) {
261
- this.wallet = lib.rgblib_new_wallet(JSON.stringify(walletData));
289
+ constructor(walletData, singlesigKeys) {
290
+ this.wallet = lib.rgblib_new_wallet(
291
+ JSON.stringify(walletData),
292
+ JSON.stringify(singlesigKeys),
293
+ );
262
294
  }
263
295
 
264
296
  drop() {
@@ -315,21 +347,21 @@ exports.Wallet = class Wallet {
315
347
  blindReceive(
316
348
  assetId,
317
349
  assignment,
318
- durationSeconds,
350
+ expirationTimestamp,
319
351
  transportEndpoints,
320
352
  minConfirmations,
321
353
  ) {
322
354
  const params = {
323
355
  assetId,
324
356
  assignment,
325
- durationSeconds,
357
+ expirationTimestamp,
326
358
  transportEndpoints,
327
359
  minConfirmations,
328
360
  };
329
361
  const expectedTypes = {
330
362
  assetId: "string?",
331
363
  assignment: "string",
332
- durationSeconds: "u32?",
364
+ expirationTimestamp: "u64?",
333
365
  transportEndpoints: "array[string]",
334
366
  minConfirmations: "u8",
335
367
  };
@@ -339,7 +371,7 @@ exports.Wallet = class Wallet {
339
371
  this.wallet,
340
372
  assetId,
341
373
  assignment,
342
- durationSeconds,
374
+ expirationTimestamp,
343
375
  JSON.stringify(transportEndpoints),
344
376
  minConfirmations,
345
377
  ),
@@ -408,10 +440,62 @@ exports.Wallet = class Wallet {
408
440
  );
409
441
  }
410
442
 
443
+ deleteTransfers(batchTransferIdx, noAssetOnly) {
444
+ const params = {
445
+ batchTransferIdx,
446
+ noAssetOnly,
447
+ };
448
+ const expectedTypes = {
449
+ batchTransferIdx: "i32?",
450
+ noAssetOnly: "boolean",
451
+ };
452
+ validateTypes(params, expectedTypes);
453
+ return JSON.parse(
454
+ lib.rgblib_delete_transfers(
455
+ this.wallet,
456
+ batchTransferIdx,
457
+ noAssetOnly,
458
+ ),
459
+ );
460
+ }
461
+
462
+ failTransfers(online, batchTransferIdx, noAssetOnly, skipSync) {
463
+ const params = {
464
+ online,
465
+ batchTransferIdx,
466
+ noAssetOnly,
467
+ skipSync,
468
+ };
469
+ const expectedTypes = {
470
+ online: "object",
471
+ batchTransferIdx: "i32?",
472
+ noAssetOnly: "boolean",
473
+ skipSync: "boolean",
474
+ };
475
+ validateTypes(params, expectedTypes);
476
+ return JSON.parse(
477
+ lib.rgblib_fail_transfers(
478
+ this.wallet,
479
+ online,
480
+ batchTransferIdx,
481
+ noAssetOnly,
482
+ skipSync,
483
+ ),
484
+ );
485
+ }
486
+
411
487
  getAddress() {
412
488
  return lib.rgblib_get_address(this.wallet);
413
489
  }
414
490
 
491
+ rotateVanillaAddress() {
492
+ return lib.rgblib_rotate_vanilla_address(this.wallet);
493
+ }
494
+
495
+ rotateColoredAddress() {
496
+ return lib.rgblib_rotate_colored_address(this.wallet);
497
+ }
498
+
415
499
  getAssetBalance(assetId) {
416
500
  const params = { assetId };
417
501
  const expectedTypes = {
@@ -421,6 +505,15 @@ exports.Wallet = class Wallet {
421
505
  return JSON.parse(lib.rgblib_get_asset_balance(this.wallet, assetId));
422
506
  }
423
507
 
508
+ getAssetMetadata(assetId) {
509
+ const params = { assetId };
510
+ const expectedTypes = {
511
+ assetId: "string",
512
+ };
513
+ validateTypes(params, expectedTypes);
514
+ return JSON.parse(lib.rgblib_get_asset_metadata(this.wallet, assetId));
515
+ }
516
+
424
517
  getBtcBalance(online, skipSync) {
425
518
  const params = { online, skipSync };
426
519
  const expectedTypes = {
@@ -555,6 +648,9 @@ exports.Wallet = class Wallet {
555
648
  filterAssetSchemas: "array[string]",
556
649
  };
557
650
  validateTypes(params, expectedTypes);
651
+ validateEnumValues(params, {
652
+ filterAssetSchemas: AssetSchema,
653
+ });
558
654
  return JSON.parse(
559
655
  lib.rgblib_list_assets(
560
656
  this.wallet,
@@ -633,57 +729,22 @@ exports.Wallet = class Wallet {
633
729
  );
634
730
  }
635
731
 
636
- deleteTransfers(batchTransferIdx, noAssetOnly) {
637
- const params = {
638
- batchTransferIdx,
639
- noAssetOnly,
640
- };
641
- const expectedTypes = {
642
- batchTransferIdx: "i32?",
643
- noAssetOnly: "boolean",
644
- };
645
- validateTypes(params, expectedTypes);
646
- return JSON.parse(
647
- lib.rgblib_delete_transfers(
648
- this.wallet,
649
- batchTransferIdx,
650
- noAssetOnly,
651
- ),
652
- );
653
- }
654
-
655
- failTransfers(online, batchTransferIdx, noAssetOnly, skipSync) {
656
- const params = {
657
- online,
658
- batchTransferIdx,
659
- noAssetOnly,
660
- skipSync,
661
- };
662
- const expectedTypes = {
663
- online: "object",
664
- batchTransferIdx: "i32?",
665
- noAssetOnly: "boolean",
666
- skipSync: "boolean",
667
- };
668
- validateTypes(params, expectedTypes);
669
- return JSON.parse(
670
- lib.rgblib_fail_transfers(
671
- this.wallet,
672
- online,
673
- batchTransferIdx,
674
- noAssetOnly,
675
- skipSync,
676
- ),
677
- );
678
- }
679
-
680
- send(online, recipientMap, donation, feeRate, minConfirmations, skipSync) {
732
+ send(
733
+ online,
734
+ recipientMap,
735
+ donation,
736
+ feeRate,
737
+ minConfirmations,
738
+ expirationTimestamp,
739
+ skipSync,
740
+ ) {
681
741
  const params = {
682
742
  online,
683
743
  recipientMap,
684
744
  donation,
685
745
  feeRate,
686
746
  minConfirmations,
747
+ expirationTimestamp,
687
748
  skipSync,
688
749
  };
689
750
  const expectedTypes = {
@@ -692,6 +753,7 @@ exports.Wallet = class Wallet {
692
753
  donation: "boolean",
693
754
  feeRate: "u64",
694
755
  minConfirmations: "u8",
756
+ expirationTimestamp: "u64?",
695
757
  skipSync: "boolean",
696
758
  };
697
759
  validateTypes(params, expectedTypes);
@@ -703,18 +765,29 @@ exports.Wallet = class Wallet {
703
765
  donation,
704
766
  feeRate,
705
767
  minConfirmations,
768
+ expirationTimestamp,
706
769
  skipSync,
707
770
  ),
708
771
  );
709
772
  }
710
773
 
711
- sendBegin(online, recipientMap, donation, feeRate, minConfirmations) {
774
+ sendBegin(
775
+ online,
776
+ recipientMap,
777
+ donation,
778
+ feeRate,
779
+ minConfirmations,
780
+ expirationTimestamp,
781
+ dryRun,
782
+ ) {
712
783
  const params = {
713
784
  online,
714
785
  recipientMap,
715
786
  donation,
716
787
  feeRate,
717
788
  minConfirmations,
789
+ expirationTimestamp,
790
+ dryRun,
718
791
  };
719
792
  const expectedTypes = {
720
793
  online: "object",
@@ -722,6 +795,8 @@ exports.Wallet = class Wallet {
722
795
  donation: "boolean",
723
796
  feeRate: "u64",
724
797
  minConfirmations: "u8",
798
+ expirationTimestamp: "u64?",
799
+ dryRun: "boolean",
725
800
  };
726
801
  validateTypes(params, expectedTypes);
727
802
  return lib.rgblib_send_begin(
@@ -731,28 +806,8 @@ exports.Wallet = class Wallet {
731
806
  donation,
732
807
  feeRate,
733
808
  minConfirmations,
734
- );
735
- }
736
-
737
- sendEnd(online, signedPsbt, skipSync) {
738
- const params = {
739
- online,
740
- signedPsbt,
741
- skipSync,
742
- };
743
- const expectedTypes = {
744
- online: "object",
745
- signedPsbt: "string",
746
- skipSync: "boolean",
747
- };
748
- validateTypes(params, expectedTypes);
749
- return JSON.parse(
750
- lib.rgblib_send_end(
751
- this.wallet,
752
- online,
753
- signedPsbt,
754
- skipSync,
755
- ),
809
+ expirationTimestamp,
810
+ dryRun,
756
811
  );
757
812
  }
758
813
 
@@ -782,33 +837,7 @@ exports.Wallet = class Wallet {
782
837
  );
783
838
  }
784
839
 
785
- sendBtcBegin(online, address, amount, feeRate, skipSync) {
786
- const params = {
787
- online,
788
- address,
789
- amount,
790
- feeRate,
791
- skipSync,
792
- };
793
- const expectedTypes = {
794
- online: "object",
795
- address: "string",
796
- amount: "u64",
797
- feeRate: "u64",
798
- skipSync: "boolean",
799
- };
800
- validateTypes(params, expectedTypes);
801
- return lib.rgblib_send_btc_begin(
802
- this.wallet,
803
- online,
804
- address,
805
- amount,
806
- feeRate,
807
- skipSync,
808
- );
809
- }
810
-
811
- sendBtcEnd(online, signedPsbt, skipSync) {
840
+ sendEnd(online, signedPsbt, skipSync) {
812
841
  const params = {
813
842
  online,
814
843
  signedPsbt,
@@ -820,11 +849,8 @@ exports.Wallet = class Wallet {
820
849
  skipSync: "boolean",
821
850
  };
822
851
  validateTypes(params, expectedTypes);
823
- return lib.rgblib_send_btc_end(
824
- this.wallet,
825
- online,
826
- signedPsbt,
827
- skipSync,
852
+ return JSON.parse(
853
+ lib.rgblib_send_end(this.wallet, online, signedPsbt, skipSync),
828
854
  );
829
855
  }
830
856
 
@@ -849,21 +875,21 @@ exports.Wallet = class Wallet {
849
875
  witnessReceive(
850
876
  assetId,
851
877
  assignment,
852
- durationSeconds,
878
+ expirationTimestamp,
853
879
  transportEndpoints,
854
880
  minConfirmations,
855
881
  ) {
856
882
  const params = {
857
883
  assetId,
858
884
  assignment,
859
- durationSeconds,
885
+ expirationTimestamp,
860
886
  transportEndpoints,
861
887
  minConfirmations,
862
888
  };
863
889
  const expectedTypes = {
864
890
  assetId: "string?",
865
891
  assignment: "string",
866
- durationSeconds: "u32?",
892
+ expirationTimestamp: "u64?",
867
893
  transportEndpoints: "array[string]",
868
894
  minConfirmations: "u8",
869
895
  };
@@ -873,7 +899,7 @@ exports.Wallet = class Wallet {
873
899
  this.wallet,
874
900
  assetId,
875
901
  assignment,
876
- durationSeconds,
902
+ expirationTimestamp,
877
903
  JSON.stringify(transportEndpoints),
878
904
  minConfirmations,
879
905
  ),
@@ -898,6 +924,34 @@ exports.validateConsignment = function validateConsignment(filePath, indexerUrl,
898
924
  );
899
925
  };
900
926
 
927
+ exports.validateConsignmentOffchain = function validateConsignmentOffchain(
928
+ filePath,
929
+ txid,
930
+ indexerUrl,
931
+ bitcoinNetwork,
932
+ ) {
933
+ const params = { filePath, txid, indexerUrl, bitcoinNetwork };
934
+ const expectedTypes = {
935
+ filePath: "string",
936
+ txid: "string",
937
+ indexerUrl: "string",
938
+ bitcoinNetwork: "string",
939
+ };
940
+ validateTypes(params, expectedTypes);
941
+ validateEnumValues(
942
+ { bitcoinNetwork },
943
+ { bitcoinNetwork: BitcoinNetwork },
944
+ );
945
+ return JSON.parse(
946
+ lib.rgblib_validate_consignment_offchain(
947
+ filePath,
948
+ txid,
949
+ indexerUrl,
950
+ bitcoinNetwork,
951
+ ),
952
+ );
953
+ };
954
+
901
955
  exports.Invoice = class Invoice {
902
956
  constructor(invoiceString) {
903
957
  const params = { invoiceString };