@breeztech/breez-sdk-spark 0.2.5-dev1 → 0.2.6

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.
@@ -275,15 +275,15 @@ module.exports.task_worker_entry_point = function(ptr) {
275
275
  };
276
276
 
277
277
  function __wbg_adapter_52(arg0, arg1) {
278
- wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf7c49586be6831c4(arg0, arg1);
278
+ wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__he5eedad33b9ff4bf(arg0, arg1);
279
279
  }
280
280
 
281
281
  function __wbg_adapter_55(arg0, arg1, arg2) {
282
- wasm.closure772_externref_shim(arg0, arg1, arg2);
282
+ wasm.closure780_externref_shim(arg0, arg1, arg2);
283
283
  }
284
284
 
285
- function __wbg_adapter_180(arg0, arg1, arg2, arg3) {
286
- wasm.closure424_externref_shim(arg0, arg1, arg2, arg3);
285
+ function __wbg_adapter_183(arg0, arg1, arg2, arg3) {
286
+ wasm.closure434_externref_shim(arg0, arg1, arg2, arg3);
287
287
  }
288
288
 
289
289
  const __wbindgen_enum_ReadableStreamType = ["bytes"];
@@ -325,35 +325,28 @@ class BreezSdk {
325
325
  }
326
326
  /**
327
327
  * @param {EventListener} listener
328
- * @returns {string}
328
+ * @returns {Promise<string>}
329
329
  */
330
330
  addEventListener(listener) {
331
- let deferred1_0;
332
- let deferred1_1;
333
- try {
334
- const ret = wasm.breezsdk_addEventListener(this.__wbg_ptr, listener);
335
- deferred1_0 = ret[0];
336
- deferred1_1 = ret[1];
337
- return getStringFromWasm0(ret[0], ret[1]);
338
- } finally {
339
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
340
- }
331
+ const ret = wasm.breezsdk_addEventListener(this.__wbg_ptr, listener);
332
+ return ret;
341
333
  }
342
334
  /**
343
335
  * @param {string} id
344
- * @returns {boolean}
336
+ * @returns {Promise<boolean>}
345
337
  */
346
338
  removeEventListener(id) {
347
339
  const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
348
340
  const len0 = WASM_VECTOR_LEN;
349
341
  const ret = wasm.breezsdk_removeEventListener(this.__wbg_ptr, ptr0, len0);
350
- return ret !== 0;
342
+ return ret;
351
343
  }
344
+ /**
345
+ * @returns {Promise<void>}
346
+ */
352
347
  disconnect() {
353
348
  const ret = wasm.breezsdk_disconnect(this.__wbg_ptr);
354
- if (ret[1]) {
355
- throw takeFromExternrefTable0(ret[0]);
356
- }
349
+ return ret;
357
350
  }
358
351
  /**
359
352
  * @param {GetInfoRequest} request
@@ -405,14 +398,11 @@ class BreezSdk {
405
398
  }
406
399
  /**
407
400
  * @param {SyncWalletRequest} request
408
- * @returns {SyncWalletResponse}
401
+ * @returns {Promise<SyncWalletResponse>}
409
402
  */
410
403
  syncWallet(request) {
411
404
  const ret = wasm.breezsdk_syncWallet(this.__wbg_ptr, request);
412
- if (ret[2]) {
413
- throw takeFromExternrefTable0(ret[1]);
414
- }
415
- return takeFromExternrefTable0(ret[0]);
405
+ return ret;
416
406
  }
417
407
  /**
418
408
  * @param {ListPaymentsRequest} request
@@ -498,6 +488,14 @@ class BreezSdk {
498
488
  const ret = wasm.breezsdk_listFiatRates(this.__wbg_ptr);
499
489
  return ret;
500
490
  }
491
+ /**
492
+ * @param {WaitForPaymentRequest} request
493
+ * @returns {Promise<WaitForPaymentResponse>}
494
+ */
495
+ waitForPayment(request) {
496
+ const ret = wasm.breezsdk_waitForPayment(this.__wbg_ptr, request);
497
+ return ret;
498
+ }
501
499
  }
502
500
  module.exports.BreezSdk = BreezSdk;
503
501
 
@@ -908,6 +906,19 @@ module.exports.__wbg_getPaymentById_c23144bfc404b2fc = function() { return handl
908
906
  }
909
907
  }, arguments) };
