@atomiqlabs/lp-lib 15.0.2 → 15.0.3

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 (160) 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 +40 -40
  5. package/dist/index.js +56 -56
  6. package/dist/info/InfoHandler.d.ts +17 -17
  7. package/dist/info/InfoHandler.js +61 -61
  8. package/dist/plugins/IPlugin.d.ts +143 -143
  9. package/dist/plugins/IPlugin.js +34 -34
  10. package/dist/plugins/PluginManager.d.ts +112 -112
  11. package/dist/plugins/PluginManager.js +259 -259
  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 +18 -18
  23. package/dist/storagemanager/IntermediaryStorageManager.js +104 -104
  24. package/dist/storagemanager/StorageManager.d.ts +12 -12
  25. package/dist/storagemanager/StorageManager.js +57 -57
  26. package/dist/swaps/SwapHandler.d.ts +156 -156
  27. package/dist/swaps/SwapHandler.js +163 -163
  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 +72 -72
  32. package/dist/swaps/assertions/FromBtcAmountAssertions.d.ts +76 -76
  33. package/dist/swaps/assertions/FromBtcAmountAssertions.js +172 -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 +101 -101
  45. package/dist/swaps/escrow/FromBtcBaseSwapHandler.js +207 -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 +675 -675
  56. package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.d.ts +32 -32
  57. package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.js +88 -88
  58. package/dist/swaps/escrow/tobtc_abstract/ToBtcAbs.d.ts +171 -171
  59. package/dist/swaps/escrow/tobtc_abstract/ToBtcAbs.js +706 -706
  60. package/dist/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.d.ts +26 -26
  61. package/dist/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.js +62 -62
  62. package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.d.ts +177 -177
  63. package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.js +863 -861
  64. package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.d.ts +24 -23
  65. package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.js +58 -56
  66. package/dist/swaps/spv_vault_swap/SpvVault.d.ts +41 -41
  67. package/dist/swaps/spv_vault_swap/SpvVault.js +111 -111
  68. package/dist/swaps/spv_vault_swap/SpvVaultSwap.d.ts +67 -67
  69. package/dist/swaps/spv_vault_swap/SpvVaultSwap.js +158 -158
  70. package/dist/swaps/spv_vault_swap/SpvVaultSwapHandler.d.ts +68 -68
  71. package/dist/swaps/spv_vault_swap/SpvVaultSwapHandler.js +491 -491
  72. package/dist/swaps/spv_vault_swap/SpvVaults.d.ts +57 -57
  73. package/dist/swaps/spv_vault_swap/SpvVaults.js +369 -369
  74. package/dist/swaps/trusted/frombtc_trusted/FromBtcTrusted.d.ts +51 -51
  75. package/dist/swaps/trusted/frombtc_trusted/FromBtcTrusted.js +650 -650
  76. package/dist/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.d.ts +52 -52
  77. package/dist/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.js +118 -118
  78. package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.d.ts +76 -76
  79. package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.js +495 -495
  80. package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.d.ts +34 -34
  81. package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.js +81 -81
  82. package/dist/utils/Utils.d.ts +29 -29
  83. package/dist/utils/Utils.js +88 -88
  84. package/dist/utils/paramcoders/IParamReader.d.ts +5 -5
  85. package/dist/utils/paramcoders/IParamReader.js +2 -2
  86. package/dist/utils/paramcoders/IParamWriter.d.ts +4 -4
  87. package/dist/utils/paramcoders/IParamWriter.js +2 -2
  88. package/dist/utils/paramcoders/LegacyParamEncoder.d.ts +10 -10
  89. package/dist/utils/paramcoders/LegacyParamEncoder.js +22 -22
  90. package/dist/utils/paramcoders/ParamDecoder.d.ts +25 -25
  91. package/dist/utils/paramcoders/ParamDecoder.js +222 -222
  92. package/dist/utils/paramcoders/ParamEncoder.d.ts +9 -9
  93. package/dist/utils/paramcoders/ParamEncoder.js +22 -22
  94. package/dist/utils/paramcoders/SchemaVerifier.d.ts +21 -21
  95. package/dist/utils/paramcoders/SchemaVerifier.js +84 -84
  96. package/dist/utils/paramcoders/server/ServerParamDecoder.d.ts +8 -8
  97. package/dist/utils/paramcoders/server/ServerParamDecoder.js +105 -105
  98. package/dist/utils/paramcoders/server/ServerParamEncoder.d.ts +11 -11
  99. package/dist/utils/paramcoders/server/ServerParamEncoder.js +65 -65
  100. package/dist/wallets/IBitcoinWallet.d.ts +67 -67
  101. package/dist/wallets/IBitcoinWallet.js +2 -2
  102. package/dist/wallets/ILightningWallet.d.ts +117 -117
  103. package/dist/wallets/ILightningWallet.js +37 -37
  104. package/dist/wallets/ISpvVaultSigner.d.ts +7 -7
  105. package/dist/wallets/ISpvVaultSigner.js +2 -2
  106. package/dist/wallets/ISpvVaultWallet.d.ts +42 -42
  107. package/dist/wallets/ISpvVaultWallet.js +2 -2
  108. package/package.json +36 -36
  109. package/src/fees/IBtcFeeEstimator.ts +6 -6
  110. package/src/index.ts +51 -51
  111. package/src/info/InfoHandler.ts +106 -106
  112. package/src/plugins/IPlugin.ts +168 -168
  113. package/src/plugins/PluginManager.ts +336 -336
  114. package/src/prices/BinanceSwapPrice.ts +113 -113
  115. package/src/prices/CoinGeckoSwapPrice.ts +87 -87
  116. package/src/prices/ISwapPrice.ts +88 -88
  117. package/src/prices/OKXSwapPrice.ts +113 -113
  118. package/src/storage/IIntermediaryStorage.ts +19 -19
  119. package/src/storagemanager/IntermediaryStorageManager.ts +109 -109
  120. package/src/storagemanager/StorageManager.ts +68 -68
  121. package/src/swaps/SwapHandler.ts +280 -280
  122. package/src/swaps/SwapHandlerSwap.ts +141 -141
  123. package/src/swaps/assertions/AmountAssertions.ts +76 -76
  124. package/src/swaps/assertions/FromBtcAmountAssertions.ts +238 -238
  125. package/src/swaps/assertions/LightningAssertions.ts +103 -103
  126. package/src/swaps/assertions/ToBtcAmountAssertions.ts +203 -203
  127. package/src/swaps/escrow/EscrowHandler.ts +179 -179
  128. package/src/swaps/escrow/EscrowHandlerSwap.ts +86 -86
  129. package/src/swaps/escrow/FromBtcBaseSwap.ts +38 -38
  130. package/src/swaps/escrow/FromBtcBaseSwapHandler.ts +283 -283
  131. package/src/swaps/escrow/ToBtcBaseSwap.ts +85 -85
  132. package/src/swaps/escrow/ToBtcBaseSwapHandler.ts +129 -129
  133. package/src/swaps/escrow/frombtc_abstract/FromBtcAbs.ts +452 -452
  134. package/src/swaps/escrow/frombtc_abstract/FromBtcSwapAbs.ts +61 -61
  135. package/src/swaps/escrow/frombtcln_abstract/FromBtcLnAbs.ts +856 -856
  136. package/src/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.ts +137 -137
  137. package/src/swaps/escrow/tobtc_abstract/ToBtcAbs.ts +879 -879
  138. package/src/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.ts +102 -102
  139. package/src/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.ts +1112 -1110
  140. package/src/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.ts +80 -77
  141. package/src/swaps/spv_vault_swap/SpvVault.ts +143 -143
  142. package/src/swaps/spv_vault_swap/SpvVaultSwap.ts +225 -225
  143. package/src/swaps/spv_vault_swap/SpvVaultSwapHandler.ts +627 -627
  144. package/src/swaps/spv_vault_swap/SpvVaults.ts +440 -440
  145. package/src/swaps/trusted/frombtc_trusted/FromBtcTrusted.ts +747 -747
  146. package/src/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.ts +185 -185
  147. package/src/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.ts +592 -592
  148. package/src/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.ts +121 -121
  149. package/src/utils/Utils.ts +102 -102
  150. package/src/utils/paramcoders/IParamReader.ts +7 -7
  151. package/src/utils/paramcoders/IParamWriter.ts +8 -8
  152. package/src/utils/paramcoders/LegacyParamEncoder.ts +27 -27
  153. package/src/utils/paramcoders/ParamDecoder.ts +218 -218
  154. package/src/utils/paramcoders/ParamEncoder.ts +29 -29
  155. package/src/utils/paramcoders/SchemaVerifier.ts +96 -96
  156. package/src/utils/paramcoders/server/ServerParamDecoder.ts +115 -115
  157. package/src/utils/paramcoders/server/ServerParamEncoder.ts +75 -75
  158. package/src/wallets/IBitcoinWallet.ts +68 -68
  159. package/src/wallets/ILightningWallet.ts +178 -178
  160. package/src/wallets/ISpvVaultSigner.ts +10 -10
