@breeztech/breez-sdk-spark-react-native 0.14.0 → 0.15.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.
@@ -49,6 +49,42 @@ export declare function defaultConfig(network: Network): Config;
49
49
  * Result containing the signer as `Arc<dyn ExternalSigner>`
50
50
  */
51
51
  export declare function defaultExternalSigner(mnemonic: string, passphrase: string | undefined, network: Network, keySetConfig: KeySetConfig | undefined): ExternalSigner;
52
+ /**
53
+ * Builds a [`Config`] suitable for multi-tenant server-mode deployments.
54
+ *
55
+ * This preset returns the same configuration as [`default_config`] with
56
+ * [`background_tasks_enabled`](Config::background_tasks_enabled) set to
57
+ * `false`. In server mode, the SDK is treated as a library: the host
58
+ * orchestrates sync, claiming, and event delivery (typically via webhooks)
59
+ * explicitly, so an ephemeral SDK instance stays cheap and predictable.
60
+ *
61
+ * Config fields whose background services are gated off are reset to their
62
+ * inactive shape: `real_time_sync_server_url` is set to `None`, and both
63
+ * `leaf_optimization_config.auto_enabled` and
64
+ * `token_optimization_config.auto_enabled` are set to `false`. The SDK
65
+ * rejects builds where `background_tasks_enabled` is `false` and any of
66
+ * those fields is left in its active shape, so flip the flag via this
67
+ * helper rather than by hand.
68
+ *
69
+ * Explicit operations (`sync_wallet`, `claim_deposit`,
70
+ * `list_unclaimed_deposits`, `refund_deposit`,
71
+ * `refund_pending_conversions`, etc.) continue to work and are the intended
72
+ * entry points in this mode.
73
+ *
74
+ * Stable Balance is not supported in this mode because its conversion worker
75
+ * is a background service.
76
+ *
77
+ * One-time setup that the SDK normally applies automatically — notably
78
+ * `private_enabled_default` — is NOT applied in this mode. Drive setup
79
+ * explicitly via `update_user_settings` (and any other relevant APIs) so
80
+ * ephemeral per-request SDK instances incur no implicit setup overhead.
81
+ *
82
+ * `get_info` reads balance directly from the spark wallet in this mode
83
+ * rather than from the background-maintained storage cache, so balance
84
+ * reflects the latest local sync and `ensure_synced=true` is rejected with
85
+ * an invalid-input error
86
+ */
87
+ export declare function defaultServerConfig(network: Network): Config;
52
88
  /**
53
89
  * Fetches the current status of Spark network services relevant to the SDK.
54
90
  *
@@ -59,15 +95,6 @@ export declare function getSparkStatus(asyncOpts_?: {
59
95
  signal: AbortSignal;
60
96
  }): Promise<SparkStatus>;
61
97
  export declare function initLogging(logDir: string | undefined, appLogger: Logger | undefined, logFilter: string | undefined): void;
62
- /**
63
- * Creates a new shareable [`ConnectionManager`].
64
- *
65
- * `connections_per_operator` controls per-operator connection pooling:
66
- * `None` keeps a single connection per operator (suitable for almost every
67
- * deployment); `Some(n)` opens `n` connections per operator and balances
68
- * requests across them.
69
- */
70
- export declare function newConnectionManager(connectionsPerOperator: /*u32*/ number | undefined): ConnectionManagerInterface;
71
98
  /**
72
99
  * Constructs a shareable REST-based [`BitcoinChainService`].
73
100
  *
@@ -83,14 +110,16 @@ export declare function newRestChainService(url: string, network: Network, apiTy
83
110
  signal: AbortSignal;
84
111
  }): Promise<BitcoinChainService>;
85
112
  /**
86
- * Construct a new shared SSP connection manager.
113
+ * Constructs an [`SdkContext`] from a `SdkContextConfig`.
87
114
  *
88
- * Pass the returned `Arc<SspConnectionManager>` to
89
- * [`SdkBuilder::with_ssp_connection_manager`](crate::SdkBuilder::with_ssp_connection_manager)
90
- * when building each SDK instance that should share the underlying HTTP
91
- * connection pool.
115
+ * The returned `Arc` is cheap to clone and can back many SDK instances.
116
+ * `SdkContextConfig::new(network)` yields an in-memory, single-tenant setup;
117
+ * supply a DB config to back the SDKs with a shared `PostgreSQL` or `MySQL`
118
+ * pool.
92
119
  */
93
- export declare function newSspConnectionManager(userAgent: string | undefined): SspConnectionManagerInterface;
120
+ export declare function newSharedSdkContext(config: SdkContextConfig, asyncOpts_?: {
121
+ signal: AbortSignal;
122
+ }): Promise<SdkContextInterface>;
94
123
  /**
95
124
  * Trait for event listeners
96
125
  */
