Skip to main content

SdkBuilder

Struct SdkBuilder 

Source
pub struct SdkBuilder { /* private fields */ }
Expand description

Builder for creating BreezSdk instances with customizable components.

Implementations§

Source§

impl SdkBuilder

Source

pub fn new(config: Config, seed: Seed) -> Self

Creates a new SdkBuilder with the provided configuration and seed.

For external signer support, use new_with_signer instead.

§Arguments
  • config: The configuration to be used.
  • seed: The seed for wallet generation.
Source

pub fn new_with_signer( config: Config, breez_signer: Arc<dyn ExternalBreezSigner>, spark_signer: Arc<dyn ExternalSparkSigner>, ) -> Self

Creates a new SdkBuilder with the provided configuration and external signers.

§Arguments
  • config: The configuration to be used.
  • breez_signer: External signer for non-Spark SDK signing (LNURL-auth, real-time sync, message signing, ECIES).
  • spark_signer: External high-level Spark signer for the Spark wallet.
Source

pub fn new_with_signing_only_signer( config: Config, breez_signer: Arc<dyn ExternalSigningSigner>, spark_signer: Arc<dyn ExternalSparkSigner>, ) -> Self

Creates a new SdkBuilder with a signing-only external signer.

Use this for a signer that can’t perform the SDK’s local ECIES/HMAC operations (for example a policy-restricted enclave). The SDK keeps session tokens in plaintext and disables the features that rely on ECIES/HMAC.

§Arguments
  • config: The configuration to be used.
  • breez_signer: Signing-only external signer for non-Spark SDK signing.
  • spark_signer: External high-level Spark signer for the Spark wallet.
Source

pub fn with_account_number(self, account_number: u32) -> Self

Sets the account number for key derivation. All wallet keys derive from the seed at m/8797555'/<account number>', so each account number yields an independent wallet from the same seed.

When unset, the account number defaults to 0 on Regtest and 1 on all other networks.

Note: This only applies when using a seed-based signer. It has no effect when using an external signer (created with new_with_signer).

§Arguments
  • account_number: The account number in the derivation path.
Source

pub fn with_storage_backend(self, storage: Arc<dyn StorageBackend>) -> Self

Sets the storage backend to be used by the SDK.

Build the StorageBackend with default_storage, postgres_storage, mysql_storage or custom_storage. Arguments:

  • storage: The storage backend to be used.
Source

pub fn with_session_store(self, session_store: Arc<dyn SessionStore>) -> Self

Overrides the session store used to cache Spark operator and SSP auth tokens, replacing the one the StorageBackend provides.

Supply any [SessionStore]: a different persistence layer, or a decorator that wraps the backend’s own store (from default_session_store) to transform tokens on read/write while keeping its persistence. One such transform is at-rest encryption, which the SDK does not apply itself: wrap the store in a [SessionStore] that encrypts in set_session and decrypts in get_session.

Arguments:

  • session_store: The session store to use in place of the backend’s.
Source

pub fn with_storage(self, storage: Arc<dyn Storage>) -> Self

👎Deprecated: use with_storage_backend(custom_storage(storage))

Deprecated. Use with_storage_backend with custom_storage. Arguments:

  • storage: The storage implementation to be used.
Source

pub fn with_shared_context(self, context: Arc<SdkContext>) -> Self

Threads a shared SdkContext into this builder.

Construct the context once via new_shared_sdk_context and pass the same Arc to every SdkBuilder whose SDKs should share its underlying resources (operator gRPC channels, SSP HTTP client, database pool).

If not set, build() constructs a context internally from the SDK’s own network and api key — fine for a single-SDK process with no DB backend.

Source

pub fn with_chain_service( self, chain_service: Arc<dyn BitcoinChainService>, ) -> Self

Sets the chain service to be used by the SDK. Arguments:

  • chain_service: The chain service to be used.
Source

pub fn with_rest_chain_service( self, url: String, api_type: ChainApiType, credentials: Option<Credentials>, ) -> Self

Configures a REST chain service to be used by the SDK.

The service is constructed during build() so it can reuse the shared HTTP client carried by the SdkContext.

Arguments:

  • url: The base URL of the REST API.
  • api_type: The API type to be used.
  • credentials: Optional credentials for basic authentication.
Source

pub fn with_fiat_service(self, fiat_service: Arc<dyn FiatService>) -> Self

Sets the fiat service to be used by the SDK. Arguments:

  • fiat_service: The fiat service to be used.
Source

pub fn with_lnurl_client(self, lnurl_client: Arc<dyn RestClient>) -> Self

Source

pub fn with_lnurl_server_client( self, lnurl_serverclient: Arc<dyn LnurlServerClient>, ) -> Self

Source

pub fn with_payment_observer( self, payment_observer: Arc<dyn PaymentObserver>, ) -> Self

Sets the payment observer to be used by the SDK. This observer will receive callbacks before outgoing payments for Lightning, Spark and onchain Bitcoin. Arguments:

  • payment_observer: The payment observer to be used.
Source

pub async fn build(self) -> Result<BreezSdk, SdkError>

Builds the BreezSdk instance from the configured components, reading top-to-bottom as a sequence of named assembly steps.

Trait Implementations§

Source§

impl Clone for SdkBuilder

Source§

fn clone(&self) -> SdkBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more