@buildonspark/spark-sdk 0.3.5 → 0.3.7

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 (113) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/bare/index.cjs +4079 -4662
  3. package/dist/bare/index.d.cts +689 -89
  4. package/dist/bare/index.d.ts +689 -89
  5. package/dist/bare/index.js +5565 -5972
  6. package/dist/{chunk-JE73HB26.js → chunk-KDEVNW7C.js} +12671 -13161
  7. package/dist/chunk-P4HYYSMU.js +7 -0
  8. package/dist/chunk-SRPKOCG4.js +139 -0
  9. package/dist/chunk-UYTT3C6H.js +605 -0
  10. package/dist/{client-DWml6sjL.d.cts → client-Bcb7TUIp.d.cts} +12 -10
  11. package/dist/{client-DBZ43pJT.d.ts → client-D9T58OY8.d.ts} +12 -10
  12. package/dist/debug.cjs +9248 -9782
  13. package/dist/debug.d.cts +8 -8
  14. package/dist/debug.d.ts +8 -8
  15. package/dist/debug.js +5 -3
  16. package/dist/graphql/objects/index.d.cts +3 -3
  17. package/dist/graphql/objects/index.d.ts +3 -3
  18. package/dist/index.cjs +695 -1286
  19. package/dist/index.d.cts +7 -18
  20. package/dist/index.d.ts +7 -18
  21. package/dist/index.js +5 -4
  22. package/dist/index.node.cjs +1365 -1496
  23. package/dist/index.node.d.cts +6 -7
  24. package/dist/index.node.d.ts +6 -7
  25. package/dist/index.node.js +7 -66
  26. package/dist/{logging-Dt2ooQiP.d.ts → logging-JIaZZIbR.d.ts} +3 -3
  27. package/dist/{logging-BUpzk4Z6.d.cts → logging-zkr4UlOi.d.cts} +3 -3
  28. package/dist/native/{chunk-D3SZRO65.js → chunk-X2QXUON7.js} +15 -0
  29. package/dist/native/{index.cjs → index.react-native.cjs} +875 -1274
  30. package/dist/native/{index.d.cts → index.react-native.d.cts} +1124 -520
  31. package/dist/native/{index.d.ts → index.react-native.d.ts} +1124 -520
  32. package/dist/native/{index.js → index.react-native.js} +870 -1100
  33. package/dist/native/{wasm-KT5NZXRN.js → wasm-GKEDPGTM.js} +1 -2
  34. package/dist/proto/spark.d.cts +1 -1
  35. package/dist/proto/spark.d.ts +1 -1
  36. package/dist/proto/spark_token.d.cts +1 -1
  37. package/dist/proto/spark_token.d.ts +1 -1
  38. package/dist/{spark-DasxuVfm.d.cts → spark-WA_4wcBr.d.cts} +1 -1
  39. package/dist/{spark-DasxuVfm.d.ts → spark-WA_4wcBr.d.ts} +1 -1
  40. package/dist/{spark-wallet-jlC0XN5f.d.ts → spark-wallet-BuFrUWeE.d.cts} +107 -75
  41. package/dist/{spark-wallet-BoMIOPWW.d.cts → spark-wallet-CE5PYiIb.d.ts} +107 -75
  42. package/dist/spark-wallet.browser-BwYkkOBU.d.ts +26 -0
  43. package/dist/spark-wallet.browser-DC3jdQPW.d.cts +26 -0
  44. package/dist/spark-wallet.node-C9d2W-Nb.d.ts +90 -0
  45. package/dist/spark-wallet.node-CR_zNxmy.d.cts +90 -0
  46. package/dist/tests/test-utils.cjs +17563 -7501
  47. package/dist/tests/test-utils.d.cts +8 -22
  48. package/dist/tests/test-utils.d.ts +8 -22
  49. package/dist/tests/test-utils.js +30 -4
  50. package/dist/{token-transactions-DscJaJOE.d.ts → token-transactions-BZoJuvuE.d.ts} +2 -2
  51. package/dist/{token-transactions-BDzCrQSk.d.cts → token-transactions-I_OFIoNH.d.cts} +2 -2
  52. package/dist/types/index.d.cts +2 -2
  53. package/dist/types/index.d.ts +2 -2
  54. package/package.json +20 -16
  55. package/src/bare/index.ts +1 -1
  56. package/src/debug.ts +1 -1
  57. package/src/graphql/client.ts +6 -9
  58. package/src/graphql/mutations/CompleteCoopExit.ts +1 -1
  59. package/src/graphql/mutations/RequestCoopExit.ts +3 -1
  60. package/src/graphql/mutations/RequestLightningSend.ts +3 -1
  61. package/src/graphql/objects/CompleteCoopExitInput.ts +22 -33
  62. package/src/graphql/objects/RequestCoopExitInput.ts +39 -45
  63. package/src/graphql/objects/RequestLightningSendInput.ts +31 -39
  64. package/src/index.node.ts +2 -1
  65. package/src/index.react-native.ts +21 -0
  66. package/src/index.ts +2 -1
  67. package/src/services/config.ts +2 -2
  68. package/src/services/connection/connection.browser.ts +130 -0
  69. package/src/services/connection/connection.node.ts +158 -0
  70. package/src/services/{connection.ts → connection/connection.ts} +58 -259
  71. package/src/services/coop-exit.ts +8 -4
  72. package/src/services/deposit.ts +1 -1
  73. package/src/services/index.ts +1 -1
  74. package/src/services/lightning.ts +1 -1
  75. package/src/services/token-transactions.ts +9 -9
  76. package/src/services/transfer.ts +1 -1
  77. package/src/spark-wallet/spark-wallet.bare.ts +12 -0
  78. package/src/spark-wallet/spark-wallet.browser.ts +9 -24
  79. package/src/spark-wallet/spark-wallet.node.ts +4 -24
  80. package/src/spark-wallet/spark-wallet.react-native.ts +17 -0
  81. package/src/spark-wallet/spark-wallet.ts +130 -82
  82. package/src/spark-wallet/types.ts +4 -2
  83. package/src/tests/integration/coop-exit.test.ts +5 -3
  84. package/src/tests/integration/lightning.test.ts +9 -5
  85. package/src/tests/integration/ssp/coop-exit-validation.test.ts +8 -11
  86. package/src/tests/integration/ssp/coop-exit.test.ts +3 -5
  87. package/src/tests/integration/ssp/lightning.test.ts +1 -1
  88. package/src/tests/integration/ssp/static-deposit-validation.test.ts +2 -2
  89. package/src/tests/integration/ssp/static_deposit.test.ts +94 -101
  90. package/src/tests/integration/ssp/swap.test.ts +4 -5
  91. package/src/tests/integration/ssp/transfers.test.ts +10 -11
  92. package/src/tests/integration/static_deposit.test.ts +4 -4
  93. package/src/tests/integration/token-output.test.ts +2 -2
  94. package/src/tests/integration/transfer.test.ts +30 -26
  95. package/src/tests/integration/watchtower.test.ts +3 -3
  96. package/src/tests/optimize.test.ts +45 -0
  97. package/src/tests/spark-wallet/queryNodes.test.ts +1 -2
  98. package/src/tests/test-utils.ts +3 -3
  99. package/src/tests/token-outputs.test.ts +61 -2
  100. package/src/tests/utils/spark-testing-wallet.ts +18 -58
  101. package/src/tests/utils/test-faucet.ts +12 -8
  102. package/src/tests/utils/utils.ts +63 -0
  103. package/src/tests/wrapWithOtelSpan.test.ts +7 -0
  104. package/src/utils/network.ts +11 -10
  105. package/src/utils/optimize.ts +226 -0
  106. package/dist/bare/xhr-transport-EEEC7FYA.js +0 -165
  107. package/dist/chunk-DIXXHATX.js +0 -70
  108. package/dist/native/chunk-C3WN3D4O.js +0 -19
  109. package/dist/native/xhr-transport-TNCG4HTW.js +0 -168
  110. package/dist/spark-wallet.node-07PksUHH.d.cts +0 -12
  111. package/dist/spark-wallet.node-CdWkKMSq.d.ts +0 -12
  112. package/dist/xhr-transport-IWJPYF7F.js +0 -167
  113. package/src/native/index.ts +0 -20
@@ -1,16 +1,16 @@
1
1
  import * as _scure_base from '@scure/base';
2
2
  import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
3
- import { CallOptions } from 'nice-grpc-common';
3
+ import { CallOptions, ClientMiddlewareCall, Metadata } from 'nice-grpc-common';
4
4
  import * as btc from '@scure/btc-signer';
5
5
  import { Transaction } from '@scure/btc-signer';
6
- import * as bitcoin from 'bitcoinjs-lib';
7
6
  import { TransactionOutput, TransactionInput } from '@scure/btc-signer/psbt';
8
7
  import { HDKey } from '@scure/bip32';
9
8
  import { Query, Logger, LoggingLevel } from '@lightsparkdev/core';
10
9
  import { Channel } from 'nice-grpc';
11
- import { Channel as Channel$1 } from 'nice-grpc-web';
10
+ import { Channel as Channel$1, createChannel } from 'nice-grpc-web';
12
11
  import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
13
12
  import { EventEmitter } from 'eventemitter3';
13
+ import * as nice_grpc_web_lib_client_Transport_js from 'nice-grpc-web/lib/client/Transport.js';
14
14
 