@@ -794,8 +823,15 @@ export type Config = {
794
823
  /**
795
824
  * Whether the Spark private mode is enabled by default.
796
825
  *
797
- * If set to true, the Spark private mode will be enabled on the first initialization of the SDK.
798
- * If set to false, no changes will be made to the Spark private mode.
826
+ * If set to true, the Spark private mode will be enabled on the first
827
+ * initialization of the SDK. If set to false, no changes will be made
828
+ * to the Spark private mode.
829
+ *
830
+ * This default is only auto-applied when `background_tasks_enabled` is
831
+ * `true`. When `background_tasks_enabled` is `false`, the SDK does not
832
+ * touch the Spark private mode on startup; call `update_user_settings`
833
+ * with `spark_private_mode_enabled` set as needed on a one-time setup
834
+ * pass.
799
835
  */
800
836
  privateEnabledDefault: boolean;
801
837
  /**
@@ -805,7 +841,16 @@ export type Config = {
805
841
  * Fewer, bigger leaves allow for more funds to be exited unilaterally.
806
842
  * More leaves allow payments to be made without needing a swap, reducing payment latency.
807
843
  */
808
- optimizationConfig: OptimizationConfig;
844
+ leafOptimizationConfig: LeafOptimizationConfig;
845
+ /**
846
+ * Configuration for token-output optimization.
847
+ *
848
+ * Token-output optimization controls automatic consolidation of a token's
849
+ * available outputs. Keeping the output set small reduces transaction size,
850
+ * while keeping enough distinct outputs preserves concurrency for parallel
851
+ * sends.
852
+ */
853
+ tokenOptimizationConfig: TokenOptimizationConfig;
809
854
  /**
810
855
  * Configuration for automatic conversion of Bitcoin to stable tokens.
811
856
  *
@@ -827,6 +872,33 @@ export type Config = {
827
872
  * deployments (e.g. dev/staging environments).
828
873
  */
829
874
  sparkConfig: SparkConfig | undefined;
875
+ /**
876
+ * Master switch for per-instance background services.
877
+ *
878
+ * When `true` (default), the SDK runs its standard background work:
879
+ * periodic sync, lightning-address recovery, private-mode initialization,
880
+ * the leaf and token-output optimizers, the Spark server-event
881
+ * subscription, and the real-time sync client (when
882
+ * `real_time_sync_server_url` is set).
883
+ *
884
+ * When `false`, **no background service is started**, regardless of any
885
+ * other setting on this config. This is intended for multi-tenant server
886
+ * deployments where the host application orchestrates sync and claims
887
+ * explicitly and receives events via webhooks. Use
888
+ * `default_server_config` to get this preset.
889
+ *
890
+ * Explicit operations (`sync_wallet`, `claim_deposit`,
891
+ * `list_unclaimed_deposits`, `refund_deposit`,
892
+ * `refund_pending_conversions`, leaf/token optimization, etc.) work
893
+ * regardless of this flag.
894
+ *
895
+ * When `false`, the SDK rejects builds where fields whose backing
896
+ * service is gated off are still in their active shape:
897
+ * `stable_balance_config` must be `None`, `real_time_sync_server_url`
898
+ * must be `None`, and `optimization_config.auto_enabled` must be `false`.
899
+ * `default_server_config` already sets these compatible values.
900
+ */
901
+ backgroundTasksEnabled: boolean;
830
902
  };
831
903
  /**
832
904
  * Generated factory for {@link Config} record objects.
@@ -1880,6 +1952,14 @@ export declare const FreezeIssuerTokenResponse: Readonly<{
1880
1952
  * Request to get the balance of the wallet
1881
1953
  */
1882
1954
  export type GetInfoRequest = {
1955
+ /**
1956
+ * When `Some(true)`, and `background_tasks_enabled` is `true`, the call
1957
+ * waits for the initial Full sync to complete before returning.
1958
+ *
1959
+ * When `background_tasks_enabled` is `false`, setting this to `Some(true)`
1960
+ * is rejected with an invalid-input error. There is no background sync to
1961
+ * wait on; call `sync_wallet` explicitly first if you need fresh state.
1962
+ */
1883
1963
  ensureSynced: boolean | undefined;
1884
1964
  };
1885
1965
  /**
@@ -2186,6 +2266,53 @@ export declare const KeySetConfig: Readonly<{
2186
2266
  */
2187
2267
  defaults: () => Partial<KeySetConfig>;
2188
2268
  }>;
