@buildonspark/spark-sdk 0.1.43 → 0.1.45

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 (153) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{RequestLightningSendInput-D7fZdT4A.d.ts → RequestLightningSendInput-DEPd_fPO.d.ts} +43 -4
  3. package/dist/{RequestLightningSendInput-Na1mHdWg.d.cts → RequestLightningSendInput-Du0z7Om7.d.cts} +43 -4
  4. package/dist/address/index.cjs +2 -2
  5. package/dist/address/index.d.cts +2 -2
  6. package/dist/address/index.d.ts +2 -2
  7. package/dist/address/index.js +2 -2
  8. package/dist/{chunk-IRW5TWMH.js → chunk-5FUB65LX.js} +7 -9
  9. package/dist/{chunk-BUTZWYBW.js → chunk-6264CGDM.js} +4 -4
  10. package/dist/{chunk-VFJQNBFX.js → chunk-7V6N75CC.js} +5 -2
  11. package/dist/{chunk-M6A4KFIG.js → chunk-BGGEVUJK.js} +1505 -445
  12. package/dist/{chunk-DQYKQJRZ.js → chunk-C2S227QR.js} +675 -52
  13. package/dist/{chunk-GYQR4B4P.js → chunk-GZ5IPPJ2.js} +2 -2
  14. package/dist/{chunk-6AFUC5M2.js → chunk-HWJWKEIU.js} +8 -2
  15. package/dist/{chunk-TOSP3INR.js → chunk-I54FARY2.js} +4 -2
  16. package/dist/{chunk-WWOTVNPP.js → chunk-J2IE4Z7Y.js} +544 -431
  17. package/dist/{chunk-O4RYNJNB.js → chunk-KMUMFYFX.js} +3 -3
  18. package/dist/chunk-LHRD2WT6.js +2374 -0
  19. package/dist/{chunk-ABZA6R5S.js → chunk-NTFKFRQ2.js} +1 -1
  20. package/dist/{chunk-MIVX3GHD.js → chunk-OBFKIEMP.js} +1 -1
  21. package/dist/{chunk-HRQRRDSS.js → chunk-PQN3C2MF.js} +15 -15
  22. package/dist/{chunk-DOA6QXYQ.js → chunk-R5PXJZQS.js} +3 -1
  23. package/dist/{chunk-TIUBYNN5.js → chunk-YUPMXTCJ.js} +4 -4
  24. package/dist/graphql/objects/index.d.cts +6 -43
  25. package/dist/graphql/objects/index.d.ts +6 -43
  26. package/dist/graphql/objects/index.js +1 -1
  27. package/dist/index-B2AwKW5J.d.cts +214 -0
  28. package/dist/index-CJDi1HWc.d.ts +214 -0
  29. package/dist/index.cjs +4150 -1026
  30. package/dist/index.d.cts +764 -19
  31. package/dist/index.d.ts +764 -19
  32. package/dist/index.js +17 -21
  33. package/dist/index.node.cjs +4153 -1033
  34. package/dist/index.node.d.cts +10 -8
  35. package/dist/index.node.d.ts +10 -8
  36. package/dist/index.node.js +20 -28
  37. package/dist/native/index.cjs +4166 -1042
  38. package/dist/native/index.d.cts +369 -108
  39. package/dist/native/index.d.ts +369 -108
  40. package/dist/native/index.js +4138 -1015
  41. package/dist/{network-xkBSpaTn.d.ts → network-BTJl-Sul.d.ts} +1 -1
  42. package/dist/{network-D5lKssVl.d.cts → network-CqgsdUF2.d.cts} +1 -1
  43. package/dist/proto/lrc20.cjs +222 -19
  44. package/dist/proto/lrc20.d.cts +1 -1
  45. package/dist/proto/lrc20.d.ts +1 -1
  46. package/dist/proto/lrc20.js +2 -2
  47. package/dist/proto/spark.cjs +1502 -442
  48. package/dist/proto/spark.d.cts +1 -1
  49. package/dist/proto/spark.d.ts +1 -1
  50. package/dist/proto/spark.js +5 -5
  51. package/dist/proto/spark_token.cjs +1515 -56
  52. package/dist/proto/spark_token.d.cts +153 -15
  53. package/dist/proto/spark_token.d.ts +153 -15
  54. package/dist/proto/spark_token.js +40 -4
  55. package/dist/{sdk-types-B-q9py_P.d.cts → sdk-types-B0SwjolI.d.cts} +1 -1
  56. package/dist/{sdk-types-BPoPgzda.d.ts → sdk-types-Cc4l4kb1.d.ts} +1 -1
  57. package/dist/services/config.cjs +7 -3
  58. package/dist/services/config.d.cts +5 -4
  59. package/dist/services/config.d.ts +5 -4
  60. package/dist/services/config.js +6 -6
  61. package/dist/services/connection.cjs +2938 -646
  62. package/dist/services/connection.d.cts +5 -4
  63. package/dist/services/connection.d.ts +5 -4
  64. package/dist/services/connection.js +4 -4
  65. package/dist/services/index.cjs +6381 -3461
  66. package/dist/services/index.d.cts +7 -6
  67. package/dist/services/index.d.ts +7 -6
  68. package/dist/services/index.js +15 -13
  69. package/dist/services/lrc-connection.cjs +227 -21
  70. package/dist/services/lrc-connection.d.cts +5 -4
  71. package/dist/services/lrc-connection.d.ts +5 -4
  72. package/dist/services/lrc-connection.js +4 -4
  73. package/dist/services/token-transactions.cjs +868 -244
  74. package/dist/services/token-transactions.d.cts +25 -7
  75. package/dist/services/token-transactions.d.ts +25 -7
  76. package/dist/services/token-transactions.js +5 -4
  77. package/dist/services/wallet-config.cjs +4 -1
  78. package/dist/services/wallet-config.d.cts +7 -5
  79. package/dist/services/wallet-config.d.ts +7 -5
  80. package/dist/services/wallet-config.js +3 -1
  81. package/dist/signer/signer.cjs +5 -2
  82. package/dist/signer/signer.d.cts +3 -2
  83. package/dist/signer/signer.d.ts +3 -2
  84. package/dist/signer/signer.js +2 -2
  85. package/dist/{signer-wqesWifN.d.ts → signer-BocS_J6B.d.ts} +2 -6
  86. package/dist/{signer-IO3oMRNj.d.cts → signer-DKS0AJkw.d.cts} +2 -6
  87. package/dist/{spark-CDm4gqS6.d.cts → spark-dM7EYXYQ.d.cts} +138 -42
  88. package/dist/{spark-CDm4gqS6.d.ts → spark-dM7EYXYQ.d.ts} +138 -42
  89. package/dist/spark_bindings/native/index.cjs +183 -0
  90. package/dist/spark_bindings/native/index.d.cts +14 -0
  91. package/dist/spark_bindings/native/index.d.ts +14 -0
  92. package/dist/spark_bindings/native/index.js +141 -0
  93. package/dist/spark_bindings/wasm/index.cjs +1093 -0
  94. package/dist/spark_bindings/wasm/index.d.cts +47 -0
  95. package/dist/spark_bindings/wasm/index.d.ts +47 -0
  96. package/dist/{chunk-K4C4W5FC.js → spark_bindings/wasm/index.js} +7 -6
  97. package/dist/types/index.cjs +1503 -443
  98. package/dist/types/index.d.cts +6 -5
  99. package/dist/types/index.d.ts +6 -5
  100. package/dist/types/index.js +3 -3
  101. package/dist/types-C-Rp0Oo7.d.cts +46 -0
  102. package/dist/types-C-Rp0Oo7.d.ts +46 -0
  103. package/dist/utils/index.cjs +358 -36
  104. package/dist/utils/index.d.cts +14 -134
  105. package/dist/utils/index.d.ts +14 -134
  106. package/dist/utils/index.js +8 -8
  107. package/package.json +21 -1
  108. package/src/constants.ts +5 -1
  109. package/src/graphql/client.ts +28 -0
  110. package/src/graphql/mutations/RequestCoopExit.ts +6 -0
  111. package/src/graphql/mutations/RequestSwapLeaves.ts +2 -0
  112. package/src/graphql/queries/GetCoopExitFeeQuote.ts +20 -0
  113. package/src/index.node.ts +0 -1
  114. package/src/index.ts +0 -1
  115. package/src/native/index.ts +1 -2
  116. package/src/proto/common.ts +5 -5
  117. package/src/proto/google/protobuf/descriptor.ts +34 -34
  118. package/src/proto/google/protobuf/duration.ts +2 -2
  119. package/src/proto/google/protobuf/empty.ts +2 -2
  120. package/src/proto/google/protobuf/timestamp.ts +2 -2
  121. package/src/proto/mock.ts +4 -4
  122. package/src/proto/spark.ts +1924 -525
  123. package/src/proto/spark_authn.ts +7 -7
  124. package/src/proto/spark_token.ts +1668 -105
  125. package/src/proto/validate/validate.ts +24 -24
  126. package/src/services/bolt11-spark.ts +62 -187
  127. package/src/services/coop-exit.ts +3 -0
  128. package/src/services/lrc20.ts +1 -1
  129. package/src/services/token-transactions.ts +209 -9
  130. package/src/services/transfer.ts +22 -3
  131. package/src/services/tree-creation.ts +13 -0
  132. package/src/services/wallet-config.ts +2 -1
  133. package/src/spark-wallet/spark-wallet.node.ts +3 -7
  134. package/src/spark-wallet/spark-wallet.ts +376 -232
  135. package/src/spark-wallet/types.ts +39 -3
  136. package/src/tests/bolt11-spark.test.ts +7 -15
  137. package/src/tests/integration/deposit.test.ts +16 -0
  138. package/src/tests/integration/ssp/coop-exit.test.ts +85 -21
  139. package/src/tests/integration/ssp/swap.test.ts +47 -0
  140. package/src/tests/integration/swap.test.ts +453 -433
  141. package/src/tests/integration/transfer.test.ts +261 -248
  142. package/src/tests/token-identifier.test.ts +54 -0
  143. package/src/tests/tokens.test.ts +218 -22
  144. package/src/utils/token-hashing.ts +346 -52
  145. package/src/utils/token-identifier.ts +88 -0
  146. package/src/utils/token-transaction-validation.ts +350 -5
  147. package/src/utils/token-transactions.ts +12 -8
  148. package/src/utils/transaction.ts +2 -8
  149. package/dist/chunk-VA7MV4MZ.js +0 -1073
  150. package/dist/index-7RYRH5wc.d.ts +0 -815
  151. package/dist/index-BJOc8Ur-.d.cts +0 -815
  152. package/dist/wasm-7OWFHDMS.js +0 -21
  153. package/src/logger.ts +0 -3
