@breeztech/breez-sdk-spark 0.5.1 → 0.6.0-rc1

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.
@@ -230,20 +230,20 @@ module.exports.initLogging = function(logger, filter) {
230
230
  };
231
231
 
232
232
  /**
233
- * @param {ConnectRequest} request
234
- * @returns {Promise<BreezSdk>}
233
+ * @param {Network} network
234
+ * @returns {Config}
235
235
  */
236
- module.exports.connect = function(request) {
237
- const ret = wasm.connect(request);
236
+ module.exports.defaultConfig = function(network) {
237
+ const ret = wasm.defaultConfig(network);
238
238
  return ret;
239
239
  };
240
240
 
241
241
  /**
242
- * @param {Network} network
243
- * @returns {Config}
242
+ * @param {ConnectRequest} request
243
+ * @returns {Promise<BreezSdk>}
244
244
  */
245
- module.exports.defaultConfig = function(network) {
246
- const ret = wasm.defaultConfig(network);
245
+ module.exports.connect = function(request) {
246
+ const ret = wasm.connect(request);
247
247
  return ret;
248
248
  };
249
249
 
@@ -264,15 +264,15 @@ module.exports.task_worker_entry_point = function(ptr) {
264
264
  };
265
265
 
266
266
  function __wbg_adapter_58(arg0, arg1) {
267
- wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hbac93e35ba6a14f4(arg0, arg1);
267
+ wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hd4a74686750ed5d4(arg0, arg1);
268
268
  }
269
269
 
270
270
  function __wbg_adapter_61(arg0, arg1, arg2) {
271
- wasm.closure937_externref_shim(arg0, arg1, arg2);
271
+ wasm.closure979_externref_shim(arg0, arg1, arg2);
272
272
  }
273
273
 
274
- function __wbg_adapter_225(arg0, arg1, arg2, arg3) {
275
- wasm.closure538_externref_shim(arg0, arg1, arg2, arg3);
274
+ function __wbg_adapter_227(arg0, arg1, arg2, arg3) {
275
+ wasm.closure561_externref_shim(arg0, arg1, arg2, arg3);
276
276
  }
277
277
 
278
278
  const __wbindgen_enum_ReadableStreamType = ["bytes"];
@@ -1431,7 +1431,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function(arg0, arg1) {
1431
1431
  const a = state0.a;
1432
1432
  state0.a = 0;
1433
1433
  try {
1434
- return __wbg_adapter_225(a, state0.b, arg0, arg1);
1434
+ return __wbg_adapter_227(a, state0.b, arg0, arg1);
1435
1435
  } finally {
1436
1436
  state0.a = a;
1437
1437
  }
@@ -1623,6 +1623,13 @@ module.exports.__wbg_setCachedItem_91b03741dfb0b4c2 = function() { return handle
1623
1623
  }
1624
1624
  }, arguments) };
1625
1625
 
1626
+ module.exports.__wbg_setLnurlMetadata_0bf15cc7efb6cc11 = function() { return handleError(function (arg0, arg1, arg2) {
1627
+ var v0 = getArrayJsValueFromWasm0(arg1, arg2).slice();
1628
+ wasm.__wbindgen_free(arg1, arg2 * 4, 4);
1629
+ const ret = arg0.setLnurlMetadata(v0);
1630
+ return ret;
1631
+ }, arguments) };
1632
+
1626
1633
  module.exports.__wbg_setPaymentMetadata_0bbf82aa72b85deb = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1627
1634
  let deferred0_0;
1628
1635
  let deferred0_1;
@@ -1902,13 +1909,13 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
1902
1909
  return ret;
1903
1910
  };
1904
1911
 
