Struct LexeWallet

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

Top-level handle to a Lexe wallet.

Implementations§

Source§

impl LexeWallet

Source

pub fn fresh( env_config: WalletEnvConfig, credentials: CredentialsRef<'_>, lexe_data_dir: Option<PathBuf>, ) -> Result<Self>

Create a fresh LexeWallet, deleting any existing database state for this user. Data for other users and environments is not affected.

It is recommended to always pass the same lexe_data_dir, regardless of which environment we’re in (dev/staging/prod) and which user this LexeWallet is for. Users and environments will not interfere with each other as all data is namespaced internally. Defaults to ~/.lexe if not specified.

Source

pub fn load( env_config: WalletEnvConfig, credentials: CredentialsRef<'_>, lexe_data_dir: Option<PathBuf>, ) -> Result<Option<Self>>

Load an existing LexeWallet with persistence from lexe_data_dir. Returns None if no local data exists, in which case you should use fresh to create the wallet and local data cache.

If you are authenticating with RootSeeds and this returns None, you should call signup after creating the wallet if you’re not sure whether the user has been signed up with Lexe.

It is recommended to always pass the same lexe_data_dir, regardless of which environment we’re in (dev/staging/prod) and which user this LexeWallet is for. Users and environments will not interfere with each other as all data is namespaced internally. Defaults to ~/.lexe if not specified.

Source

pub fn load_or_fresh( env_config: WalletEnvConfig, credentials: CredentialsRef<'_>, lexe_data_dir: Option<PathBuf>, ) -> Result<Self>

Load an existing LexeWallet with persistence from lexe_data_dir, or create a fresh one if no local data exists. If you are authenticating with client credentials, this is generally what you want to use.

It is recommended to always pass the same lexe_data_dir, regardless of which environment we’re in (dev/staging/prod) and which user this LexeWallet is for. Users and environments will not interfere with each other as all data is namespaced internally. Defaults to ~/.lexe if not specified.

Source

pub fn without_db( env_config: WalletEnvConfig, credentials: CredentialsRef<'_>, ) -> Result<Self>

Create a LexeWallet without any persistence. It is recommended to use fresh or load instead, to initialize with persistence.

Node operations (invoices, payments, node info) work normally. Local payment cache operations (sync_payments, list_payments, clear_payments) are not available and will return an error.

Source

pub async fn sync_payments(&self) -> Result<PaymentSyncSummary>

Sync payments from the user node to the local database. This fetches updated payments from the node and persists them locally.

Returns an error if this wallet was created without local persistence.

Source

pub fn list_payments( &self, filter: &PaymentFilter, order: Option<Order>, limit: Option<usize>, after: Option<&PaymentCreatedIndex>, ) -> Result<ListPaymentsResponse>

List payments from local storage with cursor-based pagination.

Defaults to descending order (newest first) with a limit of 100.

To continue paginating, set after to the next_index from the previous response. after is an exclusive index.

If needed, use sync_payments to fetch the latest data from the node before calling this method.

Returns an error if this wallet was created without local persistence.

Source

pub fn clear_payments(&self) -> Result<()>

Clear all local payment data for this wallet.

Clears the local payment cache only. Remote data on the node is not affected. Call sync_payments to re-populate.

Returns an error if this wallet was created without local persistence.

Source

pub async fn wait_for_payment( &self, index: PaymentCreatedIndex, timeout: Option<Duration>, ) -> Result<Payment>

Wait for a payment to reach a terminal state (completed or failed).

Polls the node with exponential backoff until the payment finalizes or the timeout is reached. Defaults to 10 minutes if not specified. Maximum timeout is 86,400 seconds (24 hours).

Source

pub async fn signup( &self, root_seed: &RootSeed, partner_pk: Option<UserPk>, ) -> Result<()>

Registers this user with Lexe, then provisions the node. This method must be called after the user’s LexeWallet has been created for the first time, otherwise subsequent requests will fail.

It is only necessary to call this method once, ever, per user, but it is also okay to call this method even if the user has already been signed up; in other words, this method is idempotent.

After a successful signup, make sure the user’s root seed has been persisted somewhere! Without access to their root seed, your user will lose their funds forever. If adding Lexe to a broader wallet, a good strategy is to derive Lexe’s RootSeed from your own root seed.

  • partner_pk: Set to your company’s UserPk to earn a share of this wallet’s fees.
Source

pub async fn provision(&self, credentials: CredentialsRef<'_>) -> Result<()>

Ensures the wallet is provisioned to all recent trusted releases. This should be called every time the wallet is loaded, to ensure the user is running the most up-to-date enclave software.

This fetches the current enclaves from the gateway, computes which releases need to be provisioned, and provisions them.

Source

pub fn user_config(&self) -> &WalletUserConfig

Get a reference to the user’s wallet configuration.

Source

pub async fn node_info(&self) -> Result<NodeInfo>

Get information about this Lexe node, including balance and channels.

Source

pub async fn create_invoice( &self, req: CreateInvoiceRequest, ) -> Result<CreateInvoiceResponse>

Create a BOLT 11 invoice to receive a Lightning payment.

Source

pub async fn pay_invoice( &self, req: PayInvoiceRequest, ) -> Result<PayInvoiceResponse>

Pay a BOLT 11 invoice over Lightning.

Source

pub async fn get_payment( &self, req: GetPaymentRequest, ) -> Result<GetPaymentResponse>

Get information about a payment by its created index.

Source

pub async fn update_payment_note( &self, req: UpdatePaymentNoteRequest, ) -> Result<()>

Update the personal note on an existing payment. The note is stored on the user node and is not visible to the counterparty.

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
§

impl<F, T, U> Apply<F, U> for T
where F: FnOnce(T) -> U,

§

fn apply(self, f: F) -> U

Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

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
Source§

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, 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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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