@@ -342,6 +342,87 @@ var import_wire2 = require("@bufbuild/protobuf/wire");
342
342
 
343
343
  // src/proto/google/protobuf/timestamp.ts
344
344
  var import_wire3 = require("@bufbuild/protobuf/wire");
345
+ function createBaseTimestamp() {
346
+ return { seconds: 0, nanos: 0 };
347
+ }
348
+ var Timestamp = {
349
+ encode(message, writer = new import_wire3.BinaryWriter()) {
350
+ if (message.seconds !== 0) {
351
+ writer.uint32(8).int64(message.seconds);
352
+ }
353
+ if (message.nanos !== 0) {
354
+ writer.uint32(16).int32(message.nanos);
355
+ }
356
+ return writer;
357
+ },
358
+ decode(input, length) {
359
+ const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
360
+ const end = length === void 0 ? reader.len : reader.pos + length;
361
+ const message = createBaseTimestamp();
362
+ while (reader.pos < end) {
363
+ const tag = reader.uint32();
364
+ switch (tag >>> 3) {
365
+ case 1: {
366
+ if (tag !== 8) {
367
+ break;
368
+ }
369
+ message.seconds = longToNumber(reader.int64());
370
+ continue;
371
+ }
372
+ case 2: {
373
+ if (tag !== 16) {
374
+ break;
375
+ }
376
+ message.nanos = reader.int32();
377
+ continue;
378
+ }
379
+ }
380
+ if ((tag & 7) === 4 || tag === 0) {
381
+ break;
382
+ }
383
+ reader.skip(tag & 7);
384
+ }
385
+ return message;
386
+ },
387
+ fromJSON(object) {
388
+ return {
389
+ seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0,
390
+ nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0
391
+ };
392
+ },
393
+ toJSON(message) {
394
+ const obj = {};
395
+ if (message.seconds !== 0) {
396
+ obj.seconds = Math.round(message.seconds);
397
+ }
398
+ if (message.nanos !== 0) {
399
+ obj.nanos = Math.round(message.nanos);
400
+ }
401
+ return obj;
402
+ },
403
+ create(base) {
404
+ return Timestamp.fromPartial(base ?? {});
405
+ },
406
+ fromPartial(object) {
407
+ const message = createBaseTimestamp();
408
+ message.seconds = object.seconds ?? 0;
409
+ message.nanos = object.nanos ?? 0;
410
+ return message;
411
+ }
412
+ };
413
+ function longToNumber(int64) {
414
+ const num = globalThis.Number(int64.toString());
415
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
416
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
417
+ }
418
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
419
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
420
+ }
421
+ return num;
422
+ }
423
+ function isSet(value) {
424
+ return value !== null && value !== void 0;
425
+ }
345
426
 
