@breeztech/breez-sdk-spark-react-native 0.13.12-dev1 → 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
  *
@@ -79,16 +106,20 @@ export declare function newConnectionManager(connectionsPerOperator: /*u32*/ num
79
106
  * For one-off, non-shared use, prefer
80
107
  * [`SdkBuilder::with_rest_chain_service`](crate::SdkBuilder::with_rest_chain_service).
81
108
  */
82
- export declare function newRestChainService(url: string, network: Network, apiType: ChainApiType, credentials: Credentials | undefined): BitcoinChainService;
109
+ export declare function newRestChainService(url: string, network: Network, apiType: ChainApiType, credentials: Credentials | undefined, asyncOpts_?: {
110
+ signal: AbortSignal;
111
+ }): Promise<BitcoinChainService>;
83
112
  /**
84
- * Construct a new shared SSP connection manager.
113
+ * Constructs an [`SdkContext`] from a `SdkContextConfig`.
85
114
  *
86
- * Pass the returned `Arc<SspConnectionManager>` to
87
- * [`SdkBuilder::with_ssp_connection_manager`](crate::SdkBuilder::with_ssp_connection_manager)
88
- * when building each SDK instance that should share the underlying HTTP
89
- * 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.
90
119
  */
91
- export declare function newSspConnectionManager(userAgent: string | undefined): SspConnectionManagerInterface;
120
+ export declare function newSharedSdkContext(config: SdkContextConfig, asyncOpts_?: {
121
+ signal: AbortSignal;
122
+ }): Promise<SdkContextInterface>;
92
123
  /**
93
124
  * Trait for event listeners
94
125
  */
@@ -792,8 +823,15 @@ export type Config = {
792
823
  /**
793
824
  * Whether the Spark private mode is enabled by default.
794
825
  *
795
- * If set to true, the Spark private mode will be enabled on the first initialization of the SDK.
796
- * 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.
797
835
  */
798
836
  privateEnabledDefault: boolean;
799
837
  /**
@@ -803,7 +841,16 @@ export type Config = {
803
841
  * Fewer, bigger leaves allow for more funds to be exited unilaterally.
804
842
  * More leaves allow payments to be made without needing a swap, reducing payment latency.
805
843
  */
806
- 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;
807
854
  /**
808
855
  * Configuration for automatic conversion of Bitcoin to stable tokens.
809
856
  *
@@ -825,6 +872,33 @@ export type Config = {
825
872
  * deployments (e.g. dev/staging environments).
826
873
  */
827
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;
828
902
  };
829
903
  /**
830
904
  * Generated factory for {@link Config} record objects.
@@ -1878,6 +1952,14 @@ export declare const FreezeIssuerTokenResponse: Readonly<{
1878
1952
  * Request to get the balance of the wallet
1879
1953
  */
1880
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
+ */
1881
1963
  ensureSynced: boolean | undefined;
1882
1964
  };
1883
1965
  /**
@@ -2184,6 +2266,53 @@ export declare const KeySetConfig: Readonly<{
2184
2266
  */
2185
2267
  defaults: () => Partial<KeySetConfig>;