1905
- module.exports.__wbindgen_closure_wrapper11446 = function(arg0, arg1, arg2) {
1906
- const ret = makeMutClosure(arg0, arg1, 938, __wbg_adapter_61);
1912
+ module.exports.__wbindgen_closure_wrapper11748 = function(arg0, arg1, arg2) {
1913
+ const ret = makeMutClosure(arg0, arg1, 980, __wbg_adapter_61);
1907
1914
  return ret;
1908
1915
  };
1909
1916
 
1910
- module.exports.__wbindgen_closure_wrapper9553 = function(arg0, arg1, arg2) {
1911
- const ret = makeMutClosure(arg0, arg1, 710, __wbg_adapter_58);
1917
+ module.exports.__wbindgen_closure_wrapper9873 = function(arg0, arg1, arg2) {
1918
+ const ret = makeMutClosure(arg0, arg1, 752, __wbg_adapter_58);
1912
1919
  return ret;
1913
1920
  };
1914
1921
 
Binary file
@@ -82,7 +82,7 @@ export const __wbindgen_export_5: WebAssembly.Table;
82
82
  export const __externref_drop_slice: (a: number, b: number) => void;
83
83
  export const __wbindgen_export_7: WebAssembly.Table;
84
84
  export const __externref_table_dealloc: (a: number) => void;
85
- export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hbac93e35ba6a14f4: (a: number, b: number) => void;
86
- export const closure937_externref_shim: (a: number, b: number, c: any) => void;
87
- export const closure538_externref_shim: (a: number, b: number, c: any, d: any) => void;
85
+ export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hd4a74686750ed5d4: (a: number, b: number) => void;
86
+ export const closure979_externref_shim: (a: number, b: number, c: any) => void;
87
+ export const closure561_externref_shim: (a: number, b: number, c: any, d: any) => void;
88
88
  export const __wbindgen_start: () => void;
@@ -212,11 +212,15 @@ class SqliteStorage {
212
212
  , t.invoice_details AS token_invoice_details
213
213
  , s.invoice_details AS spark_invoice_details
214
214
  , s.htlc_details AS spark_htlc_details
215
+ , lrm.nostr_zap_request AS lnurl_nostr_zap_request
216
+ , lrm.nostr_zap_receipt AS lnurl_nostr_zap_receipt
217
+ , lrm.sender_comment AS lnurl_sender_comment
215
218
  FROM payments p
216
219
  LEFT JOIN payment_details_lightning l ON p.id = l.payment_id
217
220
  LEFT JOIN payment_details_token t ON p.id = t.payment_id
218
221
  LEFT JOIN payment_details_spark s ON p.id = s.payment_id
219
222
  LEFT JOIN payment_metadata pm ON p.id = pm.payment_id
223
+ LEFT JOIN lnurl_receive_metadata lrm ON l.payment_hash = lrm.payment_hash
220
224
  ${whereSql}
221
225
  ORDER BY p.timestamp ${orderDirection}
222
226
  LIMIT ? OFFSET ?
@@ -363,11 +367,15 @@ class SqliteStorage {
363
367
  , t.invoice_details AS token_invoice_details
364
368
  , s.invoice_details AS spark_invoice_details
365
369
  , s.htlc_details AS spark_htlc_details
370
+ , lrm.nostr_zap_request AS lnurl_nostr_zap_request
371
+ , lrm.nostr_zap_receipt AS lnurl_nostr_zap_receipt
372
+ , lrm.sender_comment AS lnurl_sender_comment
366
373
  FROM payments p
367
374
  LEFT JOIN payment_details_lightning l ON p.id = l.payment_id
368
375
  LEFT JOIN payment_details_token t ON p.id = t.payment_id
369
376
  LEFT JOIN payment_details_spark s ON p.id = s.payment_id
370
377
  LEFT JOIN payment_metadata pm ON p.id = pm.payment_id
378
+ LEFT JOIN lnurl_receive_metadata lrm ON l.payment_hash = lrm.payment_hash
371
379
  WHERE p.id = ?
372
380
  `);
373
381
 
@@ -422,11 +430,15 @@ class SqliteStorage {
422
430
  , t.invoice_details AS token_invoice_details
423
431
  , s.invoice_details AS spark_invoice_details
424
432
  , s.htlc_details AS spark_htlc_details
433
+ , lrm.nostr_zap_request AS lnurl_nostr_zap_request
434
+ , lrm.nostr_zap_receipt AS lnurl_nostr_zap_receipt
435
+ , lrm.sender_comment AS lnurl_sender_comment
425
436
  FROM payments p
426
437
  LEFT JOIN payment_details_lightning l ON p.id = l.payment_id
427
438
  LEFT JOIN payment_details_token t ON p.id = t.payment_id
428
439
  LEFT JOIN payment_details_spark s ON p.id = s.payment_id
429
440
  LEFT JOIN payment_metadata pm ON p.id = pm.payment_id
441
+ LEFT JOIN lnurl_receive_metadata lrm ON l.payment_hash = lrm.payment_hash
430
442
  WHERE l.invoice = ?
431
443
  `);
432
444
 
@@ -573,6 +585,35 @@ class SqliteStorage {
573
585
  }
574
586
  }
575
587
 
588
+ setLnurlMetadata(metadata) {
589
+ try {
590
+ const stmt = this.db.prepare(
591
+ "INSERT OR REPLACE INTO lnurl_receive_metadata (payment_hash, nostr_zap_request, nostr_zap_receipt, sender_comment) VALUES (?, ?, ?, ?)"
592
+ );
593
+
594
+ const transaction = this.db.transaction(() => {
595
+ for (const item of metadata) {
596
+ stmt.run(
597
+ item.paymentHash,
598
+ item.nostrZapRequest || null,
599
+ item.nostrZapReceipt || null,
600
+ item.senderComment || null
601
+ );
602
+ }
603
+ });
604
+
605
+ transaction();
606
+ return Promise.resolve();
607
+ } catch (error) {
608
+ return Promise.reject(
609
+ new StorageError(
610
+ `Failed to add lnurl metadata: ${error.message}`,
611
+ error
612
+ )
613
+ );
614
+ }
615
+ }
616
+
576
617
  // ===== Private Helper Methods =====
577
618
 
578
619
  _rowToPayment(row) {
@@ -608,6 +649,14 @@ class SqliteStorage {
608
649
  );
609
650
  }
610
651
  }
652
+
653
+ if (row.lnurl_nostr_zap_request || row.lnurl_sender_comment) {
654
+ details.lnurlReceiveMetadata = {
655
+ nostrZapRequest: row.lnurl_nostr_zap_request || null,
656
+ nostrZapReceipt: row.lnurl_nostr_zap_receipt || null,
657
+ senderComment: row.lnurl_sender_comment || null,
658
+ };
659
+ }
611
660
  } else if (row.withdraw_tx_id) {
612
661
  details = {
613
662
  type: "withdraw",
@@ -278,6 +278,21 @@ class MigrationManager {
278
278
  `DROP TABLE tmp_payment_details_spark`,
279
279
  ],
280
280
  },
281
+ {
282
+ name: "Create lnurl_receive_metadata table",
283
+ sql: `CREATE TABLE lnurl_receive_metadata (
284
+ payment_hash TEXT NOT NULL PRIMARY KEY,
285
+ nostr_zap_request TEXT,
286
+ nostr_zap_receipt TEXT,
287
+ sender_comment TEXT
288
+ )`
289
+ },
290
+ {
291
+ // Delete all unclaimed deposits to clear old claim_error JSON format.
292
+ // Deposits will be recovered on next sync.
293
+ name: "Clear unclaimed deposits for claim_error format change",
294
+ sql: `DELETE FROM unclaimed_deposits`
295
+ }
281
296
  ];
282
297
  }
283
298
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@breeztech/breez-sdk-spark",
3
- "version": "0.5.1",
3
+ "version": "0.6.0-rc1",
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)",