346
427
  // src/proto/spark.ts
347
428
  function networkFromJSON(object) {
@@ -385,7 +466,7 @@ function networkToJSON(object) {
385
466
  }
386
467
  }
387
468
  function createBaseSigningKeyshare() {
388
- return { ownerIdentifiers: [], threshold: 0, publicKey: new Uint8Array(0) };
469
+ return { ownerIdentifiers: [], threshold: 0, publicKey: new Uint8Array(0), publicShares: {}, updatedTime: void 0 };
389
470
  }
390
471
  var SigningKeyshare = {
391
472
  encode(message, writer = new import_wire4.BinaryWriter()) {
@@ -398,11 +479,17 @@ var SigningKeyshare = {
398
479
  if (message.publicKey.length !== 0) {
399
480
  writer.uint32(26).bytes(message.publicKey);
400
481
  }
482
+ Object.entries(message.publicShares).forEach(([key, value]) => {
483
+ SigningKeyshare_PublicSharesEntry.encode({ key, value }, writer.uint32(34).fork()).join();
484
+ });
485
+ if (message.updatedTime !== void 0) {
486
+ Timestamp.encode(toTimestamp(message.updatedTime), writer.uint32(42).fork()).join();
487
+ }
401
488
  return writer;
402
489
  },
403
490
  decode(input, length) {
404
491
  const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
405
- let end = length === void 0 ? reader.len : reader.pos + length;
492
+ const end = length === void 0 ? reader.len : reader.pos + length;
406
493
  const message = createBaseSigningKeyshare();
407
494
  while (reader.pos < end) {
408
495
  const tag = reader.uint32();
@@ -428,6 +515,23 @@ var SigningKeyshare = {
428
515
  message.publicKey = reader.bytes();
429
516
  continue;
430
517
  }
518
+ case 4: {
519
+ if (tag !== 34) {
520
+ break;
521
+ }
522
+ const entry4 = SigningKeyshare_PublicSharesEntry.decode(reader, reader.uint32());
523
+ if (entry4.value !== void 0) {
524
+ message.publicShares[entry4.key] = entry4.value;
525
+ }
526
+ continue;
527
+ }
528
+ case 5: {
529
+ if (tag !== 42) {
530
+ break;
531
+ }
532
+ message.updatedTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
533
+ continue;
534
+ }
431
535
  }
432
536
  if ((tag & 7) === 4 || tag === 0) {
433
537
  break;
@@ -439,8 +543,13 @@ var SigningKeyshare = {
439
543
  fromJSON(object) {
440
544
  return {
441
545
  ownerIdentifiers: globalThis.Array.isArray(object?.ownerIdentifiers) ? object.ownerIdentifiers.map((e) => globalThis.String(e)) : [],
442
- threshold: isSet(object.threshold) ? globalThis.Number(object.threshold) : 0,
443
- publicKey: isSet(object.publicKey) ? bytesFromBase64(object.publicKey) : new Uint8Array(0)
546
+ threshold: isSet2(object.threshold) ? globalThis.Number(object.threshold) : 0,
547
+ publicKey: isSet2(object.publicKey) ? bytesFromBase64(object.publicKey) : new Uint8Array(0),
548
+ publicShares: isObject(object.publicShares) ? Object.entries(object.publicShares).reduce((acc, [key, value]) => {
549
+ acc[key] = bytesFromBase64(value);
550
+ return acc;
551
+ }, {}) : {},
552
+ updatedTime: isSet2(object.updatedTime) ? fromJsonTimestamp(object.updatedTime) : void 0
444
553
  };
445
554
  },
446
555
  toJSON(message) {
@@ -454,6 +563,18 @@ var SigningKeyshare = {
454
563
  if (message.publicKey.length !== 0) {
455
564
  obj.publicKey = base64FromBytes(message.publicKey);
456
565
  }
566
+ if (message.publicShares) {
567
+ const entries = Object.entries(message.publicShares);
568
+ if (entries.length > 0) {
569
+ obj.publicShares = {};
570
+ entries.forEach(([k, v]) => {
571
+ obj.publicShares[k] = base64FromBytes(v);
572
+ });
573
+ }
574
+ }
575
+ if (message.updatedTime !== void 0) {
576
+ obj.updatedTime = message.updatedTime.toISOString();
577
+ }
457
578
  return obj;
458
579
  },
459
580
  create(base) {
@@ -464,6 +585,84 @@ var SigningKeyshare = {
464
585
  message.ownerIdentifiers = object.ownerIdentifiers?.map((e) => e) || [];
465
586
  message.threshold = object.threshold ?? 0;
466
587
  message.publicKey = object.publicKey ?? new Uint8Array(0);
588
+ message.publicShares = Object.entries(object.publicShares ?? {}).reduce(
589
+ (acc, [key, value]) => {
590
+ if (value !== void 0) {
591
+ acc[key] = value;
592
+ }
593
+ return acc;
594
+ },
595
+ {}
596
+ );
597
+ message.updatedTime = object.updatedTime ?? void 0;
598
+ return message;
599
+ }
600
+ };
601
+ function createBaseSigningKeyshare_PublicSharesEntry() {
602
+ return { key: "", value: new Uint8Array(0) };
603
+ }
604
+ var SigningKeyshare_PublicSharesEntry = {
605
+ encode(message, writer = new import_wire4.BinaryWriter()) {
606
+ if (message.key !== "") {
607
+ writer.uint32(10).string(message.key);
608
+ }
609
+ if (message.value.length !== 0) {
610
+ writer.uint32(18).bytes(message.value);
611
+ }
612
+ return writer;
613
+ },
614
+ decode(input, length) {
615
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
616
+ const end = length === void 0 ? reader.len : reader.pos + length;
617
+ const message = createBaseSigningKeyshare_PublicSharesEntry();
618
+ while (reader.pos < end) {
619
+ const tag = reader.uint32();
620
+ switch (tag >>> 3) {
621
+ case 1: {
622
+ if (tag !== 10) {
623
+ break;
624
+ }
625
+ message.key = reader.string();
626
+ continue;
627
+ }
628
+ case 2: {
629
+ if (tag !== 18) {
630
+ break;
631
+ }
632
+ message.value = reader.bytes();
633
+ continue;
634
+ }
635
+ }
636
+ if ((tag & 7) === 4 || tag === 0) {
637
+ break;
638
+ }
639
+ reader.skip(tag & 7);
640
+ }
641
+ return message;
642
+ },
643
+ fromJSON(object) {
644
+ return {
645
+ key: isSet2(object.key) ? globalThis.String(object.key) : "",
646
+ value: isSet2(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0)
647
+ };
648
+ },
649
+ toJSON(message) {
650
+ const obj = {};
651
+ if (message.key !== "") {
652
+ obj.key = message.key;
653
+ }
654
+ if (message.value.length !== 0) {
655
+ obj.value = base64FromBytes(message.value);
656
+ }
657
+ return obj;
658
+ },
659
+ create(base) {
660
+ return SigningKeyshare_PublicSharesEntry.fromPartial(base ?? {});
661
+ },
662
+ fromPartial(object) {
663
+ const message = createBaseSigningKeyshare_PublicSharesEntry();
664
+ message.key = object.key ?? "";
665
+ message.value = object.value ?? new Uint8Array(0);
467
666
  return message;
468
667
  }
469
668
  };
@@ -480,7 +679,13 @@ function createBaseTreeNode() {
480
679
  ownerIdentityPublicKey: new Uint8Array(0),
481
680
  signingKeyshare: void 0,
482
681
  status: "",
483
- network: 0
682
+ network: 0,
683
+ createdTime: void 0,
684
+ updatedTime: void 0,
685
+ ownerSigningPublicKey: new Uint8Array(0),
686
+ directTx: new Uint8Array(0),
687
+ directRefundTx: new Uint8Array(0),
688
+ directFromCpfpRefundTx: new Uint8Array(0)
484
689
  };
485
690
  }
486
691
  var TreeNode = {
@@ -521,11 +726,29 @@ var TreeNode = {
521
726
  if (message.network !== 0) {
522
727
  writer.uint32(96).int32(message.network);
523
728
  }
729
+ if (message.createdTime !== void 0) {
730
+ Timestamp.encode(toTimestamp(message.createdTime), writer.uint32(106).fork()).join();
731
+ }
732
+ if (message.updatedTime !== void 0) {
733
+ Timestamp.encode(toTimestamp(message.updatedTime), writer.uint32(114).fork()).join();
734
+ }
735
+ if (message.ownerSigningPublicKey.length !== 0) {
736
+ writer.uint32(122).bytes(message.ownerSigningPublicKey);
737
+ }
738
+ if (message.directTx.length !== 0) {
739
+ writer.uint32(130).bytes(message.directTx);
740
+ }
741
+ if (message.directRefundTx.length !== 0) {
742
+ writer.uint32(138).bytes(message.directRefundTx);
743
+ }
744
+ if (message.directFromCpfpRefundTx.length !== 0) {
745
+ writer.uint32(146).bytes(message.directFromCpfpRefundTx);
746
+ }
524
747
  return writer;
525
748
  },
526
749
  decode(input, length) {
527
750
  const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
528
- let end = length === void 0 ? reader.len : reader.pos + length;
751
+ const end = length === void 0 ? reader.len : reader.pos + length;
529
752
  const message = createBaseTreeNode();
530
753
  while (reader.pos < end) {
531
754
  const tag = reader.uint32();
@@ -548,7 +771,7 @@ var TreeNode = {
548
771
  if (tag !== 24) {
549
772
  break;
550
773
  }
551
- message.value = longToNumber(reader.uint64());
774
+ message.value = longToNumber2(reader.uint64());
552
775
  continue;
553
776
  }
554
777
  case 4: {
@@ -614,6 +837,48 @@ var TreeNode = {
614
837
  message.network = reader.int32();
615
838
  continue;
616
839
  }
840
+ case 13: {
841
+ if (tag !== 106) {
842
+ break;
843
+ }
844
+ message.createdTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
845
+ continue;
846
+ }
847
+ case 14: {
848
+ if (tag !== 114) {
849
+ break;
850
+ }
851
+ message.updatedTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
852
+ continue;
853
+ }
854
+ case 15: {
855
+ if (tag !== 122) {
856
+ break;
857
+ }
858
+ message.ownerSigningPublicKey = reader.bytes();
859
+ continue;
860
+ }
861
+ case 16: {
862
+ if (tag !== 130) {
863
+ break;
864
+ }
865
+ message.directTx = reader.bytes();
866
+ continue;
867
+ }
868
+ case 17: {
869
+ if (tag !== 138) {
870
+ break;
871
+ }
872
+ message.directRefundTx = reader.bytes();
873
+ continue;
874
+ }
875
+ case 18: {
876
+ if (tag !== 146) {
877
+ break;
878
+ }
879
+ message.directFromCpfpRefundTx = reader.bytes();
880
+ continue;
881
+ }
617
882
  }
618
883
  if ((tag & 7) === 4 || tag === 0) {
619
884
  break;
@@ -624,18 +889,24 @@ var TreeNode = {
624
889
  },
625
890
  fromJSON(object) {
626
891
  return {
627
- id: isSet(object.id) ? globalThis.String(object.id) : "",
628
- treeId: isSet(object.treeId) ? globalThis.String(object.treeId) : "",
629
- value: isSet(object.value) ? globalThis.Number(object.value) : 0,
630
- parentNodeId: isSet(object.parentNodeId) ? globalThis.String(object.parentNodeId) : void 0,
631
- nodeTx: isSet(object.nodeTx) ? bytesFromBase64(object.nodeTx) : new Uint8Array(0),
632
- refundTx: isSet(object.refundTx) ? bytesFromBase64(object.refundTx) : new Uint8Array(0),
633
- vout: isSet(object.vout) ? globalThis.Number(object.vout) : 0,
634
- verifyingPublicKey: isSet(object.verifyingPublicKey) ? bytesFromBase64(object.verifyingPublicKey) : new Uint8Array(0),
635
- ownerIdentityPublicKey: isSet(object.ownerIdentityPublicKey) ? bytesFromBase64(object.ownerIdentityPublicKey) : new Uint8Array(0),
636
- signingKeyshare: isSet(object.signingKeyshare) ? SigningKeyshare.fromJSON(object.signingKeyshare) : void 0,
637
- status: isSet(object.status) ? globalThis.String(object.status) : "",
638
- network: isSet(object.network) ? networkFromJSON(object.network) : 0
892
+ id: isSet2(object.id) ? globalThis.String(object.id) : "",
893
+ treeId: isSet2(object.treeId) ? globalThis.String(object.treeId) : "",
894
+ value: isSet2(object.value) ? globalThis.Number(object.value) : 0,
895
+ parentNodeId: isSet2(object.parentNodeId) ? globalThis.String(object.parentNodeId) : void 0,
896
+ nodeTx: isSet2(object.nodeTx) ? bytesFromBase64(object.nodeTx) : new Uint8Array(0),
897
+ refundTx: isSet2(object.refundTx) ? bytesFromBase64(object.refundTx) : new Uint8Array(0),
898
+ vout: isSet2(object.vout) ? globalThis.Number(object.vout) : 0,
899
+ verifyingPublicKey: isSet2(object.verifyingPublicKey) ? bytesFromBase64(object.verifyingPublicKey) : new Uint8Array(0),
900
+ ownerIdentityPublicKey: isSet2(object.ownerIdentityPublicKey) ? bytesFromBase64(object.ownerIdentityPublicKey) : new Uint8Array(0),
901
+ signingKeyshare: isSet2(object.signingKeyshare) ? SigningKeyshare.fromJSON(object.signingKeyshare) : void 0,
902
+ status: isSet2(object.status) ? globalThis.String(object.status) : "",
903
+ network: isSet2(object.network) ? networkFromJSON(object.network) : 0,
904
+ createdTime: isSet2(object.createdTime) ? fromJsonTimestamp(object.createdTime) : void 0,
905
+ updatedTime: isSet2(object.updatedTime) ? fromJsonTimestamp(object.updatedTime) : void 0,
906
+ ownerSigningPublicKey: isSet2(object.ownerSigningPublicKey) ? bytesFromBase64(object.ownerSigningPublicKey) : new Uint8Array(0),
907
+ directTx: isSet2(object.directTx) ? bytesFromBase64(object.directTx) : new Uint8Array(0),
908
+ directRefundTx: isSet2(object.directRefundTx) ? bytesFromBase64(object.directRefundTx) : new Uint8Array(0),
909
+ directFromCpfpRefundTx: isSet2(object.directFromCpfpRefundTx) ? bytesFromBase64(object.directFromCpfpRefundTx) : new Uint8Array(0)
639
910
  };
640
911
  },
641
912
  toJSON(message) {
@@ -676,6 +947,24 @@ var TreeNode = {
676
947
  if (message.network !== 0) {
677
948
  obj.network = networkToJSON(message.network);
678
949
  }
950
+ if (message.createdTime !== void 0) {
951
+ obj.createdTime = message.createdTime.toISOString();
952
+ }
953
+ if (message.updatedTime !== void 0) {
954
+ obj.updatedTime = message.updatedTime.toISOString();
955
+ }
956
+ if (message.ownerSigningPublicKey.length !== 0) {
957
+ obj.ownerSigningPublicKey = base64FromBytes(message.ownerSigningPublicKey);
958
+ }
959
+ if (message.directTx.length !== 0) {
960
+ obj.directTx = base64FromBytes(message.directTx);
961
+ }
962
+ if (message.directRefundTx.length !== 0) {
963
+ obj.directRefundTx = base64FromBytes(message.directRefundTx);
964
+ }
965
+ if (message.directFromCpfpRefundTx.length !== 0) {
966
+ obj.directFromCpfpRefundTx = base64FromBytes(message.directFromCpfpRefundTx);
967
+ }
679
968
  return obj;
680
969
  },
681
970
  create(base) {
@@ -695,6 +984,12 @@ var TreeNode = {
695
984
  message.signingKeyshare = object.signingKeyshare !== void 0 && object.signingKeyshare !== null ? SigningKeyshare.fromPartial(object.signingKeyshare) : void 0;
696
985
  message.status = object.status ?? "";
697
986
  message.network = object.network ?? 0;
987
+ message.createdTime = object.createdTime ?? void 0;
988
+ message.updatedTime = object.updatedTime ?? void 0;
989
+ message.ownerSigningPublicKey = object.ownerSigningPublicKey ?? new Uint8Array(0);
990
+ message.directTx = object.directTx ?? new Uint8Array(0);
991
+ message.directRefundTx = object.directRefundTx ?? new Uint8Array(0);
992
+ message.directFromCpfpRefundTx = object.directFromCpfpRefundTx ?? new Uint8Array(0);
698
993
  return message;
699
994
  }
700
995
  };
@@ -713,7 +1008,7 @@ var SparkAddress = {
713
1008
  },
714
1009
  decode(input, length) {
715
1010
  const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
716
- let end = length === void 0 ? reader.len : reader.pos + length;
1011
+ const end = length === void 0 ? reader.len : reader.pos + length;
717
1012
  const message = createBaseSparkAddress();
718
1013
  while (reader.pos < end) {
719
1014
  const tag = reader.uint32();
@@ -742,8 +1037,8 @@ var SparkAddress = {
742
1037
  },
743
1038
  fromJSON(object) {
744
1039
  return {
745
- identityPublicKey: isSet(object.identityPublicKey) ? bytesFromBase64(object.identityPublicKey) : new Uint8Array(0),
746
- paymentIntentFields: isSet(object.paymentIntentFields) ? PaymentIntentFields.fromJSON(object.paymentIntentFields) : void 0
1040
+ identityPublicKey: isSet2(object.identityPublicKey) ? bytesFromBase64(object.identityPublicKey) : new Uint8Array(0),
1041
+ paymentIntentFields: isSet2(object.paymentIntentFields) ? PaymentIntentFields.fromJSON(object.paymentIntentFields) : void 0
747
1042
  };
748
1043
  },
749
1044
  toJSON(message) {
@@ -787,7 +1082,7 @@ var PaymentIntentFields = {
787
1082
  },
788
1083
  decode(input, length) {
789
1084
  const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
790
- let end = length === void 0 ? reader.len : reader.pos + length;
1085
+ const end = length === void 0 ? reader.len : reader.pos + length;
791
1086
  const message = createBasePaymentIntentFields();
792
1087
  while (reader.pos < end) {
793
1088
  const tag = reader.uint32();
@@ -830,10 +1125,10 @@ var PaymentIntentFields = {
830
1125
  },
831
1126
  fromJSON(object) {
832
1127
  return {
833
- id: isSet(object.id) ? bytesFromBase64(object.id) : new Uint8Array(0),
834
- assetIdentifier: isSet(object.assetIdentifier) ? bytesFromBase64(object.assetIdentifier) : void 0,
835
- assetAmount: isSet(object.assetAmount) ? bytesFromBase64(object.assetAmount) : new Uint8Array(0),
836
- memo: isSet(object.memo) ? globalThis.String(object.memo) : void 0
1128
+ id: isSet2(object.id) ? bytesFromBase64(object.id) : new Uint8Array(0),
1129
+ assetIdentifier: isSet2(object.assetIdentifier) ? bytesFromBase64(object.assetIdentifier) : void 0,
1130
+ assetAmount: isSet2(object.assetAmount) ? bytesFromBase64(object.assetAmount) : new Uint8Array(0),
1131
+ memo: isSet2(object.memo) ? globalThis.String(object.memo) : void 0
837
1132
  };
838
1133
  },
839
1134
  toJSON(message) {
@@ -887,7 +1182,26 @@ function base64FromBytes(arr) {
887
1182
  return globalThis.btoa(bin.join(""));
888
1183
  }
889
1184
  }
890
- function longToNumber(int64) {
1185
+ function toTimestamp(date) {
1186
+ const seconds = Math.trunc(date.getTime() / 1e3);
1187
+ const nanos = date.getTime() % 1e3 * 1e6;
1188
+ return { seconds, nanos };
1189
+ }
1190
+ function fromTimestamp(t) {
1191
+ let millis = (t.seconds || 0) * 1e3;
1192
+ millis += (t.nanos || 0) / 1e6;
1193
+ return new globalThis.Date(millis);
1194
+ }
1195
+ function fromJsonTimestamp(o) {
1196
+ if (o instanceof globalThis.Date) {
1197
+ return o;
1198
+ } else if (typeof o === "string") {
1199
+ return new globalThis.Date(o);
1200
+ } else {
1201
+ return fromTimestamp(Timestamp.fromJSON(o));
1202
+ }
1203
+ }
1204
+ function longToNumber2(int64) {
891
1205
  const num = globalThis.Number(int64.toString());
892
1206
  if (num > globalThis.Number.MAX_SAFE_INTEGER) {
893
1207
  throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
@@ -897,7 +1211,10 @@ function longToNumber(int64) {
897
1211
  }
898
1212
  return num;
899
1213
  }
900
- function isSet(value) {
1214
+ function isObject(value) {
1215
+ return typeof value === "object" && value !== null;
1216
+ }
1217
+ function isSet2(value) {
901
1218
  return value !== null && value !== void 0;
902
1219
  }
903
1220
 
@@ -1367,7 +1684,8 @@ var BASE_CONFIG = {
1367
1684
  }
1368
1685
  };
1369
1686
  var LOCAL_WALLET_CONFIG = {
1370
- ...BASE_CONFIG
1687
+ ...BASE_CONFIG,
1688
+ threshold: 3
1371
1689
  };
1372
1690
  var LOCAL_WALLET_CONFIG_SCHNORR = {
1373
1691
  ...LOCAL_WALLET_CONFIG,
@@ -1905,13 +2223,19 @@ function checkIfSelectedOutputsAreAvailable(selectedOutputs, tokenOutputs, token
1905
2223
  return true;
1906
2224
  }
1907
2225
  function filterTokenBalanceForTokenPublicKey(tokenBalances, publicKey) {
1908
- if (!tokenBalances || !tokenBalances.has(publicKey)) {
2226
+ if (!tokenBalances) {
2227
+ return { balance: 0n };
2228
+ }
2229
+ const tokenBalance = [...tokenBalances.entries()].find(
2230
+ ([, info]) => info.tokenMetadata.tokenPublicKey === publicKey
2231
+ );
2232
+ if (!tokenBalance) {
1909
2233
  return {
1910
2234
  balance: 0n
1911
2235
  };
1912
2236
  }
1913
2237
  return {
1914
- balance: tokenBalances.get(publicKey).balance
2238
+ balance: tokenBalance[1].balance
1915
2239
  };
1916
2240
  }
1917
2241
 
@@ -1992,18 +2316,16 @@ function checkIfValidSequence(currSequence) {
1992
2316
  }
1993
2317
  }
1994
2318
  function getNextTransactionSequence(currSequence, forRefresh) {
1995
- checkIfValidSequence(currSequence);
1996
2319
  const currentTimelock = getCurrentTimelock(currSequence);
1997
2320
  const nextTimelock = currentTimelock - TIME_LOCK_INTERVAL;
1998
- checkIfValidSequence(nextTimelock);
1999
2321
  if (forRefresh && nextTimelock <= 100 && currentTimelock > 0) {
2000
2322
  return {
2001
2323
  nextSequence: 1 << 30 | nextTimelock,
2002
2324
  needRefresh: true
2003
2325
  };
2004
2326
  }
2005
- if (nextTimelock < 100) {
2006
- throw new ValidationError("timelock interval is less than 100", {
2327
+ if (nextTimelock < 0) {
2328
+ throw new ValidationError("timelock interval is less than 0", {
2007
2329
  field: "nextTimelock",
2008
2330
  value: nextTimelock
2009
2331
  });