15
15
  declare class SparkSDKError extends Error {
16
16
  readonly context: Record<string, unknown>;
@@ -1559,6 +1559,495 @@ interface TokenTransfer {
1559
1559
  finalTokenTransactionHash: Uint8Array;
1560
1560
  }
1561
1561
  declare const TokenTransfer: MessageFns$2<TokenTransfer>;
1562
+ type SparkServiceDefinition = typeof SparkServiceDefinition;
1563
+ declare const SparkServiceDefinition: {
1564
+ readonly name: "SparkService";
1565
+ readonly fullName: "spark.SparkService";
1566
+ readonly methods: {
1567
+ readonly generate_deposit_address: {
1568
+ readonly name: "generate_deposit_address";
1569
+ readonly requestType: MessageFns$2<GenerateDepositAddressRequest>;
1570
+ readonly requestStream: false;
1571
+ readonly responseType: MessageFns$2<GenerateDepositAddressResponse>;
1572
+ readonly responseStream: false;
1573
+ readonly options: {};
1574
+ };
1575
+ /** Generates a new static deposit address of the user or returns the existing one for the specified network. */
1576
+ readonly generate_static_deposit_address: {
1577
+ readonly name: "generate_static_deposit_address";
1578
+ readonly requestType: MessageFns$2<GenerateStaticDepositAddressRequest>;
1579
+ readonly requestStream: false;
1580
+ readonly responseType: MessageFns$2<GenerateStaticDepositAddressResponse>;
1581
+ readonly responseStream: false;
1582
+ readonly options: {};
1583
+ };
1584
+ readonly start_deposit_tree_creation: {
1585
+ readonly name: "start_deposit_tree_creation";
1586
+ readonly requestType: MessageFns$2<StartDepositTreeCreationRequest>;
1587
+ readonly requestStream: false;
1588
+ readonly responseType: MessageFns$2<StartDepositTreeCreationResponse>;
1589
+ readonly responseStream: false;
1590
+ readonly options: {};
1591
+ };
1592
+ /**
1593
+ * This is deprecated, please use start_deposit_tree_creation instead.
1594
+ *
1595
+ * @deprecated
1596
+ */
1597
+ readonly start_tree_creation: {
1598
+ readonly name: "start_tree_creation";
1599
+ readonly requestType: MessageFns$2<StartTreeCreationRequest>;
1600
+ readonly requestStream: false;
1601
+ readonly responseType: MessageFns$2<StartTreeCreationResponse>;
1602
+ readonly responseStream: false;
1603
+ readonly options: {};
1604
+ };
1605
+ readonly finalize_node_signatures: {
1606
+ readonly name: "finalize_node_signatures";
1607
+ readonly requestType: MessageFns$2<FinalizeNodeSignaturesRequest>;
1608
+ readonly requestStream: false;
1609
+ readonly responseType: MessageFns$2<FinalizeNodeSignaturesResponse>;
1610
+ readonly responseStream: false;
1611
+ readonly options: {};
1612
+ };
1613
+ readonly start_transfer: {
1614
+ readonly name: "start_transfer";
1615
+ readonly requestType: MessageFns$2<StartTransferRequest>;
1616
+ readonly requestStream: false;
1617
+ readonly responseType: MessageFns$2<StartTransferResponse>;
1618
+ readonly responseStream: false;
1619
+ readonly options: {};
1620
+ };
1621
+ /**
1622
+ * This is deprecated, please use finalize_transfer_with_transfer_package instead.
1623
+ *
1624
+ * @deprecated
1625
+ */
1626
+ readonly finalize_transfer: {
1627
+ readonly name: "finalize_transfer";
1628
+ readonly requestType: MessageFns$2<FinalizeTransferRequest>;
1629
+ readonly requestStream: false;
1630
+ readonly responseType: MessageFns$2<FinalizeTransferResponse>;
1631
+ readonly responseStream: false;
1632
+ readonly options: {};
1633
+ };
1634
+ readonly finalize_transfer_with_transfer_package: {
1635
+ readonly name: "finalize_transfer_with_transfer_package";
1636
+ readonly requestType: MessageFns$2<FinalizeTransferWithTransferPackageRequest>;
1637
+ readonly requestStream: false;
1638
+ readonly responseType: MessageFns$2<FinalizeTransferResponse>;
1639
+ readonly responseStream: false;
1640
+ readonly options: {};
1641
+ };
1642
+ readonly cancel_transfer: {
1643
+ readonly name: "cancel_transfer";
1644
+ readonly requestType: MessageFns$2<CancelTransferRequest>;
1645
+ readonly requestStream: false;
1646
+ readonly responseType: MessageFns$2<CancelTransferResponse>;
1647
+ readonly responseStream: false;
1648
+ readonly options: {};
1649
+ };
1650
+ readonly query_pending_transfers: {
1651
+ readonly name: "query_pending_transfers";
1652
+ readonly requestType: MessageFns$2<TransferFilter>;
1653
+ readonly requestStream: false;
1654
+ readonly responseType: MessageFns$2<QueryTransfersResponse>;
1655
+ readonly responseStream: false;
1656
+ readonly options: {};
1657
+ };
1658
+ readonly query_all_transfers: {
1659
+ readonly name: "query_all_transfers";
1660
+ readonly requestType: MessageFns$2<TransferFilter>;
1661
+ readonly requestStream: false;
1662
+ readonly responseType: MessageFns$2<QueryTransfersResponse>;
1663
+ readonly responseStream: false;
1664
+ readonly options: {};
1665
+ };
1666
+ readonly claim_transfer_tweak_keys: {
1667
+ readonly name: "claim_transfer_tweak_keys";
1668
+ readonly requestType: MessageFns$2<ClaimTransferTweakKeysRequest>;
1669
+ readonly requestStream: false;
1670
+ readonly responseType: MessageFns$4<Empty>;
1671
+ readonly responseStream: false;
1672
+ readonly options: {};
1673
+ };
1674
+ readonly claim_transfer_sign_refunds: {
1675
+ readonly name: "claim_transfer_sign_refunds";
1676
+ readonly requestType: MessageFns$2<ClaimTransferSignRefundsRequest>;
1677
+ readonly requestStream: false;
1678
+ readonly responseType: MessageFns$2<ClaimTransferSignRefundsResponse>;
1679
+ readonly responseStream: false;
1680
+ readonly options: {};
1681
+ };
1682
+ readonly store_preimage_share: {
1683
+ readonly name: "store_preimage_share";
1684
+ readonly requestType: MessageFns$2<StorePreimageShareRequest>;
1685
+ readonly requestStream: false;
1686
+ readonly responseType: MessageFns$4<Empty>;
1687
+ readonly responseStream: false;
1688
+ readonly options: {};
1689
+ };
1690
+ readonly get_signing_commitments: {
1691
+ readonly name: "get_signing_commitments";
1692
+ readonly requestType: MessageFns$2<GetSigningCommitmentsRequest>;
1693
+ readonly requestStream: false;
1694
+ readonly responseType: MessageFns$2<GetSigningCommitmentsResponse>;
1695
+ readonly responseStream: false;
1696
+ readonly options: {};
1697
+ };
1698
+ readonly cooperative_exit: {
1699
+ readonly name: "cooperative_exit";
1700
+ readonly requestType: MessageFns$2<CooperativeExitRequest>;
1701
+ readonly requestStream: false;
1702
+ readonly responseType: MessageFns$2<CooperativeExitResponse>;
1703
+ readonly responseStream: false;
1704
+ readonly options: {};
1705
+ };
1706
+ readonly initiate_preimage_swap: {
1707
+ readonly name: "initiate_preimage_swap";
1708
+ readonly requestType: MessageFns$2<InitiatePreimageSwapRequest>;
1709
+ readonly requestStream: false;
1710
+ readonly responseType: MessageFns$2<InitiatePreimageSwapResponse>;
1711
+ readonly responseStream: false;
1712
+ readonly options: {};
1713
+ };
1714
+ readonly provide_preimage: {
1715
+ readonly name: "provide_preimage";
1716
+ readonly requestType: MessageFns$2<ProvidePreimageRequest>;
1717
+ readonly requestStream: false;
1718
+ readonly responseType: MessageFns$2<ProvidePreimageResponse>;
1719
+ readonly responseStream: false;
1720
+ readonly options: {};
1721
+ };
1722
+ /**
1723
+ * This is the exact same as start_transfer, but expresses to the SO
1724
+ * this transfer is specifically for a leaf swap.
1725
+ */
1726
+ readonly start_leaf_swap: {
1727
+ readonly name: "start_leaf_swap";
1728
+ readonly requestType: MessageFns$2<StartTransferRequest>;
1729
+ readonly requestStream: false;
1730
+ readonly responseType: MessageFns$2<StartTransferResponse>;
1731
+ readonly responseStream: false;
1732
+ readonly options: {};
1733
+ };
1734
+ /**
1735
+ * This is deprecated, please use counter_leaf_swap instead.
1736
+ *
1737
+ * @deprecated
1738
+ */
1739
+ readonly leaf_swap: {
1740
+ readonly name: "leaf_swap";
1741
+ readonly requestType: MessageFns$2<CounterLeafSwapRequest>;
1742
+ readonly requestStream: false;
1743
+ readonly responseType: MessageFns$2<CounterLeafSwapResponse>;
1744
+ readonly responseStream: false;
1745
+ readonly options: {};
1746
+ };
1747
+ /**
1748
+ * This is the exact same as start_leaf_swap, but signs with
1749
+ * an adaptor public key after a counterparty has begun the swap via start_leaf_swap.
1750
+ */
1751
+ readonly counter_leaf_swap: {
1752
+ readonly name: "counter_leaf_swap";
1753
+ readonly requestType: MessageFns$2<CounterLeafSwapRequest>;
1754
+ readonly requestStream: false;
1755
+ readonly responseType: MessageFns$2<CounterLeafSwapResponse>;
1756
+ readonly responseStream: false;
1757
+ readonly options: {};
1758
+ };
1759
+ readonly refresh_timelock: {
1760
+ readonly name: "refresh_timelock";
1761
+ readonly requestType: MessageFns$2<RefreshTimelockRequest>;
1762
+ readonly requestStream: false;
1763
+ readonly responseType: MessageFns$2<RefreshTimelockResponse>;
1764
+ readonly responseStream: false;
1765
+ readonly options: {};
1766
+ };
1767
+ readonly extend_leaf: {
1768
+ readonly name: "extend_leaf";
1769
+ readonly requestType: MessageFns$2<ExtendLeafRequest>;
1770
+ readonly requestStream: false;
1771
+ readonly responseType: MessageFns$2<ExtendLeafResponse>;
1772
+ readonly responseStream: false;
1773
+ readonly options: {};
1774
+ };
1775
+ /**
1776
+ * Resets the timelocks for a leaf's transactions. Can be used to reset the
1777
+ * refund transaction timelock for a leaf (when the node transaction
1778
+ * timelock is still > 300) or reset the node and refund transaction
1779
+ * timelock. Returns an error if a leaf is not yet eligible to renew the
1780
+ * timelocks, see RenewLeafRequest for more details.
1781
+ */
1782
+ readonly renew_leaf: {
1783
+ readonly name: "renew_leaf";
1784
+ readonly requestType: MessageFns$2<RenewLeafRequest>;
1785
+ readonly requestStream: false;
1786
+ readonly responseType: MessageFns$2<RenewLeafResponse>;
1787
+ readonly responseStream: false;
1788
+ readonly options: {};
1789
+ };
1790
+ readonly get_signing_operator_list: {
1791
+ readonly name: "get_signing_operator_list";
1792
+ readonly requestType: MessageFns$4<Empty>;
1793
+ readonly requestStream: false;
1794
+ readonly responseType: MessageFns$2<GetSigningOperatorListResponse>;
1795
+ readonly responseStream: false;
1796
+ readonly options: {};
1797
+ };
1798
+ readonly query_nodes: {
1799
+ readonly name: "query_nodes";
1800
+ readonly requestType: MessageFns$2<QueryNodesRequest>;
1801
+ readonly requestStream: false;
1802
+ readonly responseType: MessageFns$2<QueryNodesResponse>;
1803
+ readonly responseStream: false;
1804
+ readonly options: {};
1805
+ };
1806
+ readonly query_nodes_distribution: {
1807
+ readonly name: "query_nodes_distribution";
1808
+ readonly requestType: MessageFns$2<QueryNodesDistributionRequest>;
1809
+ readonly requestStream: false;
1810
+ readonly responseType: MessageFns$2<QueryNodesDistributionResponse>;
1811
+ readonly responseStream: false;
1812
+ readonly options: {};
1813
+ };
1814
+ readonly query_nodes_by_value: {
1815
+ readonly name: "query_nodes_by_value";
1816
+ readonly requestType: MessageFns$2<QueryNodesByValueRequest>;
1817
+ readonly requestStream: false;
1818
+ readonly responseType: MessageFns$2<QueryNodesByValueResponse>;
1819
+ readonly responseStream: false;
1820
+ readonly options: {};
1821
+ };
1822
+ readonly query_balance: {
1823
+ readonly name: "query_balance";
1824
+ readonly requestType: MessageFns$2<QueryBalanceRequest>;
1825
+ readonly requestStream: false;
1826
+ readonly responseType: MessageFns$2<QueryBalanceResponse>;
1827
+ readonly responseStream: false;
1828
+ readonly options: {};
1829
+ };
1830
+ readonly query_user_signed_refunds: {
1831
+ readonly name: "query_user_signed_refunds";
1832
+ readonly requestType: MessageFns$2<QueryUserSignedRefundsRequest>;
1833
+ readonly requestStream: false;
1834
+ readonly responseType: MessageFns$2<QueryUserSignedRefundsResponse>;
1835
+ readonly responseStream: false;
1836
+ readonly options: {};
1837
+ };
1838
+ /** Token RPCs */
1839
+ readonly start_token_transaction: {
1840
+ readonly name: "start_token_transaction";
1841
+ readonly requestType: MessageFns$2<StartTokenTransactionRequest>;
1842
+ readonly requestStream: false;
1843
+ readonly responseType: MessageFns$2<StartTokenTransactionResponse>;
1844
+ readonly responseStream: false;
1845
+ readonly options: {};
1846
+ };
1847
+ readonly sign_token_transaction: {
1848
+ readonly name: "sign_token_transaction";
1849
+ readonly requestType: MessageFns$2<SignTokenTransactionRequest>;
1850
+ readonly requestStream: false;
1851
+ readonly responseType: MessageFns$2<SignTokenTransactionResponse>;
1852
+ readonly responseStream: false;
1853
+ readonly options: {};
1854
+ };
1855
+ readonly finalize_token_transaction: {
1856
+ readonly name: "finalize_token_transaction";
1857
+ readonly requestType: MessageFns$2<FinalizeTokenTransactionRequest>;
1858
+ readonly requestStream: false;
1859
+ readonly responseType: MessageFns$4<Empty>;
1860
+ readonly responseStream: false;
1861
+ readonly options: {};
1862
+ };
1863
+ readonly freeze_tokens: {
1864
+ readonly name: "freeze_tokens";
1865
+ readonly requestType: MessageFns$2<FreezeTokensRequest$1>;
1866
+ readonly requestStream: false;
1867
+ readonly responseType: MessageFns$2<FreezeTokensResponse$1>;
1868
+ readonly responseStream: false;
1869
+ readonly options: {};
1870
+ };
1871
+ readonly query_token_outputs: {
1872
+ readonly name: "query_token_outputs";
1873
+ readonly requestType: MessageFns$2<QueryTokenOutputsRequest$1>;
1874
+ readonly requestStream: false;
1875
+ readonly responseType: MessageFns$2<QueryTokenOutputsResponse$1>;
1876
+ readonly responseStream: false;
1877
+ readonly options: {};
1878
+ };
1879
+ readonly query_token_transactions: {
1880
+ readonly name: "query_token_transactions";
1881
+ readonly requestType: MessageFns$2<QueryTokenTransactionsRequest$1>;
1882
+ readonly requestStream: false;
1883
+ readonly responseType: MessageFns$2<QueryTokenTransactionsResponse$1>;
1884
+ readonly responseStream: false;
1885
+ readonly options: {};
1886
+ };
1887
+ readonly return_lightning_payment: {
1888
+ readonly name: "return_lightning_payment";
1889
+ readonly requestType: MessageFns$2<ReturnLightningPaymentRequest>;
1890
+ readonly requestStream: false;
1891
+ readonly responseType: MessageFns$4<Empty>;
1892
+ readonly responseStream: false;
1893
+ readonly options: {};
1894
+ };
1895
+ readonly query_unused_deposit_addresses: {
1896
+ readonly name: "query_unused_deposit_addresses";
1897
+ readonly requestType: MessageFns$2<QueryUnusedDepositAddressesRequest>;
1898
+ readonly requestStream: false;
1899
+ readonly responseType: MessageFns$2<QueryUnusedDepositAddressesResponse>;
1900
+ readonly responseStream: false;
1901
+ readonly options: {};
1902
+ };
1903
+ readonly query_static_deposit_addresses: {
1904
+ readonly name: "query_static_deposit_addresses";
1905
+ readonly requestType: MessageFns$2<QueryStaticDepositAddressesRequest>;
1906
+ readonly requestStream: false;
1907
+ readonly responseType: MessageFns$2<QueryStaticDepositAddressesResponse>;
1908
+ readonly responseStream: false;
1909
+ readonly options: {};
1910
+ };
1911
+ readonly subscribe_to_events: {
1912
+ readonly name: "subscribe_to_events";
1913
+ readonly requestType: MessageFns$2<SubscribeToEventsRequest>;
1914
+ readonly requestStream: false;
1915
+ readonly responseType: MessageFns$2<SubscribeToEventsResponse>;
1916
+ readonly responseStream: true;
1917
+ readonly options: {};
1918
+ };
1919
+ /**
1920
+ * Signs the provided refund transaction which spends the UTXO from a static
1921
+ * deposit address. If successful, the UTXO will no longer be available to claim on
1922
+ * the Spark network, and the refund transaction must be broadcasted on L1 to claim
1923
+ * the funds. Returns an error if the UTXO has already been claimed.
1924
+ */
1925
+ readonly initiate_static_deposit_utxo_refund: {
1926
+ readonly name: "initiate_static_deposit_utxo_refund";
1927
+ readonly requestType: MessageFns$2<InitiateStaticDepositUtxoRefundRequest>;
1928
+ readonly requestStream: false;
1929
+ readonly responseType: MessageFns$2<InitiateStaticDepositUtxoRefundResponse>;
1930
+ readonly responseStream: false;
1931
+ readonly options: {};
1932
+ };
1933
+ /**
1934
+ * DEPRECATED: This unified method is being split for better clarity and type safety
1935
+ *
1936
+ * For swap operations: Use spark_ssp_internal.initiate_static_deposit_utxo_swap()
1937
+ * For refund operations: Use initiate_static_deposit_utxo_refund()
1938
+ *
1939
+ * @deprecated
1940
+ */
1941
+ readonly initiate_utxo_swap: {
1942
+ readonly name: "initiate_utxo_swap";
1943
+ readonly requestType: MessageFns$2<InitiateUtxoSwapRequest>;
1944
+ readonly requestStream: false;
1945
+ readonly responseType: MessageFns$2<InitiateUtxoSwapResponse>;
1946
+ readonly responseStream: false;
1947
+ readonly options: {};
1948
+ };
1949
+ readonly exit_single_node_trees: {
1950
+ readonly name: "exit_single_node_trees";
1951
+ readonly requestType: MessageFns$2<ExitSingleNodeTreesRequest>;
1952
+ readonly requestStream: false;
1953
+ readonly responseType: MessageFns$2<ExitSingleNodeTreesResponse>;
1954
+ readonly responseStream: false;
1955
+ readonly options: {};
1956
+ };
1957
+ /**
1958
+ * The following endpoints enforce inclusion of Direct Transactions used
1959
+ * for unilateral exits
1960
+ */
1961
+ readonly cooperative_exit_v2: {
1962
+ readonly name: "cooperative_exit_v2";
1963
+ readonly requestType: MessageFns$2<CooperativeExitRequest>;
1964
+ readonly requestStream: false;
1965
+ readonly responseType: MessageFns$2<CooperativeExitResponse>;
1966
+ readonly responseStream: false;
1967
+ readonly options: {};
1968
+ };
1969
+ readonly extend_leaf_v2: {
1970
+ readonly name: "extend_leaf_v2";
1971
+ readonly requestType: MessageFns$2<ExtendLeafRequest>;
1972
+ readonly requestStream: false;
1973
+ readonly responseType: MessageFns$2<ExtendLeafResponse>;
1974
+ readonly responseStream: false;
1975
+ readonly options: {};
1976
+ };
1977
+ readonly claim_transfer_sign_refunds_v2: {
1978
+ readonly name: "claim_transfer_sign_refunds_v2";
1979
+ readonly requestType: MessageFns$2<ClaimTransferSignRefundsRequest>;
1980
+ readonly requestStream: false;
1981
+ readonly responseType: MessageFns$2<ClaimTransferSignRefundsResponse>;
1982
+ readonly responseStream: false;
1983
+ readonly options: {};
1984
+ };
1985
+ readonly finalize_node_signatures_v2: {
1986
+ readonly name: "finalize_node_signatures_v2";
1987
+ readonly requestType: MessageFns$2<FinalizeNodeSignaturesRequest>;
1988
+ readonly requestStream: false;
1989
+ readonly responseType: MessageFns$2<FinalizeNodeSignaturesResponse>;
1990
+ readonly responseStream: false;
1991
+ readonly options: {};
1992
+ };
1993
+ readonly initiate_preimage_swap_v2: {
1994
+ readonly name: "initiate_preimage_swap_v2";
1995
+ readonly requestType: MessageFns$2<InitiatePreimageSwapRequest>;
1996
+ readonly requestStream: false;
1997
+ readonly responseType: MessageFns$2<InitiatePreimageSwapResponse>;
1998
+ readonly responseStream: false;
1999
+ readonly options: {};
2000
+ };
2001
+ readonly start_leaf_swap_v2: {
2002
+ readonly name: "start_leaf_swap_v2";
2003
+ readonly requestType: MessageFns$2<StartTransferRequest>;
2004
+ readonly requestStream: false;
2005
+ readonly responseType: MessageFns$2<StartTransferResponse>;
2006
+ readonly responseStream: false;
2007
+ readonly options: {};
2008
+ };
2009
+ readonly counter_leaf_swap_v2: {
2010
+ readonly name: "counter_leaf_swap_v2";
2011
+ readonly requestType: MessageFns$2<CounterLeafSwapRequest>;
2012
+ readonly requestStream: false;
2013
+ readonly responseType: MessageFns$2<CounterLeafSwapResponse>;
2014
+ readonly responseStream: false;
2015
+ readonly options: {};
2016
+ };
2017
+ readonly start_transfer_v2: {
2018
+ readonly name: "start_transfer_v2";
2019
+ readonly requestType: MessageFns$2<StartTransferRequest>;
2020
+ readonly requestStream: false;
2021
+ readonly responseType: MessageFns$2<StartTransferResponse>;
2022
+ readonly responseStream: false;
2023
+ readonly options: {};
2024
+ };
2025
+ readonly refresh_timelock_v2: {
2026
+ readonly name: "refresh_timelock_v2";
2027
+ readonly requestType: MessageFns$2<RefreshTimelockRequest>;
2028
+ readonly requestStream: false;
2029
+ readonly responseType: MessageFns$2<RefreshTimelockResponse>;
2030
+ readonly responseStream: false;
2031
+ readonly options: {};
2032
+ };
2033
+ readonly get_utxos_for_address: {
2034
+ readonly name: "get_utxos_for_address";
2035
+ readonly requestType: MessageFns$2<GetUtxosForAddressRequest>;
2036
+ readonly requestStream: false;
2037
+ readonly responseType: MessageFns$2<GetUtxosForAddressResponse>;
2038
+ readonly responseStream: false;
2039
+ readonly options: {};
2040
+ };
2041
+ readonly query_spark_invoices: {
2042
+ readonly name: "query_spark_invoices";
2043
+ readonly requestType: MessageFns$2<QuerySparkInvoicesRequest>;
2044
+ readonly requestStream: false;
2045
+ readonly responseType: MessageFns$2<QuerySparkInvoicesResponse>;
2046
+ readonly responseStream: false;
2047
+ readonly options: {};
2048
+ };
2049
+ };
2050
+ };
1562
2051
  interface SparkServiceClient<CallOptionsExt = {}> {
1563
2052
  generate_deposit_address(request: DeepPartial$2<GenerateDepositAddressRequest>, options?: CallOptions & CallOptionsExt): Promise<GenerateDepositAddressResponse>;
1564
2053
  /** Generates a new static deposit address of the user or returns the existing one for the specified network. */
@@ -1712,13 +2201,6 @@ type NetworkType = keyof typeof Network;
1712
2201
  declare const NetworkToProto: Record<Network, Network$1>;
1713
2202
  declare const protoToNetwork: (protoNetwork: Network$1) => Network | undefined;
1714
2203
  declare const getNetwork: (network: Network) => typeof btc.NETWORK;
1715
- declare const LRC_WALLET_NETWORK: Readonly<{
1716
- 0: bitcoin.networks.Network;
1717
- 1: bitcoin.networks.Network;
1718
- 2: bitcoin.networks.Network;
1719
- 3: bitcoin.networks.Network;
1720
- 4: bitcoin.networks.Network;
1721
- }>;
1722
2204
  /**
1723
2205
  * Utility function to determine the network from a Bitcoin address.
1724
2206
  *
@@ -2220,6 +2702,69 @@ interface FreezeTokensResponse {
2220
2702
  impactedTokenAmount: Uint8Array;
2221
2703
  }
2222
2704
  declare const FreezeTokensResponse: MessageFns$1<FreezeTokensResponse>;
2705
+ type SparkTokenServiceDefinition = typeof SparkTokenServiceDefinition;
2706
+ declare const SparkTokenServiceDefinition: {
2707
+ readonly name: "SparkTokenService";
2708
+ readonly fullName: "spark_token.SparkTokenService";
2709
+ readonly methods: {
2710
+ /**
2711
+ * Start process to create final token transaction with all inputs required
2712
+ * from user and SOs (including revocation secret commitment)
2713
+ */
2714
+ readonly start_transaction: {
2715
+ readonly name: "start_transaction";
2716
+ readonly requestType: MessageFns$1<StartTransactionRequest>;
2717
+ readonly requestStream: false;
2718
+ readonly responseType: MessageFns$1<StartTransactionResponse>;
2719
+ readonly responseStream: false;
2720
+ readonly options: {};
2721
+ };
2722
+ /**
2723
+ * Complete the transaction and commit it with all SOs. This will be
2724
+ * coordinated by one SO.
2725
+ */
2726
+ readonly commit_transaction: {
2727
+ readonly name: "commit_transaction";
2728
+ readonly requestType: MessageFns$1<CommitTransactionRequest>;
2729
+ readonly requestStream: false;
2730
+ readonly responseType: MessageFns$1<CommitTransactionResponse>;
2731
+ readonly responseStream: false;
2732
+ readonly options: {};
2733
+ };
2734
+ readonly query_token_metadata: {
2735
+ readonly name: "query_token_metadata";
2736
+ readonly requestType: MessageFns$1<QueryTokenMetadataRequest>;
2737
+ readonly requestStream: false;
2738
+ readonly responseType: MessageFns$1<QueryTokenMetadataResponse>;
2739
+ readonly responseStream: false;
2740
+ readonly options: {};
2741
+ };
2742
+ readonly query_token_transactions: {
2743
+ readonly name: "query_token_transactions";
2744
+ readonly requestType: MessageFns$1<QueryTokenTransactionsRequest>;
2745
+ readonly requestStream: false;
2746
+ readonly responseType: MessageFns$1<QueryTokenTransactionsResponse>;
2747
+ readonly responseStream: false;
2748
+ readonly options: {};
2749
+ };
2750
+ readonly query_token_outputs: {
2751
+ readonly name: "query_token_outputs";
2752
+ readonly requestType: MessageFns$1<QueryTokenOutputsRequest>;
2753
+ readonly requestStream: false;
2754
+ readonly responseType: MessageFns$1<QueryTokenOutputsResponse>;
2755
+ readonly responseStream: false;
2756
+ readonly options: {};
2757
+ };
2758
+ readonly freeze_tokens: {
2759
+ readonly name: "freeze_tokens";
2760
+ readonly requestType: MessageFns$1<FreezeTokensRequest>;
2761
+ readonly requestStream: false;
2762
+ readonly responseType: MessageFns$1<FreezeTokensResponse>;
2763
+ readonly responseStream: false;
2764
+ readonly options: {};
2765
+ };
2766
+ };
2767
+ };
2223
2768
  interface SparkTokenServiceClient<CallOptionsExt = {}> {
2224
2769
  /**
2225
2770
  * Start process to create final token transaction with all inputs required
@@ -2756,7 +3301,7 @@ interface ClaimStaticDepositOutput {
2756
3301
 
2757
3302
  interface CompleteCoopExitInput {
2758
3303
  userOutboundTransferExternalId: string;
2759
- coopExitRequestId: string;
3304
+ coopExitRequestId?: string | undefined;
2760
3305
  }
2761
3306
 
2762
3307
  interface CompleteLeavesSwapInput {
@@ -2844,11 +3389,12 @@ interface LightningSendFeeEstimateOutput {
2844
3389
  interface RequestCoopExitInput {
2845
3390
  leafExternalIds: string[];
2846
3391
  withdrawalAddress: string;
2847
- idempotencyKey: string;
3392
+ idempotencyKey?: string | undefined;
2848
3393
  exitSpeed: ExitSpeed;
2849
3394
  withdrawAll: boolean;
2850
3395
  feeLeafExternalIds?: string[] | undefined;
2851
3396
  feeQuoteId?: string | undefined;
3397
+ userOutboundTransferExternalId?: string | undefined;
2852
3398
  }
2853
3399
 
2854
3400
  interface UserLeafInput {
@@ -2908,12 +3454,13 @@ interface RequestLightningReceiveInput {
2908
3454
 
2909
3455
  interface RequestLightningSendInput {
2910
3456
  encodedInvoice: string;
2911
- idempotencyKey: string;
3457
+ idempotencyKey?: string | undefined;
2912
3458
  /**
2913
- * The amount you will pay for this invoice in sats. It should ONLY be set when the invoice amount is
2914
- * zero.
2915
- **/
3459
+ * The amount you will pay for this invoice in sats. It should ONLY be set when the invoice amount is
3460
+ * zero.
3461
+ **/
2916
3462
  amountSats?: number | undefined;
3463
+ userOutboundTransferExternalId?: string | undefined;
2917
3464
  }
