@fedimint/core 0.1.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/LICENSE +21 -0
- package/README.md +18 -0
- package/dist/dts/FedimintWallet.d.ts +51 -0
- package/dist/dts/FedimintWallet.d.ts.map +1 -0
- package/dist/dts/WalletDirector.d.ts +79 -0
- package/dist/dts/WalletDirector.d.ts.map +1 -0
- package/dist/dts/index.d.ts +5 -0
- package/dist/dts/index.d.ts.map +1 -0
- package/dist/dts/services/BalanceService.d.ts +15 -0
- package/dist/dts/services/BalanceService.d.ts.map +1 -0
- package/dist/dts/services/FederationService.d.ts +13 -0
- package/dist/dts/services/FederationService.d.ts.map +1 -0
- package/dist/dts/services/LightningService.d.ts +48 -0
- package/dist/dts/services/LightningService.d.ts.map +1 -0
- package/dist/dts/services/MintService.d.ts +23 -0
- package/dist/dts/services/MintService.d.ts.map +1 -0
- package/dist/dts/services/RecoveryService.d.ts +13 -0
- package/dist/dts/services/RecoveryService.d.ts.map +1 -0
- package/dist/dts/services/WalletService.d.ts +13 -0
- package/dist/dts/services/WalletService.d.ts.map +1 -0
- package/dist/dts/services/index.d.ts +7 -0
- package/dist/dts/services/index.d.ts.map +1 -0
- package/dist/dts/transport/TransportClient.d.ts +55 -0
- package/dist/dts/transport/TransportClient.d.ts.map +1 -0
- package/dist/dts/transport/index.d.ts +2 -0
- package/dist/dts/transport/index.d.ts.map +1 -0
- package/dist/dts/types/index.d.ts +4 -0
- package/dist/dts/types/index.d.ts.map +1 -0
- package/dist/dts/types/transport.d.ts +2 -0
- package/dist/dts/types/transport.d.ts.map +1 -0
- package/dist/dts/types/utils.d.ts +21 -0
- package/dist/dts/types/utils.d.ts.map +1 -0
- package/dist/dts/types/wallet.d.ts +241 -0
- package/dist/dts/types/wallet.d.ts.map +1 -0
- package/dist/dts/utils/logger.d.ts +24 -0
- package/dist/dts/utils/logger.d.ts.map +1 -0
- package/dist/index.d.ts +578 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +40 -0
- package/src/FedimintWallet.ts +119 -0
- package/src/WalletDirector.ts +119 -0
- package/src/index.ts +4 -0
- package/src/services/BalanceService.test.ts +26 -0
- package/src/services/BalanceService.ts +29 -0
- package/src/services/FederationService.test.ts +58 -0
- package/src/services/FederationService.ts +216 -0
- package/src/services/LightningService.test.ts +265 -0
- package/src/services/LightningService.ts +289 -0
- package/src/services/MintService.test.ts +74 -0
- package/src/services/MintService.ts +129 -0
- package/src/services/RecoveryService.ts +28 -0
- package/src/services/WalletService.test.ts +59 -0
- package/src/services/WalletService.ts +50 -0
- package/src/services/index.ts +6 -0
- package/src/transport/TransportClient.ts +254 -0
- package/src/transport/index.ts +1 -0
- package/src/types/index.ts +3 -0
- package/src/types/transport.ts +1 -0
- package/src/types/utils.ts +23 -0
- package/src/types/wallet.ts +298 -0
- package/src/utils/logger.ts +69 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
import * as _fedimint_types from '@fedimint/types';
|
|
2
|
+
import { JSONValue, TransportLogger, Transport, TransportMessageType } from '@fedimint/types';
|
|
3
|
+
export * from '@fedimint/types';
|
|
4
|
+
export { JSONValue } from '@fedimint/types';
|
|
5
|
+
|
|
6
|
+
type Alias<T> = T & {};
|
|
7
|
+
type Resolve<T> = T & unknown;
|
|
8
|
+
type Seconds = Alias<number>;
|
|
9
|
+
type Nanos = Alias<number>;
|
|
10
|
+
type Duration = {
|
|
11
|
+
nanos: Nanos;
|
|
12
|
+
secs: Seconds;
|
|
13
|
+
};
|
|
14
|
+
type MSats = Alias<number>;
|
|
15
|
+
type Sats = Alias<number>;
|
|
16
|
+
type JSONObject = Record<string, JSONValue>;
|
|
17
|
+
type Result<T, U = string> = {
|
|
18
|
+
success: true;
|
|
19
|
+
data?: T;
|
|
20
|
+
} | {
|
|
21
|
+
success: false;
|
|
22
|
+
error: U;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
25
|
+
|
|
26
|
+
declare const MODULE_KINDS: readonly ["", "ln", "mint", "wallet"];
|
|
27
|
+
type ModuleKind = (typeof MODULE_KINDS)[number];
|
|
28
|
+
type FederationConfig = JSONObject;
|
|
29
|
+
type GatewayInfo = {
|
|
30
|
+
gateway_id: string;
|
|
31
|
+
api: string;
|
|
32
|
+
node_pub_key: string;
|
|
33
|
+
federation_index: number;
|
|
34
|
+
route_hints: RouteHint[];
|
|
35
|
+
fees: FeeToAmount;
|
|
36
|
+
};
|
|
37
|
+
type LightningGateway = {
|
|
38
|
+
info: GatewayInfo;
|
|
39
|
+
vetted: boolean;
|
|
40
|
+
ttl: Duration;
|
|
41
|
+
};
|
|
42
|
+
type RouteHint = {};
|
|
43
|
+
type FeeToAmount = {};
|
|
44
|
+
type OutgoingLightningPayment = {
|
|
45
|
+
payment_type: PayType;
|
|
46
|
+
contract_id: string;
|
|
47
|
+
fee: MSats;
|
|
48
|
+
};
|
|
49
|
+
type PayType = {
|
|
50
|
+
lightning: string;
|
|
51
|
+
} | {
|
|
52
|
+
internal: string;
|
|
53
|
+
};
|
|
54
|
+
type LnPayState = 'created' | 'canceled' | {
|
|
55
|
+
funded: {
|
|
56
|
+
block_height: number;
|
|
57
|
+
};
|
|
58
|
+
} | {
|
|
59
|
+
waiting_for_refund: {
|
|
60
|
+
error_reason: string;
|
|
61
|
+
};
|
|
62
|
+
} | 'awaiting_change' | {
|
|
63
|
+
success: {
|
|
64
|
+
preimage: string;
|
|
65
|
+
};
|
|
66
|
+
} | {
|
|
67
|
+
refunded: {
|
|
68
|
+
gateway_error: string;
|
|
69
|
+
};
|
|
70
|
+
} | {
|
|
71
|
+
unexpected_error: {
|
|
72
|
+
error_message: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
type LnReceiveState = 'created' | {
|
|
76
|
+
waiting_for_payment: {
|
|
77
|
+
invoice: string;
|
|
78
|
+
timeout: number;
|
|
79
|
+
};
|
|
80
|
+
} | {
|
|
81
|
+
canceled: {
|
|
82
|
+
reason: string;
|
|
83
|
+
};
|
|
84
|
+
} | 'funded' | 'awaiting_funds' | 'claimed';
|
|
85
|
+
type LnInternalPayState = 'funding' | {
|
|
86
|
+
preimage: string;
|
|
87
|
+
} | {
|
|
88
|
+
refund_success: {
|
|
89
|
+
out_points: BtcOutPoint[];
|
|
90
|
+
error: string;
|
|
91
|
+
};
|
|
92
|
+
} | {
|
|
93
|
+
refund_error: {
|
|
94
|
+
error_message: string;
|
|
95
|
+
error: string;
|
|
96
|
+
};
|
|
97
|
+
} | {
|
|
98
|
+
funding_failed: {
|
|
99
|
+
error: string;
|
|
100
|
+
};
|
|
101
|
+
} | {
|
|
102
|
+
unexpected_error: string;
|
|
103
|
+
};
|
|
104
|
+
type CreateBolt11Response = {
|
|
105
|
+
operation_id: string;
|
|
106
|
+
invoice: string;
|
|
107
|
+
};
|
|
108
|
+
type StreamError = {
|
|
109
|
+
error: string;
|
|
110
|
+
data: never;
|
|
111
|
+
end: never;
|
|
112
|
+
};
|
|
113
|
+
type StreamSuccess<T extends JSONValue> = {
|
|
114
|
+
data: T;
|
|
115
|
+
error: never;
|
|
116
|
+
end: never;
|
|
117
|
+
};
|
|
118
|
+
type StreamEnd = {
|
|
119
|
+
end: string;
|
|
120
|
+
data: never;
|
|
121
|
+
error: never;
|
|
122
|
+
};
|
|
123
|
+
type StreamResult<T extends JSONValue> = StreamSuccess<T> | StreamError | StreamEnd;
|
|
124
|
+
type CancelFunction = () => void;
|
|
125
|
+
type ReissueExternalNotesState = 'Created' | 'Issuing' | 'Done';
|
|
126
|
+
type MintSpendNotesResponse = Array<string>;
|
|
127
|
+
type SpendNotesState = 'Created' | 'UserCanceledProcessing' | 'UserCanceledSuccess' | 'UserCanceledFailure' | 'Success' | 'Refunded';
|
|
128
|
+
type TxOutputSummary = {
|
|
129
|
+
outpoint: {
|
|
130
|
+
txid: string;
|
|
131
|
+
vout: number;
|
|
132
|
+
};
|
|
133
|
+
amount: number;
|
|
134
|
+
};
|
|
135
|
+
type BtcOutPoint = {
|
|
136
|
+
txid: string;
|
|
137
|
+
vout: number;
|
|
138
|
+
};
|
|
139
|
+
type WalletDepositState = 'WaitingForTransaction' | {
|
|
140
|
+
WaitingForConfirmation: {
|
|
141
|
+
btc_deposited: number;
|
|
142
|
+
btc_out_point: BtcOutPoint;
|
|
143
|
+
};
|
|
144
|
+
} | {
|
|
145
|
+
Confirmed: {
|
|
146
|
+
btc_deposited: number;
|
|
147
|
+
btc_out_point: BtcOutPoint;
|
|
148
|
+
};
|
|
149
|
+
} | {
|
|
150
|
+
Claimed: {
|
|
151
|
+
btc_deposited: number;
|
|
152
|
+
btc_out_point: BtcOutPoint;
|
|
153
|
+
};
|
|
154
|
+
} | {
|
|
155
|
+
Failed: string;
|
|
156
|
+
};
|
|
157
|
+
type WalletSummary = {
|
|
158
|
+
spendable_utxos: TxOutputSummary[];
|
|
159
|
+
unsigned_peg_out_txos: TxOutputSummary[];
|
|
160
|
+
unsigned_change_utxos: TxOutputSummary[];
|
|
161
|
+
unconfirmed_peg_out_txos: TxOutputSummary[];
|
|
162
|
+
unconfirmed_change_utxos: TxOutputSummary[];
|
|
163
|
+
};
|
|
164
|
+
type LnVariant = {
|
|
165
|
+
pay?: {
|
|
166
|
+
gateway_id: string;
|
|
167
|
+
invoice: string;
|
|
168
|
+
fee: number;
|
|
169
|
+
is_internal_payment: boolean;
|
|
170
|
+
out_point: {
|
|
171
|
+
out_idx: number;
|
|
172
|
+
txid: string;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
receive?: {
|
|
176
|
+
gateway_id: string;
|
|
177
|
+
invoice: string;
|
|
178
|
+
out_point: {
|
|
179
|
+
out_idx: number;
|
|
180
|
+
txid: string;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
type MintVariant = {
|
|
185
|
+
spend_o_o_b?: {
|
|
186
|
+
requested_amount: number;
|
|
187
|
+
oob_notes: string;
|
|
188
|
+
};
|
|
189
|
+
reissuance?: {
|
|
190
|
+
txid: string;
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
type WalletVariant = {
|
|
194
|
+
deposit?: {
|
|
195
|
+
address: string;
|
|
196
|
+
tweak_idx: number;
|
|
197
|
+
};
|
|
198
|
+
withdraw?: {
|
|
199
|
+
address: string;
|
|
200
|
+
amountMsats: number;
|
|
201
|
+
fee: {
|
|
202
|
+
fee_rate: {
|
|
203
|
+
sats_per_kvb: number;
|
|
204
|
+
};
|
|
205
|
+
total_weight: number;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
type OperationKey = {
|
|
210
|
+
creation_time: {
|
|
211
|
+
nanos_since_epoch: number;
|
|
212
|
+
secs_since_epoch: number;
|
|
213
|
+
};
|
|
214
|
+
operation_id: string;
|
|
215
|
+
};
|
|
216
|
+
type OperationMeta = {
|
|
217
|
+
amount: number;
|
|
218
|
+
extra_meta: JSONObject;
|
|
219
|
+
variant: LnVariant | MintVariant | WalletVariant;
|
|
220
|
+
};
|
|
221
|
+
type OperationLog = {
|
|
222
|
+
meta: OperationMeta;
|
|
223
|
+
operation_module_kind: string;
|
|
224
|
+
outcome: {
|
|
225
|
+
outcome: LnPayState | LnReceiveState | SpendNotesState | WalletDepositState;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
type BaseTransactions = {
|
|
229
|
+
timestamp: number;
|
|
230
|
+
operationId: string;
|
|
231
|
+
kind: 'ln' | 'mint' | 'wallet';
|
|
232
|
+
};
|
|
233
|
+
type LightningTransaction = BaseTransactions & {
|
|
234
|
+
type: 'send' | 'receive';
|
|
235
|
+
invoice: string;
|
|
236
|
+
outcome: 'created' | 'canceled' | 'claimed' | 'pending' | 'success' | 'funded' | 'awaiting_funds' | 'unexpected_error';
|
|
237
|
+
gateway: string;
|
|
238
|
+
fee?: number;
|
|
239
|
+
internalPay?: boolean;
|
|
240
|
+
preimage?: string;
|
|
241
|
+
txId: string;
|
|
242
|
+
};
|
|
243
|
+
type EcashTransaction = BaseTransactions & {
|
|
244
|
+
type: 'spend_oob' | 'reissue';
|
|
245
|
+
amountMsats: number;
|
|
246
|
+
outcome?: SpendNotesState | ReissueExternalNotesState;
|
|
247
|
+
notes?: string;
|
|
248
|
+
txId?: string;
|
|
249
|
+
};
|
|
250
|
+
type WalletTransaction = BaseTransactions & {
|
|
251
|
+
type: 'withdraw' | 'deposit';
|
|
252
|
+
onchainAddress: string;
|
|
253
|
+
amountMsats: number;
|
|
254
|
+
fee: number;
|
|
255
|
+
outcome?: 'WaitingForTransaction' | 'WaitingForConfirmation' | 'Confirmed' | 'Claimed' | 'Failed';
|
|
256
|
+
};
|
|
257
|
+
type Transactions = LightningTransaction | EcashTransaction | WalletTransaction;
|
|
258
|
+
/** Keys are powers of 2 */
|
|
259
|
+
type NoteCountByDenomination = Record<number, number>;
|
|
260
|
+
type GenerateAddressResponse = {
|
|
261
|
+
deposit_address: string;
|
|
262
|
+
operation_id: string;
|
|
263
|
+
};
|
|
264
|
+
//# sourceMappingURL=wallet.d.ts.map
|
|
265
|
+
|
|
266
|
+
declare const logLevels: readonly ["debug", "info", "warn", "error", "none"];
|
|
267
|
+
type LogLevel = (typeof logLevels)[number];
|
|
268
|
+
declare class Logger {
|
|
269
|
+
private level;
|
|
270
|
+
private logger;
|
|
271
|
+
/**
|
|
272
|
+
* Generic Logger for a given environment.
|
|
273
|
+
*
|
|
274
|
+
* @param _logger - The transport's logger to use. (console for web, react native, etc.)
|
|
275
|
+
* @param level - The log level to use. (debug, info, warn, error, none)
|
|
276
|
+
*/
|
|
277
|
+
constructor(_logger?: TransportLogger, level?: LogLevel);
|
|
278
|
+
setLevel(level: LogLevel): void;
|
|
279
|
+
private coerceLevel;
|
|
280
|
+
log(level: string, message: string, ...args: any[]): void;
|
|
281
|
+
debug(message: string, ...args: any[]): void;
|
|
282
|
+
info(message: string, ...args: any[]): void;
|
|
283
|
+
warn(message: string, ...args: any[]): void;
|
|
284
|
+
error(message: string, ...args: any[]): void;
|
|
285
|
+
private shouldLog;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Handles communication with a generic transport.
|
|
290
|
+
* Must be instantiated with a platform-specific transport. (wasm for web, react native, etc.)
|
|
291
|
+
*/
|
|
292
|
+
declare class TransportClient {
|
|
293
|
+
private readonly transport;
|
|
294
|
+
private requestCounter;
|
|
295
|
+
private requestCallbacks;
|
|
296
|
+
private initPromise;
|
|
297
|
+
logger: Logger;
|
|
298
|
+
/**
|
|
299
|
+
* @summary Constructor for the TransportClient
|
|
300
|
+
* @param transport - The platform-specific transport to use. (wasm for web, react native, etc.)
|
|
301
|
+
*/
|
|
302
|
+
constructor(transport: Transport);
|
|
303
|
+
initialize(): Promise<boolean>;
|
|
304
|
+
private handleLogMessage;
|
|
305
|
+
private handleTransportError;
|
|
306
|
+
private handleTransportMessage;
|
|
307
|
+
sendSingleMessage<Response extends JSONValue = JSONValue, Payload extends JSONValue = JSONValue>(type: TransportMessageType, payload?: Payload): Promise<Response>;
|
|
308
|
+
/**
|
|
309
|
+
* @summary Initiates an RPC stream with the specified module and method.
|
|
310
|
+
*
|
|
311
|
+
* @description
|
|
312
|
+
* This function sets up an RPC stream by sending a request to a worker and
|
|
313
|
+
* handling responses asynchronously. It ensures that unsubscription is handled
|
|
314
|
+
* correctly, even if the unsubscribe function is called before the subscription
|
|
315
|
+
* is fully established, by deferring the unsubscription attempt using `setTimeout`.
|
|
316
|
+
*
|
|
317
|
+
* The function operates in a non-blocking manner, leveraging Promises to manage
|
|
318
|
+
* asynchronous operations and callbacks to handle responses.
|
|
319
|
+
*
|
|
320
|
+
*
|
|
321
|
+
* @template Response - The expected type of the successful response.
|
|
322
|
+
* @template Body - The type of the request body.
|
|
323
|
+
* @param module - The module kind to interact with.
|
|
324
|
+
* @param method - The method name to invoke on the module.
|
|
325
|
+
* @param body - The request payload.
|
|
326
|
+
* @param onSuccess - Callback invoked with the response data on success.
|
|
327
|
+
* @param onError - Callback invoked with error information if an error occurs.
|
|
328
|
+
* @param onEnd - Optional callback invoked when the stream ends.
|
|
329
|
+
* @returns A function that can be called to cancel the subscription.
|
|
330
|
+
*
|
|
331
|
+
*/
|
|
332
|
+
rpcStream<Response extends JSONValue = JSONValue, Body extends JSONValue = JSONValue>(module: ModuleKind, method: string, body: Body, onSuccess: (res: Response) => void, onError: (res: StreamError['error']) => void, onEnd?: () => void): CancelFunction;
|
|
333
|
+
private _rpcStreamInner;
|
|
334
|
+
rpcSingle<Response extends JSONValue = JSONValue, Error extends string = string>(module: ModuleKind, method: string, body: JSONValue): Promise<Response>;
|
|
335
|
+
cleanup(): Promise<void>;
|
|
336
|
+
_getRequestCounter(): number;
|
|
337
|
+
_getRequestCallbackMap(): Map<number, (value: any) => void>;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
declare class MintService {
|
|
341
|
+
private client;
|
|
342
|
+
constructor(client: TransportClient);
|
|
343
|
+
/** https://web.fedimint.org/core/FedimintWallet/MintService/redeemEcash */
|
|
344
|
+
redeemEcash(notes: string): Promise<string>;
|
|
345
|
+
reissueExternalNotes(oobNotes: string, extraMeta?: JSONObject): Promise<string>;
|
|
346
|
+
subscribeReissueExternalNotes(operationId: string, onSuccess?: (state: ReissueExternalNotesState) => void, onError?: (error: string) => void): CancelFunction;
|
|
347
|
+
/** https://web.fedimint.org/core/FedimintWallet/MintService/spendNotes */
|
|
348
|
+
spendNotes(amountMsats: number, tryCancelAfter?: number | Duration, // defaults to 1 day
|
|
349
|
+
includeInvite?: boolean, extraMeta?: JSONValue): Promise<{
|
|
350
|
+
notes: string;
|
|
351
|
+
operation_id: string;
|
|
352
|
+
}>;
|
|
353
|
+
/** https://web.fedimint.org/core/FedimintWallet/MintService/parseEcash */
|
|
354
|
+
parseNotes(oobNotes: string): Promise<number>;
|
|
355
|
+
tryCancelSpendNotes(operationId: string): Promise<void>;
|
|
356
|
+
subscribeSpendNotes(operationId: string, onSuccess?: (state: SpendNotesState) => void, onError?: (error: string) => void): CancelFunction;
|
|
357
|
+
awaitSpendOobRefund(operationId: string): Promise<JSONValue>;
|
|
358
|
+
getNotesByDenomination(): Promise<NoteCountByDenomination>;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Balance Service
|
|
363
|
+
*
|
|
364
|
+
* The Balance Service provides methods to interact with the balance of a Fedimint wallet.
|
|
365
|
+
*/
|
|
366
|
+
declare class BalanceService {
|
|
367
|
+
private client;
|
|
368
|
+
constructor(client: TransportClient);
|
|
369
|
+
/** https://web.fedimint.org/core/FedimintWallet/BalanceService/getBalance */
|
|
370
|
+
getBalance(): Promise<number>;
|
|
371
|
+
/** https://web.fedimint.org/core/FedimintWallet/BalanceService/subscribeBalance */
|
|
372
|
+
subscribeBalance(onSuccess?: (balanceMsats: number) => void, onError?: (error: string) => void): CancelFunction;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
declare class LightningService {
|
|
376
|
+
private client;
|
|
377
|
+
constructor(client: TransportClient);
|
|
378
|
+
/** https://web.fedimint.org/core/FedimintWallet/LightningService/createInvoice#lightning-createinvoice */
|
|
379
|
+
createInvoice(amountMsats: number, description: string, expiryTime?: number, // in seconds
|
|
380
|
+
gatewayInfo?: GatewayInfo, extraMeta?: JSONObject): Promise<CreateBolt11Response>;
|
|
381
|
+
createInvoiceTweaked(amountMsats: number, description: string, tweakKey: string, index: number, expiryTime?: number, // in seconds
|
|
382
|
+
gatewayInfo?: GatewayInfo, extraMeta?: JSONObject): Promise<CreateBolt11Response>;
|
|
383
|
+
scanReceivesForTweaks(tweakKey: string, indices: number[], extraMeta?: JSONObject): Promise<string[]>;
|
|
384
|
+
private _getDefaultGatewayInfo;
|
|
385
|
+
/** https://web.fedimint.org/core/FedimintWallet/LightningService/payInvoice#lightning-payinvoice-invoice-string */
|
|
386
|
+
payInvoice(invoice: string, gatewayInfo?: GatewayInfo, extraMeta?: JSONObject): Promise<OutgoingLightningPayment>;
|
|
387
|
+
/** https://web.fedimint.org/core/FedimintWallet/LightningService/payInvoice#lightning-payinvoicesync-invoice-string */
|
|
388
|
+
payInvoiceSync(invoice: string, timeoutMs?: number, gatewayInfo?: GatewayInfo, extraMeta?: JSONObject): Promise<{
|
|
389
|
+
success: false;
|
|
390
|
+
error?: string;
|
|
391
|
+
} | {
|
|
392
|
+
success: true;
|
|
393
|
+
data: {
|
|
394
|
+
feeMsats: number;
|
|
395
|
+
preimage: string;
|
|
396
|
+
};
|
|
397
|
+
}>;
|
|
398
|
+
subscribeInternalPayment(operation_id: string, onSuccess?: (state: LnInternalPayState) => void, onError?: (error: string) => void): CancelFunction;
|
|
399
|
+
subscribeLnClaim(operationId: string, onSuccess?: (state: LnReceiveState) => void, onError?: (error: string) => void): CancelFunction;
|
|
400
|
+
/** https://web.fedimint.org/core/FedimintWallet/LightningService/payInvoice#lightning-payinvoice-invoice-string */
|
|
401
|
+
subscribeLnPay(operationId: string, onSuccess?: (state: LnPayState) => void, onError?: (error: string) => void): CancelFunction;
|
|
402
|
+
/** https://web.fedimint.org/core/FedimintWallet/LightningService/payInvoice#lightning-payinvoice-invoice-string */
|
|
403
|
+
waitForPay(operationId: string): Promise<{
|
|
404
|
+
success: false;
|
|
405
|
+
error?: string;
|
|
406
|
+
} | {
|
|
407
|
+
success: true;
|
|
408
|
+
data: {
|
|
409
|
+
preimage: string;
|
|
410
|
+
};
|
|
411
|
+
}>;
|
|
412
|
+
/** https://web.fedimint.org/core/FedimintWallet/LightningService/createInvoice#lightning-createinvoice */
|
|
413
|
+
subscribeLnReceive(operationId: string, onSuccess?: (state: LnReceiveState) => void, onError?: (error: string) => void): CancelFunction;
|
|
414
|
+
/** https://web.fedimint.org/core/FedimintWallet/LightningService/createInvoice#lightning-createinvoice */
|
|
415
|
+
waitForReceive(operationId: string, timeoutMs?: number): Promise<LnReceiveState>;
|
|
416
|
+
getGateway(gatewayId?: string | null, forceInternal?: boolean): Promise<LightningGateway | null>;
|
|
417
|
+
listGateways(): Promise<LightningGateway[]>;
|
|
418
|
+
updateGatewayCache(): Promise<_fedimint_types.JSONValue>;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
declare class RecoveryService {
|
|
422
|
+
private client;
|
|
423
|
+
constructor(client: TransportClient);
|
|
424
|
+
hasPendingRecoveries(): Promise<boolean>;
|
|
425
|
+
waitForAllRecoveries(): Promise<void>;
|
|
426
|
+
subscribeToRecoveryProgress(onSuccess: (progress: {
|
|
427
|
+
module_id: number;
|
|
428
|
+
progress: JSONValue;
|
|
429
|
+
}) => void, onError: (error: string) => void): CancelFunction;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
declare class FederationService {
|
|
433
|
+
private client;
|
|
434
|
+
constructor(client: TransportClient);
|
|
435
|
+
getConfig(): Promise<_fedimint_types.JSONValue>;
|
|
436
|
+
getFederationId(): Promise<string>;
|
|
437
|
+
getInviteCode(peer?: number): Promise<string | null>;
|
|
438
|
+
listOperations(limit?: number, last_seen?: OperationKey): Promise<[OperationKey, OperationLog][]>;
|
|
439
|
+
getOperation(operationId: string): Promise<OperationLog | null>;
|
|
440
|
+
listTransactions(limit?: number, last_seen?: OperationKey): Promise<Transactions[]>;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
declare class WalletService {
|
|
444
|
+
private client;
|
|
445
|
+
constructor(client: TransportClient);
|
|
446
|
+
getWalletSummary(): Promise<WalletSummary>;
|
|
447
|
+
generateAddress(extraMeta?: JSONValue): Promise<GenerateAddressResponse>;
|
|
448
|
+
sendOnchain(amountSat: number, address: string, extraMeta?: JSONValue): Promise<{
|
|
449
|
+
operation_id: string;
|
|
450
|
+
}>;
|
|
451
|
+
subscribeDeposit(operation_id: string, onSuccess?: (state: WalletDepositState) => void, onError?: (error: string) => void): CancelFunction;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
declare class FedimintWallet {
|
|
455
|
+
private _client;
|
|
456
|
+
balance: BalanceService;
|
|
457
|
+
mint: MintService;
|
|
458
|
+
lightning: LightningService;
|
|
459
|
+
federation: FederationService;
|
|
460
|
+
recovery: RecoveryService;
|
|
461
|
+
wallet: WalletService;
|
|
462
|
+
private _openPromise;
|
|
463
|
+
private _resolveOpen;
|
|
464
|
+
private _isOpen;
|
|
465
|
+
/**
|
|
466
|
+
* Creates a new instance of FedimintWallet.
|
|
467
|
+
*
|
|
468
|
+
* This constructor initializes a FedimintWallet instance, which manages communication
|
|
469
|
+
* with a Web Worker. The Web Worker is responsible for running WebAssembly code that
|
|
470
|
+
* handles the core Fedimint Client operations.
|
|
471
|
+
*
|
|
472
|
+
* (default) When not in lazy mode, the constructor immediately initializes the
|
|
473
|
+
* Web Worker and begins loading the WebAssembly module in the background. This
|
|
474
|
+
* allows for faster subsequent operations but may increase initial load time.
|
|
475
|
+
*
|
|
476
|
+
* In lazy mode, the Web Worker and WebAssembly initialization are deferred until
|
|
477
|
+
* the first operation that requires them, reducing initial overhead at the cost
|
|
478
|
+
* of a slight delay on the first operation.
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* // Create a wallet with immediate initialization
|
|
482
|
+
* const wallet = new FedimintWallet();
|
|
483
|
+
* wallet.open();
|
|
484
|
+
*
|
|
485
|
+
* // Create a wallet with lazy initialization
|
|
486
|
+
* const lazyWallet = new FedimintWallet(true);
|
|
487
|
+
* // Some time later...
|
|
488
|
+
* lazyWallet.initialize();
|
|
489
|
+
* lazyWallet.open();
|
|
490
|
+
*/
|
|
491
|
+
constructor(_client: TransportClient);
|
|
492
|
+
waitForOpen(): Promise<void>;
|
|
493
|
+
open(clientName?: string): Promise<boolean>;
|
|
494
|
+
joinFederation(inviteCode: string, clientName?: string): Promise<boolean>;
|
|
495
|
+
/**
|
|
496
|
+
* This should ONLY be called when UNLOADING the wallet client.
|
|
497
|
+
* After this call, the FedimintWallet instance should be discarded.
|
|
498
|
+
*/
|
|
499
|
+
cleanup(): Promise<void>;
|
|
500
|
+
isOpen(): boolean;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
declare class WalletDirector {
|
|
504
|
+
protected _client: TransportClient;
|
|
505
|
+
/**
|
|
506
|
+
* Creates a new instance of WalletDirector.
|
|
507
|
+
*
|
|
508
|
+
* @param {Transport} [transport] - Optional worker client instance. Provide your
|
|
509
|
+
* own to use a custom transport (e.g. React Native).
|
|
510
|
+
*
|
|
511
|
+
* @param {boolean} lazy - If true, delays Web Worker and WebAssembly initialization
|
|
512
|
+
* until needed. Default is false.
|
|
513
|
+
*/
|
|
514
|
+
constructor(transport: Transport, lazy?: boolean);
|
|
515
|
+
initialize(): Promise<void>;
|
|
516
|
+
createWallet(): Promise<FedimintWallet>;
|
|
517
|
+
previewFederation(inviteCode: string): Promise<{
|
|
518
|
+
config: FederationConfig;
|
|
519
|
+
federation_id: string;
|
|
520
|
+
}>;
|
|
521
|
+
/**
|
|
522
|
+
* Sets the log level for the library.
|
|
523
|
+
* @param level The desired log level ('DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE').
|
|
524
|
+
*/
|
|
525
|
+
setLogLevel(level: LogLevel): void;
|
|
526
|
+
/**
|
|
527
|
+
* Parses a federation invite code and retrieves its details.
|
|
528
|
+
*
|
|
529
|
+
* This method sends the provided invite code to the TransportClient for parsing.
|
|
530
|
+
* The response includes the federation_id and url.
|
|
531
|
+
*
|
|
532
|
+
* @param {string} inviteCode - The invite code to be parsed.
|
|
533
|
+
* @returns {Promise<{ federation_id: string, url: string}>}
|
|
534
|
+
* A promise that resolves to an object containing:
|
|
535
|
+
* - `federation_id`: The id of the feder.
|
|
536
|
+
* - `url`: One of the apipoints to connect to the federation
|
|
537
|
+
*
|
|
538
|
+
* @throws {Error} If the TransportClient encounters an issue during the parsing process.
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* const inviteCode = "example-invite-code";
|
|
542
|
+
* const parsedCode = await wallet.parseInviteCode(inviteCode);
|
|
543
|
+
* console.log(parsedCode.federation_id, parsedCode.url);
|
|
544
|
+
*/
|
|
545
|
+
parseInviteCode(inviteCode: string): Promise<{
|
|
546
|
+
type: string;
|
|
547
|
+
data: JSONValue;
|
|
548
|
+
requestId: number;
|
|
549
|
+
}>;
|
|
550
|
+
/**
|
|
551
|
+
* Parses a BOLT11 Lightning invoice and retrieves its details.
|
|
552
|
+
*
|
|
553
|
+
* This method sends the provided invoice string to the TransportClient for parsing.
|
|
554
|
+
* The response includes details such as the amount, expiry, and memo.
|
|
555
|
+
*
|
|
556
|
+
* @param {string} invoiceStr - The BOLT11 invoice string to be parsed.
|
|
557
|
+
* @returns {Promise<{ amount: string, expiry: number, memo: string }>}
|
|
558
|
+
* A promise that resolves to an object containing:
|
|
559
|
+
* - `amount`: The amount specified in the invoice.
|
|
560
|
+
* - `expiry`: The expiry time of the invoice in seconds.
|
|
561
|
+
* - `memo`: A description or memo attached to the invoice.
|
|
562
|
+
*
|
|
563
|
+
* @throws {Error} If the TransportClient encounters an issue during the parsing process.
|
|
564
|
+
*
|
|
565
|
+
* @example
|
|
566
|
+
* const invoiceStr = "lnbc1...";
|
|
567
|
+
* const parsedInvoice = await wallet.parseBolt11Invoice(invoiceStr);
|
|
568
|
+
* console.log(parsedInvoice.amount, parsedInvoice.expiry, parsedInvoice.memo);
|
|
569
|
+
*/
|
|
570
|
+
parseBolt11Invoice(invoiceStr: string): Promise<{
|
|
571
|
+
type: string;
|
|
572
|
+
data: JSONValue;
|
|
573
|
+
requestId: number;
|
|
574
|
+
}>;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export { FedimintWallet, TransportClient, WalletDirector };
|
|
578
|
+
export type { Alias, CancelFunction, CreateBolt11Response, Duration, EcashTransaction, FederationConfig, FeeToAmount, GatewayInfo, GenerateAddressResponse, JSONObject, LightningGateway, LightningTransaction, LnInternalPayState, LnPayState, LnReceiveState, LnVariant, MSats, MintSpendNotesResponse, MintVariant, ModuleKind, NoteCountByDenomination, OperationKey, OperationLog, OutgoingLightningPayment, PayType, ReissueExternalNotesState, Resolve, Result, RouteHint, Sats, SpendNotesState, StreamError, StreamResult, StreamSuccess, Transactions, TxOutputSummary, WalletDepositState, WalletSummary, WalletTransaction, WalletVariant };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=["debug","info","warn","error","none"];class t{constructor(e=console,t="none"){this.logger=e,this.level=t}setLevel(e){this.level=e}coerceLevel(t){return e.includes(t.toLocaleUpperCase())?t.toLocaleUpperCase():"info"}log(e,t,...i){const n=this.coerceLevel(e);if(!this.shouldLog(n))return;(0,this.logger[n])(`[${n.toUpperCase()}] ${t}`,...i)}debug(e,...t){this.log("debug",e,...t)}info(e,...t){this.log("info",e,...t)}warn(e,...t){this.log("warn",e,...t)}error(e,...t){this.log("error",e,...t)}shouldLog(e){const t=["debug","info","warn","error","none"],i=t.indexOf(e);return t.indexOf(this.level)<=i&&"none"!==this.level&&"none"!==e}}class i{constructor(e){this.requestCounter=0,this.requestCallbacks=new Map,this.initPromise=void 0,this.handleTransportError=e=>{this.logger.error("TransportClient error",e)},this.handleTransportMessage=e=>{const{type:t,requestId:i,...n}=e;"log"===t&&this.handleLogMessage(e);const s=void 0!==i?this.requestCallbacks.get(i):void 0;this.logger.debug("TransportClient - handleTransportMessage",e),s?s(n):void 0!==i&&this.logger.warn("TransportClient - handleTransportMessage - received message with no callback",i,e)},this.transport=e,this.logger=new t(e.logger),this.transport.setMessageHandler(this.handleTransportMessage),this.transport.setErrorHandler(this.handleTransportError),this.logger.info("TransportClient instantiated"),this.logger.debug("TransportClient transport",e)}initialize(){return this.initPromise||(this.initPromise=this.sendSingleMessage("init")),this.initPromise}handleLogMessage(e){const{type:t,level:i,message:n,...s}=e;this.logger.info(String(i),String(n),s)}sendSingleMessage(e,t){return new Promise(((i,n)=>{const s=++this.requestCounter;this.logger.debug("TransportClient - sendSingleMessage",s,e,t),this.requestCallbacks.set(s,(e=>{this.requestCallbacks.delete(s),this.logger.debug("TransportClient - sendSingleMessage - response",s,e),e.data?i(e.data):e.error?n(e.error):this.logger.warn("TransportClient - sendSingleMessage - malformed response",s,e)})),this.transport.postMessage({type:e,payload:t,requestId:s})}))}rpcStream(e,t,i,n,s,r=()=>{}){const a=++this.requestCounter;this.logger.debug("TransportClient - rpcStream",a,e,t,i);let o=()=>{},c=!1;const l=new Promise((e=>{o=()=>{c?e():setTimeout((()=>o()),0)}}));return this._rpcStreamInner(a,e,t,i,n,s,r,l).then((()=>{c=!0})),o}async _rpcStreamInner(e,t,i,n,s,r,a=()=>{},o){this.requestCallbacks.set(e,(t=>{void 0!==t.error?r(t.error):void 0!==t.data?s(t.data):void 0!==t.end&&(this.requestCallbacks.delete(e),a())})),this.transport.postMessage({type:"rpc",payload:{module:t,method:i,body:n},requestId:e}),o.then((()=>{this.transport.postMessage({type:"unsubscribe",requestId:e}),this.requestCallbacks.delete(e)}))}rpcSingle(e,t,i){return this.logger.debug("TransportClient - rpcSingle",e,t,i),new Promise(((n,s)=>{this.rpcStream(e,t,i,n,s)}))}async cleanup(){await this.sendSingleMessage("cleanup"),this.requestCounter=0,this.initPromise=void 0,this.requestCallbacks.clear()}_getRequestCounter(){return this.requestCounter}_getRequestCallbackMap(){return this.requestCallbacks}}class n{constructor(e){this.client=e}async redeemEcash(e){return await this.client.rpcSingle("mint","reissue_external_notes",{oob_notes:e,extra_meta:null})}async reissueExternalNotes(e,t={}){return await this.client.rpcSingle("mint","reissue_external_notes",{oob_notes:e,extra_meta:t})}subscribeReissueExternalNotes(e,t=()=>{},i=()=>{}){return this.client.rpcStream("mint","subscribe_reissue_external_notes",{operation_id:e},t,i)}async spendNotes(e,t=86400,i=!1,n={}){const s="number"==typeof t?{nanos:0,secs:t}:t,r=await this.client.rpcSingle("mint","spend_notes",{amount:e,try_cancel_after:s,include_invite:i,extra_meta:n});return{notes:r[1],operation_id:r[0]}}async parseNotes(e){return await this.client.rpcSingle("mint","validate_notes",{oob_notes:e})}async tryCancelSpendNotes(e){await this.client.rpcSingle("mint","try_cancel_spend_notes",{operation_id:e})}subscribeSpendNotes(e,t=()=>{},i=()=>{}){return this.client.rpcStream("mint","subscribe_spend_notes",{operation_id:e},(e=>t(e)),i)}async awaitSpendOobRefund(e){return await this.client.rpcSingle("mint","await_spend_oob_refund",{operation_id:e})}async getNotesByDenomination(){return await this.client.rpcSingle("mint","note_counts_by_denomination",{})}}class s{constructor(e){this.client=e}async getBalance(){return await this.client.rpcSingle("","get_balance",{})}subscribeBalance(e=()=>{},t=()=>{}){return this.client.rpcStream("","subscribe_balance_changes",{},(t=>e(parseInt(t))),t)}}class r{constructor(e){this.client=e}async createInvoice(e,t,i,n,s){const r=n??await this._getDefaultGatewayInfo();return await this.client.rpcSingle("ln","create_bolt11_invoice",{amount:e,description:t,expiry_time:i??null,extra_meta:s??{},gateway:r})}async createInvoiceTweaked(e,t,i,n,s,r,a){const o=r??await this._getDefaultGatewayInfo();return await this.client.rpcSingle("ln","create_bolt11_invoice_for_user_tweaked",{amount:e,description:t,expiry_time:s??null,user_key:i,index:n,extra_meta:a??{},gateway:o})}async scanReceivesForTweaks(e,t,i){return await this.client.rpcSingle("ln","scan_receive_for_user_tweaked",{user_key:e,indices:t,extra_meta:i??{}})}async _getDefaultGatewayInfo(){await this.updateGatewayCache();const e=await this.listGateways();return e[0]?.info}async payInvoice(e,t,i){const n=t??await this._getDefaultGatewayInfo();return await this.client.rpcSingle("ln","pay_bolt11_invoice",{maybe_gateway:n,invoice:e,extra_meta:i??{}})}async payInvoiceSync(e,t=1e4,i,n){return new Promise((async(s,r)=>{const{contract_id:a,fee:o}=await this.payInvoice(e,i,n),c=this.subscribeLnPay(a,(e=>{"string"!=typeof e&&"success"in e?(clearTimeout(l),c(),s({success:!0,data:{feeMsats:o,preimage:e.success.preimage}})):"string"!=typeof e&&"unexpected_error"in e&&r(new Error(e.unexpected_error.error_message))})),l=setTimeout((()=>{c(),s({success:!1,error:"Payment timeout"})}),t)}))}subscribeInternalPayment(e,t=()=>{},i=()=>{}){return this.client.rpcStream("ln","subscribe_internal_pay",{operation_id:e},t,i)}subscribeLnClaim(e,t=()=>{},i=()=>{}){return this.client.rpcStream("ln","subscribe_ln_claim",{operation_id:e},t,i)}subscribeLnPay(e,t=()=>{},i=()=>{}){return this.client.rpcStream("ln","subscribe_ln_pay",{operation_id:e},t,i)}async waitForPay(e){return new Promise(((t,i)=>{let n;const s=setTimeout((()=>{t({success:!1,error:"Waiting for receive timeout"})}),15e3);n=this.subscribeLnPay(e,(e=>{"string"!=typeof e&&"success"in e&&(clearTimeout(s),n(),t({success:!0,data:{preimage:e.success.preimage}}))}),(e=>{clearTimeout(s),n(),i(e)}))}))}subscribeLnReceive(e,t=()=>{},i=()=>{}){return this.client.rpcStream("ln","subscribe_ln_receive",{operation_id:e},t,i)}async waitForReceive(e,t=15e3){return new Promise(((i,n)=>{let s;const r=setTimeout((()=>{n(new Error("Timeout waiting for receive"))}),t);s=this.subscribeLnReceive(e,(e=>{"claimed"===e&&(clearTimeout(r),s(),i(e))}),(e=>{clearTimeout(r),s(),n(e)}))}))}async getGateway(e=null,t=!1){return await this.client.rpcSingle("ln","get_gateway",{gateway_id:e,force_internal:t})}async listGateways(){return await this.client.rpcSingle("ln","list_gateways",{})}async updateGatewayCache(){return await this.client.rpcSingle("ln","update_gateway_cache",{})}}class a{constructor(e){this.client=e}async hasPendingRecoveries(){return await this.client.rpcSingle("","has_pending_recoveries",{})}async waitForAllRecoveries(){await this.client.rpcSingle("","wait_for_all_recoveries",{})}subscribeToRecoveryProgress(e,t){return this.client.rpcStream("","subscribe_to_recovery_progress",{},e,t)}}class o{constructor(e){this.client=e}async getConfig(){return await this.client.rpcSingle("","get_config",{})}async getFederationId(){return await this.client.rpcSingle("","get_federation_id",{})}async getInviteCode(e=0){return await this.client.rpcSingle("","get_invite_code",{peer:e})}async listOperations(e,t){return await this.client.rpcSingle("","list_operations",{limit:e??null,last_seen:t??null})}async getOperation(e){return await this.client.rpcSingle("","get_operation",{operation_id:e})}async listTransactions(e,t){return(await this.listOperations(e,t)).filter((e=>Array.isArray(e)&&2===e.length)).filter((([e,t])=>{const{operation_module_kind:i,meta:n}=t,s=n.variant;return"ln"===i&&(s.pay||s.receive)||"mint"===i&&(s.spend_o_o_b||s.reissuance)||"wallet"===i&&(s.deposit||s.withdraw)})).map((([e,t])=>{const i=e.creation_time?Math.round(1e3*e.creation_time.secs_since_epoch+e.creation_time.nanos_since_epoch/1e6):0,n=e.operation_id,s=t.operation_module_kind,r=t.meta,a=r.variant;let o;if(t.outcome&&t.outcome.outcome&&("string"==typeof t.outcome.outcome?o=t.outcome.outcome:"object"==typeof t.outcome.outcome&&null!==t.outcome.outcome&&("success"in t.outcome.outcome?o="success":"canceled"in t.outcome.outcome?o="canceled":"claimed"in t.outcome.outcome?o="claimed":"funded"in t.outcome.outcome?o="funded":"awaiting_funds"in t.outcome.outcome?o="awaiting_funds":"unexpected_error"in t.outcome.outcome?o="unexpected_error":"created"in t.outcome.outcome?o="created":"waiting_for_refund"in t.outcome.outcome?o="canceled":"awaiting_change"in t.outcome.outcome?o="pending":"refunded"in t.outcome.outcome?o="refunded":"waiting_for_payment"in t.outcome.outcome?o="awaiting_funds":"Created"in t.outcome.outcome?o="Created":"Success"in t.outcome.outcome?o="Success":"Refunded"in t.outcome.outcome?o="Refunded":"UserCanceledProcessing"in t.outcome.outcome?o="UserCanceledProcessing":"UserCanceledSuccess"in t.outcome.outcome?o="UserCanceledSuccess":"UserCanceledFailure"in t.outcome.outcome?o="UserCanceledFailure":"WaitingForTransaction"in t.outcome.outcome||"WaitingForConfirmation"in t.outcome.outcome?o="pending":"Confirmed"in t.outcome.outcome?o="Confirmed":"Claimed"in t.outcome.outcome?o="Claimed":"Failed"in t.outcome.outcome&&(o="Failed"))),"ln"===s){const e=!!a.pay,r=a.pay?.out_point.txid||a.receive?.out_point.txid||"",c=a.pay?"send":"receive",l=a.pay?.invoice||a.receive?.invoice||"",u=a.pay?.gateway_id||a.receive?.gateway_id||"",d=a.pay?.fee,p=a.pay?.is_internal_payment;return e&&t.outcome?.outcome&&"object"==typeof t.outcome.outcome&&"success"in t.outcome.outcome&&t.outcome.outcome.success.preimage,{timestamp:i,operationId:n,kind:s,txId:r,type:c,invoice:l,internalPay:p,fee:d,gateway:u,outcome:o}}if("mint"===s){const e=a.reissuance?.txid,t=a.reissuance?"reissue":"spend_oob",c=r.amount,l=a.spend_o_o_b?.oob_notes;return{timestamp:i,type:t,txId:e,outcome:o,operationId:n,amountMsats:c,notes:l,kind:s}}if("wallet"===s){const e=a.deposit?"deposit":"withdraw",t=a.deposit?.address||a.withdraw?.address||"",r=a.withdraw?.fee.fee_rate.sats_per_kvb;return{timestamp:i,type:e,onchainAddress:t,fee:r||0,amountMsats:a.withdraw?.amountMsats||0,outcome:o,kind:s,operationId:n}}})).filter((e=>void 0!==e))}}class c{constructor(e){this.client=e}async getWalletSummary(){return await this.client.rpcSingle("wallet","get_wallet_summary",{})}async generateAddress(e={}){return await this.client.rpcSingle("wallet","peg_in",{extra_meta:e})}async sendOnchain(e,t,i={}){return await this.client.rpcSingle("wallet","peg_out",{amount_sat:e,destination_address:t,extra_meta:i})}subscribeDeposit(e,t=()=>{},i=()=>{}){return this.client.rpcStream("ln","subscribe_deposit",{operation_id:e},t,i)}}const l="fm-default";class u{constructor(e){this._client=e,this._openPromise=void 0,this._resolveOpen=()=>{},this._isOpen=!1,this._openPromise=new Promise((e=>{this._resolveOpen=e})),this.mint=new n(this._client),this.lightning=new r(this._client),this.balance=new s(this._client),this.federation=new o(this._client),this.recovery=new a(this._client),this.wallet=new c(this._client)}async waitForOpen(){return this._isOpen?Promise.resolve():this._openPromise}async open(e=l){if(this._isOpen)throw new Error("The FedimintWallet is already open.");const{success:t}=await this._client.sendSingleMessage("open",{clientName:e});return t&&(this._isOpen=!!t,this._resolveOpen()),t}async joinFederation(e,t=l){if(this._isOpen)throw new Error("The FedimintWallet is already open. You can only call `joinFederation` on closed clients.");try{const i=await this._client.sendSingleMessage("join",{inviteCode:e,clientName:t});return i.success&&(this._isOpen=!0,this._resolveOpen()),i.success}catch(e){return this._client.logger.error("Error joining federation",e),!1}}async cleanup(){this._openPromise=void 0,this._isOpen=!1,await this._client.cleanup()}isOpen(){return this._isOpen}}class d{constructor(e,t=!1){if(!e)throw new Error("WalletDirector requires a transport implementation");this._client=new i(e),this._client.logger.info("WalletDirector instantiated"),t||this.initialize()}async initialize(){this._client.logger.info("Initializing TransportClient"),await this._client.initialize(),this._client.logger.info("TransportClient initialized")}async createWallet(){return await this._client.initialize(),new u(this._client)}async previewFederation(e){await this._client.initialize();return this._client.sendSingleMessage("previewFederation",{inviteCode:e})}setLogLevel(e){this._client.logger.setLevel(e),this._client.logger.info(`Log level set to ${e}.`)}async parseInviteCode(e){await this._client.initialize();return await this._client.sendSingleMessage("parseInviteCode",{inviteCode:e})}async parseBolt11Invoice(e){await this._client.initialize();return await this._client.sendSingleMessage("parseBolt11Invoice",{invoiceStr:e})}}export{i as TransportClient,d as WalletDirector};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/utils/logger.ts","../src/transport/TransportClient.ts","../src/services/MintService.ts","../src/services/BalanceService.ts","../src/services/LightningService.ts","../src/services/RecoveryService.ts","../src/services/FederationService.ts","../src/services/WalletService.ts","../src/FedimintWallet.ts","../src/WalletDirector.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null],"names":["logLevels","Logger","constructor","_logger","console","level","this","logger","setLevel","coerceLevel","includes","toLocaleUpperCase","log","message","args","logLevel","shouldLog","consoleFn","toUpperCase","debug","info","warn","error","messageLevel","levels","messageLevelIndex","indexOf","TransportClient","transport","requestCounter","requestCallbacks","Map","initPromise","undefined","handleTransportError","handleTransportMessage","type","requestId","data","handleLogMessage","streamCallback","get","setMessageHandler","setErrorHandler","initialize","sendSingleMessage","logMessage","String","payload","Promise","resolve","reject","set","response","delete","postMessage","rpcStream","module","method","body","onSuccess","onError","onEnd","unsubscribe","isSubscribed","unsubscribePromise","setTimeout","_rpcStreamInner","then","end","rpcSingle","cleanup","clear","_getRequestCounter","_getRequestCallbackMap","MintService","client","redeemEcash","notes","oob_notes","extra_meta","reissueExternalNotes","oobNotes","extraMeta","subscribeReissueExternalNotes","operationId","operation_id","spendNotes","amountMsats","tryCancelAfter","includeInvite","duration","nanos","secs","res","amount","try_cancel_after","include_invite","parseNotes","tryCancelSpendNotes","subscribeSpendNotes","awaitSpendOobRefund","getNotesByDenomination","BalanceService","getBalance","subscribeBalance","parseInt","LightningService","createInvoice","description","expiryTime","gatewayInfo","gateway","_getDefaultGatewayInfo","expiry_time","createInvoiceTweaked","tweakKey","index","user_key","scanReceivesForTweaks","indices","updateGatewayCache","gateways","listGateways","payInvoice","invoice","maybe_gateway","payInvoiceSync","timeoutMs","async","contract_id","fee","subscribeLnPay","clearTimeout","timeoutId","success","feeMsats","preimage","Error","unexpected_error","error_message","subscribeInternalPayment","subscribeLnClaim","waitForPay","subscribeLnReceive","waitForReceive","getGateway","gatewayId","forceInternal","gateway_id","force_internal","RecoveryService","hasPendingRecoveries","waitForAllRecoveries","subscribeToRecoveryProgress","FederationService","getConfig","getFederationId","getInviteCode","peer","listOperations","limit","last_seen","getOperation","listTransactions","filter","item","Array","isArray","length","_","op","operation_module_kind","meta","variant","pay","receive","spend_o_o_b","reissuance","deposit","withdraw","map","key","timestamp","creation_time","Math","round","secs_since_epoch","nanos_since_epoch","kind","outcome","isPay","txId","out_point","txid","internalPay","is_internal_payment","address","feeRate","fee_rate","sats_per_kvb","onchainAddress","transaction","WalletService","getWalletSummary","generateAddress","sendOnchain","amountSat","amount_sat","destination_address","subscribeDeposit","DEFAULT_CLIENT_NAME","FedimintWallet","_client","_openPromise","_resolveOpen","_isOpen","mint","lightning","balance","federation","recovery","wallet","waitForOpen","open","clientName","joinFederation","inviteCode","e","isOpen","WalletDirector","lazy","createWallet","previewFederation","setLogLevel","parseInviteCode","parseBolt11Invoice","invoiceStr"],"mappings":"AAEA,MAAMA,EAAY,CAAC,QAAS,OAAQ,OAAQ,QAAS,c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