@atomiqlabs/lp-lib 15.0.14 → 16.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/LICENSE +201 -201
  2. package/dist/fees/IBtcFeeEstimator.d.ts +3 -3
  3. package/dist/fees/IBtcFeeEstimator.js +2 -2
  4. package/dist/index.d.ts +42 -40
  5. package/dist/index.js +58 -56
  6. package/dist/info/InfoHandler.d.ts +17 -17
  7. package/dist/info/InfoHandler.js +58 -58
  8. package/dist/plugins/IPlugin.d.ts +144 -144
  9. package/dist/plugins/IPlugin.js +34 -34
  10. package/dist/plugins/PluginManager.d.ts +113 -113
  11. package/dist/plugins/PluginManager.js +274 -274
  12. package/dist/prices/BinanceSwapPrice.d.ts +26 -26
  13. package/dist/prices/BinanceSwapPrice.js +92 -92
  14. package/dist/prices/CoinGeckoSwapPrice.d.ts +30 -30
  15. package/dist/prices/CoinGeckoSwapPrice.js +64 -64
  16. package/dist/prices/ISwapPrice.d.ts +43 -43
  17. package/dist/prices/ISwapPrice.js +55 -55
  18. package/dist/prices/OKXSwapPrice.d.ts +26 -26
  19. package/dist/prices/OKXSwapPrice.js +92 -92
  20. package/dist/storage/IIntermediaryStorage.d.ts +18 -18
  21. package/dist/storage/IIntermediaryStorage.js +2 -2
  22. package/dist/storagemanager/IntermediaryStorageManager.d.ts +19 -18
  23. package/dist/storagemanager/IntermediaryStorageManager.js +111 -104
  24. package/dist/storagemanager/StorageManager.d.ts +13 -12
  25. package/dist/storagemanager/StorageManager.js +64 -57
  26. package/dist/swaps/SwapHandler.d.ts +150 -153
  27. package/dist/swaps/SwapHandler.js +154 -157
  28. package/dist/swaps/SwapHandlerSwap.d.ts +79 -79
  29. package/dist/swaps/SwapHandlerSwap.js +78 -78
  30. package/dist/swaps/assertions/AmountAssertions.d.ts +28 -28
  31. package/dist/swaps/assertions/AmountAssertions.js +74 -74
  32. package/dist/swaps/assertions/FromBtcAmountAssertions.d.ts +76 -76
  33. package/dist/swaps/assertions/FromBtcAmountAssertions.js +180 -172
  34. package/dist/swaps/assertions/LightningAssertions.d.ts +44 -44
  35. package/dist/swaps/assertions/LightningAssertions.js +86 -86
  36. package/dist/swaps/assertions/ToBtcAmountAssertions.d.ts +53 -53
  37. package/dist/swaps/assertions/ToBtcAmountAssertions.js +150 -150
  38. package/dist/swaps/escrow/EscrowHandler.d.ts +51 -51
  39. package/dist/swaps/escrow/EscrowHandler.js +158 -158
  40. package/dist/swaps/escrow/EscrowHandlerSwap.d.ts +35 -35
  41. package/dist/swaps/escrow/EscrowHandlerSwap.js +69 -69
  42. package/dist/swaps/escrow/FromBtcBaseSwap.d.ts +14 -14
  43. package/dist/swaps/escrow/FromBtcBaseSwap.js +32 -32
  44. package/dist/swaps/escrow/FromBtcBaseSwapHandler.d.ts +102 -101
  45. package/dist/swaps/escrow/FromBtcBaseSwapHandler.js +210 -207
  46. package/dist/swaps/escrow/ToBtcBaseSwap.d.ts +36 -36
  47. package/dist/swaps/escrow/ToBtcBaseSwap.js +67 -67
  48. package/dist/swaps/escrow/ToBtcBaseSwapHandler.d.ts +53 -53
  49. package/dist/swaps/escrow/ToBtcBaseSwapHandler.js +81 -81
  50. package/dist/swaps/escrow/frombtc_abstract/FromBtcAbs.d.ts +83 -83
  51. package/dist/swaps/escrow/frombtc_abstract/FromBtcAbs.js +318 -318
  52. package/dist/swaps/escrow/frombtc_abstract/FromBtcSwapAbs.d.ts +21 -21
  53. package/dist/swaps/escrow/frombtc_abstract/FromBtcSwapAbs.js +50 -50
  54. package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnAbs.d.ts +107 -107
  55. package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnAbs.js +673 -673
  56. package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.d.ts +33 -32
  57. package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.js +91 -88
  58. package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.d.ts +111 -0
  59. package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.js +682 -0
  60. package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.d.ts +55 -0
  61. package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.js +120 -0
  62. package/dist/swaps/escrow/tobtc_abstract/ToBtcAbs.d.ts +169 -171
  63. package/dist/swaps/escrow/tobtc_abstract/ToBtcAbs.js +735 -718
  64. package/dist/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.d.ts +28 -28
  65. package/dist/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.js +64 -64
  66. package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.d.ts +177 -177
  67. package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.js +865 -863
  68. package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.d.ts +24 -24
  69. package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.js +58 -58
  70. package/dist/swaps/spv_vault_swap/SpvVault.d.ts +44 -45
  71. package/dist/swaps/spv_vault_swap/SpvVault.js +145 -145
  72. package/dist/swaps/spv_vault_swap/SpvVaultSwap.d.ts +68 -68
  73. package/dist/swaps/spv_vault_swap/SpvVaultSwap.js +158 -158
  74. package/dist/swaps/spv_vault_swap/SpvVaultSwapHandler.d.ts +68 -68
  75. package/dist/swaps/spv_vault_swap/SpvVaultSwapHandler.js +530 -528
  76. package/dist/swaps/spv_vault_swap/SpvVaults.d.ts +63 -68
  77. package/dist/swaps/spv_vault_swap/SpvVaults.js +488 -454
  78. package/dist/swaps/trusted/frombtc_trusted/FromBtcTrusted.d.ts +51 -51
  79. package/dist/swaps/trusted/frombtc_trusted/FromBtcTrusted.js +650 -650
  80. package/dist/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.d.ts +52 -52
  81. package/dist/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.js +118 -118
  82. package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.d.ts +76 -76
  83. package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.js +492 -493
  84. package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.d.ts +34 -34
  85. package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.js +81 -81
  86. package/dist/utils/BitcoinUtils.d.ts +4 -4
  87. package/dist/utils/BitcoinUtils.js +61 -61
  88. package/dist/utils/Utils.d.ts +29 -29
  89. package/dist/utils/Utils.js +89 -88
  90. package/dist/utils/paramcoders/IParamReader.d.ts +5 -5
  91. package/dist/utils/paramcoders/IParamReader.js +2 -2
  92. package/dist/utils/paramcoders/IParamWriter.d.ts +4 -4
  93. package/dist/utils/paramcoders/IParamWriter.js +2 -2
  94. package/dist/utils/paramcoders/LegacyParamEncoder.d.ts +10 -10
  95. package/dist/utils/paramcoders/LegacyParamEncoder.js +22 -22
  96. package/dist/utils/paramcoders/ParamDecoder.d.ts +25 -25
  97. package/dist/utils/paramcoders/ParamDecoder.js +222 -222
  98. package/dist/utils/paramcoders/ParamEncoder.d.ts +9 -9
  99. package/dist/utils/paramcoders/ParamEncoder.js +22 -22
  100. package/dist/utils/paramcoders/SchemaVerifier.d.ts +21 -21
  101. package/dist/utils/paramcoders/SchemaVerifier.js +84 -84
  102. package/dist/utils/paramcoders/server/ServerParamDecoder.d.ts +8 -8
  103. package/dist/utils/paramcoders/server/ServerParamDecoder.js +107 -105
  104. package/dist/utils/paramcoders/server/ServerParamEncoder.d.ts +11 -11
  105. package/dist/utils/paramcoders/server/ServerParamEncoder.js +65 -65
  106. package/dist/wallets/IBitcoinWallet.d.ts +74 -67
  107. package/dist/wallets/IBitcoinWallet.js +2 -2
  108. package/dist/wallets/ILightningWallet.d.ts +117 -117
  109. package/dist/wallets/ILightningWallet.js +37 -37
  110. package/dist/wallets/ISpvVaultSigner.d.ts +7 -7
  111. package/dist/wallets/ISpvVaultSigner.js +2 -2
  112. package/package.json +36 -36
  113. package/src/fees/IBtcFeeEstimator.ts +6 -6
  114. package/src/index.ts +53 -51
  115. package/src/info/InfoHandler.ts +100 -100
  116. package/src/plugins/IPlugin.ts +174 -174
  117. package/src/plugins/PluginManager.ts +354 -354
  118. package/src/prices/BinanceSwapPrice.ts +113 -113
  119. package/src/prices/CoinGeckoSwapPrice.ts +87 -87
  120. package/src/prices/ISwapPrice.ts +88 -88
  121. package/src/prices/OKXSwapPrice.ts +113 -113
  122. package/src/storage/IIntermediaryStorage.ts +19 -19
  123. package/src/storagemanager/IntermediaryStorageManager.ts +118 -109
  124. package/src/storagemanager/StorageManager.ts +78 -68
  125. package/src/swaps/SwapHandler.ts +269 -272
  126. package/src/swaps/SwapHandlerSwap.ts +141 -141
  127. package/src/swaps/assertions/AmountAssertions.ts +77 -77
  128. package/src/swaps/assertions/FromBtcAmountAssertions.ts +246 -238
  129. package/src/swaps/assertions/LightningAssertions.ts +103 -103
  130. package/src/swaps/assertions/ToBtcAmountAssertions.ts +203 -203
  131. package/src/swaps/escrow/EscrowHandler.ts +179 -179
  132. package/src/swaps/escrow/EscrowHandlerSwap.ts +86 -86
  133. package/src/swaps/escrow/FromBtcBaseSwap.ts +38 -38
  134. package/src/swaps/escrow/FromBtcBaseSwapHandler.ts +286 -283
  135. package/src/swaps/escrow/ToBtcBaseSwap.ts +85 -85
  136. package/src/swaps/escrow/ToBtcBaseSwapHandler.ts +129 -129
  137. package/src/swaps/escrow/frombtc_abstract/FromBtcAbs.ts +452 -452
  138. package/src/swaps/escrow/frombtc_abstract/FromBtcSwapAbs.ts +61 -61
  139. package/src/swaps/escrow/frombtcln_abstract/FromBtcLnAbs.ts +855 -855
  140. package/src/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.ts +141 -137
  141. package/src/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.ts +847 -0
  142. package/src/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.ts +196 -0
  143. package/src/swaps/escrow/tobtc_abstract/ToBtcAbs.ts +909 -890
  144. package/src/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.ts +108 -108
  145. package/src/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.ts +1116 -1112
  146. package/src/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.ts +80 -80
  147. package/src/swaps/spv_vault_swap/SpvVault.ts +178 -178
  148. package/src/swaps/spv_vault_swap/SpvVaultSwap.ts +228 -228
  149. package/src/swaps/spv_vault_swap/SpvVaultSwapHandler.ts +673 -671
  150. package/src/swaps/spv_vault_swap/SpvVaults.ts +565 -526
  151. package/src/swaps/trusted/frombtc_trusted/FromBtcTrusted.ts +747 -747
  152. package/src/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.ts +185 -185
  153. package/src/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.ts +589 -591
  154. package/src/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.ts +121 -121
  155. package/src/utils/BitcoinUtils.ts +59 -59
  156. package/src/utils/Utils.ts +104 -102
  157. package/src/utils/paramcoders/IParamReader.ts +7 -7
  158. package/src/utils/paramcoders/IParamWriter.ts +8 -8
  159. package/src/utils/paramcoders/LegacyParamEncoder.ts +27 -27
  160. package/src/utils/paramcoders/ParamDecoder.ts +218 -218
  161. package/src/utils/paramcoders/ParamEncoder.ts +29 -29
  162. package/src/utils/paramcoders/SchemaVerifier.ts +96 -96
  163. package/src/utils/paramcoders/server/ServerParamDecoder.ts +118 -115
  164. package/src/utils/paramcoders/server/ServerParamEncoder.ts +75 -75
  165. package/src/wallets/IBitcoinWallet.ts +76 -68
  166. package/src/wallets/ILightningWallet.ts +178 -178
  167. package/src/wallets/ISpvVaultSigner.ts +10 -10
  168. package/dist/wallets/ISpvVaultWallet.d.ts +0 -42
  169. package/dist/wallets/ISpvVaultWallet.js +0 -2
