@breeztech/breez-sdk-spark 0.13.9-debug → 0.13.10-dev

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.
Binary file
@@ -119,16 +119,22 @@ export const intounderlyingsink_close: (a: number) => any;
119
119
  export const intounderlyingsink_write: (a: number, b: any) => any;
120
120
  export const intounderlyingsource_cancel: (a: number) => void;
121
121
  export const intounderlyingsource_pull: (a: number, b: any) => any;
122
+ export const wasm_bindgen__convert__closures_____invoke__h4fc1641481bc1d84: (a: number, b: number, c: any) => [number, number];
123
+ export const wasm_bindgen__convert__closures_____invoke__h4fc1641481bc1d84_4: (a: number, b: number, c: any) => [number, number];
124
+ export const wasm_bindgen__convert__closures_____invoke__h4fc1641481bc1d84_5: (a: number, b: number, c: any) => [number, number];
125
+ export const wasm_bindgen__convert__closures_____invoke__h4fc1641481bc1d84_6: (a: number, b: number, c: any) => [number, number];
126
+ export const wasm_bindgen__convert__closures_____invoke__h41057d61edf43a32: (a: number, b: number, c: any, d: any) => void;
127
+ export const wasm_bindgen__convert__closures_____invoke__h4819aba3eed2db57: (a: number, b: number, c: any) => void;
128
+ export const wasm_bindgen__convert__closures_____invoke__h4819aba3eed2db57_2: (a: number, b: number, c: any) => void;
129
+ export const wasm_bindgen__convert__closures_____invoke__h4819aba3eed2db57_3: (a: number, b: number, c: any) => void;
130
+ export const wasm_bindgen__convert__closures_____invoke__h484cd36e13f37bd7: (a: number, b: number) => void;
122
131
  export const __wbindgen_malloc: (a: number, b: number) => number;
123
132
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
124
133
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
125
134
  export const __wbindgen_exn_store: (a: number) => void;
126
135
  export const __externref_table_alloc: () => number;
127
- export const __wbindgen_export_5: WebAssembly.Table;
136
+ export const __wbindgen_externrefs: WebAssembly.Table;
128
137
  export const __externref_drop_slice: (a: number, b: number) => void;
129
- export const __wbindgen_export_7: WebAssembly.Table;
138
+ export const __wbindgen_destroy_closure: (a: number, b: number) => void;
130
139
  export const __externref_table_dealloc: (a: number) => void;
131
- export const closure388_externref_shim: (a: number, b: number, c: any) => void;
132
- export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1015faeeadd5b26c: (a: number, b: number) => void;
133
- export const closure668_externref_shim: (a: number, b: number, c: any, d: any) => void;
134
140
  export const __wbindgen_start: () => void;
package/nodejs/index.mjs CHANGED
@@ -4,13 +4,13 @@
4
4
  import pkg from './index.js';
5
5
 
