@breeztech/breez-sdk-spark 0.8.2 → 0.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/breez-sdk-spark.tgz +0 -0
- package/bundler/breez_sdk_spark_wasm.d.ts +551 -543
- package/bundler/breez_sdk_spark_wasm_bg.js +33 -32
- package/bundler/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/bundler/breez_sdk_spark_wasm_bg.wasm.d.ts +3 -3
- package/bundler/storage/index.js +81 -7
- package/deno/breez_sdk_spark_wasm.d.ts +551 -543
- package/deno/breez_sdk_spark_wasm.js +33 -32
- package/deno/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/deno/breez_sdk_spark_wasm_bg.wasm.d.ts +3 -3
- package/nodejs/breez_sdk_spark_wasm.d.ts +551 -543
- package/nodejs/breez_sdk_spark_wasm.js +33 -32
- package/nodejs/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/nodejs/breez_sdk_spark_wasm_bg.wasm.d.ts +3 -3
- package/nodejs/storage/index.cjs +38 -13
- package/nodejs/storage/migrations.cjs +25 -3
- package/package.json +1 -1
- package/web/breez_sdk_spark_wasm.d.ts +554 -546
- package/web/breez_sdk_spark_wasm.js +33 -32
- package/web/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/web/breez_sdk_spark_wasm_bg.wasm.d.ts +3 -3
- package/web/storage/index.js +81 -7
|
@@ -213,27 +213,6 @@ function debugString(val) {
|
|
|
213
213
|
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
214
214
|
return className;
|
|
215
215
|
}
|
|
216
|
-
/**
|
|
217
|
-
* @param {Config} config
|
|
218
|
-
* @param {ExternalSigner} signer
|
|
219
|
-
* @param {string} storage_dir
|
|
220
|
-
* @returns {Promise<BreezSdk>}
|
|
221
|
-
*/
|
|
222
|
-
export function connectWithSigner(config, signer, storage_dir) {
|
|
223
|
-
const ptr0 = passStringToWasm0(storage_dir, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
224
|
-
const len0 = WASM_VECTOR_LEN;
|
|
225
|
-
const ret = wasm.connectWithSigner(config, signer, ptr0, len0);
|
|
226
|
-
return ret;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* @param {ConnectRequest} request
|
|
231
|
-
* @returns {Promise<BreezSdk>}
|
|
232
|
-
*/
|
|
233
|
-
export function connect(request) {
|
|
234
|
-
const ret = wasm.connect(request);
|
|
235
|
-
return ret;
|
|
236
|
-
}
|
|
237
216
|
|
|
238
217
|
function takeFromExternrefTable0(idx) {
|
|
239
218
|
const value = wasm.__wbindgen_export_5.get(idx);
|
|
@@ -271,6 +250,15 @@ export function initLogging(logger, filter) {
|
|
|
271
250
|
return ret;
|
|
272
251
|
}
|
|
273
252
|
|
|
253
|
+
/**
|
|
254
|
+
* @param {Network} network
|
|
255
|
+
* @returns {Config}
|
|
256
|
+
*/
|
|
257
|
+
export function defaultConfig(network) {
|
|
258
|
+
const ret = wasm.defaultConfig(network);
|
|
259
|
+
return ret;
|
|
260
|
+
}
|
|
261
|
+
|
|
274
262
|
/**
|
|
275
263
|
* Creates a default external signer from a mnemonic phrase.
|
|
276
264
|
*
|
|
@@ -283,11 +271,24 @@ export function getSparkStatus() {
|
|
|
283
271
|
}
|
|
284
272
|
|
|
285
273
|
/**
|
|
286
|
-
* @param {
|
|
287
|
-
* @
|
|
274
|
+
* @param {Config} config
|
|
275
|
+
* @param {ExternalSigner} signer
|
|
276
|
+
* @param {string} storage_dir
|
|
277
|
+
* @returns {Promise<BreezSdk>}
|
|
288
278
|
*/
|
|
289
|
-
export function
|
|
290
|
-
const
|
|
279
|
+
export function connectWithSigner(config, signer, storage_dir) {
|
|
280
|
+
const ptr0 = passStringToWasm0(storage_dir, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
281
|
+
const len0 = WASM_VECTOR_LEN;
|
|
282
|
+
const ret = wasm.connectWithSigner(config, signer, ptr0, len0);
|
|
283
|
+
return ret;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* @param {ConnectRequest} request
|
|
288
|
+
* @returns {Promise<BreezSdk>}
|
|
289
|
+
*/
|
|
290
|
+
export function connect(request) {
|
|
291
|
+
const ret = wasm.connect(request);
|
|
291
292
|
return ret;
|
|
292
293
|
}
|
|
293
294
|
|
|
@@ -309,15 +310,15 @@ export function task_worker_entry_point(ptr) {
|
|
|
309
310
|
}
|
|
310
311
|
|
|
311
312
|
function __wbg_adapter_64(arg0, arg1) {
|
|
312
|
-
wasm.
|
|
313
|
+
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h4867a1ac48fc7b64(arg0, arg1);
|
|
313
314
|
}
|
|
314
315
|
|
|
315
316
|
function __wbg_adapter_67(arg0, arg1, arg2) {
|
|
316
|
-
wasm.
|
|
317
|
+
wasm.closure1082_externref_shim(arg0, arg1, arg2);
|
|
317
318
|
}
|
|
318
319
|
|
|
319
320
|
function __wbg_adapter_285(arg0, arg1, arg2, arg3) {
|
|
320
|
-
wasm.
|
|
321
|
+
wasm.closure667_externref_shim(arg0, arg1, arg2, arg3);
|
|
321
322
|
}
|
|
322
323
|
|
|
323
324
|
const __wbindgen_enum_ReadableStreamType = ["bytes"];
|
|
@@ -2241,12 +2242,12 @@ function __wbg_get_imports() {
|
|
|
2241
2242
|
const ret = false;
|
|
2242
2243
|
return ret;
|
|
2243
2244
|
};
|
|
2244
|
-
imports.wbg.
|
|
2245
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2245
|
+
imports.wbg.__wbindgen_closure_wrapper11841 = function(arg0, arg1, arg2) {
|
|
2246
|
+
const ret = makeMutClosure(arg0, arg1, 845, __wbg_adapter_64);
|
|
2246
2247
|
return ret;
|
|
2247
2248
|
};
|
|
2248
|
-
imports.wbg.
|
|
2249
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2249
|
+
imports.wbg.__wbindgen_closure_wrapper13789 = function(arg0, arg1, arg2) {
|
|
2250
|
+
const ret = makeMutClosure(arg0, arg1, 1083, __wbg_adapter_67);
|
|
2250
2251
|
return ret;
|
|
2251
2252
|
};
|
|
2252
2253
|
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
|
Binary file
|
|
@@ -113,7 +113,7 @@ export const __wbindgen_export_5: WebAssembly.Table;
|
|
|
113
113
|
export const __externref_drop_slice: (a: number, b: number) => void;
|
|
114
114
|
export const __wbindgen_export_7: WebAssembly.Table;
|
|
115
115
|
export const __externref_table_dealloc: (a: number) => void;
|
|
116
|
-
export const
|
|
117
|
-
export const
|
|
118
|
-
export const
|
|
116
|
+
export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h4867a1ac48fc7b64: (a: number, b: number) => void;
|
|
117
|
+
export const closure1082_externref_shim: (a: number, b: number, c: any) => void;
|
|
118
|
+
export const closure667_externref_shim: (a: number, b: number, c: any, d: any) => void;
|
|
119
119
|
export const __wbindgen_start: () => void;
|
package/web/storage/index.js
CHANGED
|
@@ -331,6 +331,72 @@ class MigrationManager {
|
|
|
331
331
|
transaction.objectStore("settings").delete("sync_initial_complete");
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
name: "Backfill htlc_details for existing Lightning payments",
|
|
337
|
+
upgrade: (db, transaction) => {
|
|
338
|
+
if (db.objectStoreNames.contains("payments")) {
|
|
339
|
+
const paymentStore = transaction.objectStore("payments");
|
|
340
|
+
const getAllRequest = paymentStore.getAll();
|
|
341
|
+
|
|
342
|
+
getAllRequest.onsuccess = () => {
|
|
343
|
+
const payments = getAllRequest.result;
|
|
344
|
+
payments.forEach((payment) => {
|
|
345
|
+
let details;
|
|
346
|
+
if (typeof payment.details === "string") {
|
|
347
|
+
try {
|
|
348
|
+
details = JSON.parse(payment.details);
|
|
349
|
+
} catch (e) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
} else {
|
|
353
|
+
details = payment.details;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (details && details.type === "lightning" && !details.htlcDetails) {
|
|
357
|
+
let htlcStatus;
|
|
358
|
+
if (payment.status === "completed") {
|
|
359
|
+
htlcStatus = "preimageShared";
|
|
360
|
+
} else if (payment.status === "pending") {
|
|
361
|
+
htlcStatus = "waitingForPreimage";
|
|
362
|
+
} else {
|
|
363
|
+
htlcStatus = "returned";
|
|
364
|
+
}
|
|
365
|
+
details.htlcDetails = {
|
|
366
|
+
paymentHash: details.paymentHash,
|
|
367
|
+
preimage: details.preimage || null,
|
|
368
|
+
expiryTime: 0,
|
|
369
|
+
status: htlcStatus,
|
|
370
|
+
};
|
|
371
|
+
payment.details = JSON.stringify(details);
|
|
372
|
+
paymentStore.put(payment);
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// Reset sync offset to trigger resync
|
|
379
|
+
if (db.objectStoreNames.contains("settings")) {
|
|
380
|
+
const settingsStore = transaction.objectStore("settings");
|
|
381
|
+
const getRequest = settingsStore.get("sync_offset");
|
|
382
|
+
|
|
383
|
+
getRequest.onsuccess = () => {
|
|
384
|
+
const syncCache = getRequest.result;
|
|
385
|
+
if (syncCache && syncCache.value) {
|
|
386
|
+
try {
|
|
387
|
+
const syncInfo = JSON.parse(syncCache.value);
|
|
388
|
+
syncInfo.offset = 0;
|
|
389
|
+
settingsStore.put({
|
|
390
|
+
key: "sync_offset",
|
|
391
|
+
value: JSON.stringify(syncInfo),
|
|
392
|
+
});
|
|
393
|
+
} catch (e) {
|
|
394
|
+
// If parsing fails, just continue
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
},
|
|
334
400
|
}
|
|
335
401
|
];
|
|
336
402
|
}
|
|
@@ -355,7 +421,7 @@ class IndexedDBStorage {
|
|
|
355
421
|
this.db = null;
|
|
356
422
|
this.migrationManager = null;
|
|
357
423
|
this.logger = logger;
|
|
358
|
-
this.dbVersion =
|
|
424
|
+
this.dbVersion = 11; // Current schema version
|
|
359
425
|
}
|
|
360
426
|
|
|
361
427
|
/**
|
|
@@ -1806,14 +1872,15 @@ class IndexedDBStorage {
|
|
|
1806
1872
|
// Filter by payment details. If any filter matches, we include the payment
|
|
1807
1873
|
let paymentDetailsFilterMatches = false;
|
|
1808
1874
|
for (const paymentDetailsFilter of request.paymentDetailsFilter) {
|
|
1809
|
-
// Filter by Spark
|
|
1875
|
+
// Filter by HTLC status (Spark or Lightning)
|
|
1810
1876
|
if (
|
|
1811
|
-
paymentDetailsFilter.type === "spark"
|
|
1877
|
+
(paymentDetailsFilter.type === "spark" ||
|
|
1878
|
+
paymentDetailsFilter.type === "lightning") &&
|
|
1812
1879
|
paymentDetailsFilter.htlcStatus != null &&
|
|
1813
1880
|
paymentDetailsFilter.htlcStatus.length > 0
|
|
1814
1881
|
) {
|
|
1815
1882
|
if (
|
|
1816
|
-
details.type !==
|
|
1883
|
+
details.type !== paymentDetailsFilter.type ||
|
|
1817
1884
|
!details.htlcDetails ||
|
|
1818
1885
|
!paymentDetailsFilter.htlcStatus.includes(
|
|
1819
1886
|
details.htlcDetails.status
|
|
@@ -1867,6 +1934,7 @@ class IndexedDBStorage {
|
|
|
1867
1934
|
}
|
|
1868
1935
|
}
|
|
1869
1936
|
|
|
1937
|
+
|
|
1870
1938
|
paymentDetailsFilterMatches = true;
|
|
1871
1939
|
break;
|
|
1872
1940
|
}
|
|
@@ -1946,6 +2014,12 @@ class IndexedDBStorage {
|
|
|
1946
2014
|
}
|
|
1947
2015
|
}
|
|
1948
2016
|
|
|
2017
|
+
if (details && details.type === "lightning" && !details.htlcDetails) {
|
|
2018
|
+
throw new StorageError(
|
|
2019
|
+
`htlc_details is required for Lightning payment ${payment.id}`
|
|
2020
|
+
);
|
|
2021
|
+
}
|
|
2022
|
+
|
|
1949
2023
|
if (metadata && details) {
|
|
1950
2024
|
if (details.type == "lightning") {
|
|
1951
2025
|
if (metadata.lnurlDescription && !details.description) {
|
|
@@ -2005,7 +2079,7 @@ class IndexedDBStorage {
|
|
|
2005
2079
|
if (
|
|
2006
2080
|
!payment.details ||
|
|
2007
2081
|
payment.details.type !== "lightning" ||
|
|
2008
|
-
!payment.details.paymentHash
|
|
2082
|
+
!payment.details.htlcDetails?.paymentHash
|
|
2009
2083
|
) {
|
|
2010
2084
|
return Promise.resolve(payment);
|
|
2011
2085
|
}
|
|
@@ -2016,7 +2090,7 @@ class IndexedDBStorage {
|
|
|
2016
2090
|
|
|
2017
2091
|
return new Promise((resolve, reject) => {
|
|
2018
2092
|
const lnurlReceiveRequest = lnurlReceiveMetadataStore.get(
|
|
2019
|
-
payment.details.paymentHash
|
|
2093
|
+
payment.details.htlcDetails.paymentHash
|
|
2020
2094
|
);
|
|
2021
2095
|
|
|
2022
2096
|
lnurlReceiveRequest.onsuccess = () => {
|
|
@@ -2052,4 +2126,4 @@ export async function createDefaultStorage(
|
|
|
2052
2126
|
return storage;
|
|
2053
2127
|
}
|
|
2054
2128
|
|
|
2055
|
-
export { IndexedDBStorage, StorageError };
|
|
2129
|
+
export { IndexedDBStorage, MigrationManager, StorageError };
|