@atomiqlabs/sdk 8.7.7 → 8.9.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.
- package/api/index.d.ts +1 -0
- package/api/index.js +3 -0
- package/dist/ApiList.d.ts +37 -0
- package/dist/ApiList.js +30 -0
- package/dist/api/ApiEndpoints.d.ts +393 -0
- package/dist/api/ApiEndpoints.js +2 -0
- package/dist/api/ApiParser.d.ts +10 -0
- package/dist/api/ApiParser.js +134 -0
- package/dist/api/ApiTypes.d.ts +157 -0
- package/dist/api/ApiTypes.js +75 -0
- package/dist/api/SerializedAction.d.ts +40 -0
- package/dist/api/SerializedAction.js +59 -0
- package/dist/api/SwapperApi.d.ts +50 -0
- package/dist/api/SwapperApi.js +431 -0
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.js +24 -0
- package/dist/bitcoin/coinselect2/accumulative.d.ts +1 -0
- package/dist/bitcoin/coinselect2/accumulative.js +1 -1
- package/dist/bitcoin/coinselect2/blackjack.d.ts +1 -0
- package/dist/bitcoin/coinselect2/blackjack.js +1 -1
- package/dist/bitcoin/coinselect2/index.d.ts +3 -2
- package/dist/bitcoin/coinselect2/index.js +2 -2
- package/dist/bitcoin/coinselect2/utils.d.ts +7 -2
- package/dist/bitcoin/coinselect2/utils.js +45 -10
- package/dist/bitcoin/wallet/BitcoinWallet.d.ts +8 -25
- package/dist/bitcoin/wallet/BitcoinWallet.js +31 -18
- package/dist/bitcoin/wallet/IBitcoinWallet.d.ts +40 -2
- package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.d.ts +7 -2
- package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.js +10 -4
- package/dist/events/UnifiedSwapEventListener.d.ts +4 -3
- package/dist/events/UnifiedSwapEventListener.js +8 -2
- package/dist/http/HttpUtils.d.ts +4 -2
- package/dist/http/HttpUtils.js +10 -4
- package/dist/http/paramcoders/client/StreamingFetchPromise.d.ts +2 -1
- package/dist/http/paramcoders/client/StreamingFetchPromise.js +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/intermediaries/IntermediaryDiscovery.d.ts +7 -2
- package/dist/intermediaries/IntermediaryDiscovery.js +4 -4
- package/dist/intermediaries/apis/IntermediaryAPI.d.ts +182 -15
- package/dist/intermediaries/apis/IntermediaryAPI.js +192 -31
- package/dist/intermediaries/auth/SignedKeyBasedAuth.d.ts +14 -0
- package/dist/intermediaries/auth/SignedKeyBasedAuth.js +68 -0
- package/dist/storage/IUnifiedStorage.d.ts +45 -3
- package/dist/storage/UnifiedSwapStorage.d.ts +8 -2
- package/dist/storage/UnifiedSwapStorage.js +46 -8
- package/dist/swapper/Swapper.d.ts +77 -4
- package/dist/swapper/Swapper.js +117 -25
- package/dist/swapper/SwapperUtils.d.ts +18 -2
- package/dist/swapper/SwapperUtils.js +39 -1
- package/dist/swaps/ISwap.d.ts +70 -9
- package/dist/swaps/ISwap.js +28 -6
- package/dist/swaps/ISwapWrapper.d.ts +11 -1
- package/dist/swaps/ISwapWrapper.js +23 -3
- package/dist/swaps/escrow_swaps/IEscrowSwap.d.ts +1 -1
- package/dist/swaps/escrow_swaps/IEscrowSwap.js +4 -2
- package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.d.ts +2 -1
- package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.js +2 -2
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.d.ts +3 -1
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.js +3 -2
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.d.ts +47 -31
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.js +201 -67
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.d.ts +3 -1
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.js +6 -6
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.d.ts +82 -15
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.js +304 -98
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.d.ts +3 -1
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.js +6 -6
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.d.ts +75 -42
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.js +424 -87
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.d.ts +3 -1
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.js +7 -7
- package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.d.ts +54 -11
- package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.js +214 -41
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.d.ts +2 -1
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.js +7 -8
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.d.ts +3 -1
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.js +5 -5
- package/dist/swaps/spv_swaps/SpvFromBTCSwap.d.ts +85 -22
- package/dist/swaps/spv_swaps/SpvFromBTCSwap.js +299 -56
- package/dist/swaps/spv_swaps/SpvFromBTCWrapper.d.ts +41 -7
- package/dist/swaps/spv_swaps/SpvFromBTCWrapper.js +183 -58
- package/dist/swaps/trusted/ln/LnForGasSwap.d.ts +53 -12
- package/dist/swaps/trusted/ln/LnForGasSwap.js +163 -49
- package/dist/swaps/trusted/ln/LnForGasWrapper.js +1 -2
- package/dist/swaps/trusted/onchain/OnchainForGasSwap.d.ts +14 -13
- package/dist/swaps/trusted/onchain/OnchainForGasSwap.js +30 -47
- package/dist/swaps/trusted/onchain/OnchainForGasWrapper.d.ts +3 -1
- package/dist/swaps/trusted/onchain/OnchainForGasWrapper.js +4 -4
- package/dist/types/SwapExecutionAction.d.ts +141 -34
- package/dist/types/SwapExecutionAction.js +104 -0
- package/dist/types/SwapExecutionStep.d.ts +144 -0
- package/dist/types/SwapExecutionStep.js +87 -0
- package/dist/types/TokenAmount.d.ts +6 -0
- package/dist/types/TokenAmount.js +26 -1
- package/dist/utils/BitcoinUtils.d.ts +4 -0
- package/dist/utils/BitcoinUtils.js +73 -1
- package/dist/utils/BitcoinWalletUtils.d.ts +2 -2
- package/dist/utils/Utils.d.ts +3 -1
- package/dist/utils/Utils.js +7 -1
- package/package.json +7 -4
- package/src/api/ApiEndpoints.ts +427 -0
- package/src/api/ApiParser.ts +138 -0
- package/src/api/ApiTypes.ts +229 -0
- package/src/api/SerializedAction.ts +97 -0
- package/src/api/SwapperApi.ts +545 -0
- package/src/api/index.ts +5 -0
- package/src/bitcoin/coinselect2/accumulative.ts +2 -1
- package/src/bitcoin/coinselect2/blackjack.ts +2 -1
- package/src/bitcoin/coinselect2/index.ts +5 -4
- package/src/bitcoin/coinselect2/utils.ts +55 -14
- package/src/bitcoin/wallet/BitcoinWallet.ts +69 -57
- package/src/bitcoin/wallet/IBitcoinWallet.ts +44 -3
- package/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts +12 -4
- package/src/events/UnifiedSwapEventListener.ts +11 -3
- package/src/http/HttpUtils.ts +10 -4
- package/src/http/paramcoders/client/StreamingFetchPromise.ts +4 -2
- package/src/index.ts +1 -0
- package/src/intermediaries/IntermediaryDiscovery.ts +9 -2
- package/src/intermediaries/apis/IntermediaryAPI.ts +335 -35
- package/src/intermediaries/auth/SignedKeyBasedAuth.ts +69 -0
- package/src/storage/IUnifiedStorage.ts +45 -4
- package/src/storage/UnifiedSwapStorage.ts +42 -8
- package/src/swapper/Swapper.ts +165 -24
- package/src/swapper/SwapperUtils.ts +42 -2
- package/src/swaps/ISwap.ts +88 -16
- package/src/swaps/ISwapWrapper.ts +28 -3
- package/src/swaps/escrow_swaps/IEscrowSwap.ts +5 -3
- package/src/swaps/escrow_swaps/IEscrowSwapWrapper.ts +3 -1
- package/src/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.ts +4 -1
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.ts +264 -67
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.ts +6 -4
- package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.ts +390 -89
- package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts +6 -4
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.ts +548 -94
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts +7 -5
- package/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts +276 -45
- package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts +7 -6
- package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.ts +5 -3
- package/src/swaps/spv_swaps/SpvFromBTCSwap.ts +413 -64
- package/src/swaps/spv_swaps/SpvFromBTCWrapper.ts +239 -61
- package/src/swaps/trusted/ln/LnForGasSwap.ts +211 -47
- package/src/swaps/trusted/ln/LnForGasWrapper.ts +1 -2
- package/src/swaps/trusted/onchain/OnchainForGasSwap.ts +32 -51
- package/src/swaps/trusted/onchain/OnchainForGasWrapper.ts +5 -3
- package/src/types/SwapExecutionAction.ts +266 -43
- package/src/types/SwapExecutionStep.ts +224 -0
- package/src/types/TokenAmount.ts +36 -2
- package/src/utils/BitcoinUtils.ts +73 -0
- package/src/utils/BitcoinWalletUtils.ts +2 -2
- package/src/utils/Utils.ts +10 -1
- package/src/intermediaries/apis/TrustedIntermediaryAPI.ts +0 -258
|
@@ -1,88 +1,195 @@
|
|
|
1
1
|
import { ChainType } from "@atomiqlabs/base";
|
|
2
2
|
import { Transaction } from "@scure/btc-signer";
|
|
3
|
+
import { TokenAmount } from "./TokenAmount";
|
|
4
|
+
import { BtcToken } from "./Token";
|
|
3
5
|
/**
|
|
4
|
-
* Swap execution action requiring
|
|
6
|
+
* Swap execution action requiring the user to send assets to a specific LIGHTNING invoice or BITCOIN
|
|
7
|
+
* on-chain address
|
|
5
8
|
*
|
|
6
9
|
* @category Swap Actions
|
|
7
10
|
*/
|
|
8
|
-
export type
|
|
9
|
-
|
|
11
|
+
export type SwapExecutionActionSendToAddress<Lightning extends boolean = boolean> = {
|
|
12
|
+
type: "SendToAddress";
|
|
13
|
+
/**
|
|
14
|
+
* Human-readable name of the action
|
|
15
|
+
*/
|
|
16
|
+
name: Lightning extends true ? "Deposit on Lightning" : "Deposit on Bitcoin";
|
|
17
|
+
/**
|
|
18
|
+
* Human-readable description of the action
|
|
19
|
+
*/
|
|
10
20
|
description: string;
|
|
11
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Chain on which the payment is expected, either `LIGHTNING` or `BITCOIN` for on-chain
|
|
23
|
+
*/
|
|
24
|
+
chain: Lightning extends true ? "LIGHTNING" : "BITCOIN";
|
|
25
|
+
/**
|
|
26
|
+
* An array of payments that should be made to different addresses, usually only a single address is returned
|
|
27
|
+
*/
|
|
12
28
|
txs: {
|
|
13
|
-
type: "BOLT11_PAYMENT_REQUEST";
|
|
29
|
+
type: Lightning extends true ? "BOLT11_PAYMENT_REQUEST" : "BITCOIN_ADDRESS";
|
|
14
30
|
address: string;
|
|
15
31
|
hyperlink: string;
|
|
32
|
+
amount: TokenAmount<BtcToken<Lightning>, true>;
|
|
16
33
|
}[];
|
|
34
|
+
/**
|
|
35
|
+
* Waits till the transaction is received, doesn't wait for the actual confirmation!
|
|
36
|
+
*
|
|
37
|
+
* @returns A transaction ID of the received transaction
|
|
38
|
+
*/
|
|
39
|
+
waitForTransactions: (maxWaitTimeSeconds?: number, pollIntervalSeconds?: number, abortSignal?: AbortSignal) => Promise<string>;
|
|
17
40
|
};
|
|
18
41
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
42
|
+
* Type guard for {@link SwapExecutionActionSendToAddress}
|
|
43
|
+
*
|
|
44
|
+
* @category Swap Actions
|
|
45
|
+
*/
|
|
46
|
+
export declare function isSwapExecutionActionSendToAddress<Lightning extends boolean = boolean>(obj: any, lightning?: Lightning): obj is SwapExecutionActionSendToAddress<Lightning>;
|
|
47
|
+
/**
|
|
48
|
+
* Swap execution action requiring the user to sign the provided PSBT and then submit it back via the provided
|
|
49
|
+
* `submitPsbt()` function, has two variations:
|
|
21
50
|
* - `"FUNDED_PSBT"` - A ready to sign PSBT with the inputs populated from the provided bitcoin wallet address
|
|
22
51
|
* - `"RAW_PSBT"` - Raw PSBT without the inputs, the implementor needs to add the input UTXOs before signing
|
|
23
|
-
* the transaction
|
|
52
|
+
* the transaction (also make sure to set the `nSequence` field of the 2nd input, index 1, to the provided
|
|
53
|
+
* `in1sequence` value)
|
|
24
54
|
*
|
|
25
55
|
* @category Swap Actions
|
|
26
56
|
*/
|
|
27
|
-
export type
|
|
28
|
-
|
|
57
|
+
export type SwapExecutionActionSignPSBT<T extends "FUNDED_PSBT" | "RAW_PSBT" = "FUNDED_PSBT" | "RAW_PSBT"> = {
|
|
58
|
+
type: "SignPSBT";
|
|
59
|
+
/**
|
|
60
|
+
* Human-readable name of the action
|
|
61
|
+
*/
|
|
62
|
+
name: "Deposit on Bitcoin";
|
|
63
|
+
/**
|
|
64
|
+
* Human-readable description of the action
|
|
65
|
+
*/
|
|
29
66
|
description: string;
|
|
67
|
+
/**
|
|
68
|
+
* Chain is always bitcoin
|
|
69
|
+
*/
|
|
30
70
|
chain: "BITCOIN";
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
hyperlink: string;
|
|
36
|
-
} : T extends "FUNDED_PSBT" ? {
|
|
71
|
+
/**
|
|
72
|
+
* An array of PSBTs that need to be signed, usually contains only a single PSBT
|
|
73
|
+
*/
|
|
74
|
+
txs: T extends "FUNDED_PSBT" ? {
|
|
37
75
|
type: "FUNDED_PSBT";
|
|
38
76
|
psbt: Transaction;
|
|
39
77
|
psbtHex: string;
|
|
40
78
|
psbtBase64: string;
|
|
41
79
|
signInputs: number[];
|
|
42
|
-
|
|
80
|
+
feeRate: number;
|
|
81
|
+
}[] : {
|
|
43
82
|
type: "RAW_PSBT";
|
|
44
83
|
psbt: Transaction;
|
|
45
84
|
psbtHex: string;
|
|
46
85
|
psbtBase64: string;
|
|
47
86
|
in1sequence: number;
|
|
48
|
-
|
|
87
|
+
feeRate: number;
|
|
88
|
+
}[];
|
|
89
|
+
/**
|
|
90
|
+
* Submit a signed PSBT, accepts hexadecimal, base64 and `@scure/btc-signer` {@link Transaction} object.
|
|
91
|
+
*
|
|
92
|
+
* @returns An array of transaction IDs of the submitted Bitcoin transactions
|
|
93
|
+
*/
|
|
94
|
+
submitPsbt: (signedPsbt: string | Transaction | (string | Transaction)[], idempotent?: boolean) => Promise<string[]>;
|
|
49
95
|
};
|
|
50
96
|
/**
|
|
51
|
-
*
|
|
97
|
+
* Type guard for {@link SwapExecutionActionSignPSBT}
|
|
52
98
|
*
|
|
53
99
|
* @category Swap Actions
|
|
54
100
|
*/
|
|
55
|
-
export
|
|
56
|
-
name: "Commit";
|
|
57
|
-
description: string;
|
|
58
|
-
chain: T["ChainId"];
|
|
59
|
-
txs: T["TX"][];
|
|
60
|
-
};
|
|
101
|
+
export declare function isSwapExecutionActionSignPSBT<T extends "FUNDED_PSBT" | "RAW_PSBT" = "FUNDED_PSBT" | "RAW_PSBT">(obj: any, psbtType?: T): obj is SwapExecutionActionSignPSBT<T>;
|
|
61
102
|
/**
|
|
62
|
-
* Swap execution action
|
|
103
|
+
* Swap execution action requiring the user to sign the provided smart chain transactions, these can then
|
|
104
|
+
* be either broadcasted manually, or sent via the provided `submitTransactions()` function
|
|
63
105
|
*
|
|
64
106
|
* @category Swap Actions
|
|
65
107
|
*/
|
|
66
|
-
export type
|
|
67
|
-
|
|
108
|
+
export type SwapExecutionActionSignSmartChainTx<T extends ChainType = ChainType> = {
|
|
109
|
+
type: "SignSmartChainTransaction";
|
|
110
|
+
/**
|
|
111
|
+
* Human-readable name of the action
|
|
112
|
+
*/
|
|
113
|
+
name: "Initiate swap" | "Settle manually" | "Refund";
|
|
114
|
+
/**
|
|
115
|
+
* Human-readable description of the action
|
|
116
|
+
*/
|
|
68
117
|
description: string;
|
|
118
|
+
/**
|
|
119
|
+
* Chain identifier of the smart chain on which the corresponding transactions should be signed
|
|
120
|
+
*/
|
|
69
121
|
chain: T["ChainId"];
|
|
122
|
+
/**
|
|
123
|
+
* Smart chain transactions that should be signed and either broadcasted manually or submitted back
|
|
124
|
+
* to the provided `submitTransactions()` function
|
|
125
|
+
*/
|
|
70
126
|
txs: T["TX"][];
|
|
127
|
+
/**
|
|
128
|
+
* Submits the signed transactions and waits for their confirmation
|
|
129
|
+
*
|
|
130
|
+
* @remarks This might not do any validation on the submitted transactions, so returned txids are informational
|
|
131
|
+
* only and may not be persisted immediately. The swap may wait for an authoritative state transition before
|
|
132
|
+
* considering the submitted transactions accepted.
|
|
133
|
+
*
|
|
134
|
+
* Make sure to only submit valid signed transactions obtained from this action object, and pass an AbortSignal
|
|
135
|
+
* if you need a timeout, otherwise this call can wait indefinitely when invalid transactions are submitted.
|
|
136
|
+
*/
|
|
137
|
+
submitTransactions: (txs: (T["SignedTXType"] | string)[], abortSignal?: AbortSignal, idempotent?: boolean) => Promise<string[]>;
|
|
138
|
+
/**
|
|
139
|
+
* The address of the signer that has to sign the transactions
|
|
140
|
+
*/
|
|
141
|
+
requiredSigner: string;
|
|
71
142
|
};
|
|
72
143
|
/**
|
|
73
|
-
*
|
|
144
|
+
* Type guard for {@link SwapExecutionActionSignSmartChainTx}
|
|
74
145
|
*
|
|
75
146
|
* @category Swap Actions
|
|
76
147
|
*/
|
|
77
|
-
export
|
|
78
|
-
|
|
148
|
+
export declare function isSwapExecutionActionSignSmartChainTx<T extends ChainType = ChainType>(obj: any, chainIdentifier?: T["ChainId"] | T["ChainId"][]): obj is SwapExecutionActionSignSmartChainTx<T>;
|
|
149
|
+
/**
|
|
150
|
+
* Swap action indicating that the user should wait for either LP to process the swap, automatic settlement to happen or
|
|
151
|
+
* until the Bitcoin transaction gets enough confirmations
|
|
152
|
+
*
|
|
153
|
+
* @category Swap Actions
|
|
154
|
+
*/
|
|
155
|
+
export type SwapExecutionActionWait<T extends "LP" | "SETTLEMENT" | "BITCOIN_CONFS" = "LP" | "SETTLEMENT" | "BITCOIN_CONFS"> = {
|
|
156
|
+
type: "Wait";
|
|
157
|
+
/**
|
|
158
|
+
* Human-readable name of the action
|
|
159
|
+
*/
|
|
160
|
+
name: T extends "LP" ? "Awaiting LP payout" : T extends "SETTLEMENT" ? "Automatic settlement" : "Bitcoin confirmations";
|
|
161
|
+
/**
|
|
162
|
+
* Human-readable description of the action
|
|
163
|
+
*/
|
|
79
164
|
description: string;
|
|
80
|
-
|
|
81
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Allows you to await till this action resolves
|
|
167
|
+
*
|
|
168
|
+
* @param maxWaitTimeSeconds Maximum time in seconds to wait for
|
|
169
|
+
* @param pollIntervalSeconds How often to poll for the state change (default 5 seconds)
|
|
170
|
+
* @param abortSignal AbortSignal to abort the wait
|
|
171
|
+
* @param btcConfirmationsCallback Optional callback when awaiting bitcoin confirmations, gets called when
|
|
172
|
+
* number of bitcoin confirmations change
|
|
173
|
+
*/
|
|
174
|
+
wait: T extends "BITCOIN_CONFS" ? (maxWaitTimeSeconds?: number, pollIntervalSeconds?: number, abortSignal?: AbortSignal, btcConfirmationsCallback?: (txId?: string, confirmations?: number, targetConfirmations?: number, txEtaMs?: number) => void) => Promise<void> : (maxWaitTimeSeconds?: number, pollIntervalSeconds?: number, abortSignal?: AbortSignal) => Promise<void>;
|
|
175
|
+
/**
|
|
176
|
+
* Expected time in seconds for this action to take
|
|
177
|
+
*/
|
|
178
|
+
expectedTimeSeconds: number;
|
|
179
|
+
/**
|
|
180
|
+
* Recommended time interval in seconds after which you should re-check the current action
|
|
181
|
+
*/
|
|
182
|
+
pollTimeSeconds: number;
|
|
82
183
|
};
|
|
184
|
+
/**
|
|
185
|
+
* Type guard for {@link SwapExecutionActionWait}
|
|
186
|
+
*
|
|
187
|
+
* @category Swap Actions
|
|
188
|
+
*/
|
|
189
|
+
export declare function isSwapExecutionActionWait<T extends "LP" | "SETTLEMENT" | "BITCOIN_CONFS" = "LP" | "SETTLEMENT" | "BITCOIN_CONFS">(obj: any, waitType?: T): obj is SwapExecutionActionWait<T>;
|
|
83
190
|
/**
|
|
84
191
|
* Swap execution action, a single step in the swapping process
|
|
85
192
|
*
|
|
86
193
|
* @category Swap Actions
|
|
87
194
|
*/
|
|
88
|
-
export type SwapExecutionAction
|
|
195
|
+
export type SwapExecutionAction = SwapExecutionActionSendToAddress | SwapExecutionActionSignPSBT | SwapExecutionActionSignSmartChainTx | SwapExecutionActionWait;
|
|
@@ -1,2 +1,106 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSwapExecutionActionWait = exports.isSwapExecutionActionSignSmartChainTx = exports.isSwapExecutionActionSignPSBT = exports.isSwapExecutionActionSendToAddress = void 0;
|
|
4
|
+
const btc_signer_1 = require("@scure/btc-signer");
|
|
5
|
+
const TokenAmount_1 = require("./TokenAmount");
|
|
6
|
+
const Token_1 = require("./Token");
|
|
7
|
+
const swapExecutionActionWaitNames = {
|
|
8
|
+
LP: "Awaiting LP payout",
|
|
9
|
+
SETTLEMENT: "Automatic settlement",
|
|
10
|
+
BITCOIN_CONFS: "Bitcoin confirmations"
|
|
11
|
+
};
|
|
12
|
+
function isSwapExecutionActionPsbtTx(obj, type) {
|
|
13
|
+
const resolvedType = type ?? obj?.type;
|
|
14
|
+
if (obj == null || typeof (obj) !== "object")
|
|
15
|
+
return false;
|
|
16
|
+
if (resolvedType !== "FUNDED_PSBT" && resolvedType !== "RAW_PSBT")
|
|
17
|
+
return false;
|
|
18
|
+
return obj.type === resolvedType &&
|
|
19
|
+
obj.psbt instanceof btc_signer_1.Transaction &&
|
|
20
|
+
typeof (obj.psbtHex) === "string" &&
|
|
21
|
+
typeof (obj.psbtBase64) === "string" &&
|
|
22
|
+
(resolvedType === "FUNDED_PSBT"
|
|
23
|
+
? Array.isArray(obj.signInputs) && obj.signInputs.every((input) => typeof (input) === "number")
|
|
24
|
+
: typeof (obj.in1sequence) === "number");
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Type guard for {@link SwapExecutionActionSendToAddress}
|
|
28
|
+
*
|
|
29
|
+
* @category Swap Actions
|
|
30
|
+
*/
|
|
31
|
+
function isSwapExecutionActionSendToAddress(obj, lightning) {
|
|
32
|
+
const resolvedLightning = lightning ?? (obj?.chain === "LIGHTNING");
|
|
33
|
+
return obj != null &&
|
|
34
|
+
typeof (obj) === "object" &&
|
|
35
|
+
obj.type === "SendToAddress" &&
|
|
36
|
+
obj.name === (resolvedLightning ? "Deposit on Lightning" : "Deposit on Bitcoin") &&
|
|
37
|
+
typeof (obj.description) === "string" &&
|
|
38
|
+
obj.chain === (resolvedLightning ? "LIGHTNING" : "BITCOIN") &&
|
|
39
|
+
Array.isArray(obj.txs) &&
|
|
40
|
+
obj.txs.every((tx) => tx != null &&
|
|
41
|
+
typeof (tx) === "object" &&
|
|
42
|
+
tx.type === (resolvedLightning ? "BOLT11_PAYMENT_REQUEST" : "BITCOIN_ADDRESS") &&
|
|
43
|
+
typeof (tx.address) === "string" &&
|
|
44
|
+
typeof (tx.hyperlink) === "string" &&
|
|
45
|
+
(0, TokenAmount_1.isTokenAmount)(tx.amount, resolvedLightning ? Token_1.BitcoinTokens.BTCLN : Token_1.BitcoinTokens.BTC, true)) &&
|
|
46
|
+
typeof (obj.waitForTransactions) === "function";
|
|
47
|
+
}
|
|
48
|
+
exports.isSwapExecutionActionSendToAddress = isSwapExecutionActionSendToAddress;
|
|
49
|
+
/**
|
|
50
|
+
* Type guard for {@link SwapExecutionActionSignPSBT}
|
|
51
|
+
*
|
|
52
|
+
* @category Swap Actions
|
|
53
|
+
*/
|
|
54
|
+
function isSwapExecutionActionSignPSBT(obj, psbtType) {
|
|
55
|
+
const resolvedPsbtType = psbtType ?? obj?.txs?.[0]?.type;
|
|
56
|
+
return obj != null &&
|
|
57
|
+
typeof (obj) === "object" &&
|
|
58
|
+
obj.type === "SignPSBT" &&
|
|
59
|
+
obj.name === "Deposit on Bitcoin" &&
|
|
60
|
+
typeof (obj.description) === "string" &&
|
|
61
|
+
obj.chain === "BITCOIN" &&
|
|
62
|
+
Array.isArray(obj.txs) &&
|
|
63
|
+
obj.txs.every((tx) => isSwapExecutionActionPsbtTx(tx, resolvedPsbtType)) &&
|
|
64
|
+
typeof (obj.submitPsbt) === "function";
|
|
65
|
+
}
|
|
66
|
+
exports.isSwapExecutionActionSignPSBT = isSwapExecutionActionSignPSBT;
|
|
67
|
+
/**
|
|
68
|
+
* Type guard for {@link SwapExecutionActionSignSmartChainTx}
|
|
69
|
+
*
|
|
70
|
+
* @category Swap Actions
|
|
71
|
+
*/
|
|
72
|
+
function isSwapExecutionActionSignSmartChainTx(obj, chainIdentifier) {
|
|
73
|
+
const allowedChains = chainIdentifier == null ? null : Array.isArray(chainIdentifier) ? chainIdentifier : [chainIdentifier];
|
|
74
|
+
return obj != null &&
|
|
75
|
+
typeof (obj) === "object" &&
|
|
76
|
+
obj.type === "SignSmartChainTransaction" &&
|
|
77
|
+
(obj.name === "Initiate swap" ||
|
|
78
|
+
obj.name === "Settle manually" ||
|
|
79
|
+
obj.name === "Refund") &&
|
|
80
|
+
typeof (obj.description) === "string" &&
|
|
81
|
+
typeof (obj.chain) === "string" &&
|
|
82
|
+
(allowedChains == null || allowedChains.includes(obj.chain)) &&
|
|
83
|
+
Array.isArray(obj.txs) &&
|
|
84
|
+
typeof (obj.submitTransactions) === "function" &&
|
|
85
|
+
typeof (obj.requiredSigner) === "string";
|
|
86
|
+
}
|
|
87
|
+
exports.isSwapExecutionActionSignSmartChainTx = isSwapExecutionActionSignSmartChainTx;
|
|
88
|
+
/**
|
|
89
|
+
* Type guard for {@link SwapExecutionActionWait}
|
|
90
|
+
*
|
|
91
|
+
* @category Swap Actions
|
|
92
|
+
*/
|
|
93
|
+
function isSwapExecutionActionWait(obj, waitType) {
|
|
94
|
+
const resolvedWaitType = waitType ??
|
|
95
|
+
Object.keys(swapExecutionActionWaitNames).find(key => swapExecutionActionWaitNames[key] === obj?.name);
|
|
96
|
+
return obj != null &&
|
|
97
|
+
typeof (obj) === "object" &&
|
|
98
|
+
obj.type === "Wait" &&
|
|
99
|
+
resolvedWaitType != null &&
|
|
100
|
+
obj.name === swapExecutionActionWaitNames[resolvedWaitType] &&
|
|
101
|
+
typeof (obj.description) === "string" &&
|
|
102
|
+
typeof (obj.wait) === "function" &&
|
|
103
|
+
typeof (obj.expectedTimeSeconds) === "number" &&
|
|
104
|
+
typeof (obj.pollTimeSeconds) === "number";
|
|
105
|
+
}
|
|
106
|
+
exports.isSwapExecutionActionWait = isSwapExecutionActionWait;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution step describing destination-side setup required before the swap can continue.
|
|
3
|
+
*
|
|
4
|
+
* @category Swap Steps
|
|
5
|
+
*/
|
|
6
|
+
export type SwapExecutionStepSetup<Chain extends string = string> = {
|
|
7
|
+
type: "Setup";
|
|
8
|
+
side: "destination";
|
|
9
|
+
chain: Chain;
|
|
10
|
+
title: string;
|
|
11
|
+
description: string;
|
|
12
|
+
/**
|
|
13
|
+
* Current status of the setup step.
|
|
14
|
+
*
|
|
15
|
+
* - `awaiting`: The setup transaction or action still needs to be performed.
|
|
16
|
+
* - `completed`: The setup was already completed successfully.
|
|
17
|
+
* - `soft_expired`: The setup should be treated as expired by the user, but it may still progress because of in-flight or background processing.
|
|
18
|
+
* - `expired`: The setup can no longer be performed because the swap expired.
|
|
19
|
+
*/
|
|
20
|
+
status: "awaiting" | "completed" | "soft_expired" | "expired";
|
|
21
|
+
setupTxId?: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Type guard for {@link SwapExecutionStepSetup}
|
|
25
|
+
*
|
|
26
|
+
* @category Swap Steps
|
|
27
|
+
*/
|
|
28
|
+
export declare function isSwapExecutionStepSetup<Chain extends string = string>(obj: any, chain?: Chain): obj is SwapExecutionStepSetup<Chain>;
|
|
29
|
+
/**
|
|
30
|
+
* Execution step describing the user payment that initiates or funds the swap.
|
|
31
|
+
*
|
|
32
|
+
* @category Swap Steps
|
|
33
|
+
*/
|
|
34
|
+
export type SwapExecutionStepPayment<Chain extends string = string> = {
|
|
35
|
+
type: "Payment";
|
|
36
|
+
side: "source";
|
|
37
|
+
chain: Chain;
|
|
38
|
+
title: string;
|
|
39
|
+
description: string;
|
|
40
|
+
/**
|
|
41
|
+
* Current status of the payment step.
|
|
42
|
+
*
|
|
43
|
+
* - `inactive`: The payment step is not yet active because a previous step must complete first.
|
|
44
|
+
* - `awaiting`: The payment is expected, but no payment transaction is known yet.
|
|
45
|
+
* - `received`: A payment transaction is known, but it is not yet fully confirmed.
|
|
46
|
+
* - `confirmed`: The payment was confirmed and fully satisfies the swap requirements.
|
|
47
|
+
* - `soft_expired`: The payment should be treated as expired by the user, but it may still progress because of in-flight or background processing.
|
|
48
|
+
* - `expired`: The payment step can no longer be completed because the swap expired.
|
|
49
|
+
*/
|
|
50
|
+
status: "inactive" | "awaiting" | "received" | "confirmed" | "soft_expired" | "expired";
|
|
51
|
+
/**
|
|
52
|
+
* Optional confirmation progress for Bitcoin on-chain payments.
|
|
53
|
+
*/
|
|
54
|
+
confirmations?: {
|
|
55
|
+
/**
|
|
56
|
+
* Number of confirmations currently observed for the payment.
|
|
57
|
+
*/
|
|
58
|
+
current: number;
|
|
59
|
+
/**
|
|
60
|
+
* Number of confirmations required before the payment is considered final.
|
|
61
|
+
*/
|
|
62
|
+
target: number;
|
|
63
|
+
/**
|
|
64
|
+
* Estimated remaining time in seconds until the target confirmation count is reached.
|
|
65
|
+
*
|
|
66
|
+
* Can be `-1` if the estimate is not available.
|
|
67
|
+
*/
|
|
68
|
+
etaSeconds: number;
|
|
69
|
+
};
|
|
70
|
+
initTxId?: string;
|
|
71
|
+
settleTxId?: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Type guard for {@link SwapExecutionStepPayment}
|
|
75
|
+
*
|
|
76
|
+
* @category Swap Steps
|
|
77
|
+
*/
|
|
78
|
+
export declare function isSwapExecutionStepPayment<Chain extends string = string>(obj: any, chain?: Chain): obj is SwapExecutionStepPayment<Chain>;
|
|
79
|
+
/**
|
|
80
|
+
* Execution step describing payout or settlement on the destination side of the swap.
|
|
81
|
+
*
|
|
82
|
+
* @category Swap Steps
|
|
83
|
+
*/
|
|
84
|
+
export type SwapExecutionStepSettlement<Chain extends string = string, AdditionalStatuses extends "awaiting_automatic" | "awaiting_manual" | "soft_settled" = "awaiting_automatic" | "awaiting_manual" | "soft_settled"> = {
|
|
85
|
+
type: "Settlement";
|
|
86
|
+
side: "destination";
|
|
87
|
+
chain: Chain;
|
|
88
|
+
title: string;
|
|
89
|
+
description: string;
|
|
90
|
+
/**
|
|
91
|
+
* Current status of the settlement step.
|
|
92
|
+
*
|
|
93
|
+
* - `inactive`: The settlement step is not yet active because a previous step must complete first.
|
|
94
|
+
* - `waiting_lp`: The swap is waiting for the intermediary (LP) to create or process the destination-side payout.
|
|
95
|
+
* - `awaiting_automatic`: The swap is waiting for automatic settlement by watchtowers.
|
|
96
|
+
* - `awaiting_manual`: The swap is ready for manual destination-side settlement by the user.
|
|
97
|
+
* - `soft_settled`: The user already received the payout, but the swap is not yet fully finalized on the source side.
|
|
98
|
+
* - `soft_expired`: The settlement should be treated as expired by the user, but it may still progress because of in-flight or background processing.
|
|
99
|
+
* - `settled`: The settlement completed successfully.
|
|
100
|
+
* - `expired`: Settlement is no longer possible because the swap expired or failed.
|
|
101
|
+
*/
|
|
102
|
+
status: "inactive" | "waiting_lp" | "soft_expired" | "settled" | "expired" | AdditionalStatuses;
|
|
103
|
+
initTxId?: string;
|
|
104
|
+
settleTxId?: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Type guard for {@link SwapExecutionStepSettlement}
|
|
108
|
+
*
|
|
109
|
+
* @category Swap Steps
|
|
110
|
+
*/
|
|
111
|
+
export declare function isSwapExecutionStepSettlement<Chain extends string = string>(obj: any, chain?: Chain): obj is SwapExecutionStepSettlement<Chain>;
|
|
112
|
+
/**
|
|
113
|
+
* Execution step describing a source-side refund path after a failed swap.
|
|
114
|
+
*
|
|
115
|
+
* @category Swap Steps
|
|
116
|
+
*/
|
|
117
|
+
export type SwapExecutionStepRefund<Chain extends string = string> = {
|
|
118
|
+
type: "Refund";
|
|
119
|
+
side: "source";
|
|
120
|
+
chain: Chain;
|
|
121
|
+
title: string;
|
|
122
|
+
description: string;
|
|
123
|
+
/**
|
|
124
|
+
* Current status of the refund step.
|
|
125
|
+
*
|
|
126
|
+
* - `inactive`: The refund path is not currently available.
|
|
127
|
+
* - `awaiting`: The swap can be refunded and the user may perform the refund action.
|
|
128
|
+
* - `refunded`: The refund was completed successfully.
|
|
129
|
+
*/
|
|
130
|
+
status: "inactive" | "awaiting" | "refunded";
|
|
131
|
+
refundTxId?: string;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Type guard for {@link SwapExecutionStepRefund}
|
|
135
|
+
*
|
|
136
|
+
* @category Swap Steps
|
|
137
|
+
*/
|
|
138
|
+
export declare function isSwapExecutionStepRefund<Chain extends string = string>(obj: any, chain?: Chain): obj is SwapExecutionStepRefund<Chain>;
|
|
139
|
+
/**
|
|
140
|
+
* Union of all supported swap execution step variants.
|
|
141
|
+
*
|
|
142
|
+
* @category Swap Steps
|
|
143
|
+
*/
|
|
144
|
+
export type SwapExecutionStep = SwapExecutionStepSetup | SwapExecutionStepPayment | SwapExecutionStepSettlement | SwapExecutionStepRefund;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSwapExecutionStepRefund = exports.isSwapExecutionStepSettlement = exports.isSwapExecutionStepPayment = exports.isSwapExecutionStepSetup = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Type guard for {@link SwapExecutionStepSetup}
|
|
6
|
+
*
|
|
7
|
+
* @category Swap Steps
|
|
8
|
+
*/
|
|
9
|
+
function isSwapExecutionStepSetup(obj, chain) {
|
|
10
|
+
return typeof (obj) === "object" &&
|
|
11
|
+
obj.type === "Setup" &&
|
|
12
|
+
obj.side === "destination" &&
|
|
13
|
+
typeof (obj.chain) === "string" &&
|
|
14
|
+
(chain == null || obj.chain === chain) &&
|
|
15
|
+
typeof (obj.title) === "string" &&
|
|
16
|
+
typeof (obj.description) === "string" &&
|
|
17
|
+
(obj.status === "awaiting" ||
|
|
18
|
+
obj.status === "completed" ||
|
|
19
|
+
obj.status === "soft_expired" ||
|
|
20
|
+
obj.status === "expired");
|
|
21
|
+
}
|
|
22
|
+
exports.isSwapExecutionStepSetup = isSwapExecutionStepSetup;
|
|
23
|
+
/**
|
|
24
|
+
* Type guard for {@link SwapExecutionStepPayment}
|
|
25
|
+
*
|
|
26
|
+
* @category Swap Steps
|
|
27
|
+
*/
|
|
28
|
+
function isSwapExecutionStepPayment(obj, chain) {
|
|
29
|
+
return typeof (obj) === "object" &&
|
|
30
|
+
obj.type === "Payment" &&
|
|
31
|
+
obj.side === "source" &&
|
|
32
|
+
typeof (obj.chain) === "string" &&
|
|
33
|
+
(chain == null || obj.chain === chain) &&
|
|
34
|
+
typeof (obj.title) === "string" &&
|
|
35
|
+
typeof (obj.description) === "string" &&
|
|
36
|
+
(obj.status === "inactive" ||
|
|
37
|
+
obj.status === "awaiting" ||
|
|
38
|
+
obj.status === "received" ||
|
|
39
|
+
obj.status === "confirmed" ||
|
|
40
|
+
obj.status === "soft_expired" ||
|
|
41
|
+
obj.status === "expired") &&
|
|
42
|
+
(obj.confirmations == null ||
|
|
43
|
+
(typeof (obj.confirmations) === "object" &&
|
|
44
|
+
typeof (obj.confirmations.current) === "number" &&
|
|
45
|
+
typeof (obj.confirmations.target) === "number" &&
|
|
46
|
+
typeof (obj.confirmations.etaSeconds) === "number"));
|
|
47
|
+
}
|
|
48
|
+
exports.isSwapExecutionStepPayment = isSwapExecutionStepPayment;
|
|
49
|
+
/**
|
|
50
|
+
* Type guard for {@link SwapExecutionStepSettlement}
|
|
51
|
+
*
|
|
52
|
+
* @category Swap Steps
|
|
53
|
+
*/
|
|
54
|
+
function isSwapExecutionStepSettlement(obj, chain) {
|
|
55
|
+
return typeof (obj) === "object" &&
|
|
56
|
+
obj.type === "Settlement" &&
|
|
57
|
+
obj.side === "destination" &&
|
|
58
|
+
typeof (obj.chain) === "string" &&
|
|
59
|
+
(chain == null || obj.chain === chain) &&
|
|
60
|
+
typeof (obj.title) === "string" &&
|
|
61
|
+
typeof (obj.description) === "string" &&
|
|
62
|
+
(obj.status === "inactive" ||
|
|
63
|
+
obj.status === "waiting_lp" ||
|
|
64
|
+
obj.status === "awaiting_automatic" ||
|
|
65
|
+
obj.status === "awaiting_manual" ||
|
|
66
|
+
obj.status === "soft_settled" ||
|
|
67
|
+
obj.status === "soft_expired" ||
|
|
68
|
+
obj.status === "settled" ||
|
|
69
|
+
obj.status === "expired");
|
|
70
|
+
}
|
|
71
|
+
exports.isSwapExecutionStepSettlement = isSwapExecutionStepSettlement;
|
|
72
|
+
/**
|
|
73
|
+
* Type guard for {@link SwapExecutionStepRefund}
|
|
74
|
+
*
|
|
75
|
+
* @category Swap Steps
|
|
76
|
+
*/
|
|
77
|
+
function isSwapExecutionStepRefund(obj, chain) {
|
|
78
|
+
return typeof (obj) === "object" &&
|
|
79
|
+
obj.type === "Refund" &&
|
|
80
|
+
obj.side === "source" &&
|
|
81
|
+
typeof (obj.chain) === "string" &&
|
|
82
|
+
(chain == null || obj.chain === chain) &&
|
|
83
|
+
typeof (obj.title) === "string" &&
|
|
84
|
+
typeof (obj.description) === "string" &&
|
|
85
|
+
(obj.status === "inactive" || obj.status === "awaiting" || obj.status === "refunded");
|
|
86
|
+
}
|
|
87
|
+
exports.isSwapExecutionStepRefund = isSwapExecutionStepRefund;
|
|
@@ -60,6 +60,12 @@ export type TokenAmount<T extends Token = Token, Known extends boolean = boolean
|
|
|
60
60
|
*/
|
|
61
61
|
isUnknown: Known extends true ? false : true;
|
|
62
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* Type guard for {@link TokenAmount}
|
|
65
|
+
*
|
|
66
|
+
* @category Tokens
|
|
67
|
+
*/
|
|
68
|
+
export declare function isTokenAmount<T extends Token = Token, Known extends boolean = boolean>(obj: any, token?: T, known?: Known): obj is TokenAmount<T, Known>;
|
|
63
69
|
/**
|
|
64
70
|
* Factory function to create a TokenAmount
|
|
65
71
|
*
|
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toTokenAmount = void 0;
|
|
3
|
+
exports.toTokenAmount = exports.isTokenAmount = void 0;
|
|
4
|
+
const Token_1 = require("./Token");
|
|
4
5
|
const Utils_1 = require("../utils/Utils");
|
|
6
|
+
/**
|
|
7
|
+
* Type guard for {@link TokenAmount}
|
|
8
|
+
*
|
|
9
|
+
* @category Tokens
|
|
10
|
+
*/
|
|
11
|
+
function isTokenAmount(obj, token, known) {
|
|
12
|
+
const hasExpectedKnownState = known == null
|
|
13
|
+
? ((typeof (obj?.rawAmount) === "bigint" && obj?.isUnknown === false) ||
|
|
14
|
+
(obj?.rawAmount === undefined && obj?.isUnknown === true))
|
|
15
|
+
: known
|
|
16
|
+
? typeof (obj?.rawAmount) === "bigint" && obj?.isUnknown === false
|
|
17
|
+
: obj?.rawAmount === undefined && obj?.isUnknown === true;
|
|
18
|
+
return obj != null &&
|
|
19
|
+
typeof (obj) === "object" &&
|
|
20
|
+
typeof (obj.amount) === "string" &&
|
|
21
|
+
typeof (obj._amount) === "number" &&
|
|
22
|
+
(token == null ? (0, Token_1.isToken)(obj.token) : token.equals(obj.token)) &&
|
|
23
|
+
typeof (obj.currentUsdValue) === "function" &&
|
|
24
|
+
typeof (obj.usdValue) === "function" &&
|
|
25
|
+
(obj.pastUsdValue == null || typeof (obj.pastUsdValue) === "number") &&
|
|
26
|
+
typeof (obj.toString) === "function" &&
|
|
27
|
+
hasExpectedKnownState;
|
|
28
|
+
}
|
|
29
|
+
exports.isTokenAmount = isTokenAmount;
|
|
5
30
|
/**
|
|
6
31
|
* Factory function to create a TokenAmount
|
|
7
32
|
*
|
|
@@ -7,8 +7,12 @@ import { CoinselectAddressTypes } from "../bitcoin/coinselect2";
|
|
|
7
7
|
export declare function fromOutputScript(network: BTC_NETWORK, outputScriptHex: string): string;
|
|
8
8
|
export declare function toOutputScript(network: BTC_NETWORK, address: string): Buffer;
|
|
9
9
|
export declare function toCoinselectAddressType(outputScript: Uint8Array): CoinselectAddressTypes;
|
|
10
|
+
export declare function getDummyOutputScript(type: CoinselectAddressTypes): Uint8Array;
|
|
11
|
+
export declare function getDummyAddress(network: BTC_NETWORK, type: CoinselectAddressTypes): string;
|
|
10
12
|
/**
|
|
11
13
|
* General parsers for PSBTs, can parse hex or base64 encoded PSBTs
|
|
12
14
|
* @param _psbt
|
|
13
15
|
*/
|
|
14
16
|
export declare function parsePsbtTransaction(_psbt: Transaction | string): Transaction;
|
|
17
|
+
export declare function getVoutIndex(psbt: Transaction, network: BTC_NETWORK, address: string, amount: bigint): number | undefined;
|
|
18
|
+
export declare function getSenderAddress(psbt: Transaction, network: BTC_NETWORK, inputIndex?: number): string | undefined;
|