6
6
  export const {
7
- defaultPostgresStorageConfig,
8
- defaultConfig,
9
7
  connect,
8
+ connectWithSigner,
9
+ defaultConfig,
10
10
  defaultExternalSigner,
11
- initLogging,
11
+ defaultPostgresStorageConfig,
12
12
  getSparkStatus,
13
- connectWithSigner,
13
+ initLogging,
14
14
  task_worker_entry_point,
15
15
  BreezSdk,
16
16
  DefaultSigner,
@@ -100,9 +100,9 @@ class PostgresTokenStore {
100
100
 
101
101
  /**
102
102
  * Run a function inside a transaction without the advisory lock. Used by
103
- * operations scoped to a single reservation_id (`cancelReservation`,
104
- * `finalizeReservation`) where MVCC + row-level locks suffice and the global
105
- * lock would only add contention.
103
+ * operations scoped to a single reservation_id (`cancelReservation`)
104
+ * where MVCC + row-level locks suffice and the global lock would only add
105
+ * contention.
106
106
  * @param {function(import('pg').PoolClient): Promise<T>} fn
107
107
  * @returns {Promise<T>}
108
108
  * @template T
@@ -295,7 +295,8 @@ class PostgresTokenStore {
295
295
  /**
296
296
  * Returns the spendable per-token balances aggregated server-side.
297
297
  * Each entry includes full token metadata + the available + swap-reserved sum.
298
- * Tokens with zero spendable balance are filtered out by the HAVING clause.
298
+ * Matches the in-memory default impl which returns all tokens that have
299
+ * at least one output (including zero spendable balance).
299
300
  * @returns {Promise<Array<{metadata: object, balance: string}>>}
300
301
  */
301
302
  async getTokenBalances() {
@@ -315,13 +316,6 @@ class PostgresTokenStore {
315
316
  LEFT JOIN token_reservations r ON o.reservation_id = r.id
316
317
  GROUP BY m.identifier, m.issuer_public_key, m.name, m.ticker,
317
318
  m.decimals, m.max_supply, m.is_freezable, m.creation_entity_public_key
318
- HAVING COALESCE(SUM(
319
- CASE
320
- WHEN o.reservation_id IS NULL THEN o.token_amount::numeric
321
- WHEN r.purpose = 'Swap' THEN o.token_amount::numeric
322
- ELSE 0
323
- END
324
- ), 0) > 0
325
319
  `);
326
320
  return result.rows.map((row) => ({
327
321
  metadata: {
@@ -720,7 +714,11 @@ class PostgresTokenStore {
720
714
  */
721
715
  async finalizeReservation(id) {
722
716
  try {
723
- await this._withTransaction(async (client) => {
717
+ // _withWriteTransaction acquires the advisory lock so this serializes
718
+ // against `setTokensOutputs`. Without it, a concurrent setTokensOutputs
719
+ // could read token_spent_outputs before our marker commits and re-insert
720
+ // the just-spent output as Available.
721
+ await this._withWriteTransaction(async (client) => {
724
722
  // Get reservation purpose
725
723
  const reservationResult = await client.query(
726
724
  "SELECT purpose FROM token_reservations WHERE id = $1",
@@ -99,9 +99,8 @@ class PostgresTreeStore {
99
99
  /**
100
100
  * Run a function inside a transaction without the advisory lock. Used by
101
101
  * operations scoped to a single reservation_id (`addLeaves`,
102
- * `cancelReservation`, `finalizeReservation`, `updateReservation`) where
103
- * MVCC + row-level locks suffice and the global lock would only add
104
- * contention.
102
+ * `cancelReservation`, `updateReservation`) where MVCC + row-level locks
103
+ * suffice and the global lock would only add contention.
105
104
  * @param {function(import('pg').PoolClient): Promise<T>} fn
106
105
  * @returns {Promise<T>}
107
106
  * @template T
@@ -345,7 +344,11 @@ class PostgresTreeStore {
345
344
  */
346
345
  async finalizeReservation(id, newLeaves) {
347
346
  try {
348
- await this._withTransaction(async (client) => {
347
+ // _withWriteTransaction acquires the advisory lock so this serializes
348
+ // against `setLeaves`. Without it, a concurrent setLeaves could read
349
+ // tree_spent_leaves before our marker commits and re-insert the
350
+ // just-spent leaf as Available.
351
+ await this._withWriteTransaction(async (client) => {
349
352
  // Check if reservation exists and get purpose
350
353
  const res = await client.query(
351
354
  "SELECT id, purpose FROM tree_reservations WHERE id = $1",
@@ -522,17 +525,13 @@ class PostgresTreeStore {
522
525
  }
523
526
  }
524
527
 
525
- /**
526
- * Largest single value the selection algorithm could possibly need.
527
- * For an unbounded target we have to return all leaves (no prefilter).
528
- */
529
528
  _maxTargetForPrefilter(targetAmounts) {
530
529
  if (!targetAmounts) return Number.MAX_SAFE_INTEGER;
531
530
  if (targetAmounts.type === "amountAndFee") {
532
- return Math.max(targetAmounts.amountSats, targetAmounts.feeSats || 0);
531
+ return targetAmounts.amountSats + (targetAmounts.feeSats || 0);
533
532
  }
534
533
  if (targetAmounts.type === "exactDenominations") {
535
- return targetAmounts.denominations.reduce((m, v) => Math.max(m, v), 0);
534
+ return targetAmounts.denominations.reduce((m, v) => m + v, 0);
536
535
  }
537
536
  return Number.MAX_SAFE_INTEGER;
538
537
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@breeztech/breez-sdk-spark",
3
- "version": "0.13.9-debug",
3
+ "version": "0.13.10-dev",
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)",
package/ssr/index.js CHANGED
@@ -23,9 +23,14 @@ export default async function init(wasmInput) {
23
23
  return _initPromise;
24
24
  }
25
25
 
26
- export function defaultPostgresStorageConfig(...args) {
27
- if (!_module) _notInitialized('defaultPostgresStorageConfig');
28
- return _module.defaultPostgresStorageConfig(...args);
26
+ export function connect(...args) {
27
+ if (!_module) _notInitialized('connect');
28
+ return _module.connect(...args);
29
+ }
30
+
31
+ export function connectWithSigner(...args) {
32
+ if (!_module) _notInitialized('connectWithSigner');
33
+ return _module.connectWithSigner(...args);
29
34
  }
30
35
 
31
36
  export function defaultConfig(...args) {
@@ -33,19 +38,14 @@ export function defaultConfig(...args) {
33
38
  return _module.defaultConfig(...args);
34
39
  }
35
40
 
36
- export function connect(...args) {
37
- if (!_module) _notInitialized('connect');
38
- return _module.connect(...args);
39
- }
40
-
41
41
  export function defaultExternalSigner(...args) {
42
42
  if (!_module) _notInitialized('defaultExternalSigner');
43
43
  return _module.defaultExternalSigner(...args);
44
44
  }
45
45
 
46
- export function initLogging(...args) {
47
- if (!_module) _notInitialized('initLogging');
48
- return _module.initLogging(...args);
46
+ export function defaultPostgresStorageConfig(...args) {
47
+ if (!_module) _notInitialized('defaultPostgresStorageConfig');
48
+ return _module.defaultPostgresStorageConfig(...args);
49
49
  }
50
50
 
51
51
  export function getSparkStatus(...args) {
@@ -53,9 +53,9 @@ export function getSparkStatus(...args) {
53
53
  return _module.getSparkStatus(...args);
54
54
  }
55
55
 
56
- export function connectWithSigner(...args) {
57
- if (!_module) _notInitialized('connectWithSigner');
58
- return _module.connectWithSigner(...args);
56
+ export function initLogging(...args) {
57
+ if (!_module) _notInitialized('initLogging');
58
+ return _module.initLogging(...args);
59
59
  }
60
60
 
61
61
  export function task_worker_entry_point(...args) {