2918
3465
 
2919
3466
  interface StaticDepositQuoteInput {
@@ -2970,10 +3517,10 @@ declare class SspClient {
2970
3517
  getLightningSendFeeEstimate(encodedInvoice: string, amountSats?: number): Promise<LightningSendFeeEstimateOutput | null>;
2971
3518
  getCoopExitFeeEstimate({ leafExternalIds, withdrawalAddress, }: CoopExitFeeEstimatesInput): Promise<CoopExitFeeEstimatesOutput | null>;
2972
3519
  getCurrentUser(): Promise<void>;
2973
- completeCoopExit({ userOutboundTransferExternalId, coopExitRequestId, }: CompleteCoopExitInput): Promise<CoopExitRequest | null>;
2974
- requestCoopExit({ leafExternalIds, withdrawalAddress, idempotencyKey, exitSpeed, feeLeafExternalIds, feeQuoteId, withdrawAll, }: RequestCoopExitInput): Promise<CoopExitRequest | null>;
3520
+ completeCoopExit({ userOutboundTransferExternalId, }: CompleteCoopExitInput): Promise<CoopExitRequest | null>;
3521
+ requestCoopExit({ leafExternalIds, withdrawalAddress, exitSpeed, feeLeafExternalIds, feeQuoteId, withdrawAll, userOutboundTransferExternalId, }: RequestCoopExitInput): Promise<CoopExitRequest | null>;
2975
3522
  requestLightningReceive({ amountSats, network, paymentHash, expirySecs, memo, includeSparkAddress, receiverIdentityPubkey, descriptionHash, }: RequestLightningReceiveInput): Promise<LightningReceiveRequest | null>;
2976
- requestLightningSend({ encodedInvoice, idempotencyKey, amountSats, }: RequestLightningSendInput): Promise<LightningSendRequest | null>;
3523
+ requestLightningSend({ encodedInvoice, amountSats, userOutboundTransferExternalId, }: RequestLightningSendInput): Promise<LightningSendRequest | null>;
2977
3524
  requestLeaveSwap({ adaptorPubkey, directAdaptorPubkey, directFromCpfpAdaptorPubkey, totalAmountSats, targetAmountSats, feeSats, userLeaves, idempotencyKey, targetAmountSatsList, }: RequestLeavesSwapInput): Promise<LeavesSwapRequest | null>;
2978
3525
  completeLeaveSwap({ adaptorSecretKey, directAdaptorSecretKey, directFromCpfpAdaptorSecretKey, userOutboundTransferExternalId, leavesSwapRequestId, }: CompleteLeavesSwapInput): Promise<LeavesSwapRequest | null>;
2979
3526
  getLightningReceiveRequest(id: string): Promise<LightningReceiveRequest | null>;
@@ -3029,507 +3576,259 @@ declare const WalletConfig: {
3029
3576
  MAINNET: Required<ConfigOptions>;
3030
3577
  };
3031
3578
 
3032
- type CreateLightningInvoiceParams = {
3033
- amountSats: number;
3034
- memo?: string;
3035
- expirySeconds?: number;
3036
- includeSparkAddress?: boolean;
3037
- receiverIdentityPubkey?: string;
3038
- descriptionHash?: string;
3039
- };
3040
- type PayLightningInvoiceParams = {
3041
- invoice: string;
3042
- maxFeeSats: number;
3043
- preferSpark?: boolean;
3044
- amountSatsToSend?: number;
3045
- };
3046
- type TransferParams = {
3047
- amountSats: number;
3048
- receiverSparkAddress: string;
3049
- };
3050
- type TransferWithInvoiceParams = {
3051
- amountSats: number;
3052
- receiverIdentityPubkey: Uint8Array;
3053
- sparkInvoice?: SparkAddressFormat;
3054
- };
3055
- type TransferWithInvoiceOutcome = {
3056
- ok: true;
3057
- transfer: WalletTransfer;
3058
- param: TransferWithInvoiceParams;
3059
- } | {
3060
- ok: false;
3061
- error: Error;
3062
- param: TransferWithInvoiceParams;
3063
- };
3064
- type FulfillSparkInvoiceResponse = {
3065
- satsTransactionSuccess: {
3066
- invoice: SparkAddressFormat;
3067
- transferResponse: WalletTransfer;
3068
- }[];
3069
- tokenTransactionSuccess: {
3070
- tokenIdentifier: Bech32mTokenIdentifier;
3071
- txid: string;
3072
- }[];
3073
- satsTransactionErrors: {
3074
- invoice: string;
3075
- error: Error;
3076
- }[];
3077
- tokenTransactionErrors: {
3078
- tokenIdentifier: Bech32mTokenIdentifier;
3079
- error: Error;
3080
- }[];
3081
- invalidInvoices: {
3082
- invoice: string;
3083
- error: Error;
3084
- }[];
3085
- };
3086
- type TokenInvoice = {
3087
- invoice: string;
3088
- identifierHex: string;
3089
- amount: bigint;
3090
- };
3091
- type InvalidInvoice = {
3092
- invoice: string;
3093
- error: Error;
3579
+ declare class WalletConfigService implements HasSspClientOptions {
3580
+ private readonly config;
3581
+ readonly signer: SparkSigner;
3582
+ readonly sspClientOptions: SspClientOptions;
3583
+ constructor(options: ConfigOptions | undefined, signer: SparkSigner);
3584
+ private getDefaultConfig;
3585
+ getCoordinatorAddress(): string;
3586
+ getSigningOperators(): Readonly<Record<string, SigningOperator>>;
3587
+ getThreshold(): number;
3588
+ getCoordinatorIdentifier(): string;
3589
+ getExpectedWithdrawBondSats(): number;
3590
+ getExpectedWithdrawRelativeBlockLocktime(): number;
3591
+ getSspNetwork(): BitcoinNetwork;
3592
+ getNetwork(): Network;
3593
+ getNetworkType(): NetworkType;
3594
+ getNetworkProto(): number;
3595
+ getTokenSignatures(): "ECDSA" | "SCHNORR";
3596
+ getTokenValidityDurationSeconds(): number;
3597
+ getElectrsUrl(): string;
3598
+ getSspBaseUrl(): string;
3599
+ getSspIdentityPublicKey(): string;
3600
+ getConsoleOptions(): ConsoleOptions;
3601
+ }
3602
+
3603
+ /** Challenge represents the core challenge data */
3604
+ interface Challenge {
3605
+ /** Protocol version for backward compatibility */
3606
+ version: number;
3607
+ /** Timestamp when challenge was issued (UTC Unix seconds) */
3608
+ timestamp: number;
3609
+ /** Random nonce to prevent replay attacks (32 bytes) */
3610
+ nonce: Uint8Array;
3611
+ /** The public key this challenge is intended for (uncompressed secp256k1 public key) */
3612
+ publicKey: Uint8Array;
3613
+ }
3614
+ declare const Challenge: MessageFns<Challenge>;
3615
+ /** ProtectedChallenge wraps a Challenge with a server HMAC */
3616
+ interface ProtectedChallenge {
3617
+ /** Protocol version for backward compatibility */
3618
+ version: number;
3619
+ /** The core challenge data */
3620
+ challenge: Challenge | undefined;
3621
+ /** Server's HMAC of the Challenge */
3622
+ serverHmac: Uint8Array;
3623
+ }
3624
+ declare const ProtectedChallenge: MessageFns<ProtectedChallenge>;
3625
+ /** Request to initiate an authentication challenge */
3626
+ interface GetChallengeRequest {
3627
+ /** Client's public key (uncompressed secp256k1 public key) */
3628
+ publicKey: Uint8Array;
3629
+ }
3630
+ declare const GetChallengeRequest: MessageFns<GetChallengeRequest>;
3631
+ /** Response containing the protected challenge */
3632
+ interface GetChallengeResponse {
3633
+ /** The protected challenge from the server */
3634
+ protectedChallenge: ProtectedChallenge | undefined;
3635
+ }
3636
+ declare const GetChallengeResponse: MessageFns<GetChallengeResponse>;
3637
+ /** Request to verify a signed challenge */
3638
+ interface VerifyChallengeRequest {
3639
+ /** The protected challenge from the server */
3640
+ protectedChallenge: ProtectedChallenge | undefined;
3641
+ /** Client's secp256k1 signature of the Challenge */
3642
+ signature: Uint8Array;
3643
+ /** Client's public key (uncompressed secp256k1 public key) */
3644
+ publicKey: Uint8Array;
3645
+ }
3646
+ declare const VerifyChallengeRequest: MessageFns<VerifyChallengeRequest>;
3647
+ /** Response after successful authentication */
3648
+ interface VerifyChallengeResponse {
3649
+ /** Session token for subsequent API calls */
3650
+ sessionToken: string;
3651
+ /** Token expiration timestamp (UTC Unix seconds) */
3652
+ expirationTimestamp: number;
3653
+ }
3654
+ declare const VerifyChallengeResponse: MessageFns<VerifyChallengeResponse>;
3655
+ type SparkAuthnServiceDefinition = typeof SparkAuthnServiceDefinition;
3656
+ declare const SparkAuthnServiceDefinition: {
3657
+ readonly name: "SparkAuthnService";
3658
+ readonly fullName: "spark_authn.SparkAuthnService";
3659
+ readonly methods: {
3660
+ /** Request a new authentication challenge for a public key */
3661
+ readonly get_challenge: {
3662
+ readonly name: "get_challenge";
3663
+ readonly requestType: MessageFns<GetChallengeRequest>;
3664
+ readonly requestStream: false;
3665
+ readonly responseType: MessageFns<GetChallengeResponse>;
3666
+ readonly responseStream: false;
3667
+ readonly options: {};
3668
+ };
3669
+ /** Verify a signed challenge and return a session token */
3670
+ readonly verify_challenge: {
3671
+ readonly name: "verify_challenge";
3672
+ readonly requestType: MessageFns<VerifyChallengeRequest>;
3673
+ readonly requestStream: false;
3674
+ readonly responseType: MessageFns<VerifyChallengeResponse>;
3675
+ readonly responseStream: false;
3676
+ readonly options: {};
3677
+ };
3678
+ };
3094
3679
  };
3095
- type GroupSparkInvoicesResult = {
3096
- satsInvoices: TransferWithInvoiceParams[];
3097
- tokenInvoices: Map<string, TokenInvoice[]>;
3098
- invalidInvoices: InvalidInvoice[];
3680
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
3681
+ type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
3682
+ $case: string;
3683
+ } ? {
3684
+ [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]>;
3685
+ } & {
3686
+ $case: T["$case"];
3687
+ } : T extends {} ? {
3688
+ [K in keyof T]?: DeepPartial<T[K]>;
3689
+ } : Partial<T>;
3690
+ interface MessageFns<T> {
3691
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
3692
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
3693
+ fromJSON(object: any): T;
3694
+ toJSON(message: T): unknown;
3695
+ create(base?: DeepPartial<T>): T;
3696
+ fromPartial(object: DeepPartial<T>): T;
3697
+ }
3698
+
3699
+ interface RetryOptions {
3700
+ retry?: boolean;
3701
+ retryMaxAttempts?: number;
3702
+ }
3703
+ type SparkCallOptions = CallOptions & RetryOptions;
3704
+
3705
+ declare class ConnectionManager {
3706
+ private config;
3707
+ protected clients: Map<string, {
3708
+ client: SparkServiceClient & {
3709
+ close?: () => void;
3710
+ };
3711
+ authToken: string;
3712
+ }>;
3713
+ private tokenClients;
3714
+ private streamClients;
3715
+ private authPromises;
3716
+ constructor(config: WalletConfigService);
3717
+ createClients(): Promise<void>;
3718
+ closeConnections(): Promise<void>;
3719
+ protected createChannelWithTLS(address: string, certPath?: string): Promise<Channel | Channel$1>;
3720
+ createSparkStreamClient(address: string, certPath?: string): Promise<SparkServiceClient & {
3721
+ close?: () => void;
3722
+ }>;
3723
+ createSparkClient(address: string, certPath?: string): Promise<SparkServiceClient & {
3724
+ close?: () => void;
3725
+ }>;
3726
+ createSparkTokenClient(address: string, certPath?: string): Promise<SparkTokenServiceClient & {
3727
+ close?: () => void;
3728
+ }>;
3729
+ getStreamChannel(address: string): Promise<Channel | Channel$1 | undefined>;
3730
+ private authenticate;
3731
+ private createSparkAuthnGrpcConnection;
3732
+ protected createAuthnMiddleware(): (call: ClientMiddlewareCall<any, any>, options: SparkCallOptions) => AsyncGenerator<any, any, undefined>;
3733
+ protected createMiddleware(address: string, authToken: string): ((call: ClientMiddlewareCall<any, any>, options: SparkCallOptions) => AsyncGenerator<any, any, undefined>) | undefined;
3734
+ protected handleMiddlewareError(error: unknown, address: string, call: ClientMiddlewareCall<any, any>, metadata: Metadata, options: SparkCallOptions): AsyncGenerator<any, any, undefined>;
3735
+ protected createGrpcClient<T>(defintion: SparkAuthnServiceDefinition | SparkServiceDefinition | SparkTokenServiceDefinition, channel: Channel | Channel$1, withRetries: boolean, middleware?: any): Promise<T & {
3736
+ close?: () => void;
3737
+ }>;
3738
+ }
3739
+
3740
+ declare class SigningService {
3741
+ private readonly config;
3742
+ constructor(config: WalletConfigService);
3743
+ private signRefundsInternal;
3744
+ signRefunds(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, cpfpSigningCommitments: RequestedSigningCommitments[], directSigningCommitments: RequestedSigningCommitments[], directFromCpfpSigningCommitments: RequestedSigningCommitments[]): Promise<{
3745
+ cpfpLeafSigningJobs: UserSignedTxSigningJob[];
3746
+ directLeafSigningJobs: UserSignedTxSigningJob[];
3747
+ directFromCpfpLeafSigningJobs: UserSignedTxSigningJob[];
3748
+ }>;
3749
+ }
3750
+
3751
+ type LeafKeyTweak = {
3752
+ leaf: TreeNode;
3753
+ keyDerivation: KeyDerivation;
3754
+ newKeyDerivation: KeyDerivation;
3099
3755
  };
3100
- type DepositParams = {
3756
+ type LeafRefundSigningData = {
3101
3757
  keyDerivation: KeyDerivation;
3102
- verifyingKey: Uint8Array;
3103
- depositTx: Transaction;
3758
+ receivingPubkey: Uint8Array;
3759
+ signingNonceCommitment: SigningCommitmentWithOptionalNonce;
3760
+ directSigningNonceCommitment: SigningCommitmentWithOptionalNonce;
3761
+ tx: Transaction;
3762
+ directTx?: Transaction;
3763
+ refundTx?: Transaction;
3764
+ directRefundTx?: Transaction;
3765
+ directFromCpfpRefundTx?: Transaction;
3766
+ directFromCpfpRefundSigningNonceCommitment: SigningCommitmentWithOptionalNonce;
3104
3767
  vout: number;
3105
3768
  };
3106
- /**
3107
- * Token metadata containing essential information about a token.
3108
- * This is the wallet's internal representation with JavaScript-friendly types.
3109
- *
3110
- * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the bech32m encoded token identifier.
3111
- *
3112
- * tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
3113
- *
3114
- * @example
3115
- * ```typescript
3116
- * const tokenMetadata: UserTokenMetadata = {
3117
- * rawTokenIdentifier: new Uint8Array([1, 2, 3]),
3118
- * tokenPublicKey: "0348fbb...",
3119
- * tokenName: "SparkToken",
3120
- * tokenTicker: "SPK",
3121
- * decimals: 8,
3122
- * maxSupply: 1000000n
3123
- * };
3124
- * ```
3125
- */
3126
- type UserTokenMetadata = {
3127
- /** Raw binary token identifier - This is used to encode the human readable token identifier */
3128
- rawTokenIdentifier: Uint8Array;
3129
- /** Public key of the token issuer - Same as issuerPublicKey */
3130
- tokenPublicKey: string;
3131
- /** Human-readable name of the token (e.g., SparkToken)*/
3132
- tokenName: string;
3133
- /** Short ticker symbol for the token (e.g., "SPK") */
3134
- tokenTicker: string;
3135
- /** Number of decimal places for token amounts */
3136
- decimals: number;
3137
- /** Maximum supply of tokens that can ever be minted */
3138
- maxSupply: bigint;
3139
- };
3140
- type TokenBalanceMap = Map<Bech32mTokenIdentifier, {
3141
- balance: bigint;
3142
- tokenMetadata: UserTokenMetadata;
3143
- }>;
3144
- type RawTokenIdentifierHex = string & {
3145
- readonly __brand: "RawTokenIdentifierHex";
3146
- };
3147
- type TokenOutputsMap = Map<Bech32mTokenIdentifier, OutputWithPreviousTransactionData$1[]>;
3148
- type TokenMetadataMap = Map<Bech32mTokenIdentifier, TokenMetadata>;
3149
- type InitWalletResponse = {
3150
- mnemonic?: string | undefined;
3151
- };
3152
- interface SparkWalletProps {
3153
- mnemonicOrSeed?: Uint8Array | string;
3154
- accountNumber?: number;
3155
- signer?: SparkSigner;
3156
- options?: ConfigOptions;
3769
+ declare class BaseTransferService {
3770
+ protected readonly config: WalletConfigService;
3771
+ protected readonly connectionManager: ConnectionManager;
3772
+ protected readonly signingService: SigningService;
3773
+ constructor(config: WalletConfigService, connectionManager: ConnectionManager, signingService: SigningService);
3774
+ deliverTransferPackage(transfer: Transfer$1, leaves: LeafKeyTweak[], cpfpRefundSignatureMap: Map<string, Uint8Array>, directRefundSignatureMap: Map<string, Uint8Array>, directFromCpfpRefundSignatureMap: Map<string, Uint8Array>): Promise<Transfer$1>;
3775
+ sendTransferWithKeyTweaks(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, sparkInvoice?: SparkAddressFormat): Promise<Transfer$1>;
3776
+ private prepareTransferPackage;
3777
+ signRefunds(leafDataMap: Map<string, LeafRefundSigningData>, operatorSigningResults: LeafRefundTxSigningResult[]): Promise<NodeSignatures[]>;
3778
+ private prepareSendTransferKeyTweaks;
3779
+ private prepareSingleSendTransferKeyTweak;
3780
+ protected findShare(shares: VerifiableSecretShare[], operatorID: number): VerifiableSecretShare | undefined;
3781
+ private compareTransfers;
3157
3782
  }
3158
- declare const SparkWalletEvent: {
3159
- readonly All: "*";
3160
- readonly TransferClaimed: "transfer:claimed";
3161
- readonly DepositConfirmed: "deposit:confirmed";
3162
- readonly StreamConnected: "stream:connected";
3163
- readonly StreamDisconnected: "stream:disconnected";
3164
- readonly StreamReconnecting: "stream:reconnecting";
3165
- };
3166
- type SparkWalletEventType = (typeof SparkWalletEvent)[keyof typeof SparkWalletEvent];
3167
- interface SparkWalletEvents {
3168
- [SparkWalletEvent.All]: (eventName: string, ...args: unknown[]) => void;
3169
- /** Emitted when an incoming transfer is successfully claimed. Includes the transfer ID and new total balance. */
3170
- [SparkWalletEvent.TransferClaimed]: (transferId: string, updatedBalance: bigint) => void;
3171
- /** Emitted when a deposit is marked as available. Includes the deposit ID and new total balance. */
3172
- [SparkWalletEvent.DepositConfirmed]: (depositId: string, updatedBalance: bigint) => void;
3173
- /** Emitted when the stream is connected */
3174
- [SparkWalletEvent.StreamConnected]: () => void;
3175
- /** Emitted when the stream disconnects and fails to reconnect after max attempts */
3176
- [SparkWalletEvent.StreamDisconnected]: (reason: string) => void;
3177
- /** Emitted when attempting to reconnect the stream */
3178
- [SparkWalletEvent.StreamReconnecting]: (attempt: number, maxAttempts: number, delayMs: number, error: string) => void;
3783
+ declare class TransferService extends BaseTransferService {
3784
+ constructor(config: WalletConfigService, connectionManager: ConnectionManager, signingService: SigningService);
3785
+ claimTransfer(transfer: Transfer$1, leaves: LeafKeyTweak[]): Promise<FinalizeNodeSignaturesResponse>;
3786
+ queryPendingTransfers(transferIds?: string[]): Promise<QueryTransfersResponse>;
3787
+ queryAllTransfers(limit: number, offset: number): Promise<QueryTransfersResponse>;
3788
+ verifyPendingTransfer(transfer: Transfer$1): Promise<Map<string, Uint8Array>>;
3789
+ queryTransfer(transferId: string): Promise<Transfer$1 | undefined>;
3790
+ sendTransferSignRefund(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date): Promise<{
3791
+ transfer: Transfer$1;
3792
+ signatureMap: Map<string, Uint8Array>;
3793
+ directSignatureMap: Map<string, Uint8Array>;
3794
+ directFromCpfpSignatureMap: Map<string, Uint8Array>;
3795
+ leafDataMap: Map<string, LeafRefundSigningData>;
3796
+ }>;
3797
+ startSwapSignRefund(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date): Promise<{
3798
+ transfer: Transfer$1;
3799
+ signatureMap: Map<string, Uint8Array>;
3800
+ directSignatureMap: Map<string, Uint8Array>;
3801
+ directFromCpfpSignatureMap: Map<string, Uint8Array>;
3802
+ leafDataMap: Map<string, LeafRefundSigningData>;
3803
+ }>;
3804
+ sendTransferSignRefundInternal(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date, forSwap: boolean): Promise<{
3805
+ transfer: Transfer$1;
3806
+ signatureMap: Map<string, Uint8Array>;
3807
+ directSignatureMap: Map<string, Uint8Array>;
3808
+ directFromCpfpSignatureMap: Map<string, Uint8Array>;
3809
+ leafDataMap: Map<string, LeafRefundSigningData>;
3810
+ signingResults: LeafRefundTxSigningResult[];
3811
+ }>;
3812
+ private prepareRefundSoSigningJobs;
3813
+ claimTransferTweakKeys(transfer: Transfer$1, leaves: LeafKeyTweak[]): Promise<Map<string, Uint8Array[]>>;
3814
+ private prepareClaimLeavesKeyTweaks;
3815
+ private prepareClaimLeafKeyTweaks;
3816
+ claimTransferSignRefunds(transfer: Transfer$1, leafKeys: LeafKeyTweak[], proofMap?: Map<string, Uint8Array[]>): Promise<NodeSignatures[]>;
3817
+ private finalizeNodeSignatures;
3818
+ queryPendingTransfersBySender(operatorAddress: string): Promise<QueryTransfersResponse>;
3819
+ private refreshTimelockNodesInternal;
3820
+ refreshTimelockNodes(node: TreeNode, parentNode: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3821
+ extendTimelock(node: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3822
+ testonly_expireTimeLockNodeTx(node: TreeNode, parentNode: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3823
+ testonly_expireTimeLockRefundtx(node: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3179
3824
  }
3180
3825
 
3181
- declare function sumAvailableTokens(outputs: OutputWithPreviousTransactionData$1[]): bigint;
3182
- declare function checkIfSelectedOutputsAreAvailable(selectedOutputs: OutputWithPreviousTransactionData$1[], tokenOutputs: TokenOutputsMap, tokenIdentifier: Bech32mTokenIdentifier): boolean;
3183
- declare function filterTokenBalanceForTokenIdentifier(tokenBalances: TokenBalanceMap, tokenIdentifier: Bech32mTokenIdentifier): {
3184
- balance: bigint;
3185
- };
3186
-
3187
- declare function getTransferPackageSigningPayload(transferID: string, transferPackage: TransferPackage): Uint8Array;
3188
-
3189
- declare const DIRECT_TIMELOCK_OFFSET = 50;
3190
- declare const INITIAL_SEQUENCE: number;
3191
- declare const INITIAL_DIRECT_SEQUENCE: number;
3192
- declare const TEST_UNILATERAL_SEQUENCE: number;
3193
- declare const TEST_UNILATERAL_DIRECT_SEQUENCE: number;
3194
- declare const DEFAULT_FEE_SATS: number;
3195
3826
  /**
3196
- * Subtracts the default fee from the amount if it's greater than the fee.
3197
- * Returns the original amount if it's less than or equal to the fee.
3827
+ * The SparkWallet class is the primary interface for interacting with the Spark network.
3828
+ * It provides methods for creating and managing wallets, handling deposits, executing transfers,
3829
+ * and interacting with the Lightning Network.
3198
3830
  */
3199
- declare function maybeApplyFee(amount: bigint): bigint;
3200
- declare function createRootTx(depositOutPoint: TransactionInput, depositTxOut: TransactionOutput): [Transaction, Transaction];
3201
- declare function createSplitTx(parentOutPoint: TransactionInput, childTxOuts: TransactionOutput[]): [Transaction, Transaction];
3202
- interface CreateNodeTxInput {
3203
- txOut: TransactionOutput;
3204
- parentOutPoint: TransactionInput;
3205
- applyFee?: boolean;
3206
- includeAnchor?: boolean;
3207
- }
3208
- declare function createNodeTx({ txOut, parentOutPoint, applyFee, includeAnchor, }: CreateNodeTxInput): Transaction;
3209
- declare function createNodeTxs(txOut: TransactionOutput, txIn: TransactionInput, directTxIn?: TransactionInput): {
3210
- cpfpNodeTx: Transaction;
3211
- directNodeTx?: Transaction;
3212
- };
3213
- declare function createLeafNodeTx(sequence: number, directSequence: number, parentOutPoint: TransactionInput, txOut: TransactionOutput, shouldCalculateFee: boolean): [Transaction, Transaction];
3214
- interface CreateRefundTxInput {
3215
- sequence: number;
3216
- input: TransactionInput;
3217
- amountSats: bigint;
3218
- receivingPubkey: Uint8Array;
3219
- network: Network;
3220
- shouldCalculateFee: boolean;
3221
- includeAnchor: boolean;
3222
- }
3223
- declare function createRefundTx({ sequence, input, amountSats, receivingPubkey, network, shouldCalculateFee, includeAnchor, }: CreateRefundTxInput): Transaction;
3224
- interface CreateRefundTxsInput {
3225
- sequence: number;
3226
- directSequence?: number;
3227
- input: TransactionInput;
3228
- directInput?: TransactionInput;
3229
- amountSats: bigint;
3230
- receivingPubkey: Uint8Array;
3231
- network: Network;
3232
- }
3233
- declare function createRefundTxs({ sequence, directSequence, input, directInput, amountSats, receivingPubkey, network, }: CreateRefundTxsInput): {
3234
- cpfpRefundTx: Transaction;
3235
- directRefundTx?: Transaction;
3236
- directFromCpfpRefundTx?: Transaction;
3237
- };
3238
- declare function createConnectorRefundTransactions(sequence: number, cpfpNodeOutPoint: TransactionInput, directNodeOutPoint: TransactionInput, connectorOutput: TransactionInput, amountSats: bigint, receiverPubKey: Uint8Array, network: Network, shouldCalculateFee: boolean): [Transaction, Transaction, Transaction];
3239
- declare function getCurrentTimelock(currSequence?: number): number;
3240
- declare function getTransactionSequence(currSequence?: number): {
3241
- nextSequence: number;
3242
- nextDirectSequence: number;
3243
- };
3244
- declare function checkIfValidSequence(currSequence?: number): void;
3245
- declare function doesLeafNeedRefresh(currSequence: number, isNodeTx?: boolean): boolean;
3246
- declare function getNextTransactionSequence(currSequence: number, isNodeTx?: boolean): {
3247
- nextSequence: number;
3248
- nextDirectSequence: number;
3249
- };
3250
- declare function getEphemeralAnchorOutput(): TransactionOutput;
3251
-
3252
- interface LeafInfo {
3253
- leafId: string;
3254
- nodeTx: string;
3255
- refundTx: string;
3256
- }
3257
- interface Utxo {
3258
- txid: string;
3259
- vout: number;
3260
- value: bigint;
3261
- script: string;
3262
- publicKey: string;
3263
- }
3264
- interface FeeRate {
3265
- satPerVbyte: number;
3266
- }
3267
- interface FeeBumpTxPackage {
3268
- tx: string;
3269
- feeBumpPsbt?: string;
3270
- }
3271
- interface FeeBumpTxChain {
3272
- leafId: string;
3273
- txPackages: FeeBumpTxPackage[];
3274
- }
3275
- interface TxChain {
3276
- leafId: string;
3277
- transactions: string[];
3278
- }
3279
- interface BroadcastConfig {
3280
- bitcoinCoreRpcUrl?: string;
3281
- rpcUsername?: string;
3282
- rpcPassword?: string;
3283
- autoBroadcast?: boolean;
3284
- network?: "MAINNET" | "REGTEST" | "TESTNET" | "SIGNET" | "LOCAL";
3285
- }
3286
- interface BroadcastResult {
3287
- success: boolean;
3288
- txids?: string[];
3289
- error?: string;
3290
- broadcastedPackages?: number;
3291
- }
3292
- declare function isEphemeralAnchorOutput(script?: Uint8Array, amount?: bigint): boolean;
3293
- declare function constructUnilateralExitTxs(nodeHexStrings: string[], sparkClient?: SparkServiceClient, network?: any): Promise<TxChain[]>;
3294
- declare function constructUnilateralExitFeeBumpPackages(nodeHexStrings: string[], utxos: Utxo[], feeRate: FeeRate, electrsUrl: string, sparkClient?: SparkServiceClient, network?: any): Promise<FeeBumpTxChain[]>;
3295
- declare function constructFeeBumpTx(txHex: string, utxos: Utxo[], feeRate: FeeRate, previousFeeBumpTx?: string): {
3296
- feeBumpPsbt: string;
3297
- usedUtxos: Utxo[];
3298
- correctedParentTx?: string;
3299
- };
3300
-
3301
- declare function getSparkAddressFromTaproot(taprootAddress: string): SparkAddressFormat;
3302
-
3303
- declare const LOGGER_NAMES: {
3304
- readonly wasm: "wasm";
3305
- };
3306
- type LoggerName = (typeof LOGGER_NAMES)[keyof typeof LOGGER_NAMES];
3307
- declare class SparkSdkLogger {
3308
- private static loggers;
3309
- static get(name: LoggerName): Logger;
3310
- static setLevel(name: LoggerName, level: LoggingLevel): void;
3311
- static setAllLevels(level: LoggingLevel): void;
3312
- static setEnabled(name: LoggerName, enabled: boolean): void;
3313
- static setAllEnabled(enabled: boolean): void;
3314
- }
3315
-
3316
- declare class ReactNativeSparkSigner extends DefaultSparkSigner {
3317
- signFrost({ message, keyDerivation, publicKey, verifyingKey, selfCommitment, statechainCommitments, adaptorPubKey, }: SignFrostParams): Promise<Uint8Array>;
3318
- aggregateFrost({ message, publicKey, verifyingKey, selfCommitment, statechainCommitments, adaptorPubKey, selfSignature, statechainSignatures, statechainPublicKeys, }: AggregateFrostParams): Promise<Uint8Array>;
3319
- }
3320
-
3321
- declare class WalletConfigService implements HasSspClientOptions {
3322
- private readonly config;
3323
- readonly signer: SparkSigner;
3324
- readonly sspClientOptions: SspClientOptions;
3325
- constructor(options?: ConfigOptions, signer?: SparkSigner);
3326
- private getDefaultConfig;
3327
- getCoordinatorAddress(): string;
3328
- getSigningOperators(): Readonly<Record<string, SigningOperator>>;
3329
- getThreshold(): number;
3330
- getCoordinatorIdentifier(): string;
3331
- getExpectedWithdrawBondSats(): number;
3332
- getExpectedWithdrawRelativeBlockLocktime(): number;
3333
- getSspNetwork(): BitcoinNetwork;
3334
- getNetwork(): Network;
3335
- getNetworkType(): NetworkType;
3336
- getNetworkProto(): number;
3337
- getTokenSignatures(): "ECDSA" | "SCHNORR";
3338
- getTokenValidityDurationSeconds(): number;
3339
- getElectrsUrl(): string;
3340
- getSspBaseUrl(): string;
3341
- getSspIdentityPublicKey(): string;
3342
- getConsoleOptions(): ConsoleOptions;
3343
- }
3344
-
3345
- declare enum InterruptTransferRequest_InterruptTransferAction {
3346
- NONE = 0,
3347
- INTERRUPT = 1,
3348
- RESUME = 2,
3349
- UNRECOGNIZED = -1
3350
- }
3351
- declare enum InterruptCoopExitRequest_InterruptCoopExitAction {
3352
- NONE = 0,
3353
- INTERRUPT = 1,
3354
- RESUME = 2,
3355
- UNRECOGNIZED = -1
3356
- }
3357
- interface CleanUpPreimageShareRequest {
3358
- paymentHash: Uint8Array;
3359
- }
3360
- declare const CleanUpPreimageShareRequest: MessageFns<CleanUpPreimageShareRequest>;
3361
- interface InterruptTransferRequest {
3362
- action: InterruptTransferRequest_InterruptTransferAction;
3363
- }
3364
- declare const InterruptTransferRequest: MessageFns<InterruptTransferRequest>;
3365
- interface UpdateNodesStatusRequest {
3366
- nodeIds: string[];
3367
- status: string;
3368
- }
3369
- declare const UpdateNodesStatusRequest: MessageFns<UpdateNodesStatusRequest>;
3370
- /** TriggerTaskRequest is used to trigger a scheduled task immediately in hermetic tests. */
3371
- interface TriggerTaskRequest {
3372
- taskName: string;
3373
- }
3374
- declare const TriggerTaskRequest: MessageFns<TriggerTaskRequest>;
3375
- interface InterruptCoopExitRequest {
3376
- action: InterruptCoopExitRequest_InterruptCoopExitAction;
3377
- /** optional, defaults to MockAction.TargetOperatorID */
3378
- targetOperator: string;
3379
- }
3380
- declare const InterruptCoopExitRequest: MessageFns<InterruptCoopExitRequest>;
3381
- interface MockServiceClient<CallOptionsExt = {}> {
3382
- clean_up_preimage_share(request: DeepPartial<CleanUpPreimageShareRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
3383
- interrupt_transfer(request: DeepPartial<InterruptTransferRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
3384
- interrupt_coop_exit(request: DeepPartial<InterruptCoopExitRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
3385
- update_nodes_status(request: DeepPartial<UpdateNodesStatusRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
3386
- /** Triggers the execution of a scheduled task immediately by name. Used by hermetic tests */
3387
- trigger_task(request: DeepPartial<TriggerTaskRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
3388
- }
3389
- type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
3390
- type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
3391
- $case: string;
3392
- } ? {
3393
- [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]>;
3394
- } & {
3395
- $case: T["$case"];
3396
- } : T extends {} ? {
3397
- [K in keyof T]?: DeepPartial<T[K]>;
3398
- } : Partial<T>;
3399
- interface MessageFns<T> {
3400
- encode(message: T, writer?: BinaryWriter): BinaryWriter;
3401
- decode(input: BinaryReader | Uint8Array, length?: number): T;
3402
- fromJSON(object: any): T;
3403
- toJSON(message: T): unknown;
3404
- create(base?: DeepPartial<T>): T;
3405
- fromPartial(object: DeepPartial<T>): T;
3406
- }
3407
-
3408
- declare class ConnectionManager {
3409
- private config;
3410
- private clients;
3411
- private tokenClients;
3412
- private streamClients;
3413
- private authPromises;
3414
- constructor(config: WalletConfigService);
3415
- createClients(): Promise<void>;
3416
- closeConnections(): Promise<void>;
3417
- createMockClient(address: string): Promise<MockServiceClient & {
3418
- close: () => void;
3419
- }>;
3420
- private createChannelWithTLS;
3421
- createSparkStreamClient(address: string, certPath?: string): Promise<SparkServiceClient & {
3422
- close?: () => void;
3423
- }>;
3424
- createSparkClient(address: string, certPath?: string): Promise<SparkServiceClient & {
3425
- close?: () => void;
3426
- }>;
3427
- createSparkTokenClient(address: string, certPath?: string): Promise<SparkTokenServiceClient & {
3428
- close?: () => void;
3429
- }>;
3430
- getStreamChannel(address: string): Promise<Channel | Channel$1 | undefined>;
3431
- private authenticate;
3432
- private createSparkAuthnGrpcConnection;
3433
- private createAuthnMiddleware;
3434
- private createMiddleware;
3435
- private handleMiddlewareError;
3436
- private createNodeMiddleware;
3437
- private createBrowserMiddleware;
3438
- private createGrpcClient;
3439
- }
3440
-
3441
- declare class SigningService {
3442
- private readonly config;
3443
- constructor(config: WalletConfigService);
3444
- private signRefundsInternal;
3445
- signRefunds(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, cpfpSigningCommitments: RequestedSigningCommitments[], directSigningCommitments: RequestedSigningCommitments[], directFromCpfpSigningCommitments: RequestedSigningCommitments[]): Promise<{
3446
- cpfpLeafSigningJobs: UserSignedTxSigningJob[];
3447
- directLeafSigningJobs: UserSignedTxSigningJob[];
3448
- directFromCpfpLeafSigningJobs: UserSignedTxSigningJob[];
3449
- }>;
3450
- }
3451
-
3452
- type LeafKeyTweak = {
3453
- leaf: TreeNode;
3454
- keyDerivation: KeyDerivation;
3455
- newKeyDerivation: KeyDerivation;
3456
- };
3457
- type LeafRefundSigningData = {
3458
- keyDerivation: KeyDerivation;
3459
- receivingPubkey: Uint8Array;
3460
- signingNonceCommitment: SigningCommitmentWithOptionalNonce;
3461
- directSigningNonceCommitment: SigningCommitmentWithOptionalNonce;
3462
- tx: Transaction;
3463
- directTx?: Transaction;
3464
- refundTx?: Transaction;
3465
- directRefundTx?: Transaction;
3466
- directFromCpfpRefundTx?: Transaction;
3467
- directFromCpfpRefundSigningNonceCommitment: SigningCommitmentWithOptionalNonce;
3468
- vout: number;
3469
- };
3470
- declare class BaseTransferService {
3471
- protected readonly config: WalletConfigService;
3472
- protected readonly connectionManager: ConnectionManager;
3473
- protected readonly signingService: SigningService;
3474
- constructor(config: WalletConfigService, connectionManager: ConnectionManager, signingService: SigningService);
3475
- deliverTransferPackage(transfer: Transfer$1, leaves: LeafKeyTweak[], cpfpRefundSignatureMap: Map<string, Uint8Array>, directRefundSignatureMap: Map<string, Uint8Array>, directFromCpfpRefundSignatureMap: Map<string, Uint8Array>): Promise<Transfer$1>;
3476
- sendTransferWithKeyTweaks(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, sparkInvoice?: SparkAddressFormat): Promise<Transfer$1>;
3477
- private prepareTransferPackage;
3478
- signRefunds(leafDataMap: Map<string, LeafRefundSigningData>, operatorSigningResults: LeafRefundTxSigningResult[]): Promise<NodeSignatures[]>;
3479
- private prepareSendTransferKeyTweaks;
3480
- private prepareSingleSendTransferKeyTweak;
3481
- protected findShare(shares: VerifiableSecretShare[], operatorID: number): VerifiableSecretShare | undefined;
3482
- private compareTransfers;
3483
- }
3484
- declare class TransferService extends BaseTransferService {
3485
- constructor(config: WalletConfigService, connectionManager: ConnectionManager, signingService: SigningService);
3486
- claimTransfer(transfer: Transfer$1, leaves: LeafKeyTweak[]): Promise<FinalizeNodeSignaturesResponse>;
3487
- queryPendingTransfers(transferIds?: string[]): Promise<QueryTransfersResponse>;
3488
- queryAllTransfers(limit: number, offset: number): Promise<QueryTransfersResponse>;
3489
- verifyPendingTransfer(transfer: Transfer$1): Promise<Map<string, Uint8Array>>;
3490
- queryTransfer(transferId: string): Promise<Transfer$1 | undefined>;
3491
- sendTransferSignRefund(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date): Promise<{
3492
- transfer: Transfer$1;
3493
- signatureMap: Map<string, Uint8Array>;
3494
- directSignatureMap: Map<string, Uint8Array>;
3495
- directFromCpfpSignatureMap: Map<string, Uint8Array>;
3496
- leafDataMap: Map<string, LeafRefundSigningData>;
3497
- }>;
3498
- startSwapSignRefund(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date): Promise<{
3499
- transfer: Transfer$1;
3500
- signatureMap: Map<string, Uint8Array>;
3501
- directSignatureMap: Map<string, Uint8Array>;
3502
- directFromCpfpSignatureMap: Map<string, Uint8Array>;
3503
- leafDataMap: Map<string, LeafRefundSigningData>;
3504
- }>;
3505
- sendTransferSignRefundInternal(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date, forSwap: boolean): Promise<{
3506
- transfer: Transfer$1;
3507
- signatureMap: Map<string, Uint8Array>;
3508
- directSignatureMap: Map<string, Uint8Array>;
3509
- directFromCpfpSignatureMap: Map<string, Uint8Array>;
3510
- leafDataMap: Map<string, LeafRefundSigningData>;
3511
- signingResults: LeafRefundTxSigningResult[];
3512
- }>;
3513
- private prepareRefundSoSigningJobs;
3514
- claimTransferTweakKeys(transfer: Transfer$1, leaves: LeafKeyTweak[]): Promise<Map<string, Uint8Array[]>>;
3515
- private prepareClaimLeavesKeyTweaks;
3516
- private prepareClaimLeafKeyTweaks;
3517
- claimTransferSignRefunds(transfer: Transfer$1, leafKeys: LeafKeyTweak[], proofMap?: Map<string, Uint8Array[]>): Promise<NodeSignatures[]>;
3518
- private finalizeNodeSignatures;
3519
- queryPendingTransfersBySender(operatorAddress: string): Promise<QueryTransfersResponse>;
3520
- private refreshTimelockNodesInternal;
3521
- refreshTimelockNodes(node: TreeNode, parentNode: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3522
- extendTimelock(node: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3523
- testonly_expireTimeLockNodeTx(node: TreeNode, parentNode: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3524
- testonly_expireTimeLockRefundtx(node: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3525
- }
3526
-
3527
- /**
3528
- * The SparkWallet class is the primary interface for interacting with the Spark network.
3529
- * It provides methods for creating and managing wallets, handling deposits, executing transfers,
3530
- * and interacting with the Lightning Network.
3531
- */
3532
- declare class SparkWallet extends EventEmitter<SparkWalletEvents> {
3831
+ declare abstract class SparkWallet extends EventEmitter<SparkWalletEvents> {
3533
3832
  protected config: WalletConfigService;
3534
3833
  protected connectionManager: ConnectionManager;
3535
3834
  protected transferService: TransferService;
@@ -3552,13 +3851,12 @@ declare class SparkWallet extends EventEmitter<SparkWalletEvents> {
3552
3851
  protected tokenOutputs: TokenOutputsMap;
3553
3852
  private claimTransfersInterval;
3554
3853
  private tracer;
3555
- protected constructor(options?: ConfigOptions, signer?: SparkSigner);
3556
- static initialize({ mnemonicOrSeed, accountNumber, signer, options, }: SparkWalletProps): Promise<{
3557
- mnemonic?: string | undefined;
3558
- wallet: SparkWallet;
3559
- }>;
3560
- private initializeWallet;
3854
+ constructor(options?: ConfigOptions, signerArg?: SparkSigner);
3855
+ static initialize<T extends SparkWallet>(this: new (options?: ConfigOptions, signer?: SparkSigner) => T, { mnemonicOrSeed, accountNumber, signer, options }: SparkWalletProps): Promise<InitWalletResponse<T>>;
3856
+ private createClientsAndSyncWallet;
3561
3857
  private getSspClient;
3858
+ protected buildSigner(): DefaultSparkSigner;
3859
+ protected buildConnectionManager(config: WalletConfigService): ConnectionManager;
3562
3860
  private handleStreamEvent;
3563
3861
  protected setupBackgroundStream(): Promise<void>;
3564
3862
  getLeaves(isBalanceCheck?: boolean): Promise<TreeNode[]>;
@@ -3631,11 +3929,10 @@ declare class SparkWallet extends EventEmitter<SparkWalletEvents> {
3631
3929
  *
3632
3930
  * @returns {Promise<Object>} Object containing:
3633
3931
  * - mnemonic: The mnemonic if one was generated (undefined for raw seed)
3634
- * - balance: The wallet's initial balance in satoshis
3635
- * - tokenBalance: Map of token balances
3932
+ * - wallet: The wallet instance
3636
3933
  * @private
3637
3934
  */
3638
- protected initWallet(mnemonicOrSeed?: Uint8Array | string, accountNumber?: number): Promise<InitWalletResponse | undefined>;
3935
+ protected initWallet(mnemonicOrSeed?: Uint8Array | string, accountNumber?: number, options?: ConfigOptions): Promise<InitWalletResponse<this>>;
3639
3936
  /**
3640
3937
  * Initializes the wallet without a seed. Meant for use with a signer with pre-existing keys.
3641
3938
  * @private
@@ -4146,6 +4443,313 @@ declare class SparkWallet extends EventEmitter<SparkWalletEvents> {
4146
4443
  private wrapSparkWalletMethodsWithTracing;
4147
4444
  }
4148
4445
 
4446
+ type CreateLightningInvoiceParams = {
4447
+ amountSats: number;
4448
+ memo?: string;
4449
+ expirySeconds?: number;
4450
+ includeSparkAddress?: boolean;
4451
+ receiverIdentityPubkey?: string;
4452
+ descriptionHash?: string;
4453
+ };
4454
+ type PayLightningInvoiceParams = {
4455
+ invoice: string;
4456
+ maxFeeSats: number;
4457
+ preferSpark?: boolean;
4458
+ amountSatsToSend?: number;
4459
+ };
4460
+ type TransferParams = {
4461
+ amountSats: number;
4462
+ receiverSparkAddress: string;
4463
+ };
4464
+ type TransferWithInvoiceParams = {
4465
+ amountSats: number;
4466
+ receiverIdentityPubkey: Uint8Array;
4467
+ sparkInvoice?: SparkAddressFormat;
4468
+ };
4469
+ type TransferWithInvoiceOutcome = {
4470
+ ok: true;
4471
+ transfer: WalletTransfer;
4472
+ param: TransferWithInvoiceParams;
4473
+ } | {
4474
+ ok: false;
4475
+ error: Error;
4476
+ param: TransferWithInvoiceParams;
4477
+ };
4478
+ type FulfillSparkInvoiceResponse = {
4479
+ satsTransactionSuccess: {
4480
+ invoice: SparkAddressFormat;
4481
+ transferResponse: WalletTransfer;
4482
+ }[];
4483
+ tokenTransactionSuccess: {
4484
+ tokenIdentifier: Bech32mTokenIdentifier;
4485
+ txid: string;
4486
+ }[];
4487
+ satsTransactionErrors: {
4488
+ invoice: string;
4489
+ error: Error;
4490
+ }[];
4491
+ tokenTransactionErrors: {
4492
+ tokenIdentifier: Bech32mTokenIdentifier;
4493
+ error: Error;
4494
+ }[];
4495
+ invalidInvoices: {
4496
+ invoice: string;
4497
+ error: Error;
4498
+ }[];
4499
+ };
4500
+ type TokenInvoice = {
4501
+ invoice: string;
4502
+ identifierHex: string;
4503
+ amount: bigint;
4504
+ };
4505
+ type InvalidInvoice = {
4506
+ invoice: string;
4507
+ error: Error;
4508
+ };
4509
+ type GroupSparkInvoicesResult = {
4510
+ satsInvoices: TransferWithInvoiceParams[];
4511
+ tokenInvoices: Map<string, TokenInvoice[]>;
4512
+ invalidInvoices: InvalidInvoice[];
4513
+ };
4514
+ type DepositParams = {
4515
+ keyDerivation: KeyDerivation;
4516
+ verifyingKey: Uint8Array;
4517
+ depositTx: Transaction;
4518
+ vout: number;
4519
+ };
4520
+ /**
4521
+ * Token metadata containing essential information about a token.
4522
+ * This is the wallet's internal representation with JavaScript-friendly types.
4523
+ *
4524
+ * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the bech32m encoded token identifier.
4525
+ *
4526
+ * tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
4527
+ *
4528
+ * @example
4529
+ * ```typescript
4530
+ * const tokenMetadata: UserTokenMetadata = {
4531
+ * rawTokenIdentifier: new Uint8Array([1, 2, 3]),
4532
+ * tokenPublicKey: "0348fbb...",
4533
+ * tokenName: "SparkToken",
4534
+ * tokenTicker: "SPK",
4535
+ * decimals: 8,
4536
+ * maxSupply: 1000000n
4537
+ * };
4538
+ * ```
4539
+ */
4540
+ type UserTokenMetadata = {
4541
+ /** Raw binary token identifier - This is used to encode the human readable token identifier */
4542
+ rawTokenIdentifier: Uint8Array;
4543
+ /** Public key of the token issuer - Same as issuerPublicKey */
4544
+ tokenPublicKey: string;
4545
+ /** Human-readable name of the token (e.g., SparkToken)*/
4546
+ tokenName: string;
4547
+ /** Short ticker symbol for the token (e.g., "SPK") */
4548
+ tokenTicker: string;
4549
+ /** Number of decimal places for token amounts */
4550
+ decimals: number;
4551
+ /** Maximum supply of tokens that can ever be minted */
4552
+ maxSupply: bigint;
4553
+ };
4554
+ type TokenBalanceMap = Map<Bech32mTokenIdentifier, {
4555
+ balance: bigint;
4556
+ tokenMetadata: UserTokenMetadata;
4557
+ }>;
4558
+ type RawTokenIdentifierHex = string & {
4559
+ readonly __brand: "RawTokenIdentifierHex";
4560
+ };
4561
+ type TokenOutputsMap = Map<Bech32mTokenIdentifier, OutputWithPreviousTransactionData$1[]>;
4562
+ type TokenMetadataMap = Map<Bech32mTokenIdentifier, TokenMetadata>;
4563
+ type InitWalletResponse<T extends SparkWallet = SparkWallet> = {
4564
+ wallet: T;
4565
+ mnemonic: string | undefined;
4566
+ };
4567
+ interface SparkWalletProps {
4568
+ mnemonicOrSeed?: Uint8Array | string;
4569
+ accountNumber?: number;
4570
+ signer?: SparkSigner;
4571
+ options?: ConfigOptions;
4572
+ }
4573
+ declare const SparkWalletEvent: {
4574
+ readonly All: "*";
4575
+ readonly TransferClaimed: "transfer:claimed";
4576
+ readonly DepositConfirmed: "deposit:confirmed";
4577
+ readonly StreamConnected: "stream:connected";
4578
+ readonly StreamDisconnected: "stream:disconnected";
4579
+ readonly StreamReconnecting: "stream:reconnecting";
4580
+ };
4581
+ type SparkWalletEventType = (typeof SparkWalletEvent)[keyof typeof SparkWalletEvent];
4582
+ interface SparkWalletEvents {
4583
+ [SparkWalletEvent.All]: (eventName: string, ...args: unknown[]) => void;
4584
+ /** Emitted when an incoming transfer is successfully claimed. Includes the transfer ID and new total balance. */
4585
+ [SparkWalletEvent.TransferClaimed]: (transferId: string, updatedBalance: bigint) => void;
4586
+ /** Emitted when a deposit is marked as available. Includes the deposit ID and new total balance. */
4587
+ [SparkWalletEvent.DepositConfirmed]: (depositId: string, updatedBalance: bigint) => void;
4588
+ /** Emitted when the stream is connected */
4589
+ [SparkWalletEvent.StreamConnected]: () => void;
4590
+ /** Emitted when the stream disconnects and fails to reconnect after max attempts */
4591
+ [SparkWalletEvent.StreamDisconnected]: (reason: string) => void;
4592
+ /** Emitted when attempting to reconnect the stream */
4593
+ [SparkWalletEvent.StreamReconnecting]: (attempt: number, maxAttempts: number, delayMs: number, error: string) => void;
4594
+ }
4595
+
4596
+ declare function sumAvailableTokens(outputs: OutputWithPreviousTransactionData$1[]): bigint;
4597
+ declare function checkIfSelectedOutputsAreAvailable(selectedOutputs: OutputWithPreviousTransactionData$1[], tokenOutputs: TokenOutputsMap, tokenIdentifier: Bech32mTokenIdentifier): boolean;
4598
+ declare function filterTokenBalanceForTokenIdentifier(tokenBalances: TokenBalanceMap, tokenIdentifier: Bech32mTokenIdentifier): {
4599
+ balance: bigint;
4600
+ };
4601
+
4602
+ declare function getTransferPackageSigningPayload(transferID: string, transferPackage: TransferPackage): Uint8Array;
4603
+
4604
+ declare const DIRECT_TIMELOCK_OFFSET = 50;
4605
+ declare const INITIAL_SEQUENCE: number;
4606
+ declare const INITIAL_DIRECT_SEQUENCE: number;
4607
+ declare const TEST_UNILATERAL_SEQUENCE: number;
4608
+ declare const TEST_UNILATERAL_DIRECT_SEQUENCE: number;
4609
+ declare const DEFAULT_FEE_SATS: number;
4610
+ /**
4611
+ * Subtracts the default fee from the amount if it's greater than the fee.
4612
+ * Returns the original amount if it's less than or equal to the fee.
4613
+ */
4614
+ declare function maybeApplyFee(amount: bigint): bigint;
4615
+ declare function createRootTx(depositOutPoint: TransactionInput, depositTxOut: TransactionOutput): [Transaction, Transaction];
4616
+ declare function createSplitTx(parentOutPoint: TransactionInput, childTxOuts: TransactionOutput[]): [Transaction, Transaction];
4617
+ interface CreateNodeTxInput {
4618
+ txOut: TransactionOutput;
4619
+ parentOutPoint: TransactionInput;
4620
+ applyFee?: boolean;
4621
+ includeAnchor?: boolean;
4622
+ }
4623
+ declare function createNodeTx({ txOut, parentOutPoint, applyFee, includeAnchor, }: CreateNodeTxInput): Transaction;
4624
+ declare function createNodeTxs(txOut: TransactionOutput, txIn: TransactionInput, directTxIn?: TransactionInput): {
4625
+ cpfpNodeTx: Transaction;
4626
+ directNodeTx?: Transaction;
4627
+ };
4628
+ declare function createLeafNodeTx(sequence: number, directSequence: number, parentOutPoint: TransactionInput, txOut: TransactionOutput, shouldCalculateFee: boolean): [Transaction, Transaction];
4629
+ interface CreateRefundTxInput {
4630
+ sequence: number;
4631
+ input: TransactionInput;
4632
+ amountSats: bigint;
4633
+ receivingPubkey: Uint8Array;
4634
+ network: Network;
4635
+ shouldCalculateFee: boolean;
4636
+ includeAnchor: boolean;
4637
+ }
4638
+ declare function createRefundTx({ sequence, input, amountSats, receivingPubkey, network, shouldCalculateFee, includeAnchor, }: CreateRefundTxInput): Transaction;
4639
+ interface CreateRefundTxsInput {
4640
+ sequence: number;
4641
+ directSequence?: number;
4642
+ input: TransactionInput;
4643
+ directInput?: TransactionInput;
4644
+ amountSats: bigint;
4645
+ receivingPubkey: Uint8Array;
4646
+ network: Network;
4647
+ }
4648
+ declare function createRefundTxs({ sequence, directSequence, input, directInput, amountSats, receivingPubkey, network, }: CreateRefundTxsInput): {
4649
+ cpfpRefundTx: Transaction;
4650
+ directRefundTx?: Transaction;
4651
+ directFromCpfpRefundTx?: Transaction;
4652
+ };
4653
+ declare function createConnectorRefundTransactions(sequence: number, cpfpNodeOutPoint: TransactionInput, directNodeOutPoint: TransactionInput, connectorOutput: TransactionInput, amountSats: bigint, receiverPubKey: Uint8Array, network: Network, shouldCalculateFee: boolean): [Transaction, Transaction, Transaction];
4654
+ declare function getCurrentTimelock(currSequence?: number): number;
4655
+ declare function getTransactionSequence(currSequence?: number): {
4656
+ nextSequence: number;
4657
+ nextDirectSequence: number;
4658
+ };
4659
+ declare function checkIfValidSequence(currSequence?: number): void;
4660
+ declare function doesLeafNeedRefresh(currSequence: number, isNodeTx?: boolean): boolean;
4661
+ declare function getNextTransactionSequence(currSequence: number, isNodeTx?: boolean): {
4662
+ nextSequence: number;
4663
+ nextDirectSequence: number;
4664
+ };
4665
+ declare function getEphemeralAnchorOutput(): TransactionOutput;
4666
+
4667
+ interface LeafInfo {
4668
+ leafId: string;
4669
+ nodeTx: string;
4670
+ refundTx: string;
4671
+ }
4672
+ interface Utxo {
4673
+ txid: string;
4674
+ vout: number;
4675
+ value: bigint;
4676
+ script: string;
4677
+ publicKey: string;
4678
+ }
4679
+ interface FeeRate {
4680
+ satPerVbyte: number;
4681
+ }
4682
+ interface FeeBumpTxPackage {
4683
+ tx: string;
4684
+ feeBumpPsbt?: string;
4685
+ }
4686
+ interface FeeBumpTxChain {
4687
+ leafId: string;
4688
+ txPackages: FeeBumpTxPackage[];
4689
+ }
4690
+ interface TxChain {
4691
+ leafId: string;
4692
+ transactions: string[];
4693
+ }
4694
+ interface BroadcastConfig {
4695
+ bitcoinCoreRpcUrl?: string;
4696
+ rpcUsername?: string;
4697
+ rpcPassword?: string;
4698
+ autoBroadcast?: boolean;
4699
+ network?: "MAINNET" | "REGTEST" | "TESTNET" | "SIGNET" | "LOCAL";
4700
+ }
4701
+ interface BroadcastResult {
4702
+ success: boolean;
4703
+ txids?: string[];
4704
+ error?: string;
4705
+ broadcastedPackages?: number;
4706
+ }
4707
+ declare function isEphemeralAnchorOutput(script?: Uint8Array, amount?: bigint): boolean;
4708
+ declare function constructUnilateralExitTxs(nodeHexStrings: string[], sparkClient?: SparkServiceClient, network?: any): Promise<TxChain[]>;
4709
+ declare function constructUnilateralExitFeeBumpPackages(nodeHexStrings: string[], utxos: Utxo[], feeRate: FeeRate, electrsUrl: string, sparkClient?: SparkServiceClient, network?: any): Promise<FeeBumpTxChain[]>;
4710
+ declare function constructFeeBumpTx(txHex: string, utxos: Utxo[], feeRate: FeeRate, previousFeeBumpTx?: string): {
4711
+ feeBumpPsbt: string;
4712
+ usedUtxos: Utxo[];
4713
+ correctedParentTx?: string;
4714
+ };
4715
+
4716
+ declare function getSparkAddressFromTaproot(taprootAddress: string): SparkAddressFormat;
4717
+
4718
+ declare const LOGGER_NAMES: {
4719
+ readonly wasm: "wasm";
4720
+ };
4721
+ type LoggerName = (typeof LOGGER_NAMES)[keyof typeof LOGGER_NAMES];
4722
+ declare class SparkSdkLogger {
4723
+ private static loggers;
4724
+ static get(name: LoggerName): Logger;
4725
+ static setLevel(name: LoggerName, level: LoggingLevel): void;
4726
+ static setAllLevels(level: LoggingLevel): void;
4727
+ static setEnabled(name: LoggerName, enabled: boolean): void;
4728
+ static setAllEnabled(enabled: boolean): void;
4729
+ }
4730
+
4731
+ declare class ReactNativeSparkSigner extends DefaultSparkSigner {
4732
+ signFrost({ message, keyDerivation, publicKey, verifyingKey, selfCommitment, statechainCommitments, adaptorPubKey, }: SignFrostParams): Promise<Uint8Array>;
4733
+ aggregateFrost({ message, publicKey, verifyingKey, selfCommitment, statechainCommitments, adaptorPubKey, selfSignature, statechainSignatures, statechainPublicKeys, }: AggregateFrostParams): Promise<Uint8Array>;
4734
+ }
4735
+
4736
+ type Transport = NonNullable<Parameters<typeof createChannel>[1]>;
4737
+ declare class ConnectionManagerBrowser extends ConnectionManager {
4738
+ protected transport: Transport;
4739
+ constructor(config: WalletConfigService, transport?: nice_grpc_web_lib_client_Transport_js.Transport);
4740
+ protected createChannelWithTLS(address: string, certPath?: string): Promise<Channel$1>;
4741
+ protected createAuthnMiddleware(): (call: ClientMiddlewareCall<any, any>, options: SparkCallOptions) => AsyncGenerator<any, any, undefined>;
4742
+ protected createMiddleware(address: string, initialAuthToken: string): (call: ClientMiddlewareCall<any, any>, options: SparkCallOptions) => AsyncGenerator<any, any, undefined>;
4743
+ protected createGrpcClient<T>(defintion: SparkAuthnServiceDefinition | SparkServiceDefinition | SparkTokenServiceDefinition, channel: Channel$1, withRetries: boolean, middleware?: any): Promise<T & {
4744
+ close: undefined;
4745
+ }>;
4746
+ }
4747
+
4748
+ declare class SparkWalletReactNative extends SparkWallet {
4749
+ protected buildSigner(): ReactNativeSparkSigner;
4750
+ protected buildConnectionManager(config: WalletConfigService): ConnectionManagerBrowser;
4751
+ }
4752
+
4149
4753
  interface FetchOwnedTokenOutputsParams {
4150
4754
  ownerPublicKeys: Uint8Array[];
4151
4755
  issuerPublicKeys?: Uint8Array[];
@@ -4191,4 +4795,4 @@ declare class TokenTransactionService {
4191
4795
  private createSignaturesForOperators;
4192
4796
  }
4193
4797
 
4194
- export { AuthenticationError, type Bech32mTokenIdentifier, type Bech32mTokenIdentifierData, type BroadcastConfig, type BroadcastResult, type ConfigOptions, ConfigurationError, ConnectionManager, type CreateLightningInvoiceParams, DEFAULT_FEE_SATS, DIRECT_TIMELOCK_OFFSET, type DecodedSparkAddressData, ReactNativeSparkSigner as DefaultSparkSigner, type DepositParams, type FeeBumpTxChain, type FeeBumpTxPackage, type FeeRate, type FulfillSparkInvoiceResponse, type GroupSparkInvoicesResult, INITIAL_DIRECT_SEQUENCE, INITIAL_SEQUENCE, type InitWalletResponse, InternalValidationError, type InvalidInvoice, LOGGER_NAMES, LRC_WALLET_NETWORK, type LeafInfo, type LegacySparkAddressFormat, type LoggerName, Network, NetworkError, NetworkToProto, type NetworkType, NotImplementedError, type PayLightningInvoiceParams, RPCError, type RawTokenIdentifierHex, ReactNativeSparkSigner, type SparkAddressData, type SparkAddressFormat, SparkSDKError, SparkSdkLogger, SparkWallet, SparkWalletEvent, type SparkWalletEventType, type SparkWalletEvents, type SparkWalletProps, TEST_UNILATERAL_DIRECT_SEQUENCE, TEST_UNILATERAL_SEQUENCE, type TokenBalanceMap, type TokenInvoice, type TokenMetadataMap, type TokenOutputsMap, TokenTransactionService, type TransferParams, type TransferWithInvoiceOutcome, type TransferWithInvoiceParams, type TxChain, type UserTokenMetadata, type Utxo, ValidationError, type VerifiableSecretShare, WalletConfig, WalletConfigService, addPrivateKeys, addPublicKeys, applyAdaptorToSignature, applyAdditiveTweakToPublicKey, assertBech32, bech32mDecode, bigIntToPrivateKey, checkIfSelectedOutputsAreAvailable, checkIfValidSequence, collectResponses, computeTaprootKeyNoScript, computerLagrangeCoefficients, constructFeeBumpTx, constructUnilateralExitFeeBumpPackages, constructUnilateralExitTxs, createConnectorRefundTransactions, createLeafNodeTx, createNodeTx, createNodeTxs, createRefundTx, createRefundTxs, createRootTx, createSigningCommitment, createSigningNonce, createSplitTx, decodeBech32mTokenIdentifier, decodeBytesToSigningCommitment, decodeBytesToSigningNonce, decodeSparkAddress, doesLeafNeedRefresh, encodeBech32mTokenIdentifier, encodeSigningCommitmentToBytes, encodeSigningNonceToBytes, encodeSparkAddress, encodeSparkAddressWithSignature, evaluatePolynomial, fieldDiv, filterTokenBalanceForTokenIdentifier, generateAdaptorFromSignature, generatePolynomialForSecretSharing, generateSignatureFromExistingAdaptor, getCurrentTimelock, getEphemeralAnchorOutput, getLatestDepositTxId, getNetwork, getNetworkFromAddress, getNetworkFromBech32mTokenIdentifier, getNetworkFromSparkAddress, getNetworkFromString, getNextTransactionSequence, getP2TRAddressFromPkScript, getP2TRAddressFromPublicKey, getP2TRScriptFromPublicKey, getP2WPKHAddressFromPublicKey, getRandomBigInt, getRandomSigningNonce, getSigHashFromTx, getSigningCommitmentFromNonce, getSparkAddressFromTaproot, getTransactionSequence, getTransferPackageSigningPayload, getTxEstimatedVbytesSizeByNumberOfInputsOutputs, getTxFromRawTxBytes, getTxFromRawTxHex, getTxId, getTxIdNoReverse, isEphemeralAnchorOutput, isLegacySparkAddress, isSafeForNumber, isTxBroadcast, isValidPublicKey, isValidSparkAddress, lastKeyWithTarget, maybeApplyFee, modInverse, proofOfPossessionMessageHashForDepositAddress, protoToNetwork, recoverSecret, splitSecret, splitSecretWithProofs, subtractPrivateKeys, subtractPublicKeys, sumAvailableTokens, sumOfPrivateKeys, toProtoTimestamp, validateOutboundAdaptorSignature, validateShare, validateSparkInvoiceFields, validateSparkInvoiceSignature };
4798
+ export { AuthenticationError, ConnectionManager as BaseConnectionManager, type Bech32mTokenIdentifier, type Bech32mTokenIdentifierData, type BroadcastConfig, type BroadcastResult, type ConfigOptions, ConfigurationError, ConnectionManagerBrowser as ConnectionManager, type CreateLightningInvoiceParams, DEFAULT_FEE_SATS, DIRECT_TIMELOCK_OFFSET, type DecodedSparkAddressData, ReactNativeSparkSigner as DefaultSparkSigner, type DepositParams, type FeeBumpTxChain, type FeeBumpTxPackage, type FeeRate, type FulfillSparkInvoiceResponse, type GroupSparkInvoicesResult, INITIAL_DIRECT_SEQUENCE, INITIAL_SEQUENCE, type InitWalletResponse, InternalValidationError, type InvalidInvoice, LOGGER_NAMES, type LeafInfo, type LegacySparkAddressFormat, type LoggerName, Network, NetworkError, NetworkToProto, type NetworkType, NotImplementedError, type PayLightningInvoiceParams, RPCError, type RawTokenIdentifierHex, ReactNativeSparkSigner, type SparkAddressData, type SparkAddressFormat, SparkSDKError, SparkSdkLogger, SparkWalletReactNative as SparkWallet, SparkWalletEvent, type SparkWalletEventType, type SparkWalletEvents, type SparkWalletProps, TEST_UNILATERAL_DIRECT_SEQUENCE, TEST_UNILATERAL_SEQUENCE, type TokenBalanceMap, type TokenInvoice, type TokenMetadataMap, type TokenOutputsMap, TokenTransactionService, type TransferParams, type TransferWithInvoiceOutcome, type TransferWithInvoiceParams, type TxChain, type UserTokenMetadata, type Utxo, ValidationError, type VerifiableSecretShare, WalletConfig, WalletConfigService, addPrivateKeys, addPublicKeys, applyAdaptorToSignature, applyAdditiveTweakToPublicKey, assertBech32, bech32mDecode, bigIntToPrivateKey, checkIfSelectedOutputsAreAvailable, checkIfValidSequence, collectResponses, computeTaprootKeyNoScript, computerLagrangeCoefficients, constructFeeBumpTx, constructUnilateralExitFeeBumpPackages, constructUnilateralExitTxs, createConnectorRefundTransactions, createLeafNodeTx, createNodeTx, createNodeTxs, createRefundTx, createRefundTxs, createRootTx, createSigningCommitment, createSigningNonce, createSplitTx, decodeBech32mTokenIdentifier, decodeBytesToSigningCommitment, decodeBytesToSigningNonce, decodeSparkAddress, doesLeafNeedRefresh, encodeBech32mTokenIdentifier, encodeSigningCommitmentToBytes, encodeSigningNonceToBytes, encodeSparkAddress, encodeSparkAddressWithSignature, evaluatePolynomial, fieldDiv, filterTokenBalanceForTokenIdentifier, generateAdaptorFromSignature, generatePolynomialForSecretSharing, generateSignatureFromExistingAdaptor, getCurrentTimelock, getEphemeralAnchorOutput, getLatestDepositTxId, getNetwork, getNetworkFromAddress, getNetworkFromBech32mTokenIdentifier, getNetworkFromSparkAddress, getNetworkFromString, getNextTransactionSequence, getP2TRAddressFromPkScript, getP2TRAddressFromPublicKey, getP2TRScriptFromPublicKey, getP2WPKHAddressFromPublicKey, getRandomBigInt, getRandomSigningNonce, getSigHashFromTx, getSigningCommitmentFromNonce, getSparkAddressFromTaproot, getTransactionSequence, getTransferPackageSigningPayload, getTxEstimatedVbytesSizeByNumberOfInputsOutputs, getTxFromRawTxBytes, getTxFromRawTxHex, getTxId, getTxIdNoReverse, isEphemeralAnchorOutput, isLegacySparkAddress, isSafeForNumber, isTxBroadcast, isValidPublicKey, isValidSparkAddress, lastKeyWithTarget, maybeApplyFee, modInverse, proofOfPossessionMessageHashForDepositAddress, protoToNetwork, recoverSecret, splitSecret, splitSecretWithProofs, subtractPrivateKeys, subtractPublicKeys, sumAvailableTokens, sumOfPrivateKeys, toProtoTimestamp, validateOutboundAdaptorSignature, validateShare, validateSparkInvoiceFields, validateSparkInvoiceSignature };