@breeztech/breez-sdk-spark 0.12.2-dev2 → 0.12.2-dev4
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/README.md +4 -4
- package/breez-sdk-spark.tgz +0 -0
- package/bundler/breez_sdk_spark_wasm.d.ts +601 -731
- package/bundler/breez_sdk_spark_wasm_bg.js +54 -151
- package/bundler/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/bundler/breez_sdk_spark_wasm_bg.wasm.d.ts +5 -7
- package/bundler/storage/index.js +43 -65
- package/deno/breez_sdk_spark_wasm.d.ts +601 -731
- package/deno/breez_sdk_spark_wasm.js +54 -141
- package/deno/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/deno/breez_sdk_spark_wasm_bg.wasm.d.ts +5 -7
- package/nodejs/breez_sdk_spark_wasm.d.ts +601 -731
- package/nodejs/breez_sdk_spark_wasm.js +54 -151
- package/nodejs/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/nodejs/breez_sdk_spark_wasm_bg.wasm.d.ts +5 -7
- package/nodejs/index.js +2 -16
- package/nodejs/package.json +0 -1
- package/nodejs/postgres-storage/index.cjs +31 -42
- package/nodejs/postgres-storage/migrations.cjs +0 -24
- package/nodejs/postgres-tree-store/index.cjs +2 -12
- package/nodejs/storage/index.cjs +28 -19
- package/nodejs/storage/migrations.cjs +0 -18
- package/package.json +1 -1
- package/web/breez_sdk_spark_wasm.d.ts +606 -738
- package/web/breez_sdk_spark_wasm.js +54 -141
- package/web/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/web/breez_sdk_spark_wasm_bg.wasm.d.ts +5 -7
- package/web/storage/index.js +43 -65
- package/nodejs/postgres-token-store/errors.cjs +0 -13
- package/nodejs/postgres-token-store/index.cjs +0 -857
- package/nodejs/postgres-token-store/migrations.cjs +0 -163
- package/nodejs/postgres-token-store/package.json +0 -9
|
@@ -28,7 +28,7 @@ const { TreeStoreMigrationManager } = require("./migrations.cjs");
|
|
|
28
28
|
* Advisory lock key for serializing tree store write operations.
|
|
29
29
|
* Matches the Rust constant TREE_STORE_WRITE_LOCK_KEY = 0x7472_6565_5354_4f52
|
|
30
30
|
*/
|
|
31
|
-
const TREE_STORE_WRITE_LOCK_KEY = "
|
|
31
|
+
const TREE_STORE_WRITE_LOCK_KEY = "8391086132283252818"; // 0x7472656553544f52 as decimal string
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Timeout for reservations in seconds. Reservations older than this are stale.
|
|
@@ -789,20 +789,10 @@ async function createPostgresTreeStore(config, logger = null) {
|
|
|
789
789
|
connectionTimeoutMillis: config.createTimeoutSecs * 1000,
|
|
790
790
|
idleTimeoutMillis: config.recycleTimeoutSecs * 1000,
|
|
791
791
|
});
|
|
792
|
-
return createPostgresTreeStoreWithPool(pool, logger);
|
|
793
|
-
}
|
|
794
792
|
|
|
795
|
-
/**
|
|
796
|
-
* Create a PostgresTreeStore instance from an existing pg.Pool.
|
|
797
|
-
*
|
|
798
|
-
* @param {pg.Pool} pool - An existing connection pool
|
|
799
|
-
* @param {object} [logger] - Optional logger
|
|
800
|
-
* @returns {Promise<PostgresTreeStore>}
|
|
801
|
-
*/
|
|
802
|
-
async function createPostgresTreeStoreWithPool(pool, logger = null) {
|
|
803
793
|
const store = new PostgresTreeStore(pool, logger);
|
|
804
794
|
await store.initialize();
|
|
805
795
|
return store;
|
|
806
796
|
}
|
|
807
797
|
|
|
808
|
-
module.exports = { PostgresTreeStore, createPostgresTreeStore,
|
|
798
|
+
module.exports = { PostgresTreeStore, createPostgresTreeStore, TreeStoreError };
|
package/nodejs/storage/index.cjs
CHANGED
|
@@ -53,7 +53,6 @@ const SELECT_PAYMENT_SQL = `
|
|
|
53
53
|
pm.lnurl_pay_info,
|
|
54
54
|
pm.lnurl_withdraw_info,
|
|
55
55
|
pm.conversion_info,
|
|
56
|
-
pm.conversion_status,
|
|
57
56
|
t.metadata AS token_metadata,
|
|
58
57
|
t.tx_hash AS token_tx_hash,
|
|
59
58
|
t.tx_type AS token_tx_type,
|
|
@@ -261,6 +260,21 @@ class SqliteStorage {
|
|
|
261
260
|
paymentDetailsClauses.push("t.tx_type = ?");
|
|
262
261
|
params.push(paymentDetailsFilter.txType);
|
|
263
262
|
}
|
|
263
|
+
// Filter by LNURL preimage status
|
|
264
|
+
if (
|
|
265
|
+
paymentDetailsFilter.type === "lightning" &&
|
|
266
|
+
paymentDetailsFilter.hasLnurlPreimage !== undefined
|
|
267
|
+
) {
|
|
268
|
+
if (paymentDetailsFilter.hasLnurlPreimage) {
|
|
269
|
+
paymentDetailsClauses.push("lrm.preimage IS NOT NULL");
|
|
270
|
+
} else {
|
|
271
|
+
paymentDetailsClauses.push(
|
|
272
|
+
"lrm.payment_hash IS NOT NULL AND l.preimage IS NOT NULL AND lrm.preimage IS NULL"
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
|
|
264
278
|
if (paymentDetailsClauses.length > 0) {
|
|
265
279
|
allPaymentDetailsClauses.push(`(${paymentDetailsClauses.join(" AND ")})`);
|
|
266
280
|
}
|
|
@@ -546,15 +560,14 @@ class SqliteStorage {
|
|
|
546
560
|
insertPaymentMetadata(paymentId, metadata) {
|
|
547
561
|
try {
|
|
548
562
|
const stmt = this.db.prepare(`
|
|
549
|
-
INSERT INTO payment_metadata (payment_id, parent_payment_id, lnurl_pay_info, lnurl_withdraw_info, lnurl_description, conversion_info
|
|
550
|
-
VALUES (?, ?, ?, ?, ?,
|
|
563
|
+
INSERT INTO payment_metadata (payment_id, parent_payment_id, lnurl_pay_info, lnurl_withdraw_info, lnurl_description, conversion_info)
|
|
564
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
551
565
|
ON CONFLICT(payment_id) DO UPDATE SET
|
|
552
566
|
parent_payment_id = COALESCE(excluded.parent_payment_id, parent_payment_id),
|
|
553
567
|
lnurl_pay_info = COALESCE(excluded.lnurl_pay_info, lnurl_pay_info),
|
|
554
568
|
lnurl_withdraw_info = COALESCE(excluded.lnurl_withdraw_info, lnurl_withdraw_info),
|
|
555
569
|
lnurl_description = COALESCE(excluded.lnurl_description, lnurl_description),
|
|
556
|
-
conversion_info = COALESCE(excluded.conversion_info, conversion_info)
|
|
557
|
-
conversion_status = COALESCE(excluded.conversion_status, conversion_status)
|
|
570
|
+
conversion_info = COALESCE(excluded.conversion_info, conversion_info)
|
|
558
571
|
`);
|
|
559
572
|
|
|
560
573
|
stmt.run(
|
|
@@ -567,8 +580,7 @@ class SqliteStorage {
|
|
|
567
580
|
metadata.lnurlDescription,
|
|
568
581
|
metadata.conversionInfo
|
|
569
582
|
? JSON.stringify(metadata.conversionInfo)
|
|
570
|
-
: null
|
|
571
|
-
metadata.conversionStatus ?? null
|
|
583
|
+
: null
|
|
572
584
|
);
|
|
573
585
|
return Promise.resolve();
|
|
574
586
|
} catch (error) {
|
|
@@ -583,15 +595,14 @@ class SqliteStorage {
|
|
|
583
595
|
|
|
584
596
|
// ===== Deposit Operations =====
|
|
585
597
|
|
|
586
|
-
addDeposit(txid, vout, amountSats
|
|
598
|
+
addDeposit(txid, vout, amountSats) {
|
|
587
599
|
try {
|
|
588
600
|
const stmt = this.db.prepare(`
|
|
589
|
-
INSERT INTO unclaimed_deposits (txid, vout, amount_sats
|
|
590
|
-
VALUES (?, ?,
|
|
591
|
-
ON CONFLICT(txid, vout) DO UPDATE SET is_mature = excluded.is_mature, amount_sats = excluded.amount_sats
|
|
601
|
+
INSERT OR IGNORE INTO unclaimed_deposits (txid, vout, amount_sats)
|
|
602
|
+
VALUES (?, ?, ?)
|
|
592
603
|
`);
|
|
593
604
|
|
|
594
|
-
stmt.run(txid, vout, amountSats
|
|
605
|
+
stmt.run(txid, vout, amountSats);
|
|
595
606
|
return Promise.resolve();
|
|
596
607
|
} catch (error) {
|
|
597
608
|
return Promise.reject(
|
|
@@ -624,7 +635,7 @@ class SqliteStorage {
|
|
|
624
635
|
listDeposits() {
|
|
625
636
|
try {
|
|
626
637
|
const stmt = this.db.prepare(`
|
|
627
|
-
SELECT txid, vout, amount_sats,
|
|
638
|
+
SELECT txid, vout, amount_sats, claim_error, refund_tx, refund_tx_id
|
|
628
639
|
FROM unclaimed_deposits
|
|
629
640
|
`);
|
|
630
641
|
|
|
@@ -634,7 +645,6 @@ class SqliteStorage {
|
|
|
634
645
|
txid: row.txid,
|
|
635
646
|
vout: row.vout,
|
|
636
647
|
amountSats: row.amount_sats,
|
|
637
|
-
isMature: Boolean(row.is_mature ?? 1),
|
|
638
648
|
claimError: row.claim_error ? JSON.parse(row.claim_error) : null,
|
|
639
649
|
refundTx: row.refund_tx,
|
|
640
650
|
refundTxId: row.refund_tx_id,
|
|
@@ -685,7 +695,7 @@ class SqliteStorage {
|
|
|
685
695
|
setLnurlMetadata(metadata) {
|
|
686
696
|
try {
|
|
687
697
|
const stmt = this.db.prepare(
|
|
688
|
-
"INSERT OR REPLACE INTO lnurl_receive_metadata (payment_hash, nostr_zap_request, nostr_zap_receipt, sender_comment) VALUES (?, ?, ?, ?)"
|
|
698
|
+
"INSERT OR REPLACE INTO lnurl_receive_metadata (payment_hash, nostr_zap_request, nostr_zap_receipt, sender_comment, preimage) VALUES (?, ?, ?, ?, ?)"
|
|
689
699
|
);
|
|
690
700
|
|
|
691
701
|
const transaction = this.db.transaction(() => {
|
|
@@ -694,7 +704,8 @@ class SqliteStorage {
|
|
|
694
704
|
item.paymentHash,
|
|
695
705
|
item.nostrZapRequest || null,
|
|
696
706
|
item.nostrZapReceipt || null,
|
|
697
|
-
item.senderComment || null
|
|
707
|
+
item.senderComment || null,
|
|
708
|
+
item.preimage || null
|
|
698
709
|
);
|
|
699
710
|
}
|
|
700
711
|
});
|
|
@@ -819,9 +830,7 @@ class SqliteStorage {
|
|
|
819
830
|
timestamp: row.timestamp,
|
|
820
831
|
method,
|
|
821
832
|
details,
|
|
822
|
-
conversionDetails:
|
|
823
|
-
? { status: row.conversion_status, from: null, to: null }
|
|
824
|
-
: null,
|
|
833
|
+
conversionDetails: null,
|
|
825
834
|
};
|
|
826
835
|
}
|
|
827
836
|
|
|
@@ -392,24 +392,6 @@ class MigrationManager {
|
|
|
392
392
|
updated_at INTEGER NOT NULL
|
|
393
393
|
)`
|
|
394
394
|
},
|
|
395
|
-
{
|
|
396
|
-
name: "Drop preimage column from lnurl_receive_metadata",
|
|
397
|
-
sql: `ALTER TABLE lnurl_receive_metadata DROP COLUMN preimage`
|
|
398
|
-
},
|
|
399
|
-
{
|
|
400
|
-
name: "Clear cached lightning address for CachedLightningAddress format change",
|
|
401
|
-
sql: `DELETE FROM settings WHERE key = 'lightning_address'`
|
|
402
|
-
},
|
|
403
|
-
{
|
|
404
|
-
name: "Add is_mature to unclaimed_deposits",
|
|
405
|
-
sql: [
|
|
406
|
-
`ALTER TABLE unclaimed_deposits ADD COLUMN is_mature INTEGER NOT NULL DEFAULT 1`,
|
|
407
|
-
]
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
name: "Add conversion_status to payment_metadata",
|
|
411
|
-
sql: `ALTER TABLE payment_metadata ADD COLUMN conversion_status TEXT`,
|
|
412
|
-
},
|
|
413
395
|
];
|
|
414
396
|
}
|
|
415
397
|
}
|
package/package.json
CHANGED