@breeztech/breez-sdk-spark 0.6.6 → 0.7.0-dev1
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 +615 -412
- package/bundler/breez_sdk_spark_wasm_bg.js +460 -22
- package/bundler/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/bundler/breez_sdk_spark_wasm_bg.wasm.d.ts +27 -3
- package/bundler/storage/index.js +150 -41
- package/deno/breez_sdk_spark_wasm.d.ts +615 -412
- package/deno/breez_sdk_spark_wasm.js +438 -22
- package/deno/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/deno/breez_sdk_spark_wasm_bg.wasm.d.ts +27 -3
- package/nodejs/breez_sdk_spark_wasm.d.ts +615 -412
- package/nodejs/breez_sdk_spark_wasm.js +461 -22
- package/nodejs/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/nodejs/breez_sdk_spark_wasm_bg.wasm.d.ts +27 -3
- package/nodejs/storage/index.cjs +101 -24
- package/nodejs/storage/migrations.cjs +23 -1
- package/package.json +1 -1
- package/web/breez_sdk_spark_wasm.d.ts +642 -415
- package/web/breez_sdk_spark_wasm.js +438 -22
- package/web/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/web/breez_sdk_spark_wasm_bg.wasm.d.ts +27 -3
- package/web/storage/index.js +150 -41
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_breezsdk_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_defaultsigner_free: (a: number, b: number) => void;
|
|
5
6
|
export const __wbg_sdkbuilder_free: (a: number, b: number) => void;
|
|
6
7
|
export const __wbg_tokenissuer_free: (a: number, b: number) => void;
|
|
7
8
|
export const breezsdk_addEventListener: (a: number, b: any) => any;
|
|
@@ -12,6 +13,7 @@ export const breezsdk_claimDeposit: (a: number, b: any) => any;
|
|
|
12
13
|
export const breezsdk_claimHtlcPayment: (a: number, b: any) => any;
|
|
13
14
|
export const breezsdk_deleteLightningAddress: (a: number) => any;
|
|
14
15
|
export const breezsdk_disconnect: (a: number) => any;
|
|
16
|
+
export const breezsdk_fetchTokenConversionLimits: (a: number, b: any) => any;
|
|
15
17
|
export const breezsdk_getInfo: (a: number, b: any) => any;
|
|
16
18
|
export const breezsdk_getLeafOptimizationProgress: (a: number) => any;
|
|
17
19
|
export const breezsdk_getLightningAddress: (a: number) => any;
|
|
@@ -39,14 +41,36 @@ export const breezsdk_startLeafOptimization: (a: number) => void;
|
|
|
39
41
|
export const breezsdk_syncWallet: (a: number, b: any) => any;
|
|
40
42
|
export const breezsdk_updateUserSettings: (a: number, b: any) => any;
|
|
41
43
|
export const connect: (a: any) => any;
|
|
44
|
+
export const connectWithSigner: (a: any, b: any, c: number, d: number) => any;
|
|
42
45
|
export const defaultConfig: (a: any) => any;
|
|
46
|
+
export const defaultExternalSigner: (a: number, b: number, c: number, d: number, e: any, f: number) => [number, number, number];
|
|
47
|
+
export const defaultsigner_aggregateFrost: (a: number, b: any) => any;
|
|
48
|
+
export const defaultsigner_derivePublicKey: (a: number, b: number, c: number) => any;
|
|
49
|
+
export const defaultsigner_eciesDecrypt: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
50
|
+
export const defaultsigner_eciesEncrypt: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
51
|
+
export const defaultsigner_encryptPrivateKeyForReceiver: (a: number, b: any, c: any) => any;
|
|
52
|
+
export const defaultsigner_generateFrostSigningCommitments: (a: number) => any;
|
|
53
|
+
export const defaultsigner_generateRandomKey: (a: number) => any;
|
|
54
|
+
export const defaultsigner_getPublicKeyForNode: (a: number, b: any) => any;
|
|
55
|
+
export const defaultsigner_getPublicKeyFromPrivateKeySource: (a: number, b: any) => any;
|
|
56
|
+
export const defaultsigner_getStaticDepositPrivateKey: (a: number, b: number) => any;
|
|
57
|
+
export const defaultsigner_getStaticDepositPrivateKeySource: (a: number, b: number) => any;
|
|
58
|
+
export const defaultsigner_getStaticDepositPublicKey: (a: number, b: number) => any;
|
|
59
|
+
export const defaultsigner_identityPublicKey: (a: number) => [number, number, number];
|
|
60
|
+
export const defaultsigner_signEcdsa: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
61
|
+
export const defaultsigner_signEcdsaRecoverable: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
62
|
+
export const defaultsigner_signFrost: (a: number, b: any) => any;
|
|
63
|
+
export const defaultsigner_signHashSchnorr: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
64
|
+
export const defaultsigner_splitSecretWithProofs: (a: number, b: any, c: number, d: number) => any;
|
|
65
|
+
export const defaultsigner_subtractPrivateKeys: (a: number, b: any, c: any) => any;
|
|
43
66
|
export const initLogging: (a: any, b: number, c: number) => any;
|
|
44
67
|
export const sdkbuilder_build: (a: number) => any;
|
|
45
68
|
export const sdkbuilder_new: (a: any, b: any) => number;
|
|
69
|
+
export const sdkbuilder_newWithSigner: (a: any, b: any) => number;
|
|
46
70
|
export const sdkbuilder_withChainService: (a: number, b: any) => number;
|
|
47
71
|
export const sdkbuilder_withDefaultStorage: (a: number, b: number, c: number) => any;
|
|
48
72
|
export const sdkbuilder_withFiatService: (a: number, b: any) => number;
|
|
49
|
-
export const sdkbuilder_withKeySet: (a: number, b: any
|
|
73
|
+
export const sdkbuilder_withKeySet: (a: number, b: any) => number;
|
|
50
74
|
export const sdkbuilder_withLnurlClient: (a: number, b: any) => number;
|
|
51
75
|
export const sdkbuilder_withPaymentObserver: (a: number, b: any) => number;
|
|
52
76
|
export const sdkbuilder_withRestChainService: (a: number, b: number, c: number, d: any, e: number) => number;
|
|
@@ -86,6 +110,6 @@ export const __externref_drop_slice: (a: number, b: number) => void;
|
|
|
86
110
|
export const __wbindgen_export_7: WebAssembly.Table;
|
|
87
111
|
export const __externref_table_dealloc: (a: number) => void;
|
|
88
112
|
export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hdf0ebd5238280272: (a: number, b: number) => void;
|
|
89
|
-
export const
|
|
90
|
-
export const
|
|
113
|
+
export const closure1047_externref_shim: (a: number, b: number, c: any) => void;
|
|
114
|
+
export const closure632_externref_shim: (a: number, b: number, c: any, d: any) => void;
|
|
91
115
|
export const __wbindgen_start: () => void;
|
package/nodejs/storage/index.cjs
CHANGED
|
@@ -154,18 +154,58 @@ class SqliteStorage {
|
|
|
154
154
|
params.push(request.toTimestamp);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
// Filter by
|
|
158
|
-
if (
|
|
159
|
-
|
|
160
|
-
request.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
157
|
+
// Filter by payment details. If any filter matches, we include the payment
|
|
158
|
+
if (request.paymentDetailsFilter && request.paymentDetailsFilter.length > 0) {
|
|
159
|
+
const allPaymentDetailsClauses = [];
|
|
160
|
+
for (const paymentDetailsFilter of request.paymentDetailsFilter) {
|
|
161
|
+
const paymentDetailsClauses = [];
|
|
162
|
+
// Filter by Spark HTLC status
|
|
163
|
+
if (
|
|
164
|
+
paymentDetailsFilter.type === "spark" &&
|
|
165
|
+
paymentDetailsFilter.htlcStatus !== undefined &&
|
|
166
|
+
paymentDetailsFilter.htlcStatus.length > 0
|
|
167
|
+
) {
|
|
168
|
+
const placeholders = paymentDetailsFilter.htlcStatus
|
|
169
|
+
.map(() => "?")
|
|
170
|
+
.join(", ");
|
|
171
|
+
paymentDetailsClauses.push(
|
|
172
|
+
`json_extract(s.htlc_details, '$.status') IN (${placeholders})`
|
|
173
|
+
);
|
|
174
|
+
params.push(...paymentDetailsFilter.htlcStatus);
|
|
175
|
+
}
|
|
176
|
+
// Filter by token conversion info presence
|
|
177
|
+
if (
|
|
178
|
+
(paymentDetailsFilter.type === "spark" || paymentDetailsFilter.type === "token") &&
|
|
179
|
+
paymentDetailsFilter.conversionRefundNeeded !== undefined
|
|
180
|
+
) {
|
|
181
|
+
const typeCheck = paymentDetailsFilter.type === "spark" ? "p.spark = 1" : "p.spark IS NULL";
|
|
182
|
+
const nullCheck =
|
|
183
|
+
paymentDetailsFilter.conversionRefundNeeded === true
|
|
184
|
+
? "IS NULL"
|
|
185
|
+
: "IS NOT NULL";
|
|
186
|
+
paymentDetailsClauses.push(
|
|
187
|
+
`${typeCheck} AND pm.token_conversion_info IS NOT NULL AND
|
|
188
|
+
json_extract(pm.token_conversion_info, '$.paymentId') IS NULL AND
|
|
189
|
+
json_extract(pm.token_conversion_info, '$.refundIdentifier') ${nullCheck}`
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
// Filter by token transaction hash
|
|
193
|
+
if (
|
|
194
|
+
paymentDetailsFilter.type === "token" &&
|
|
195
|
+
paymentDetailsFilter.txHash !== undefined
|
|
196
|
+
) {
|
|
197
|
+
paymentDetailsClauses.push("t.tx_hash = ?");
|
|
198
|
+
params.push(paymentDetailsFilter.txHash);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (paymentDetailsClauses.length > 0) {
|
|
202
|
+
allPaymentDetailsClauses.push(`(${paymentDetailsClauses.join(" AND ")})`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (allPaymentDetailsClauses.length > 0) {
|
|
207
|
+
whereClauses.push(`(${allPaymentDetailsClauses.join(" OR ")})`);
|
|
208
|
+
}
|
|
169
209
|
}
|
|
170
210
|
|
|
171
211
|
// Filter by payment details/method
|
|
@@ -207,6 +247,7 @@ class SqliteStorage {
|
|
|
207
247
|
, l.preimage AS lightning_preimage
|
|
208
248
|
, pm.lnurl_pay_info
|
|
209
249
|
, pm.lnurl_withdraw_info
|
|
250
|
+
, pm.token_conversion_info
|
|
210
251
|
, t.metadata AS token_metadata
|
|
211
252
|
, t.tx_hash AS token_tx_hash
|
|
212
253
|
, t.invoice_details AS token_invoice_details
|
|
@@ -229,7 +270,8 @@ class SqliteStorage {
|
|
|
229
270
|
params.push(actualLimit, actualOffset);
|
|
230
271
|
const stmt = this.db.prepare(query);
|
|
231
272
|
const rows = stmt.all(...params);
|
|
232
|
-
|
|
273
|
+
const payments = rows.map(this._rowToPayment.bind(this));
|
|
274
|
+
return Promise.resolve(payments);
|
|
233
275
|
} catch (error) {
|
|
234
276
|
return Promise.reject(
|
|
235
277
|
new StorageError(
|
|
@@ -251,23 +293,46 @@ class SqliteStorage {
|
|
|
251
293
|
}
|
|
252
294
|
|
|
253
295
|
const paymentInsert = this.db.prepare(
|
|
254
|
-
`INSERT
|
|
255
|
-
VALUES (@id, @paymentType, @status, @amount, @fees, @timestamp, @method, @withdrawTxId, @depositTxId, @spark)
|
|
296
|
+
`INSERT INTO payments (id, payment_type, status, amount, fees, timestamp, method, withdraw_tx_id, deposit_tx_id, spark)
|
|
297
|
+
VALUES (@id, @paymentType, @status, @amount, @fees, @timestamp, @method, @withdrawTxId, @depositTxId, @spark)
|
|
298
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
299
|
+
payment_type=excluded.payment_type,
|
|
300
|
+
status=excluded.status,
|
|
301
|
+
amount=excluded.amount,
|
|
302
|
+
fees=excluded.fees,
|
|
303
|
+
timestamp=excluded.timestamp,
|
|
304
|
+
method=excluded.method,
|
|
305
|
+
withdraw_tx_id=excluded.withdraw_tx_id,
|
|
306
|
+
deposit_tx_id=excluded.deposit_tx_id,
|
|
307
|
+
spark=excluded.spark`
|
|
256
308
|
);
|
|
257
309
|
const lightningInsert = this.db.prepare(
|
|
258
|
-
`INSERT
|
|
310
|
+
`INSERT INTO payment_details_lightning
|
|
259
311
|
(payment_id, invoice, payment_hash, destination_pubkey, description, preimage)
|
|
260
|
-
VALUES (@id, @invoice, @paymentHash, @destinationPubkey, @description, @preimage)
|
|
312
|
+
VALUES (@id, @invoice, @paymentHash, @destinationPubkey, @description, @preimage)
|
|
313
|
+
ON CONFLICT(payment_id) DO UPDATE SET
|
|
314
|
+
invoice=excluded.invoice,
|
|
315
|
+
payment_hash=excluded.payment_hash,
|
|
316
|
+
destination_pubkey=excluded.destination_pubkey,
|
|
317
|
+
description=excluded.description,
|
|
318
|
+
preimage=excluded.preimage`
|
|
261
319
|
);
|
|
262
320
|
const tokenInsert = this.db.prepare(
|
|
263
|
-
`INSERT
|
|
321
|
+
`INSERT INTO payment_details_token
|
|
264
322
|
(payment_id, metadata, tx_hash, invoice_details)
|
|
265
|
-
VALUES (@id, @metadata, @txHash, @invoiceDetails)
|
|
323
|
+
VALUES (@id, @metadata, @txHash, @invoiceDetails)
|
|
324
|
+
ON CONFLICT(payment_id) DO UPDATE SET
|
|
325
|
+
metadata=excluded.metadata,
|
|
326
|
+
tx_hash=excluded.tx_hash,
|
|
327
|
+
invoice_details=COALESCE(excluded.invoice_details, payment_details_token.invoice_details)`
|
|
266
328
|
);
|
|
267
329
|
const sparkInsert = this.db.prepare(
|
|
268
|
-
`INSERT
|
|
330
|
+
`INSERT INTO payment_details_spark
|
|
269
331
|
(payment_id, invoice_details, htlc_details)
|
|
270
|
-
VALUES (@id, @invoiceDetails, @htlcDetails)
|
|
332
|
+
VALUES (@id, @invoiceDetails, @htlcDetails)
|
|
333
|
+
ON CONFLICT(payment_id) DO UPDATE SET
|
|
334
|
+
invoice_details=COALESCE(excluded.invoice_details, payment_details_spark.invoice_details),
|
|
335
|
+
htlc_details=COALESCE(excluded.htlc_details, payment_details_spark.htlc_details)`
|
|
271
336
|
);
|
|
272
337
|
const transaction = this.db.transaction(() => {
|
|
273
338
|
paymentInsert.run({
|
|
@@ -362,6 +427,7 @@ class SqliteStorage {
|
|
|
362
427
|
, l.preimage AS lightning_preimage
|
|
363
428
|
, pm.lnurl_pay_info
|
|
364
429
|
, pm.lnurl_withdraw_info
|
|
430
|
+
, pm.token_conversion_info
|
|
365
431
|
, t.metadata AS token_metadata
|
|
366
432
|
, t.tx_hash AS token_tx_hash
|
|
367
433
|
, t.invoice_details AS token_invoice_details
|
|
@@ -425,6 +491,7 @@ class SqliteStorage {
|
|
|
425
491
|
, l.preimage AS lightning_preimage
|
|
426
492
|
, pm.lnurl_pay_info
|
|
427
493
|
, pm.lnurl_withdraw_info
|
|
494
|
+
, pm.token_conversion_info
|
|
428
495
|
, t.metadata AS token_metadata
|
|
429
496
|
, t.tx_hash AS token_tx_hash
|
|
430
497
|
, t.invoice_details AS token_invoice_details
|
|
@@ -463,17 +530,21 @@ class SqliteStorage {
|
|
|
463
530
|
setPaymentMetadata(paymentId, metadata) {
|
|
464
531
|
try {
|
|
465
532
|
const stmt = this.db.prepare(`
|
|
466
|
-
INSERT OR REPLACE INTO payment_metadata (payment_id, lnurl_pay_info, lnurl_withdraw_info, lnurl_description)
|
|
467
|
-
VALUES (?, ?, ?, ?)
|
|
533
|
+
INSERT OR REPLACE INTO payment_metadata (payment_id, parent_payment_id, lnurl_pay_info, lnurl_withdraw_info, lnurl_description, token_conversion_info)
|
|
534
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
468
535
|
`);
|
|
469
536
|
|
|
470
537
|
stmt.run(
|
|
471
538
|
paymentId,
|
|
539
|
+
metadata.parentPaymentId,
|
|
472
540
|
metadata.lnurlPayInfo ? JSON.stringify(metadata.lnurlPayInfo) : null,
|
|
473
541
|
metadata.lnurlWithdrawInfo
|
|
474
542
|
? JSON.stringify(metadata.lnurlWithdrawInfo)
|
|
475
543
|
: null,
|
|
476
|
-
metadata.lnurlDescription
|
|
544
|
+
metadata.lnurlDescription,
|
|
545
|
+
metadata.tokenConversionInfo
|
|
546
|
+
? JSON.stringify(metadata.tokenConversionInfo)
|
|
547
|
+
: null
|
|
477
548
|
);
|
|
478
549
|
return Promise.resolve();
|
|
479
550
|
} catch (error) {
|
|
@@ -676,6 +747,9 @@ class SqliteStorage {
|
|
|
676
747
|
htlcDetails: row.spark_htlc_details
|
|
677
748
|
? JSON.parse(row.spark_htlc_details)
|
|
678
749
|
: null,
|
|
750
|
+
tokenConversionInfo: row.token_conversion_info
|
|
751
|
+
? JSON.parse(row.token_conversion_info)
|
|
752
|
+
: null,
|
|
679
753
|
};
|
|
680
754
|
} else if (row.token_metadata) {
|
|
681
755
|
details = {
|
|
@@ -685,6 +759,9 @@ class SqliteStorage {
|
|
|
685
759
|
invoiceDetails: row.token_invoice_details
|
|
686
760
|
? JSON.parse(row.token_invoice_details)
|
|
687
761
|
: null,
|
|
762
|
+
tokenConversionInfo: row.token_conversion_info
|
|
763
|
+
? JSON.parse(row.token_conversion_info)
|
|
764
|
+
: null,
|
|
688
765
|
};
|
|
689
766
|
}
|
|
690
767
|
|
|
@@ -292,7 +292,29 @@ class MigrationManager {
|
|
|
292
292
|
// Deposits will be recovered on next sync.
|
|
293
293
|
name: "Clear unclaimed deposits for claim_error format change",
|
|
294
294
|
sql: `DELETE FROM unclaimed_deposits`
|
|
295
|
-
}
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
// Clear all sync tables due to BreezSigner signature change.
|
|
298
|
+
// This forces users to sync from scratch to the sync server.
|
|
299
|
+
// Also delete the sync_initial_complete flag to force re-populating
|
|
300
|
+
// all payment metadata for outgoing sync using the new key.
|
|
301
|
+
name: "Clear sync tables for BreezSigner backward compatibility",
|
|
302
|
+
sql: [
|
|
303
|
+
`DELETE FROM sync_outgoing`,
|
|
304
|
+
`DELETE FROM sync_incoming`,
|
|
305
|
+
`DELETE FROM sync_state`,
|
|
306
|
+
`UPDATE sync_revision SET revision = 0`,
|
|
307
|
+
`DELETE FROM settings WHERE key = 'sync_initial_complete'`
|
|
308
|
+
]
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
name: "Add token conversion info to payment_metadata",
|
|
312
|
+
sql: `ALTER TABLE payment_metadata ADD COLUMN token_conversion_info TEXT`
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
name: "Add parent payment id to payment_metadata",
|
|
316
|
+
sql: `ALTER TABLE payment_metadata ADD COLUMN parent_payment_id TEXT`
|
|
317
|
+
},
|
|
296
318
|
];
|
|
297
319
|
}
|
|
298
320
|
}
|
package/package.json
CHANGED