2186
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
+ }>;
2187
2316
  export type LightningAddressDetails = {
2188
2317
  address: string;
2189
2318
  payRequest: LnurlPayRequestDetails;
@@ -2996,50 +3125,6 @@ export declare const NostrRelayConfig: Readonly<{
2996
3125
  */
2997
3126
  defaults: () => Partial<NostrRelayConfig>;
2998
3127
  }>;
2999
- export type OptimizationConfig = {
3000
- /**
3001
- * Whether automatic leaf optimization is enabled.
3002
- *
3003
- * If set to true, the SDK will automatically optimize the leaf set when it changes.
3004
- * Otherwise, the manual optimization API must be used to optimize the leaf set.
3005
- *
3006
- * Default value is true.
3007
- */
3008
- autoEnabled: boolean;
3009
- /**
3010
- * The desired multiplicity for the leaf set.
3011
- *
3012
- * Setting this to 0 will optimize for maximizing unilateral exit.
3013
- * Higher values will optimize for minimizing transfer swaps, with higher values
3014
- * being more aggressive and allowing better TPS rates.
3015
- *
3016
- * For end-user wallets, values of 1-5 are recommended. Values above 5 are
3017
- * intended for high-throughput server environments and are not recommended
3018
- * for end-user wallets due to significantly higher unilateral exit costs.
3019
- *
3020
- * Default value is 1.
3021
- */
3022
- multiplicity: number;
3023
- };
3024
- /**
3025
- * Generated factory for {@link OptimizationConfig} record objects.
3026
- */
3027
- export declare const OptimizationConfig: Readonly<{
3028
- /**
3029
- * Create a frozen instance of {@link OptimizationConfig}, with defaults specified
3030
- * in Rust, in the {@link breez_sdk_spark} crate.
3031
- */
3032
- create: (partial: Partial<OptimizationConfig> & Required<Omit<OptimizationConfig, never>>) => OptimizationConfig;
3033
- /**
3034
- * Create a frozen instance of {@link OptimizationConfig}, with defaults specified
3035
- * in Rust, in the {@link breez_sdk_spark} crate.
3036
- */
3037
- new: (partial: Partial<OptimizationConfig> & Required<Omit<OptimizationConfig, never>>) => OptimizationConfig;
3038
- /**
3039
- * Defaults specified in the {@link breez_sdk_spark} crate.
3040
- */
3041
- defaults: () => Partial<OptimizationConfig>;
3042
- }>;
3043
3128
  export type OptimizationProgress = {
3044
3129
  isRunning: boolean;
3045
3130
  currentRound: number;
@@ -3811,6 +3896,50 @@ export declare const SchnorrSignatureBytes: Readonly<{
3811
3896
  */
3812
3897
  defaults: () => Partial<SchnorrSignatureBytes>;
3813
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
+ }>;
3814
3943
  /**
3815
3944
  * FFI-safe representation of a private key (32 bytes)
3816
3945
  */
@@ -4664,6 +4793,66 @@ export declare const TokenMetadata: Readonly<{
4664
4793
  */
4665
4794
  defaults: () => Partial<TokenMetadata>;
4666
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
+ }>;
4667
4856
  export type TxStatus = {
4668
4857
  confirmed: boolean;
4669
4858
  blockHeight: /*u32*/ number | undefined;
@@ -13909,6 +14098,20 @@ export interface BreezSdkInterface {
13909
14098
  refundDeposit(request: RefundDepositRequest, asyncOpts_?: {
13910
14099
  signal: AbortSignal;
13911
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>;
13912
14115
  registerLightningAddress(request: RegisterLightningAddressRequest, asyncOpts_?: {
13913
14116
  signal: AbortSignal;
13914
14117
  }): Promise<LightningAddressInfo>;
@@ -14280,6 +14483,20 @@ export declare class BreezSdk extends UniffiAbstractObject implements BreezSdkIn
14280
14483
  refundDeposit(request: RefundDepositRequest, asyncOpts_?: {
14281
14484
  signal: AbortSignal;
14282
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>;
14283
14500
  registerLightningAddress(request: RegisterLightningAddressRequest, asyncOpts_?: {
14284
14501
  signal: AbortSignal;
14285
14502
  }): Promise<LightningAddressInfo>;
@@ -14383,45 +14600,6 @@ export declare class BreezSdk extends UniffiAbstractObject implements BreezSdkIn
14383
14600
  uniffiDestroy(): void;
14384
14601
  static instanceOf(obj: any): obj is BreezSdk;
14385
14602
  }
14386
- /**
14387
- * A shareable manager for gRPC connections to the Spark operators.
14388
- *
14389
- * Construct one via [`new_connection_manager`] and pass the same `Arc` to
14390
- * multiple [`SdkBuilder`](crate::SdkBuilder)s via
14391
- * [`SdkBuilder::with_connection_manager`](crate::SdkBuilder::with_connection_manager).
14392
- * Connections close when the last `Arc<ConnectionManager>` is dropped;
14393
- * [`BreezSdk::disconnect`](crate::BreezSdk::disconnect) does not affect them.
14394
- *
14395
- * All SDK instances sharing a `ConnectionManager` must be configured for the
14396
- * same network and operator pool. The TLS settings and user agent of the
14397
- * first SDK to connect to a given operator are reused for everyone afterwards.
14398
- */
14399
- export interface ConnectionManagerInterface {
14400
- }
14401
- /**
14402
- * A shareable manager for gRPC connections to the Spark operators.
14403
- *
14404
- * Construct one via [`new_connection_manager`] and pass the same `Arc` to
14405
- * multiple [`SdkBuilder`](crate::SdkBuilder)s via
14406
- * [`SdkBuilder::with_connection_manager`](crate::SdkBuilder::with_connection_manager).
14407
- * Connections close when the last `Arc<ConnectionManager>` is dropped;
14408
- * [`BreezSdk::disconnect`](crate::BreezSdk::disconnect) does not affect them.
14409
- *
14410
- * All SDK instances sharing a `ConnectionManager` must be configured for the
14411
- * same network and operator pool. The TLS settings and user agent of the
14412
- * first SDK to connect to a given operator are reused for everyone afterwards.
14413
- */
14414
- export declare class ConnectionManager extends UniffiAbstractObject implements ConnectionManagerInterface {
14415
- readonly [uniffiTypeNameSymbol] = "ConnectionManager";
14416
- readonly [destructorGuardSymbol]: UniffiRustArcPtr;
14417
- readonly [pointerLiteralSymbol]: UnsafeMutableRawPointer;
14418
- private constructor();
14419
- /**
14420
- * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
14421
- */
14422
- uniffiDestroy(): void;
14423
- static instanceOf(obj: any): obj is ConnectionManager;
14424
- }
14425
14603
  /**
14426
14604
  * External signer trait that can be implemented by users and passed to the SDK.
14427
14605
  *
@@ -15419,14 +15597,6 @@ export interface SdkBuilderInterface {
15419
15597
  withChainService(chainService: BitcoinChainService, asyncOpts_?: {
15420
15598
  signal: AbortSignal;
15421
15599
  }): Promise<void>;
15422
- /**
15423
- * Sets a shared connection manager to be reused across SDK instances.
15424
- * Arguments:
15425
- * - `connection_manager`: The shared connection manager.
15426
- */
15427
- withConnectionManager(connectionManager: ConnectionManagerInterface, asyncOpts_?: {
15428
- signal: AbortSignal;
15429
- }): Promise<void>;
15430
15600
  /**
15431
15601
  * Sets the root storage directory to initialize the default storage with.
15432
15602
  * This initializes both storage and real-time sync storage with the
@@ -15475,21 +15645,14 @@ export interface SdkBuilderInterface {
15475
15645
  signal: AbortSignal;
15476
15646
  }): Promise<void>;
15477
15647
  /**
15478
- * Sets a custom session manager used to persist authentication sessions.
15648
+ * Threads a shared [`SdkContext`](crate::SdkContext) into the builder.
15479
15649
  *
15480
- * Provide a shared, persistent implementation (e.g. backed by `PostgreSQL`
15481
- * or Redis) to let multiple SDK instances share authentication state and
15482
- * 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).
15483
15654
  */
15484
- withSessionManager(sessionManager: SessionManager, asyncOpts_?: {
15485
- signal: AbortSignal;
15486
- }): Promise<void>;
15487
- /**
15488
- * Sets a shared SSP connection manager to be reused across SDK instances.
15489
- * Arguments:
15490
- * - `manager`: The shared SSP connection manager.
15491
- */
15492
- withSspConnectionManager(manager: SspConnectionManagerInterface, asyncOpts_?: {
15655
+ withSharedContext(context: SdkContextInterface, asyncOpts_?: {
15493
15656
  signal: AbortSignal;
15494
15657
  }): Promise<void>;
15495
15658
  /**
@@ -15529,14 +15692,6 @@ export declare class SdkBuilder extends UniffiAbstractObject implements SdkBuild
15529
15692
  withChainService(chainService: BitcoinChainService, asyncOpts_?: {
15530
15693
  signal: AbortSignal;
15531
15694
  }): Promise<void>;
15532
- /**
15533
- * Sets a shared connection manager to be reused across SDK instances.
15534
- * Arguments:
15535
- * - `connection_manager`: The shared connection manager.
15536
- */
15537
- withConnectionManager(connectionManager: ConnectionManagerInterface, asyncOpts_?: {
15538
- signal: AbortSignal;
15539
- }): Promise<void>;
15540
15695
  /**
15541
15696
  * Sets the root storage directory to initialize the default storage with.
15542
15697
  * This initializes both storage and real-time sync storage with the
@@ -15585,21 +15740,14 @@ export declare class SdkBuilder extends UniffiAbstractObject implements SdkBuild
15585
15740
  signal: AbortSignal;
15586
15741
  }): Promise<void>;
15587
15742
  /**
15588
- * Sets a custom session manager used to persist authentication sessions.
15743
+ * Threads a shared [`SdkContext`](crate::SdkContext) into the builder.
15589
15744
  *
15590
- * Provide a shared, persistent implementation (e.g. backed by `PostgreSQL`
15591
- * or Redis) to let multiple SDK instances share authentication state and
15592
- * bootstrap quickly. If not set, an in-memory session manager is used.
15593
- */
15594
- withSessionManager(sessionManager: SessionManager, asyncOpts_?: {
15595
- signal: AbortSignal;
15596
- }): Promise<void>;
15597
- /**
15598
- * Sets a shared SSP connection manager to be reused across SDK instances.
15599
- * Arguments:
15600
- * - `manager`: The shared SSP connection manager.
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).
15601
15749
  */
15602
- withSspConnectionManager(manager: SspConnectionManagerInterface, asyncOpts_?: {
15750
+ withSharedContext(context: SdkContextInterface, asyncOpts_?: {
15603
15751
  signal: AbortSignal;
15604
15752
  }): Promise<void>;
15605
15753
  /**
@@ -15616,6 +15764,49 @@ export declare class SdkBuilder extends UniffiAbstractObject implements SdkBuild
15616
15764
  uniffiDestroy(): void;
15617
15765
  static instanceOf(obj: any): obj is SdkBuilder;
15618
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
+ }
15619
15810
  /**
15620
15811
  * Persistent storage for authentication sessions, keyed by the service's
15621
15812
  * identity public key. Implementations should be thread-safe and may be
@@ -15653,53 +15844,6 @@ export declare class SessionManagerImpl extends UniffiAbstractObject implements
15653
15844
  uniffiDestroy(): void;
15654
15845
  static instanceOf(obj: any): obj is SessionManagerImpl;
15655
15846
  }
15656
- /**
15657
- * A shared HTTP transport for SSP GraphQL traffic.
15658
- *
15659
- * All SDK instances that are built with the same `SspConnectionManager` send
15660
- * SSP requests over the same pooled `reqwest::Client`. This means each
15661
- * process opens at most one TCP+TLS+HTTP/2 connection to the SSP regardless
15662
- * of how many wallets are loaded — useful for multi-tenant servers running
15663
- * many SDK instances.
15664
- *
15665
- * # Caveats
15666
- *
15667
- * - The user-agent of the first SDK to construct this manager is reused for
15668
- * all subsequent instances. This is rarely a problem since SDK instances
15669
- * in one process typically share a build version.
15670
- * - Connections close when the last `Arc<SspConnectionManager>` is dropped.
15671
- * `BreezSdk::disconnect` does not close them.
15672
- */
15673
- export interface SspConnectionManagerInterface {
15674
- }
15675
- /**
15676
- * A shared HTTP transport for SSP GraphQL traffic.
15677
- *
15678
- * All SDK instances that are built with the same `SspConnectionManager` send
15679
- * SSP requests over the same pooled `reqwest::Client`. This means each
15680
- * process opens at most one TCP+TLS+HTTP/2 connection to the SSP regardless
15681
- * of how many wallets are loaded — useful for multi-tenant servers running
15682
- * many SDK instances.
15683
- *
15684
- * # Caveats
15685
- *
15686
- * - The user-agent of the first SDK to construct this manager is reused for
15687
- * all subsequent instances. This is rarely a problem since SDK instances
15688
- * in one process typically share a build version.
15689
- * - Connections close when the last `Arc<SspConnectionManager>` is dropped.
15690
- * `BreezSdk::disconnect` does not close them.
15691
- */
15692
- export declare class SspConnectionManager extends UniffiAbstractObject implements SspConnectionManagerInterface {
15693
- readonly [uniffiTypeNameSymbol] = "SspConnectionManager";
15694
- readonly [destructorGuardSymbol]: UniffiRustArcPtr;
15695
- readonly [pointerLiteralSymbol]: UnsafeMutableRawPointer;
15696
- private constructor();
15697
- /**
15698
- * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
15699
- */
15700
- uniffiDestroy(): void;
15701
- static instanceOf(obj: any): obj is SspConnectionManager;
15702
- }
15703
15847
  /**
15704
15848
  * Trait for persistent storage
15705
15849
  */
@@ -16656,7 +16800,6 @@ declare const _default: Readonly<{
16656
16800
  lift(value: UniffiByteArray): ConnectWithSignerRequest;
16657
16801
  lower(value: ConnectWithSignerRequest): UniffiByteArray;
16658
16802
  };
16659
- FfiConverterTypeConnectionManager: FfiConverterObject<ConnectionManagerInterface>;
16660
16803
  FfiConverterTypeContact: {
16661
16804
  read(from: RustBuffer): Contact;
16662
16805
  write(value: Contact, into: RustBuffer): void;
@@ -17016,6 +17159,13 @@ declare const _default: Readonly<{
17016
17159
  lift(value: UniffiByteArray): KeySetType;
17017
17160
  lower(value: KeySetType): UniffiByteArray;
17018
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
+ };
17019
17169
  FfiConverterTypeLightningAddressDetails: {
17020
17170
  read(from: RustBuffer): LightningAddressDetails;
17021
17171
  write(value: LightningAddressDetails, into: RustBuffer): void;
@@ -17240,13 +17390,6 @@ declare const _default: Readonly<{
17240
17390
  lift(value: UniffiByteArray): OnchainConfirmationSpeed;
17241
17391
  lower(value: OnchainConfirmationSpeed): UniffiByteArray;
17242
17392
  };
17243
- FfiConverterTypeOptimizationConfig: {
17244
- read(from: RustBuffer): OptimizationConfig;
17245
- write(value: OptimizationConfig, into: RustBuffer): void;
17246
- allocationSize(value: OptimizationConfig): number;
17247
- lift(value: UniffiByteArray): OptimizationConfig;
17248
- lower(value: OptimizationConfig): UniffiByteArray;
17249
- };
17250
17393
  FfiConverterTypeOptimizationEvent: {
17251
17394
  read(from: RustBuffer): OptimizationEvent;
17252
17395
  write(value: OptimizationEvent, into: RustBuffer): void;
@@ -17512,6 +17655,14 @@ declare const _default: Readonly<{
17512
17655
  lower(value: SchnorrSignatureBytes): UniffiByteArray;
17513
17656
  };
17514
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
+ };
17515
17666
  FfiConverterTypeSdkError: {
17516
17667
  read(from: RustBuffer): SdkError;
17517
17668
  write(value: SdkError, into: RustBuffer): void;
@@ -17716,7 +17867,6 @@ declare const _default: Readonly<{
17716
17867
  lift(value: UniffiByteArray): SparkStatus;
17717
17868
  lower(value: SparkStatus): UniffiByteArray;
17718
17869
  };
17719
- FfiConverterTypeSspConnectionManager: FfiConverterObject<SspConnectionManagerInterface>;
17720
17870
  FfiConverterTypeStableBalanceActiveLabel: {
17721
17871
  read(from: RustBuffer): StableBalanceActiveLabel;
17722
17872
  write(value: StableBalanceActiveLabel, into: RustBuffer): void;
@@ -17810,6 +17960,13 @@ declare const _default: Readonly<{
17810
17960
  lift(value: UniffiByteArray): TokenMetadata;
17811
17961
  lower(value: TokenMetadata): UniffiByteArray;
17812
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
+ };
17813
17970
  FfiConverterTypeTokenTransactionType: {
17814
17971
  read(from: RustBuffer): TokenTransactionType;
17815
17972
  write(value: TokenTransactionType, into: RustBuffer): void;