@atomiqlabs/lp-lib 14.0.0-dev.13 → 14.0.0-dev.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/dist/fees/IBtcFeeEstimator.d.ts +3 -3
- package/dist/fees/IBtcFeeEstimator.js +2 -2
- package/dist/index.d.ts +42 -42
- package/dist/index.js +58 -58
- package/dist/info/InfoHandler.d.ts +17 -17
- package/dist/info/InfoHandler.js +61 -61
- package/dist/plugins/IPlugin.d.ts +143 -143
- package/dist/plugins/IPlugin.js +34 -34
- package/dist/plugins/PluginManager.d.ts +112 -112
- package/dist/plugins/PluginManager.js +259 -259
- package/dist/prices/BinanceSwapPrice.d.ts +26 -26
- package/dist/prices/BinanceSwapPrice.js +92 -92
- package/dist/prices/CoinGeckoSwapPrice.d.ts +30 -30
- package/dist/prices/CoinGeckoSwapPrice.js +64 -64
- package/dist/prices/ISwapPrice.d.ts +43 -43
- package/dist/prices/ISwapPrice.js +55 -55
- package/dist/prices/OKXSwapPrice.d.ts +26 -26
- package/dist/prices/OKXSwapPrice.js +92 -92
- package/dist/storage/IIntermediaryStorage.d.ts +18 -18
- package/dist/storage/IIntermediaryStorage.js +2 -2
- package/dist/storagemanager/IntermediaryStorageManager.d.ts +19 -19
- package/dist/storagemanager/IntermediaryStorageManager.js +111 -111
- package/dist/storagemanager/StorageManager.d.ts +13 -13
- package/dist/storagemanager/StorageManager.js +64 -64
- package/dist/swaps/SwapHandler.d.ts +153 -153
- package/dist/swaps/SwapHandler.js +160 -160
- package/dist/swaps/SwapHandlerSwap.d.ts +79 -79
- package/dist/swaps/SwapHandlerSwap.js +78 -78
- package/dist/swaps/assertions/AmountAssertions.d.ts +28 -28
- package/dist/swaps/assertions/AmountAssertions.js +72 -72
- package/dist/swaps/assertions/FromBtcAmountAssertions.d.ts +76 -76
- package/dist/swaps/assertions/FromBtcAmountAssertions.js +180 -172
- package/dist/swaps/assertions/LightningAssertions.d.ts +44 -44
- package/dist/swaps/assertions/LightningAssertions.js +86 -86
- package/dist/swaps/assertions/ToBtcAmountAssertions.d.ts +53 -53
- package/dist/swaps/assertions/ToBtcAmountAssertions.js +150 -150
- package/dist/swaps/escrow/EscrowHandler.d.ts +51 -51
- package/dist/swaps/escrow/EscrowHandler.js +158 -158
- package/dist/swaps/escrow/EscrowHandlerSwap.d.ts +35 -35
- package/dist/swaps/escrow/EscrowHandlerSwap.js +69 -69
- package/dist/swaps/escrow/FromBtcBaseSwap.d.ts +14 -14
- package/dist/swaps/escrow/FromBtcBaseSwap.js +32 -32
- package/dist/swaps/escrow/FromBtcBaseSwapHandler.d.ts +102 -102
- package/dist/swaps/escrow/FromBtcBaseSwapHandler.js +210 -210
- package/dist/swaps/escrow/ToBtcBaseSwap.d.ts +36 -36
- package/dist/swaps/escrow/ToBtcBaseSwap.js +67 -67
- package/dist/swaps/escrow/ToBtcBaseSwapHandler.d.ts +53 -53
- package/dist/swaps/escrow/ToBtcBaseSwapHandler.js +81 -81
- package/dist/swaps/escrow/frombtc_abstract/FromBtcAbs.d.ts +83 -83
- package/dist/swaps/escrow/frombtc_abstract/FromBtcAbs.js +318 -318
- package/dist/swaps/escrow/frombtc_abstract/FromBtcSwapAbs.d.ts +21 -21
- package/dist/swaps/escrow/frombtc_abstract/FromBtcSwapAbs.js +50 -50
- package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnAbs.d.ts +107 -107
- package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnAbs.js +675 -675
- package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.d.ts +33 -33
- package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.js +91 -91
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.d.ts +104 -104
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.js +659 -659
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.d.ts +55 -55
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.js +120 -120
- package/dist/swaps/escrow/tobtc_abstract/ToBtcAbs.d.ts +171 -171
- package/dist/swaps/escrow/tobtc_abstract/ToBtcAbs.js +706 -706
- package/dist/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.d.ts +26 -26
- package/dist/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.js +62 -62
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.d.ts +177 -177
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.js +861 -861
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.d.ts +23 -23
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.js +56 -56
- package/dist/swaps/spv_vault_swap/SpvVault.d.ts +41 -41
- package/dist/swaps/spv_vault_swap/SpvVault.js +111 -111
- package/dist/swaps/spv_vault_swap/SpvVaultSwap.d.ts +67 -67
- package/dist/swaps/spv_vault_swap/SpvVaultSwap.js +158 -158
- package/dist/swaps/spv_vault_swap/SpvVaultSwapHandler.d.ts +68 -68
- package/dist/swaps/spv_vault_swap/SpvVaultSwapHandler.js +491 -491
- package/dist/swaps/spv_vault_swap/SpvVaults.d.ts +52 -52
- package/dist/swaps/spv_vault_swap/SpvVaults.js +364 -364
- package/dist/swaps/trusted/frombtc_trusted/FromBtcTrusted.d.ts +51 -51
- package/dist/swaps/trusted/frombtc_trusted/FromBtcTrusted.js +650 -650
- package/dist/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.d.ts +52 -52
- package/dist/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.js +118 -118
- package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.d.ts +76 -76
- package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.js +494 -494
- package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.d.ts +34 -34
- package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.js +81 -81
- package/dist/utils/Utils.d.ts +29 -29
- package/dist/utils/Utils.js +89 -89
- package/dist/utils/paramcoders/IParamReader.d.ts +5 -5
- package/dist/utils/paramcoders/IParamReader.js +2 -2
- package/dist/utils/paramcoders/IParamWriter.d.ts +4 -4
- package/dist/utils/paramcoders/IParamWriter.js +2 -2
- package/dist/utils/paramcoders/LegacyParamEncoder.d.ts +10 -10
- package/dist/utils/paramcoders/LegacyParamEncoder.js +22 -22
- package/dist/utils/paramcoders/ParamDecoder.d.ts +25 -25
- package/dist/utils/paramcoders/ParamDecoder.js +222 -222
- package/dist/utils/paramcoders/ParamEncoder.d.ts +9 -9
- package/dist/utils/paramcoders/ParamEncoder.js +22 -22
- package/dist/utils/paramcoders/SchemaVerifier.d.ts +21 -21
- package/dist/utils/paramcoders/SchemaVerifier.js +84 -84
- package/dist/utils/paramcoders/server/ServerParamDecoder.d.ts +8 -8
- package/dist/utils/paramcoders/server/ServerParamDecoder.js +107 -107
- package/dist/utils/paramcoders/server/ServerParamEncoder.d.ts +11 -11
- package/dist/utils/paramcoders/server/ServerParamEncoder.js +65 -65
- package/dist/wallets/IBitcoinWallet.d.ts +67 -67
- package/dist/wallets/IBitcoinWallet.js +2 -2
- package/dist/wallets/ILightningWallet.d.ts +117 -117
- package/dist/wallets/ILightningWallet.js +37 -37
- package/dist/wallets/ISpvVaultSigner.d.ts +7 -7
- package/dist/wallets/ISpvVaultSigner.js +2 -2
- package/package.json +36 -36
- package/src/fees/IBtcFeeEstimator.ts +6 -6
- package/src/index.ts +53 -53
- package/src/info/InfoHandler.ts +106 -106
- package/src/plugins/IPlugin.ts +168 -168
- package/src/plugins/PluginManager.ts +336 -336
- package/src/prices/BinanceSwapPrice.ts +113 -113
- package/src/prices/CoinGeckoSwapPrice.ts +87 -87
- package/src/prices/ISwapPrice.ts +88 -88
- package/src/prices/OKXSwapPrice.ts +113 -113
- package/src/storage/IIntermediaryStorage.ts +19 -19
- package/src/storagemanager/IntermediaryStorageManager.ts +118 -118
- package/src/storagemanager/StorageManager.ts +78 -78
- package/src/swaps/SwapHandler.ts +277 -277
- package/src/swaps/SwapHandlerSwap.ts +141 -141
- package/src/swaps/assertions/AmountAssertions.ts +76 -76
- package/src/swaps/assertions/FromBtcAmountAssertions.ts +246 -238
- package/src/swaps/assertions/LightningAssertions.ts +103 -103
- package/src/swaps/assertions/ToBtcAmountAssertions.ts +203 -203
- package/src/swaps/escrow/EscrowHandler.ts +179 -179
- package/src/swaps/escrow/EscrowHandlerSwap.ts +86 -86
- package/src/swaps/escrow/FromBtcBaseSwap.ts +38 -38
- package/src/swaps/escrow/FromBtcBaseSwapHandler.ts +286 -286
- package/src/swaps/escrow/ToBtcBaseSwap.ts +85 -85
- package/src/swaps/escrow/ToBtcBaseSwapHandler.ts +129 -129
- package/src/swaps/escrow/frombtc_abstract/FromBtcAbs.ts +452 -452
- package/src/swaps/escrow/frombtc_abstract/FromBtcSwapAbs.ts +61 -61
- package/src/swaps/escrow/frombtcln_abstract/FromBtcLnAbs.ts +856 -856
- package/src/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.ts +141 -141
- package/src/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.ts +822 -822
- package/src/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.ts +196 -196
- package/src/swaps/escrow/tobtc_abstract/ToBtcAbs.ts +879 -879
- package/src/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.ts +102 -102
- package/src/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.ts +1110 -1110
- package/src/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.ts +77 -77
- package/src/swaps/spv_vault_swap/SpvVault.ts +143 -143
- package/src/swaps/spv_vault_swap/SpvVaultSwap.ts +225 -225
- package/src/swaps/spv_vault_swap/SpvVaultSwapHandler.ts +627 -627
- package/src/swaps/spv_vault_swap/SpvVaults.ts +435 -435
- package/src/swaps/trusted/frombtc_trusted/FromBtcTrusted.ts +747 -747
- package/src/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.ts +185 -185
- package/src/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.ts +590 -590
- package/src/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.ts +121 -121
- package/src/utils/Utils.ts +104 -104
- package/src/utils/paramcoders/IParamReader.ts +7 -7
- package/src/utils/paramcoders/IParamWriter.ts +8 -8
- package/src/utils/paramcoders/LegacyParamEncoder.ts +27 -27
- package/src/utils/paramcoders/ParamDecoder.ts +218 -218
- package/src/utils/paramcoders/ParamEncoder.ts +29 -29
- package/src/utils/paramcoders/SchemaVerifier.ts +96 -96
- package/src/utils/paramcoders/server/ServerParamDecoder.ts +118 -118
- package/src/utils/paramcoders/server/ServerParamEncoder.ts +75 -75
- package/src/wallets/IBitcoinWallet.ts +68 -68
- package/src/wallets/ILightningWallet.ts +178 -178
- 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 });
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@atomiqlabs/lp-lib",
|
|
3
|
-
"version": "14.0.0-dev.
|
|
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": "^10.0.0-dev.9",
|
|
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": "14.0.0-dev.16",
|
|
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": "^10.0.0-dev.9",
|
|
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
|
}
|