2269
+ /**
2270
+ * Configuration for leaf optimization.
2271
+ */
2272
+ export type LeafOptimizationConfig = {
2273
+ /**
2274
+ * Whether automatic leaf optimization is enabled.
2275
+ *
2276
+ * If set to true, the SDK will automatically optimize the leaf set when it changes.
2277
+ * Otherwise, the manual optimization API must be used to optimize the leaf set.
2278
+ *
2279
+ * Default value is true.
2280
+ */
2281
+ autoEnabled: boolean;
2282
+ /**
2283
+ * The desired multiplicity for the leaf set.
2284
+ *
2285
+ * Setting this to 0 will optimize for maximizing unilateral exit.
2286
+ * Higher values will optimize for minimizing transfer swaps, with higher values
2287
+ * being more aggressive and allowing better TPS rates.
2288
+ *
2289
+ * For end-user wallets, values of 1-5 are recommended. Values above 5 are
2290
+ * intended for high-throughput server environments and are not recommended
2291
+ * for end-user wallets due to significantly higher unilateral exit costs.
2292
+ *
2293
+ * Default value is 1.
2294
+ */
2295
+ multiplicity: number;
2296
+ };
2297
+ /**
2298
+ * Generated factory for {@link LeafOptimizationConfig} record objects.
2299
+ */
2300
+ export declare const LeafOptimizationConfig: Readonly<{
2301
+ /**
2302
+ * Create a frozen instance of {@link LeafOptimizationConfig}, with defaults specified
2303
+ * in Rust, in the {@link breez_sdk_spark} crate.
2304
+ */
2305
+ create: (partial: Partial<LeafOptimizationConfig> & Required<Omit<LeafOptimizationConfig, never>>) => LeafOptimizationConfig;
2306
+ /**
2307
+ * Create a frozen instance of {@link LeafOptimizationConfig}, with defaults specified
2308
+ * in Rust, in the {@link breez_sdk_spark} crate.
2309
+ */
2310
+ new: (partial: Partial<LeafOptimizationConfig> & Required<Omit<LeafOptimizationConfig, never>>) => LeafOptimizationConfig;
2311
+ /**
2312
+ * Defaults specified in the {@link breez_sdk_spark} crate.
2313
+ */
2314
+ defaults: () => Partial<LeafOptimizationConfig>;
2315
+ }>;
2189
2316
  export type LightningAddressDetails = {
2190
2317
  address: string;
2191
2318
  payRequest: LnurlPayRequestDetails;
@@ -2998,50 +3125,6 @@ export declare const NostrRelayConfig: Readonly<{
2998
3125
  */
2999
3126
  defaults: () => Partial<NostrRelayConfig>;
3000
3127
  }>;
3001
- export type OptimizationConfig = {
3002
- /**
3003
- * Whether automatic leaf optimization is enabled.
3004
- *
3005
- * If set to true, the SDK will automatically optimize the leaf set when it changes.
3006
- * Otherwise, the manual optimization API must be used to optimize the leaf set.
3007
- *
3008
- * Default value is true.
3009
- */
3010
- autoEnabled: boolean;
3011
- /**
3012
- * The desired multiplicity for the leaf set.
3013
- *
3014
- * Setting this to 0 will optimize for maximizing unilateral exit.
3015
- * Higher values will optimize for minimizing transfer swaps, with higher values
3016
- * being more aggressive and allowing better TPS rates.
3017
- *
3018
- * For end-user wallets, values of 1-5 are recommended. Values above 5 are
3019
- * intended for high-throughput server environments and are not recommended
3020
- * for end-user wallets due to significantly higher unilateral exit costs.
3021
- *
3022
- * Default value is 1.
3023
- */
3024
- multiplicity: number;
3025
- };
3026
- /**
3027
- * Generated factory for {@link OptimizationConfig} record objects.
3028
- */
3029
- export declare const OptimizationConfig: Readonly<{
3030
- /**
3031
- * Create a frozen instance of {@link OptimizationConfig}, with defaults specified
3032
- * in Rust, in the {@link breez_sdk_spark} crate.
3033
- */
3034
- create: (partial: Partial<OptimizationConfig> & Required<Omit<OptimizationConfig, never>>) => OptimizationConfig;
3035
- /**
3036
- * Create a frozen instance of {@link OptimizationConfig}, with defaults specified
3037
- * in Rust, in the {@link breez_sdk_spark} crate.
3038
- */
3039
- new: (partial: Partial<OptimizationConfig> & Required<Omit<OptimizationConfig, never>>) => OptimizationConfig;
3040
- /**
3041
- * Defaults specified in the {@link breez_sdk_spark} crate.
3042
- */
3043
- defaults: () => Partial<OptimizationConfig>;
3044
- }>;
3045
3128
  export type OptimizationProgress = {
3046
3129
  isRunning: boolean;
3047
3130
  currentRound: number;
@@ -3813,6 +3896,50 @@ export declare const SchnorrSignatureBytes: Readonly<{
3813
3896
  */
3814
3897
  defaults: () => Partial<SchnorrSignatureBytes>;
3815
3898
  }>;
3899
+ /**
3900
+ * Settings for [`new_shared_sdk_context`]. All fields are optional; the defaults
3901
+ * match the single-SDK happy path.
3902
+ */
3903
+ export type SdkContextConfig = {
3904
+ /**
3905
+ * Network the shared resources target. Defaults to [`Network::Mainnet`].
3906
+ * Used to gate the partner JWT header provider — only constructed on
3907
+ * Mainnet, since Regtest has no JWT-issuing Breez endpoint.
3908
+ */
3909
+ network: Network;
3910
+ /**
3911
+ * Breez API key. When set together with `network == Mainnet`, the
3912
+ * context constructs a shared partner JWT header provider that all
3913
+ * SDKs built from this context will attach to their SO requests.
3914
+ */
3915
+ apiKey: string | undefined;
3916
+ /**
3917
+ * Number of gRPC connections per Spark operator. `None` (or `Some(1)`)
3918
+ * keeps a single connection per operator (the right choice for most
3919
+ * deployments); `Some(n)` opens `n` channels per operator and balances
3920
+ * requests across them.
3921
+ */
3922
+ connectionsPerOperator: /*u32*/ number | undefined;
3923
+ };
3924
+ /**
3925
+ * Generated factory for {@link SdkContextConfig} record objects.
3926
+ */
3927
+ export declare const SdkContextConfig: Readonly<{
3928
+ /**
3929
+ * Create a frozen instance of {@link SdkContextConfig}, with defaults specified
3930
+ * in Rust, in the {@link breez_sdk_spark} crate.
3931
+ */
3932
+ create: (partial: Partial<SdkContextConfig> & Required<Omit<SdkContextConfig, "apiKey" | "connectionsPerOperator">>) => SdkContextConfig;
3933
+ /**
3934
+ * Create a frozen instance of {@link SdkContextConfig}, with defaults specified
3935
+ * in Rust, in the {@link breez_sdk_spark} crate.
3936
+ */
3937
+ new: (partial: Partial<SdkContextConfig> & Required<Omit<SdkContextConfig, "apiKey" | "connectionsPerOperator">>) => SdkContextConfig;
3938
+ /**
3939
+ * Defaults specified in the {@link breez_sdk_spark} crate.
3940
+ */
3941
+ defaults: () => Partial<SdkContextConfig>;
3942
+ }>;
3816
3943
  /**
3817
3944
  * FFI-safe representation of a private key (32 bytes)
3818
3945
  */
@@ -4666,6 +4793,66 @@ export declare const TokenMetadata: Readonly<{
4666
4793
  */
4667
4794
  defaults: () => Partial<TokenMetadata>;
4668
4795
  }>;
4796
+ /**
4797
+ * Configuration for token-output optimization.
4798
+ */
4799
+ export type TokenOptimizationConfig = {
4800
+ /**
4801
+ * Whether automatic token-output consolidation is enabled.
4802
+ *
4803
+ * If set to true, the SDK will periodically consolidate a token's outputs
4804
+ * once their count exceeds [`Self::min_outputs_threshold`]. Otherwise, no
4805
+ * automatic consolidation is performed.
4806
+ *
4807
+ * Default value is true.
4808
+ */
4809
+ autoEnabled: boolean;
4810
+ /**
4811
+ * Number of token outputs to produce when token-output auto-consolidation
4812
+ * fires.
4813
+ *
4814
+ * Instead of collapsing a token's outputs into a single output (which
4815
+ * serializes subsequent payments), the SDK splits the consolidated balance
4816
+ * across this many outputs of roughly equal value. Higher values preserve
4817
+ * concurrency for parallel sends at the cost of a slightly larger output
4818
+ * set.
4819
+ *
4820
+ * Must be >= 1 and strictly less than [`Self::min_outputs_threshold`].
4821
+ *
4822
+ * Default value is 5.
4823
+ */
4824
+ targetOutputCount: number;
4825
+ /**
4826
+ * Output count that triggers per-token auto-consolidation.
4827
+ *
4828
+ * Auto-consolidation triggers for a token when its available output count
4829
+ * strictly exceeds this threshold.
4830
+ *
4831
+ * Must be greater than 1.
4832
+ *
4833
+ * Default value is 50.
4834
+ */
4835
+ minOutputsThreshold: number;
4836
+ };
4837
+ /**
4838
+ * Generated factory for {@link TokenOptimizationConfig} record objects.
4839
+ */
4840
+ export declare const TokenOptimizationConfig: Readonly<{
4841
+ /**
4842
+ * Create a frozen instance of {@link TokenOptimizationConfig}, with defaults specified
4843
+ * in Rust, in the {@link breez_sdk_spark} crate.
4844
+ */
4845
+ create: (partial: Partial<TokenOptimizationConfig> & Required<Omit<TokenOptimizationConfig, never>>) => TokenOptimizationConfig;
4846
+ /**
4847
+ * Create a frozen instance of {@link TokenOptimizationConfig}, with defaults specified
4848
+ * in Rust, in the {@link breez_sdk_spark} crate.
4849
+ */
4850
+ new: (partial: Partial<TokenOptimizationConfig> & Required<Omit<TokenOptimizationConfig, never>>) => TokenOptimizationConfig;
4851
+ /**
4852
+ * Defaults specified in the {@link breez_sdk_spark} crate.
4853
+ */
4854
+ defaults: () => Partial<TokenOptimizationConfig>;
4855
+ }>;
4669
4856
  export type TxStatus = {
4670
4857
  confirmed: boolean;
4671
4858
  blockHeight: /*u32*/ number | undefined;
@@ -13911,6 +14098,20 @@ export interface BreezSdkInterface {
13911
14098
  refundDeposit(request: RefundDepositRequest, asyncOpts_?: {
13912
14099
  signal: AbortSignal;
13913
14100
  }): Promise<RefundDepositResponse>;
14101
+ /**
14102
+ * Runs one pass of the pending-conversion refunder.
14103
+ *
14104
+ * Iterates over payments whose conversions failed and have a refund
14105
+ * pending, then attempts to refund each one. This is the same logic the
14106
+ * SDK runs internally on a periodic schedule when
14107
+ * `background_tasks_enabled` is `true`. When background tasks are
14108
+ * disabled the periodic refunder does not run, and this method is the
14109
+ * explicit entry point for driving the pass; when background tasks are
14110
+ * enabled, it can be called to force an immediate refund pass.
14111
+ */
14112
+ refundPendingConversions(asyncOpts_?: {
14113
+ signal: AbortSignal;
14114
+ }): Promise<void>;
13914
14115
  registerLightningAddress(request: RegisterLightningAddressRequest, asyncOpts_?: {
13915
14116
  signal: AbortSignal;
13916
14117
  }): Promise<LightningAddressInfo>;
@@ -14282,6 +14483,20 @@ export declare class BreezSdk extends UniffiAbstractObject implements BreezSdkIn
14282
14483
  refundDeposit(request: RefundDepositRequest, asyncOpts_?: {
14283
14484
  signal: AbortSignal;
14284
14485
  }): Promise<RefundDepositResponse>;
14486
+ /**
14487
+ * Runs one pass of the pending-conversion refunder.
14488
+ *
14489
+ * Iterates over payments whose conversions failed and have a refund
14490
+ * pending, then attempts to refund each one. This is the same logic the
14491
+ * SDK runs internally on a periodic schedule when
14492
+ * `background_tasks_enabled` is `true`. When background tasks are
14493
+ * disabled the periodic refunder does not run, and this method is the
14494
+ * explicit entry point for driving the pass; when background tasks are
14495
+ * enabled, it can be called to force an immediate refund pass.
14496
+ */
14497
+ refundPendingConversions(asyncOpts_?: {
14498
+ signal: AbortSignal;
14499
+ }): Promise<void>;
14285
14500
  registerLightningAddress(request: RegisterLightningAddressRequest, asyncOpts_?: {
14286
14501
  signal: AbortSignal;
14287
14502
  }): Promise<LightningAddressInfo>;
@@ -14385,45 +14600,6 @@ export declare class BreezSdk extends UniffiAbstractObject implements BreezSdkIn
14385
14600
  uniffiDestroy(): void;
14386
14601
  static instanceOf(obj: any): obj is BreezSdk;
14387
14602
  }
14388
- /**
14389
- * A shareable manager for gRPC connections to the Spark operators.
14390
- *
14391
- * Construct one via [`new_connection_manager`] and pass the same `Arc` to
14392
- * multiple [`SdkBuilder`](crate::SdkBuilder)s via
14393
- * [`SdkBuilder::with_connection_manager`](crate::SdkBuilder::with_connection_manager).
14394
- * Connections close when the last `Arc<ConnectionManager>` is dropped;
14395
- * [`BreezSdk::disconnect`](crate::BreezSdk::disconnect) does not affect them.
14396
- *
14397
- * All SDK instances sharing a `ConnectionManager` must be configured for the
14398
- * same network and operator pool. The TLS settings and user agent of the
14399
- * first SDK to connect to a given operator are reused for everyone afterwards.
14400
- */
14401
- export interface ConnectionManagerInterface {
14402
- }
14403
- /**
14404
- * A shareable manager for gRPC connections to the Spark operators.
14405
- *
14406
- * Construct one via [`new_connection_manager`] and pass the same `Arc` to
14407
- * multiple [`SdkBuilder`](crate::SdkBuilder)s via
14408
- * [`SdkBuilder::with_connection_manager`](crate::SdkBuilder::with_connection_manager).
14409
- * Connections close when the last `Arc<ConnectionManager>` is dropped;
14410
- * [`BreezSdk::disconnect`](crate::BreezSdk::disconnect) does not affect them.
14411
- *
14412
- * All SDK instances sharing a `ConnectionManager` must be configured for the
14413
- * same network and operator pool. The TLS settings and user agent of the
14414
- * first SDK to connect to a given operator are reused for everyone afterwards.
14415
- */
14416
- export declare class ConnectionManager extends UniffiAbstractObject implements ConnectionManagerInterface {
14417
- readonly [uniffiTypeNameSymbol] = "ConnectionManager";
14418
- readonly [destructorGuardSymbol]: UniffiRustArcPtr;
14419
- readonly [pointerLiteralSymbol]: UnsafeMutableRawPointer;
14420
- private constructor();
14421
- /**
14422
- * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
14423
- */
14424
- uniffiDestroy(): void;
14425
- static instanceOf(obj: any): obj is ConnectionManager;
14426
- }
14427
14603
  /**
14428
14604
  * External signer trait that can be implemented by users and passed to the SDK.
14429
14605
  *
@@ -15421,14 +15597,6 @@ export interface SdkBuilderInterface {
15421
15597
  withChainService(chainService: BitcoinChainService, asyncOpts_?: {
15422
15598
  signal: AbortSignal;
15423
15599
  }): Promise<void>;
15424
- /**
15425
- * Sets a shared connection manager to be reused across SDK instances.
15426
- * Arguments:
15427
- * - `connection_manager`: The shared connection manager.
15428
- */
15429
- withConnectionManager(connectionManager: ConnectionManagerInterface, asyncOpts_?: {
15430
- signal: AbortSignal;
15431
- }): Promise<void>;
15432
15600
  /**
15433
15601
  * Sets the root storage directory to initialize the default storage with.
15434
15602
  * This initializes both storage and real-time sync storage with the
@@ -15477,21 +15645,14 @@ export interface SdkBuilderInterface {
15477
15645
  signal: AbortSignal;
15478
15646
  }): Promise<void>;
15479
15647
  /**
15480
- * Sets a custom session manager used to persist authentication sessions.
15648
+ * Threads a shared [`SdkContext`](crate::SdkContext) into the builder.
15481
15649
  *
15482
- * Provide a shared, persistent implementation (e.g. backed by `PostgreSQL`
15483
- * or Redis) to let multiple SDK instances share authentication state and
15484
- * bootstrap quickly. If not set, an in-memory session manager is used.
15650
+ * Construct the context once via
15651
+ * [`new_shared_sdk_context`](crate::new_shared_sdk_context) and pass the
15652
+ * same `Arc` to every `SdkBuilder` whose SDKs should share its resources
15653
+ * (operator gRPC channels, SSP HTTP client, database pool).
15485
15654
  */
15486
- withSessionManager(sessionManager: SessionManager, asyncOpts_?: {
15487
- signal: AbortSignal;
15488
- }): Promise<void>;
15489
- /**
15490
- * Sets a shared SSP connection manager to be reused across SDK instances.
15491
- * Arguments:
15492
- * - `manager`: The shared SSP connection manager.
15493
- */
15494
- withSspConnectionManager(manager: SspConnectionManagerInterface, asyncOpts_?: {
15655
+ withSharedContext(context: SdkContextInterface, asyncOpts_?: {
15495
15656
  signal: AbortSignal;
15496
15657
  }): Promise<void>;
15497
15658
  /**
@@ -15531,14 +15692,6 @@ export declare class SdkBuilder extends UniffiAbstractObject implements SdkBuild
15531
15692
  withChainService(chainService: BitcoinChainService, asyncOpts_?: {
15532
15693
  signal: AbortSignal;
15533
15694
  }): Promise<void>;
15534
- /**
15535
- * Sets a shared connection manager to be reused across SDK instances.
15536
- * Arguments:
15537
- * - `connection_manager`: The shared connection manager.
15538
- */
15539
- withConnectionManager(connectionManager: ConnectionManagerInterface, asyncOpts_?: {
15540
- signal: AbortSignal;
15541
- }): Promise<void>;
15542
15695
  /**
15543
15696
  * Sets the root storage directory to initialize the default storage with.
15544
15697
  * This initializes both storage and real-time sync storage with the
@@ -15587,21 +15740,14 @@ export declare class SdkBuilder extends UniffiAbstractObject implements SdkBuild
15587
15740
  signal: AbortSignal;
15588
15741
  }): Promise<void>;
15589
15742
  /**
15590
- * Sets a custom session manager used to persist authentication sessions.
15743
+ * Threads a shared [`SdkContext`](crate::SdkContext) into the builder.
15591
15744
  *
15592
- * Provide a shared, persistent implementation (e.g. backed by `PostgreSQL`
15593
- * or Redis) to let multiple SDK instances share authentication state and
15594
- * bootstrap quickly. If not set, an in-memory session manager is used.
15745
+ * Construct the context once via
15746
+ * [`new_shared_sdk_context`](crate::new_shared_sdk_context) and pass the
15747
+ * same `Arc` to every `SdkBuilder` whose SDKs should share its resources
15748
+ * (operator gRPC channels, SSP HTTP client, database pool).
15595
15749
  */
15596
- withSessionManager(sessionManager: SessionManager, asyncOpts_?: {
15597
- signal: AbortSignal;
15598
- }): Promise<void>;
15599
- /**
15600
- * Sets a shared SSP connection manager to be reused across SDK instances.
15601
- * Arguments:
15602
- * - `manager`: The shared SSP connection manager.
15603
- */
15604
- withSspConnectionManager(manager: SspConnectionManagerInterface, asyncOpts_?: {
15750
+ withSharedContext(context: SdkContextInterface, asyncOpts_?: {
15605
15751
  signal: AbortSignal;
15606
15752
  }): Promise<void>;
15607
15753
  /**
@@ -15618,6 +15764,49 @@ export declare class SdkBuilder extends UniffiAbstractObject implements SdkBuild
15618
15764
  uniffiDestroy(): void;
15619
15765
  static instanceOf(obj: any): obj is SdkBuilder;
15620
15766
  }
15767
+ /**
15768
+ * Process-shared resources that can back many `BreezSdk` instances.
15769
+ *
15770
+ * Construct one with [`new_shared_sdk_context`] and pass the same `Arc` to every
15771
+ * [`SdkBuilder`](crate::SdkBuilder) whose SDKs should share those resources
15772
+ * (a single HTTP client across SSP / chain / LNURL / JWT / etc., a gRPC
15773
+ * channel pool to the Spark operators, the Breez backend gRPC client, a
15774
+ * database connection pool, …). Useful for multi-tenant servers that load
15775
+ * many wallets in one process.
15776
+ *
15777
+ * The struct is intentionally opaque — all fields are crate-private. There
15778
+ * is no way to inject pre-built sub-components: the factory builds them
15779
+ * from settings so callers don't need to know about session managers,
15780
+ * connection-manager wiring, or pool plumbing.
15781
+ */
15782
+ export interface SdkContextInterface {
15783
+ }
15784
+ /**
15785
+ * Process-shared resources that can back many `BreezSdk` instances.
15786
+ *
15787
+ * Construct one with [`new_shared_sdk_context`] and pass the same `Arc` to every
15788
+ * [`SdkBuilder`](crate::SdkBuilder) whose SDKs should share those resources
15789
+ * (a single HTTP client across SSP / chain / LNURL / JWT / etc., a gRPC
15790
+ * channel pool to the Spark operators, the Breez backend gRPC client, a
15791
+ * database connection pool, …). Useful for multi-tenant servers that load
15792
+ * many wallets in one process.
15793
+ *
15794
+ * The struct is intentionally opaque — all fields are crate-private. There
15795
+ * is no way to inject pre-built sub-components: the factory builds them
15796
+ * from settings so callers don't need to know about session managers,
15797
+ * connection-manager wiring, or pool plumbing.
15798
+ */
15799
+ export declare class SdkContext extends UniffiAbstractObject implements SdkContextInterface {
15800
+ readonly [uniffiTypeNameSymbol] = "SdkContext";
15801
+ readonly [destructorGuardSymbol]: UniffiRustArcPtr;
15802
+ readonly [pointerLiteralSymbol]: UnsafeMutableRawPointer;
15803
+ private constructor();
15804
+ /**
15805
+ * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
15806
+ */
15807
+ uniffiDestroy(): void;
15808
+ static instanceOf(obj: any): obj is SdkContext;
15809
+ }
15621
15810
  /**
15622
15811
  * Persistent storage for authentication sessions, keyed by the service's
15623
15812
  * identity public key. Implementations should be thread-safe and may be
@@ -15655,53 +15844,6 @@ export declare class SessionManagerImpl extends UniffiAbstractObject implements
15655
15844
  uniffiDestroy(): void;
15656
15845
  static instanceOf(obj: any): obj is SessionManagerImpl;
15657
15846
  }
15658
- /**
15659
- * A shared HTTP transport for SSP GraphQL traffic.
15660
- *
15661
- * All SDK instances that are built with the same `SspConnectionManager` send
15662
- * SSP requests over the same pooled `reqwest::Client`. This means each
15663
- * process opens at most one TCP+TLS+HTTP/2 connection to the SSP regardless
15664
- * of how many wallets are loaded — useful for multi-tenant servers running
15665
- * many SDK instances.
15666
- *
15667
- * # Caveats
15668
- *
15669
- * - The user-agent of the first SDK to construct this manager is reused for
15670
- * all subsequent instances. This is rarely a problem since SDK instances
15671
- * in one process typically share a build version.
15672
- * - Connections close when the last `Arc<SspConnectionManager>` is dropped.
15673
- * `BreezSdk::disconnect` does not close them.
15674
- */
15675
- export interface SspConnectionManagerInterface {
15676
- }
15677
- /**
15678
- * A shared HTTP transport for SSP GraphQL traffic.
15679
- *
15680
- * All SDK instances that are built with the same `SspConnectionManager` send
15681
- * SSP requests over the same pooled `reqwest::Client`. This means each
15682
- * process opens at most one TCP+TLS+HTTP/2 connection to the SSP regardless
15683
- * of how many wallets are loaded — useful for multi-tenant servers running
15684
- * many SDK instances.
15685
- *
15686
- * # Caveats
15687
- *
15688
- * - The user-agent of the first SDK to construct this manager is reused for
15689
- * all subsequent instances. This is rarely a problem since SDK instances
15690
- * in one process typically share a build version.
15691
- * - Connections close when the last `Arc<SspConnectionManager>` is dropped.
15692
- * `BreezSdk::disconnect` does not close them.
15693
- */
15694
- export declare class SspConnectionManager extends UniffiAbstractObject implements SspConnectionManagerInterface {
15695
- readonly [uniffiTypeNameSymbol] = "SspConnectionManager";
15696
- readonly [destructorGuardSymbol]: UniffiRustArcPtr;
15697
- readonly [pointerLiteralSymbol]: UnsafeMutableRawPointer;
15698
- private constructor();
15699
- /**
15700
- * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
15701
- */
15702
- uniffiDestroy(): void;
15703
- static instanceOf(obj: any): obj is SspConnectionManager;
15704
- }
15705
15847
  /**
15706
15848
  * Trait for persistent storage
15707
15849
  */
@@ -16658,7 +16800,6 @@ declare const _default: Readonly<{
16658
16800
  lift(value: UniffiByteArray): ConnectWithSignerRequest;
16659
16801
  lower(value: ConnectWithSignerRequest): UniffiByteArray;
16660
16802
  };
16661
- FfiConverterTypeConnectionManager: FfiConverterObject<ConnectionManagerInterface>;
16662
16803
  FfiConverterTypeContact: {
16663
16804
  read(from: RustBuffer): Contact;
16664
16805
  write(value: Contact, into: RustBuffer): void;
@@ -17018,6 +17159,13 @@ declare const _default: Readonly<{
17018
17159
  lift(value: UniffiByteArray): KeySetType;
17019
17160
  lower(value: KeySetType): UniffiByteArray;
17020
17161
  };
17162
+ FfiConverterTypeLeafOptimizationConfig: {
17163
+ read(from: RustBuffer): LeafOptimizationConfig;
17164
+ write(value: LeafOptimizationConfig, into: RustBuffer): void;
17165
+ allocationSize(value: LeafOptimizationConfig): number;
17166
+ lift(value: UniffiByteArray): LeafOptimizationConfig;
17167
+ lower(value: LeafOptimizationConfig): UniffiByteArray;
17168
+ };
17021
17169
  FfiConverterTypeLightningAddressDetails: {
17022
17170
  read(from: RustBuffer): LightningAddressDetails;
17023
17171
  write(value: LightningAddressDetails, into: RustBuffer): void;
@@ -17242,13 +17390,6 @@ declare const _default: Readonly<{
17242
17390
  lift(value: UniffiByteArray): OnchainConfirmationSpeed;
17243
17391
  lower(value: OnchainConfirmationSpeed): UniffiByteArray;
17244
17392
  };
17245
- FfiConverterTypeOptimizationConfig: {
17246
- read(from: RustBuffer): OptimizationConfig;
17247
- write(value: OptimizationConfig, into: RustBuffer): void;
17248
- allocationSize(value: OptimizationConfig): number;
17249
- lift(value: UniffiByteArray): OptimizationConfig;
17250
- lower(value: OptimizationConfig): UniffiByteArray;
17251
- };
17252
17393
  FfiConverterTypeOptimizationEvent: {
17253
17394
  read(from: RustBuffer): OptimizationEvent;
17254
17395
  write(value: OptimizationEvent, into: RustBuffer): void;
@@ -17514,6 +17655,14 @@ declare const _default: Readonly<{
17514
17655
  lower(value: SchnorrSignatureBytes): UniffiByteArray;
17515
17656
  };
17516
17657
  FfiConverterTypeSdkBuilder: FfiConverterObject<SdkBuilderInterface>;
17658
+ FfiConverterTypeSdkContext: FfiConverterObject<SdkContextInterface>;
17659
+ FfiConverterTypeSdkContextConfig: {
17660
+ read(from: RustBuffer): SdkContextConfig;
17661
+ write(value: SdkContextConfig, into: RustBuffer): void;
17662
+ allocationSize(value: SdkContextConfig): number;
17663
+ lift(value: UniffiByteArray): SdkContextConfig;
17664
+ lower(value: SdkContextConfig): UniffiByteArray;
17665
+ };
17517
17666
  FfiConverterTypeSdkError: {
17518
17667
  read(from: RustBuffer): SdkError;
17519
17668
  write(value: SdkError, into: RustBuffer): void;
@@ -17718,7 +17867,6 @@ declare const _default: Readonly<{
17718
17867
  lift(value: UniffiByteArray): SparkStatus;
17719
17868
  lower(value: SparkStatus): UniffiByteArray;
17720
17869
  };
17721
- FfiConverterTypeSspConnectionManager: FfiConverterObject<SspConnectionManagerInterface>;
17722
17870
  FfiConverterTypeStableBalanceActiveLabel: {
17723
17871
  read(from: RustBuffer): StableBalanceActiveLabel;
17724
17872
  write(value: StableBalanceActiveLabel, into: RustBuffer): void;
@@ -17812,6 +17960,13 @@ declare const _default: Readonly<{
17812
17960
  lift(value: UniffiByteArray): TokenMetadata;
17813
17961
  lower(value: TokenMetadata): UniffiByteArray;
17814
17962
  };
17963
+ FfiConverterTypeTokenOptimizationConfig: {
17964
+ read(from: RustBuffer): TokenOptimizationConfig;
17965
+ write(value: TokenOptimizationConfig, into: RustBuffer): void;
17966
+ allocationSize(value: TokenOptimizationConfig): number;
17967
+ lift(value: UniffiByteArray): TokenOptimizationConfig;
17968
+ lower(value: TokenOptimizationConfig): UniffiByteArray;
17969
+ };
17815
17970
  FfiConverterTypeTokenTransactionType: {
17816
17971
  read(from: RustBuffer): TokenTransactionType;
17817
17972
  write(value: TokenTransactionType, into: RustBuffer): void;