@@ -1,67 +1,74 @@
1
- /// <reference types="node" />
2
- import { BtcTx } from "@atomiqlabs/base";
3
- import { Command } from "@atomiqlabs/server-base";
4
- import { Transaction } from "@scure/btc-signer";
5
- export type BitcoinUtxo = {
6
- address: string;
7
- type: "p2wpkh" | "p2sh-p2wpkh" | "p2tr";
8
- confirmations: number;
9
- outputScript: Buffer;
10
- value: number;
11
- txId: string;
12
- vout: number;
13
- };
14
- export type SignPsbtResponse = {
15
- psbt: Transaction;
16
- tx: Transaction;
17
- raw: string;
18
- txId: string;
19
- networkFee: number;
20
- };
21
- export interface IBitcoinWallet {
22
- init(): Promise<void>;
23
- isReady(): boolean;
24
- getStatus(): string;
25
- getStatusInfo(): Promise<Record<string, string>>;
26
- getCommands(): Command<any>[];
27
- toOutputScript(address: string): Buffer;
28
- getAddressType(): "p2wpkh" | "p2sh-p2wpkh" | "p2tr";
29
- /**
30
- * Returns an unused address suitable for receiving
31
- */
32
- getAddress(): Promise<string>;
33
- /**
34
- * Adds previously returned address (with getAddress call), to the pool of unused addresses
35
- * @param address
36
- */
37
- addUnusedAddress(address: string): Promise<void>;
38
- getUtxos(): Promise<BitcoinUtxo[]>;
39
- getBalance(): Promise<{
40
- confirmed: number;
41
- unconfirmed: number;
42
- }>;
43
- /**
44
- * Returns required reserve amount that needs to be kept in the wallet (for e.g. lightning anchor channels)
45
- */
46
- getRequiredReserve(): Promise<number>;
47
- getWalletTransactions(startHeight?: number): Promise<BtcTx[]>;
48
- getWalletTransaction(txId: string): Promise<BtcTx | null>;
49
- subscribeToWalletTransactions(callback: (tx: BtcTx) => void, abortSignal?: AbortSignal): void;
50
- fundPsbt(psbt: Transaction, feeRate?: number): Promise<Transaction>;
51
- signPsbt(psbt: Transaction): Promise<SignPsbtResponse>;
52
- sendRawTransaction(tx: string): Promise<void>;
53
- getSignedTransaction(destination: string, amount: number, feeRate?: number, nonce?: bigint, maxAllowedFeeRate?: number): Promise<SignPsbtResponse>;
54
- getSignedMultiTransaction(destinations: {
55
- address: string;
56
- amount: number;
57
- }[], feeRate?: number, nonce?: bigint, maxAllowedFeeRate?: number): Promise<SignPsbtResponse>;
58
- estimateFee(destination: string, amount: number, feeRate?: number, feeRateMultiplier?: number): Promise<{
59
- satsPerVbyte: number;
60
- networkFee: number;
61
- }>;
62
- drainAll(destination: string | Buffer, inputs: Omit<BitcoinUtxo, "address">[], feeRate?: number): Promise<SignPsbtResponse>;
63
- burnAll(inputs: Omit<BitcoinUtxo, "address">[]): Promise<SignPsbtResponse>;
64
- parsePsbt(psbt: Transaction): Promise<BtcTx>;
65
- getBlockheight(): Promise<number>;
66
- getFeeRate(): Promise<number>;
67
- }
1
+ /// <reference types="node" />
2
+ import { BtcTx } from "@atomiqlabs/base";
3
+ import { Command } from "@atomiqlabs/server-base";
4
+ import { Transaction } from "@scure/btc-signer";
5
+ export type BitcoinUtxo = {
6
+ address: string;
7
+ type: "p2wpkh" | "p2sh-p2wpkh" | "p2tr";
8
+ confirmations: number;
9
+ outputScript: Buffer;
10
+ value: number;
11
+ txId: string;
12
+ vout: number;
13
+ };
14
+ export type SignPsbtResponse = {
15
+ psbt: Transaction;
16
+ tx: Transaction;
17
+ raw: string;
18
+ txId: string;
19
+ networkFee: number;
20
+ };
21
+ export interface IBitcoinWallet {
22
+ init(): Promise<void>;
23
+ isReady(): boolean;
24
+ getStatus(): string;
25
+ getStatusInfo(): Promise<Record<string, string>>;
26
+ getCommands(): Command<any>[];
27
+ toOutputScript(address: string): Buffer;
28
+ getAddressType(): "p2wpkh" | "p2sh-p2wpkh" | "p2tr";
29
+ /**
30
+ * Returns an unused address suitable for receiving
31
+ */
32
+ getAddress(): Promise<string>;
33
+ /**
34
+ * Adds previously returned address (with getAddress call), to the pool of unused addresses
35
+ * @param address
36
+ */
37
+ addUnusedAddress(address: string): Promise<void>;
38
+ getUtxos(): Promise<BitcoinUtxo[]>;
39
+ getBalance(): Promise<{
40
+ confirmed: number;
41
+ unconfirmed: number;
42
+ }>;
43
+ /**
44
+ * Returns required reserve amount that needs to be kept in the wallet (for e.g. lightning anchor channels)
45
+ */
46
+ getRequiredReserve(): Promise<number>;
47
+ getWalletTransactions(startHeight?: number): Promise<BtcTx[]>;
48
+ getWalletTransaction(txId: string): Promise<BtcTx | null>;
49
+ subscribeToWalletTransactions(callback: (tx: BtcTx) => void, abortSignal?: AbortSignal): void;
50
+ fundPsbt(psbt: Transaction, feeRate?: number): Promise<Transaction>;
51
+ signPsbt(psbt: Transaction): Promise<SignPsbtResponse>;
52
+ sendRawTransaction(tx: string): Promise<void>;
53
+ getSignedTransaction(destination: string, amount: number, feeRate?: number, nonce?: bigint, maxAllowedFeeRate?: number): Promise<SignPsbtResponse>;
54
+ getSignedMultiTransaction(destinations: {
55
+ address: string;
56
+ amount: number;
57
+ }[], feeRate?: number, nonce?: bigint, maxAllowedFeeRate?: number): Promise<SignPsbtResponse>;
58
+ estimateFee(destination: string, amount: number, feeRate?: number, feeRateMultiplier?: number): Promise<{
59
+ satsPerVbyte: number;
60
+ networkFee: number;
61
+ }>;
62
+ drainAll(destination: string | Buffer, inputs: Omit<BitcoinUtxo, "address">[], feeRate?: number): Promise<SignPsbtResponse>;
63
+ burnAll(inputs: Omit<BitcoinUtxo, "address">[]): Promise<SignPsbtResponse>;
64
+ parsePsbt(psbt: Transaction): Promise<BtcTx>;
65
+ getBlockheight(): Promise<number>;
66
+ getFeeRate(): Promise<number>;
67
+ /**
68
+ * Post a task to be executed on the sequential thread of the wallet, this makes sure the UTXOs stay consistent during
69
+ * operation, it is recommended to use this approach when spending wallet UTXOs
70
+ *
71
+ * @param executor
72
+ */
73
+ execute(executor: () => Promise<void>): Promise<void>;
74
+ }
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,117 +1,117 @@
1
- import { Command } from "@atomiqlabs/server-base";
2
- export type IncomingLightningNetworkPayment = {
3
- createdAt: number;
4
- confirmedAt: number;
5
- createdHeight: number;
6
- timeout: number;
7
- status: "held" | "canceled" | "confirmed";
8
- mtokens: bigint;
9
- };
10
- export type LightningNetworkInvoice = {
11
- id: string;
12
- request: string;
13
- secret?: string;
14
- cltvDelta: number;
15
- mtokens: bigint;
16
- createdAt: number;
17
- expiresAt: number;
18
- description: string;
19
- descriptionHash?: string;
20
- payments: IncomingLightningNetworkPayment[];
21
- status: "unpaid" | "held" | "canceled" | "confirmed";
22
- };
23
- export type OutgoingLightningNetworkPayment = {
24
- failedReason?: "insufficient_balance" | "invalid_payment" | "pathfinding_timeout" | "route_not_found";
25
- status: "confirmed" | "failed" | "pending";
26
- secret?: string;
27
- feeMtokens?: bigint;
28
- };
29
- export type LightningNetworkChannel = {
30
- id: string;
31
- capacity: bigint;
32
- isActive: boolean;
33
- localBalance: bigint;
34
- localReserve: bigint;
35
- remoteBalance: bigint;
36
- remoteReserve: bigint;
37
- unsettledBalance: bigint;
38
- transactionId: string;
39
- transactionVout: number;
40
- };
41
- export type InvoiceInit = {
42
- mtokens: bigint;
43
- descriptionHash?: string;
44
- description?: string;
45
- cltvDelta?: number;
46
- expiresAt?: number;
47
- };
48
- export type HodlInvoiceInit = {
49
- description: string;
50
- cltvDelta: number;
51
- expiresAt: number;
52
- id: string;
53
- mtokens: bigint;
54
- descriptionHash?: string;
55
- };
56
- export type LNRoutes = {
57
- publicKey: string;
58
- feeRate?: number;
59
- cltvDelta?: number;
60
- channel?: string;
61
- baseFeeMtokens?: bigint;
62
- }[][];
63
- export type ParsedPaymentRequest = {
64
- id: string;
65
- mtokens: bigint;
66
- expiryEpochMillis: number;
67
- destination: string;
68
- cltvDelta: number;
69
- description: string;
70
- routes: LNRoutes;
71
- };
72
- export type LightningPaymentInit = {
73
- request: string;
74
- maxFeeMtokens?: bigint;
75
- maxTimeoutHeight?: number;
76
- };
77
- export type LightningBalanceResponse = {
78
- localBalance: bigint;
79
- remoteBalance: bigint;
80
- unsettledBalance: bigint;
81
- };
82
- export type ProbeAndRouteInit = {
83
- request: string;
84
- amountMtokens: bigint;
85
- maxFeeMtokens: bigint;
86
- maxTimeoutHeight: number;
87
- };
88
- export type ProbeAndRouteResponse = {
89
- confidence: number;
90
- feeMtokens: bigint;
91
- destination: string;
92
- privateRoutes: LNRoutes;
93
- };
94
- export declare function routesMatch(routesA: LNRoutes, routesB: LNRoutes): boolean;
95
- export interface ILightningWallet {
96
- init(): Promise<void>;
97
- isReady(): boolean;
98
- getStatus(): string;
99
- getStatusInfo(): Promise<Record<string, string>>;
100
- getCommands(): Command<any>[];
101
- createInvoice(init: InvoiceInit): Promise<LightningNetworkInvoice>;
102
- createHodlInvoice(init: HodlInvoiceInit): Promise<LightningNetworkInvoice>;
103
- getInvoice(paymentHash: string): Promise<LightningNetworkInvoice | null>;
104
- cancelHodlInvoice(paymentHash: string): Promise<void>;
105
- settleHodlInvoice(secret: string): Promise<void>;
106
- waitForInvoice(paymentHash: string, abortSignal?: AbortSignal): Promise<LightningNetworkInvoice>;
107
- pay(init: LightningPaymentInit): Promise<void>;
108
- getPayment(paymentHash: string): Promise<OutgoingLightningNetworkPayment | null>;
109
- waitForPayment(paymentHash: string, abortSignal?: AbortSignal): Promise<OutgoingLightningNetworkPayment>;
110
- probe(init: ProbeAndRouteInit): Promise<ProbeAndRouteResponse | null>;
111
- route(init: ProbeAndRouteInit): Promise<ProbeAndRouteResponse | null>;
112
- parsePaymentRequest(request: string): Promise<ParsedPaymentRequest>;
113
- getBlockheight(): Promise<number>;
114
- getChannels(activeOnly?: boolean): Promise<LightningNetworkChannel[]>;
115
- getLightningBalance(): Promise<LightningBalanceResponse>;
116
- getIdentityPublicKey(): Promise<string>;
117
- }
1
+ import { Command } from "@atomiqlabs/server-base";
2
+ export type IncomingLightningNetworkPayment = {
3
+ createdAt: number;
4
+ confirmedAt: number;
5
+ createdHeight: number;
6
+ timeout: number;
7
+ status: "held" | "canceled" | "confirmed";
8
+ mtokens: bigint;
9
+ };
10
+ export type LightningNetworkInvoice = {
11
+ id: string;
12
+ request: string;
13
+ secret?: string;
14
+ cltvDelta: number;
15
+ mtokens: bigint;
16
+ createdAt: number;
17
+ expiresAt: number;
18
+ description: string;
19
+ descriptionHash?: string;
20
+ payments: IncomingLightningNetworkPayment[];
21
+ status: "unpaid" | "held" | "canceled" | "confirmed";
22
+ };
23
+ export type OutgoingLightningNetworkPayment = {
24
+ failedReason?: "insufficient_balance" | "invalid_payment" | "pathfinding_timeout" | "route_not_found";
25
+ status: "confirmed" | "failed" | "pending";
26
+ secret?: string;
27
+ feeMtokens?: bigint;
28
+ };
29
+ export type LightningNetworkChannel = {
30
+ id: string;
31
+ capacity: bigint;
32
+ isActive: boolean;
33
+ localBalance: bigint;
34
+ localReserve: bigint;
35
+ remoteBalance: bigint;
36
+ remoteReserve: bigint;
37
+ unsettledBalance: bigint;
38
+ transactionId: string;
39
+ transactionVout: number;
40
+ };
41
+ export type InvoiceInit = {
42
+ mtokens: bigint;
43
+ descriptionHash?: string;
44
+ description?: string;
45
+ cltvDelta?: number;
46
+ expiresAt?: number;
47
+ };
48
+ export type HodlInvoiceInit = {
49
+ description: string;
50
+ cltvDelta: number;
51
+ expiresAt: number;
52
+ id: string;
53
+ mtokens: bigint;
54
+ descriptionHash?: string;
55
+ };
56
+ export type LNRoutes = {
57
+ publicKey: string;
58
+ feeRate?: number;
59
+ cltvDelta?: number;
60
+ channel?: string;
61
+ baseFeeMtokens?: bigint;
62
+ }[][];
63
+ export type ParsedPaymentRequest = {
64
+ id: string;
65
+ mtokens: bigint;
66
+ expiryEpochMillis: number;
67
+ destination: string;
68
+ cltvDelta: number;
69
+ description: string;
70
+ routes: LNRoutes;
71
+ };
72
+ export type LightningPaymentInit = {
73
+ request: string;
74
+ maxFeeMtokens?: bigint;
75
+ maxTimeoutHeight?: number;
76
+ };
77
+ export type LightningBalanceResponse = {
78
+ localBalance: bigint;
79
+ remoteBalance: bigint;
80
+ unsettledBalance: bigint;
81
+ };
82
+ export type ProbeAndRouteInit = {
83
+ request: string;
84
+ amountMtokens: bigint;
85
+ maxFeeMtokens: bigint;
86
+ maxTimeoutHeight: number;
87
+ };
88
+ export type ProbeAndRouteResponse = {
89
+ confidence: number;
90
+ feeMtokens: bigint;
91
+ destination: string;
92
+ privateRoutes: LNRoutes;
93
+ };
94
+ export declare function routesMatch(routesA: LNRoutes, routesB: LNRoutes): boolean;
95
+ export interface ILightningWallet {
96
+ init(): Promise<void>;
97
+ isReady(): boolean;
98
+ getStatus(): string;
99
+ getStatusInfo(): Promise<Record<string, string>>;
100
+ getCommands(): Command<any>[];
101
+ createInvoice(init: InvoiceInit): Promise<LightningNetworkInvoice>;
102
+ createHodlInvoice(init: HodlInvoiceInit): Promise<LightningNetworkInvoice>;
103
+ getInvoice(paymentHash: string): Promise<LightningNetworkInvoice | null>;
104
+ cancelHodlInvoice(paymentHash: string): Promise<void>;
105
+ settleHodlInvoice(secret: string): Promise<void>;
106
+ waitForInvoice(paymentHash: string, abortSignal?: AbortSignal): Promise<LightningNetworkInvoice>;
107
+ pay(init: LightningPaymentInit): Promise<void>;
108
+ getPayment(paymentHash: string): Promise<OutgoingLightningNetworkPayment | null>;
109
+ waitForPayment(paymentHash: string, abortSignal?: AbortSignal): Promise<OutgoingLightningNetworkPayment>;
110
+ probe(init: ProbeAndRouteInit): Promise<ProbeAndRouteResponse | null>;
111
+ route(init: ProbeAndRouteInit): Promise<ProbeAndRouteResponse | null>;
112
+ parsePaymentRequest(request: string): Promise<ParsedPaymentRequest>;
113
+ getBlockheight(): Promise<number>;
114
+ getChannels(activeOnly?: boolean): Promise<LightningNetworkChannel[]>;
115
+ getLightningBalance(): Promise<LightningBalanceResponse>;
116
+ getIdentityPublicKey(): Promise<string>;
117
+ }
@@ -1,37 +1,37 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.routesMatch = void 0;
4
- function routesMatch(routesA, routesB) {
5
- if (routesA === routesB)
6
- return true;
7
- if (routesA == null || routesB == null) {
8
- return false;
9
- }
10
- if (routesA.length !== routesB.length)
11
- return false;
12
- for (let i = 0; i < routesA.length; i++) {
13
- if (routesA[i] === routesB[i])
14
- continue;
15
- if (routesA[i] == null || routesB[i] == null) {
16
- return false;
17
- }
18
- if (routesA[i].length !== routesB[i].length)
19
- return false;
20
- for (let e = 0; e < routesA[i].length; e++) {
21
- if (routesA[i][e] === routesB[i][e])
22
- continue;
23
- if (routesA[i][e] == null || routesB[i][e] == null) {
24
- return false;
25
- }
26
- if (routesA[i][e].publicKey !== routesB[i][e].publicKey ||
27
- routesA[i][e].baseFeeMtokens !== routesB[i][e].baseFeeMtokens ||
28
- routesA[i][e].channel !== routesB[i][e].channel ||
29
- routesA[i][e].cltvDelta !== routesB[i][e].cltvDelta ||
30
- routesA[i][e].feeRate !== routesB[i][e].feeRate) {
31
- return false;
32
- }
33
- }
34
- }
35
- return true;
36
- }
37
- exports.routesMatch = routesMatch;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.routesMatch = void 0;
4
+ function routesMatch(routesA, routesB) {
5
+ if (routesA === routesB)
6
+ return true;
7
+ if (routesA == null || routesB == null) {
8
+ return false;
9
+ }
10
+ if (routesA.length !== routesB.length)
11
+ return false;
12
+ for (let i = 0; i < routesA.length; i++) {
13
+ if (routesA[i] === routesB[i])
14
+ continue;
15
+ if (routesA[i] == null || routesB[i] == null) {
16
+ return false;
17
+ }
18
+ if (routesA[i].length !== routesB[i].length)
19
+ return false;
20
+ for (let e = 0; e < routesA[i].length; e++) {
21
+ if (routesA[i][e] === routesB[i][e])
22
+ continue;
23
+ if (routesA[i][e] == null || routesB[i][e] == null) {
24
+ return false;
25
+ }
26
+ if (routesA[i][e].publicKey !== routesB[i][e].publicKey ||
27
+ routesA[i][e].baseFeeMtokens !== routesB[i][e].baseFeeMtokens ||
28
+ routesA[i][e].channel !== routesB[i][e].channel ||
29
+ routesA[i][e].cltvDelta !== routesB[i][e].cltvDelta ||
30
+ routesA[i][e].feeRate !== routesB[i][e].feeRate) {
31
+ return false;
32
+ }
33
+ }
34
+ }
35
+ return true;
36
+ }
37
+ exports.routesMatch = routesMatch;
@@ -1,7 +1,7 @@
1
- import { Transaction } from "@scure/btc-signer";
2
- export interface ISpvVaultSigner {
3
- init(): Promise<void>;
4
- getAddressType(): "p2wpkh" | "p2tr";
5
- getAddress(chainId: string, vaultId: bigint): Promise<string>;
6
- signPsbt(chainId: string, vaultId: bigint, psbt: Transaction, inputs: number[]): Promise<Transaction>;
7
- }
1
+ import { Transaction } from "@scure/btc-signer";
2
+ export interface ISpvVaultSigner {
3
+ init(): Promise<void>;
4
+ getAddressType(): "p2wpkh" | "p2tr";
5
+ getAddress(chainId: string, vaultId: bigint): Promise<string>;
6
+ signPsbt(chainId: string, vaultId: bigint, psbt: Transaction, inputs: number[]): Promise<Transaction>;
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,36 +1,36 @@
1
- {
2
- "name": "@atomiqlabs/lp-lib",
3
- "version": "15.0.14",
4
- "description": "Main functionality implementation for atomiq LP node",
5
- "main": "./dist/index.js",
6
- "types:": "./dist/index.d.ts",
7
- "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1"
9
- },
10
- "files": [
11
- "/dist",
12
- "/src"
13
- ],
14
- "keywords": [
15
- "Solana",
16
- "Bitcoin",
17
- "Cross-chain",
18
- "Cryptocurrency",
19
- "Bridge",
20
- "Trustless"
21
- ],
22
- "author": "adambor",
23
- "license": "ISC",
24
- "dependencies": {
25
- "@atomiqlabs/base": "^11.0.0",
26
- "@atomiqlabs/server-base": "^3.0.0",
27
- "@scure/btc-signer": "1.6.0",
28
- "express": "4.21.1",
29
- "promise-queue-ts": "0.0.1"
30
- },
31
- "devDependencies": {
32
- "@types/express": "4.17.21",
33
- "@types/node": "18.15.11",
34
- "typescript": "4.9.5"
35
- }
36
- }
1
+ {
2
+ "name": "@atomiqlabs/lp-lib",
3
+ "version": "16.0.0",
4
+ "description": "Main functionality implementation for atomiq LP node",
5
+ "main": "./dist/index.js",
6
+ "types:": "./dist/index.d.ts",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "files": [
11
+ "/dist",
12
+ "/src"
13
+ ],
14
+ "keywords": [
15
+ "Solana",
16
+ "Bitcoin",
17
+ "Cross-chain",
18
+ "Cryptocurrency",
19
+ "Bridge",
20
+ "Trustless"
21
+ ],
22
+ "author": "adambor",
23
+ "license": "ISC",
24
+ "dependencies": {
25
+ "@atomiqlabs/base": "^12.0.0",
26
+ "@atomiqlabs/server-base": "^3.0.0",
27
+ "@scure/btc-signer": "1.6.0",
28
+ "express": "4.21.1",
29
+ "promise-queue-ts": "1.0.0"
30
+ },
31
+ "devDependencies": {
32
+ "@types/express": "4.17.21",
33
+ "@types/node": "18.15.11",
34
+ "typescript": "4.9.5"
35
+ }
36
+ }
@@ -1,7 +1,7 @@
1
-
2
- export interface IBtcFeeEstimator {
3
-
4
- //Returns estimated fee in sats/vB
5
- estimateFee(): Promise<number | null>;
6
-
1
+
2
+ export interface IBtcFeeEstimator {
3
+
4
+ //Returns estimated fee in sats/vB
5
+ estimateFee(): Promise<number | null>;
6
+
7
7
  }