@@ -1,67 +1,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
- }
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,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 });
@@ -1,42 +1,42 @@
1
- /// <reference types="node" />
2
- import { Command } from "@atomiqlabs/server-base";
3
- import { Transaction } from "@scure/btc-signer";
4
- export type BitcoinUtxo = {
5
- address: string;
6
- type: "p2wpkh" | "p2sh-p2wpkh" | "p2tr";
7
- confirmations: number;
8
- outputScript: Buffer;
9
- value: number;
10
- txId: string;
11
- vout: number;
12
- };
13
- export type SignPsbtResponse = {
14
- psbt: Transaction;
15
- tx: Transaction;
16
- raw: string;
17
- txId: string;
18
- networkFee: number;
19
- };
20
- export interface ISpvVaultSigner {
21
- init(): Promise<void>;
22
- isReady(): boolean;
23
- getStatus(): string;
24
- getStatusInfo(): Promise<Record<string, string>>;
25
- getCommands(): Command<any>[];
26
- getAddressType(): "p2wpkh" | "p2sh-p2wpkh" | "p2tr";
27
- /**
28
- * Returns an unused address suitable for receiving
29
- */
30
- getAddress(vaultId: bigint): Promise<string>;
31
- signPsbt(vaultId: bigint, psbt: Transaction): Promise<SignPsbtResponse>;
32
- sendRawTransaction(tx: string): Promise<void>;
33
- getSignedTransaction(destination: string, amount: number, feeRate?: number, nonce?: bigint, maxAllowedFeeRate?: number): Promise<SignPsbtResponse>;
34
- estimateFee(destination: string, amount: number, feeRate?: number, feeRateMultiplier?: number): Promise<{
35
- satsPerVbyte: number;
36
- networkFee: number;
37
- }>;
38
- drainAll(destination: string | Buffer, inputs: Omit<BitcoinUtxo, "address">[], feeRate?: number): Promise<SignPsbtResponse>;
39
- burnAll(inputs: Omit<BitcoinUtxo, "address">[]): Promise<SignPsbtResponse>;
40
- getBlockheight(): Promise<number>;
41
- getFeeRate(): Promise<number>;
42
- }
1
+ /// <reference types="node" />
2
+ import { Command } from "@atomiqlabs/server-base";
3
+ import { Transaction } from "@scure/btc-signer";
4
+ export type BitcoinUtxo = {
5
+ address: string;
6
+ type: "p2wpkh" | "p2sh-p2wpkh" | "p2tr";
7
+ confirmations: number;
8
+ outputScript: Buffer;
9
+ value: number;
10
+ txId: string;
11
+ vout: number;
12
+ };
13
+ export type SignPsbtResponse = {
14
+ psbt: Transaction;
15
+ tx: Transaction;
16
+ raw: string;
17
+ txId: string;
18
+ networkFee: number;
19
+ };
20
+ export interface ISpvVaultSigner {
21
+ init(): Promise<void>;
22
+ isReady(): boolean;
23
+ getStatus(): string;
24
+ getStatusInfo(): Promise<Record<string, string>>;
25
+ getCommands(): Command<any>[];
26
+ getAddressType(): "p2wpkh" | "p2sh-p2wpkh" | "p2tr";
27
+ /**
28
+ * Returns an unused address suitable for receiving
29
+ */
30
+ getAddress(vaultId: bigint): Promise<string>;
31
+ signPsbt(vaultId: bigint, psbt: Transaction): Promise<SignPsbtResponse>;
32
+ sendRawTransaction(tx: string): Promise<void>;
33
+ getSignedTransaction(destination: string, amount: number, feeRate?: number, nonce?: bigint, maxAllowedFeeRate?: number): Promise<SignPsbtResponse>;
34
+ estimateFee(destination: string, amount: number, feeRate?: number, feeRateMultiplier?: number): Promise<{
35
+ satsPerVbyte: number;
36
+ networkFee: number;
37
+ }>;
38
+ drainAll(destination: string | Buffer, inputs: Omit<BitcoinUtxo, "address">[], feeRate?: number): Promise<SignPsbtResponse>;
39
+ burnAll(inputs: Omit<BitcoinUtxo, "address">[]): Promise<SignPsbtResponse>;
40
+ getBlockheight(): Promise<number>;
41
+ getFeeRate(): Promise<number>;
42
+ }
@@ -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.2",
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": "2.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": "15.0.3",
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": "2.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,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
  }