910
908
 
909
+ module.exports.__wbg_getPaymentByInvoice_afddfcbefa5508b0 = function() { return handleError(function (arg0, arg1, arg2) {
910
+ let deferred0_0;
911
+ let deferred0_1;
912
+ try {
913
+ deferred0_0 = arg1;
914
+ deferred0_1 = arg2;
915
+ const ret = arg0.getPaymentByInvoice(getStringFromWasm0(arg1, arg2));
916
+ return ret;
917
+ } finally {
918
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
919
+ }
920
+ }, arguments) };
921
+
911
922
  module.exports.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
912
923
  arg0.getRandomValues(arg1);
913
924
  }, arguments) };
@@ -1061,7 +1072,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function(arg0, arg1) {
1061
1072
  const a = state0.a;
1062
1073
  state0.a = 0;
1063
1074
  try {
1064
- return __wbg_adapter_180(a, state0.b, arg0, arg1);
1075
+ return __wbg_adapter_183(a, state0.b, arg0, arg1);
1065
1076
  } finally {
1066
1077
  state0.a = a;
1067
1078
  }
@@ -1424,13 +1435,13 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
1424
1435
  return ret;
1425
1436
  };
1426
1437
 
1427
- module.exports.__wbindgen_closure_wrapper7982 = function(arg0, arg1, arg2) {
1428
- const ret = makeMutClosure(arg0, arg1, 601, __wbg_adapter_52);
1438
+ module.exports.__wbindgen_closure_wrapper8079 = function(arg0, arg1, arg2) {
1439
+ const ret = makeMutClosure(arg0, arg1, 612, __wbg_adapter_52);
1429
1440
  return ret;
1430
1441
  };
1431
1442
 
1432
- module.exports.__wbindgen_closure_wrapper9620 = function(arg0, arg1, arg2) {
1433
- const ret = makeMutClosure(arg0, arg1, 773, __wbg_adapter_55);
1443
+ module.exports.__wbindgen_closure_wrapper9672 = function(arg0, arg1, arg2) {
1444
+ const ret = makeMutClosure(arg0, arg1, 781, __wbg_adapter_55);
1434
1445
  return ret;
1435
1446
  };
1436
1447
 
Binary file
@@ -7,16 +7,16 @@ export const connect: (a: any) => any;
7
7
  export const defaultConfig: (a: any) => any;
8
8
  export const defaultStorage: (a: number, b: number) => any;
9
9
  export const parse: (a: number, b: number) => any;
10
- export const breezsdk_addEventListener: (a: number, b: any) => [number, number];
11
- export const breezsdk_removeEventListener: (a: number, b: number, c: number) => number;
12
- export const breezsdk_disconnect: (a: number) => [number, number];
10
+ export const breezsdk_addEventListener: (a: number, b: any) => any;
11
+ export const breezsdk_removeEventListener: (a: number, b: number, c: number) => any;
12
+ export const breezsdk_disconnect: (a: number) => any;
13
13
  export const breezsdk_getInfo: (a: number, b: any) => any;
14
14
  export const breezsdk_receivePayment: (a: number, b: any) => any;
15
15
  export const breezsdk_prepareSendPayment: (a: number, b: any) => any;
16
16
  export const breezsdk_prepareLnurlPay: (a: number, b: any) => any;
17
17
  export const breezsdk_lnurlPay: (a: number, b: any) => any;
18
18
  export const breezsdk_sendPayment: (a: number, b: any) => any;
19
- export const breezsdk_syncWallet: (a: number, b: any) => [number, number, number];
19
+ export const breezsdk_syncWallet: (a: number, b: any) => any;
20
20
  export const breezsdk_listPayments: (a: number, b: any) => any;
21
21
  export const breezsdk_getPayment: (a: number, b: any) => any;
22
22
  export const breezsdk_claimDeposit: (a: number, b: any) => any;
@@ -28,6 +28,7 @@ export const breezsdk_registerLightningAddress: (a: number, b: any) => any;
28
28
  export const breezsdk_deleteLightningAddress: (a: number) => any;
29
29
  export const breezsdk_listFiatCurrencies: (a: number) => any;
30
30
  export const breezsdk_listFiatRates: (a: number) => any;
31
+ export const breezsdk_waitForPayment: (a: number, b: any) => any;
31
32
  export const __wbg_sdkbuilder_free: (a: number, b: number) => void;
32
33
  export const sdkbuilder_new: (a: any, b: any, c: any) => [number, number, number];
33
34
  export const sdkbuilder_withRestChainService: (a: number, b: number, c: number, d: number) => number;
@@ -59,7 +60,7 @@ export const __externref_table_alloc: () => number;
59
60
  export const __wbindgen_export_5: WebAssembly.Table;
60
61
  export const __wbindgen_export_6: WebAssembly.Table;
61
62
  export const __externref_table_dealloc: (a: number) => void;
62
- export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf7c49586be6831c4: (a: number, b: number) => void;
63
- export const closure772_externref_shim: (a: number, b: number, c: any) => void;
64
- export const closure424_externref_shim: (a: number, b: number, c: any, d: any) => void;
63
+ export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__he5eedad33b9ff4bf: (a: number, b: number) => void;
64
+ export const closure780_externref_shim: (a: number, b: number, c: any) => void;
65
+ export const closure434_externref_shim: (a: number, b: number, c: any, d: any) => void;
65
66
  export const __wbindgen_start: () => void;
@@ -126,11 +126,27 @@ class SqliteStorage {
126
126
  const actualLimit = limit !== null ? limit : 4294967295; // u32::MAX
127
127
 
128
128
  const stmt = this.db.prepare(`
129
- SELECT p.id, p.payment_type, p.status, p.amount, p.fees, p.timestamp, p.details, p.method, pm.lnurl_pay_info, pm.lnurl_description
130
- FROM payments p
131
- LEFT JOIN payment_metadata pm ON p.id = pm.payment_id
132
- ORDER BY p.timestamp DESC
133
- LIMIT ? OFFSET ?
129
+ SELECT p.id
130
+ , p.payment_type
131
+ , p.status
132
+ , p.amount
133
+ , p.fees
134
+ , p.timestamp
135
+ , p.method
136
+ , p.withdraw_tx_id
137
+ , p.deposit_tx_id
138
+ , p.spark
139
+ , l.invoice AS lightning_invoice
140
+ , l.payment_hash AS lightning_payment_hash
141
+ , l.destination_pubkey AS lightning_destination_pubkey
142
+ , COALESCE(l.description, pm.lnurl_description) AS lightning_description
143
+ , l.preimage AS lightning_preimage
144
+ , pm.lnurl_pay_info
145
+ FROM payments p
146
+ LEFT JOIN payment_details_lightning l ON p.id = l.payment_id
147
+ LEFT JOIN payment_metadata pm ON p.id = pm.payment_id
148
+ ORDER BY p.timestamp DESC
149
+ LIMIT ? OFFSET ?
134
150
  `);
135
151
 
136
152
  const rows = stmt.all(actualLimit, actualOffset);
@@ -153,21 +169,42 @@ class SqliteStorage {
153
169
  );
154
170
  }
155
171
 
156
- const stmt = this.db.prepare(`
157
- INSERT OR REPLACE INTO payments (id, payment_type, status, amount, fees, timestamp, details, method)
158
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)
159
- `);
160
-
161
- stmt.run(
162
- payment.id,
163
- payment.paymentType,
164
- payment.status,
165
- payment.amount,
166
- payment.fees,
167
- payment.timestamp,
168
- payment.details ? JSON.stringify(payment.details) : null,
169
- payment.method ? JSON.stringify(payment.method) : null
172
+ const paymentInsert = this.db.prepare(
173
+ `INSERT OR REPLACE INTO payments (id, payment_type, status, amount, fees, timestamp, method, withdraw_tx_id, deposit_tx_id, spark)
174
+ VALUES (@id, @paymentType, @status, @amount, @fees, @timestamp, @method, @withdrawTxId, @depositTxId, @spark)`
175
+ );
176
+ const lightningInsert = this.db.prepare(
177
+ `INSERT OR REPLACE INTO payment_details_lightning
178
+ (payment_id, invoice, payment_hash, destination_pubkey, description, preimage)
179
+ VALUES (@id, @invoice, @paymentHash, @destinationPubkey, @description, @preimage)`
170
180
  );
181
+ const transaction = this.db.transaction(() => {
182
+ paymentInsert.run({
183
+ id: payment.id,
184
+ paymentType: payment.paymentType,
185
+ status: payment.status,
186
+ amount: payment.amount,
187
+ fees: payment.fees,
188
+ timestamp: payment.timestamp,
189
+ method: payment.method ? JSON.stringify(payment.method) : null,
190
+ withdrawTxId: payment.details?.type === 'withdraw' ? payment.details.txId : null,
191
+ depositTxId: payment.details?.type === 'deposit' ? payment.details.txId : null,
192
+ spark: payment.details?.type === 'spark' ? 1 : null,
193
+ });
194
+
195
+ if (payment.details?.type === 'lightning') {
196
+ lightningInsert.run({
197
+ id: payment.id,
198
+ invoice: payment.details.invoice,
199
+ paymentHash: payment.details.paymentHash,
200
+ destinationPubkey: payment.details.destinationPubkey,
201
+ description: payment.details.description,
202
+ preimage: payment.details.preimage,
203
+ });
204
+ }
205
+ });
206
+
207
+ transaction();
171
208
  return Promise.resolve();
172
209
  } catch (error) {
173
210
  return Promise.reject(
@@ -188,10 +225,26 @@ class SqliteStorage {
188
225
  }
189
226
 
190
227
  const stmt = this.db.prepare(`
191
- SELECT p.id, p.payment_type, p.status, p.amount, p.fees, p.timestamp, p.details, p.method, pm.lnurl_pay_info, pm.lnurl_description
192
- FROM payments p
193
- LEFT JOIN payment_metadata pm ON p.id = pm.payment_id
194
- WHERE p.id = ?
228
+ SELECT p.id
229
+ , p.payment_type
230
+ , p.status
231
+ , p.amount
232
+ , p.fees
233
+ , p.timestamp
234
+ , p.method
235
+ , p.withdraw_tx_id
236
+ , p.deposit_tx_id
237
+ , p.spark
238
+ , l.invoice AS lightning_invoice
239
+ , l.payment_hash AS lightning_payment_hash
240
+ , l.destination_pubkey AS lightning_destination_pubkey
241
+ , COALESCE(l.description, pm.lnurl_description) AS lightning_description
242
+ , l.preimage AS lightning_preimage
243
+ , pm.lnurl_pay_info
244
+ FROM payments p
245
+ LEFT JOIN payment_details_lightning l ON p.id = l.payment_id
246
+ LEFT JOIN payment_metadata pm ON p.id = pm.payment_id
247
+ WHERE p.id = ?
195
248
  `);
196
249
 
197
250
  const row = stmt.get(id);
@@ -214,6 +267,55 @@ class SqliteStorage {
214
267
  }
215
268
  }
216
269
 
270
+ getPaymentByInvoice(invoice) {
271
+ try {
272
+ if (!invoice) {
273
+ return Promise.reject(
274
+ new StorageError("Invoice cannot be null or undefined")
275
+ );
276
+ }
277
+
278
+ const stmt = this.db.prepare(`
279
+ SELECT p.id
280
+ , p.payment_type
281
+ , p.status
282
+ , p.amount
283
+ , p.fees
284
+ , p.timestamp
285
+ , p.method
286
+ , p.withdraw_tx_id
287
+ , p.deposit_tx_id
288
+ , p.spark
289
+ , l.invoice AS lightning_invoice
290
+ , l.payment_hash AS lightning_payment_hash
291
+ , l.destination_pubkey AS lightning_destination_pubkey
292
+ , COALESCE(l.description, pm.lnurl_description) AS lightning_description
293
+ , l.preimage AS lightning_preimage
294
+ , pm.lnurl_pay_info
295
+ FROM payments p
296
+ LEFT JOIN payment_details_lightning l ON p.id = l.payment_id
297
+ LEFT JOIN payment_metadata pm ON p.id = pm.payment_id
298
+ WHERE l.invoice = ?
299
+ `);
300
+
301
+ const row = stmt.get(invoice);
302
+ if (!row) {
303
+ return Promise.resolve(null);
304
+ }
305
+
306
+ return Promise.resolve(this._rowToPayment(row));
307
+ } catch (error) {
308
+ if (error instanceof StorageError) return Promise.reject(error);
309
+ const paymentId = id || "unknown";
310
+ return Promise.reject(
311
+ new StorageError(
312
+ `Failed to get payment by invoice '${invoice}': ${error.message}`,
313
+ error
314
+ )
315
+ );
316
+ }
317
+ }
318
+
217
319
  setPaymentMetadata(paymentId, metadata) {
218
320
  try {
219
321
  const stmt = this.db.prepare(`
@@ -340,15 +442,41 @@ class SqliteStorage {
340
442
 
341
443
  _rowToPayment(row) {
342
444
  let details = null;
343
- if (row.details) {
344
- try {
345
- details = JSON.parse(row.details);
346
- } catch (e) {
347
- throw new StorageError(
348
- `Failed to parse payment details JSON for payment ${row.id}: ${e.message}`,
349
- e
350
- );
445
+ if (row.lightning_invoice) {
446
+ details = {
447
+ type: 'lightning',
448
+ invoice: row.lightning_invoice,
449
+ paymentHash: row.lightning_payment_hash,
450
+ destinationPubkey: row.lightning_destination_pubkey,
451
+ description: row.lightning_description,
452
+ preimage: row.lightning_preimage,
453
+ };
454
+
455
+ if (row.lnurl_pay_info) {
456
+ try {
457
+ details.lnurlPayInfo = JSON.parse(row.lnurl_pay_info);
458
+ } catch (e) {
459
+ throw new StorageError(
460
+ `Failed to parse lnurl_pay_info JSON for payment ${row.id}: ${e.message}`,
461
+ e
462
+ );
463
+ }
351
464
  }
465
+ } else if (row.withdraw_tx_id) {
466
+ details = {
467
+ type: 'withdraw',
468
+ txId: row.withdraw_tx_id,
469
+ };
470
+ } else if (row.deposit_tx_id) {
471
+ details = {
472
+ type: 'deposit',
473
+ txId: row.deposit_tx_id,
474
+ };
475
+ } else if (row.spark) {
476
+ details = {
477
+ type: 'spark',
478
+ amount: row.spark,
479
+ };
352
480
  }
353
481
 
354
482
  let method = null;
@@ -363,21 +491,6 @@ class SqliteStorage {
363
491
  }
364
492
  }
365
493
 
366
- // If this is a Lightning payment and we have lnurl_pay_info, add it to details
367
- if (row.lnurl_pay_info && details && details.type == 'lightning') {
368
- try {
369
- details.lnurlPayInfo = JSON.parse(row.lnurl_pay_info);
370
- if (row.lnurl_description && !details.description) {
371
- details.description = row.lnurl_description;
372
- }
373
- } catch (e) {
374
- throw new StorageError(
375
- `Failed to parse lnurl_pay_info JSON for payment ${row.id}: ${e.message}`,
376
- e
377
- );
378
- }
379
- }
380
-
381
494
  return {
382
495
  id: row.id,
383
496
  paymentType: row.payment_type,
@@ -148,6 +148,34 @@ class MigrationManager {
148
148
  {
149
149
  name: "Add lnurl_description column to payment_metadata",
150
150
  sql: `ALTER TABLE payment_metadata ADD COLUMN lnurl_description TEXT`,
151
+ },
152
+ {
153
+ name: "Flatten payment details",
154
+ sql: [
155
+ `ALTER TABLE payments ADD COLUMN withdraw_tx_id TEXT`,
156
+ `ALTER TABLE payments ADD COLUMN deposit_tx_id TEXT`,
157
+ `ALTER TABLE payments ADD COLUMN spark INTEGER`,
158
+ `CREATE TABLE payment_details_lightning (
159
+ payment_id TEXT PRIMARY KEY,
160
+ invoice TEXT NOT NULL,
161
+ payment_hash TEXT NOT NULL,
162
+ destination_pubkey TEXT NOT NULL,
163
+ description TEXT,
164
+ preimage TEXT,
165
+ FOREIGN KEY (payment_id) REFERENCES payments(id) ON DELETE CASCADE
166
+ )`,
167
+ `INSERT INTO payment_details_lightning (payment_id, invoice, payment_hash, destination_pubkey, description, preimage)
168
+ SELECT id, json_extract(details, '$.Lightning.invoice'), json_extract(details, '$.Lightning.payment_hash'),
169
+ json_extract(details, '$.Lightning.destination_pubkey'), json_extract(details, '$.Lightning.description'),
170
+ json_extract(details, '$.Lightning.preimage')
171
+ FROM payments WHERE json_extract(details, '$.Lightning.invoice') IS NOT NULL`,
172
+ `UPDATE payments SET withdraw_tx_id = json_extract(details, '$.Withdraw.tx_id')
173
+ WHERE json_extract(details, '$.Withdraw.tx_id') IS NOT NULL`,
174
+ `UPDATE payments SET deposit_tx_id = json_extract(details, '$.Deposit.tx_id')
175
+ WHERE json_extract(details, '$.Deposit.tx_id') IS NOT NULL`,
176
+ `ALTER TABLE payments DROP COLUMN details`,
177
+ `CREATE INDEX idx_payment_details_lightning_invoice ON payment_details_lightning(invoice)`,
178
+ ]
151
179
  }
152
180
  ];
153
181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@breeztech/breez-sdk-spark",
3
- "version": "0.2.5-dev1",
3
+ "version": "0.2.6",
4
4
  "description": "Breez Spark SDK",
5
5
  "repository": "https://github.com/breez/spark-sdk",
6
6
  "author": "Breez <contact@breez.technology> (https://github.com/breez)",
@@ -31,12 +31,23 @@ export interface Storage {
31
31
  insertPayment: (payment: Payment) => Promise<void>;
32
32
  setPaymentMetadata: (paymentId: string, metadata: PaymentMetadata) => Promise<void>;
33
33
  getPaymentById: (id: string) => Promise<Payment>;
34
+ getPaymentByInvoice: (invoice: string) => Promise<Payment>;
34
35
  addDeposit: (txid: string, vout: number, amount_sats: number) => Promise<void>;
35
36
  deleteDeposit: (txid: string, vout: number) => Promise<void>;
36
37
  listDeposits: () => Promise<DepositInfo[]>;
37
38
  updateDeposit: (txid: string, vout: number, payload: UpdateDepositPayload) => Promise<void>;
38
39
  }
39
40
 
41
+ export interface WaitForPaymentResponse {
42
+ payment: Payment;
43
+ }
44
+
45
+ export type WaitForPaymentIdentifier = ({ type: "paymentId" } & string) | ({ type: "paymentRequest" } & string);
46
+
47
+ export interface WaitForPaymentRequest {
48
+ identifier: WaitForPaymentIdentifier;
49
+ }
50
+
40
51
  export interface Symbol {
41
52
  grapheme?: string;
42
53
  template?: string;
@@ -137,7 +148,7 @@ export interface SendPaymentRequest {
137
148
  options?: SendPaymentOptions;
138
149
  }
139
150
 
140
- export type SendPaymentOptions = { type: "bitcoinAddress"; confirmationSpeed: OnchainConfirmationSpeed } | { type: "bolt11Invoice"; preferSpark: boolean };
151
+ export type SendPaymentOptions = { type: "bitcoinAddress"; confirmationSpeed: OnchainConfirmationSpeed } | { type: "bolt11Invoice"; preferSpark: boolean; completionTimeoutSecs?: number };
141
152
 
142
153
  export type OnchainConfirmationSpeed = "fast" | "medium" | "slow";
143
154
 
@@ -210,7 +221,9 @@ export interface GetInfoResponse {
210
221
  balanceSats: number;
211
222
  }
212
223
 
213
- export interface GetInfoRequest {}
224
+ export interface GetInfoRequest {
225
+ ensureSynced?: boolean;
226
+ }
214
227
 
215
228
  export interface Credentials {
216
229
  username: string;
@@ -509,16 +522,16 @@ export type SdkEvent = { type: "synced" } | { type: "claimDepositsFailed"; uncla
509
522
  export class BreezSdk {
510
523
  private constructor();
511
524
  free(): void;
512
- addEventListener(listener: EventListener): string;
513
- removeEventListener(id: string): boolean;
514
- disconnect(): void;
525
+ addEventListener(listener: EventListener): Promise<string>;
526
+ removeEventListener(id: string): Promise<boolean>;
527
+ disconnect(): Promise<void>;
515
528
  getInfo(request: GetInfoRequest): Promise<GetInfoResponse>;
516
529
  receivePayment(request: ReceivePaymentRequest): Promise<ReceivePaymentResponse>;
517
530
  prepareSendPayment(request: PrepareSendPaymentRequest): Promise<PrepareSendPaymentResponse>;
518
531
  prepareLnurlPay(request: PrepareLnurlPayRequest): Promise<PrepareLnurlPayResponse>;
519
532
  lnurlPay(request: LnurlPayRequest): Promise<LnurlPayResponse>;
520
533
  sendPayment(request: SendPaymentRequest): Promise<SendPaymentResponse>;
521
- syncWallet(request: SyncWalletRequest): SyncWalletResponse;
534
+ syncWallet(request: SyncWalletRequest): Promise<SyncWalletResponse>;
522
535
  listPayments(request: ListPaymentsRequest): Promise<ListPaymentsResponse>;
523
536
  getPayment(request: GetPaymentRequest): Promise<GetPaymentResponse>;
524
537
  claimDeposit(request: ClaimDepositRequest): Promise<ClaimDepositResponse>;
@@ -530,6 +543,7 @@ export class BreezSdk {
530
543
  deleteLightningAddress(): Promise<void>;
531
544
  listFiatCurrencies(): Promise<ListFiatCurrenciesResponse>;
532
545
  listFiatRates(): Promise<ListFiatRatesResponse>;
546
+ waitForPayment(request: WaitForPaymentRequest): Promise<WaitForPaymentResponse>;
533
547
  }
534
548
  export class IntoUnderlyingByteSource {
535
549
  private constructor();
@@ -572,16 +586,16 @@ export interface InitOutput {
572
586
  readonly defaultConfig: (a: any) => any;
573
587
  readonly defaultStorage: (a: number, b: number) => any;
574
588
  readonly parse: (a: number, b: number) => any;
575
- readonly breezsdk_addEventListener: (a: number, b: any) => [number, number];
576
- readonly breezsdk_removeEventListener: (a: number, b: number, c: number) => number;
577
- readonly breezsdk_disconnect: (a: number) => [number, number];
589
+ readonly breezsdk_addEventListener: (a: number, b: any) => any;
590
+ readonly breezsdk_removeEventListener: (a: number, b: number, c: number) => any;
591
+ readonly breezsdk_disconnect: (a: number) => any;
578
592
  readonly breezsdk_getInfo: (a: number, b: any) => any;
579
593
  readonly breezsdk_receivePayment: (a: number, b: any) => any;
580
594
  readonly breezsdk_prepareSendPayment: (a: number, b: any) => any;
581
595
  readonly breezsdk_prepareLnurlPay: (a: number, b: any) => any;
582
596
  readonly breezsdk_lnurlPay: (a: number, b: any) => any;
583
597
  readonly breezsdk_sendPayment: (a: number, b: any) => any;
584
- readonly breezsdk_syncWallet: (a: number, b: any) => [number, number, number];
598
+ readonly breezsdk_syncWallet: (a: number, b: any) => any;
585
599
  readonly breezsdk_listPayments: (a: number, b: any) => any;
586
600
  readonly breezsdk_getPayment: (a: number, b: any) => any;
587
601
  readonly breezsdk_claimDeposit: (a: number, b: any) => any;
@@ -593,6 +607,7 @@ export interface InitOutput {
593
607
  readonly breezsdk_deleteLightningAddress: (a: number) => any;
594
608
  readonly breezsdk_listFiatCurrencies: (a: number) => any;
595
609
  readonly breezsdk_listFiatRates: (a: number) => any;
610
+ readonly breezsdk_waitForPayment: (a: number, b: any) => any;
596
611
  readonly __wbg_sdkbuilder_free: (a: number, b: number) => void;
597
612
  readonly sdkbuilder_new: (a: any, b: any, c: any) => [number, number, number];
598
613
  readonly sdkbuilder_withRestChainService: (a: number, b: number, c: number, d: number) => number;
@@ -624,9 +639,9 @@ export interface InitOutput {
624
639
  readonly __wbindgen_export_5: WebAssembly.Table;
625
640
  readonly __wbindgen_export_6: WebAssembly.Table;
626
641
  readonly __externref_table_dealloc: (a: number) => void;
627
- readonly _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf7c49586be6831c4: (a: number, b: number) => void;
628
- readonly closure772_externref_shim: (a: number, b: number, c: any) => void;
629
- readonly closure424_externref_shim: (a: number, b: number, c: any, d: any) => void;
642
+ readonly _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__he5eedad33b9ff4bf: (a: number, b: number) => void;
643
+ readonly closure780_externref_shim: (a: number, b: number, c: any) => void;
644
+ readonly closure434_externref_shim: (a: number, b: number, c: any, d: any) => void;
630
645
  readonly __wbindgen_start: () => void;
631
646
  }
632
647