pub struct LexeWallet<Db> { /* private fields */ }Expand description
Top-level handle to a Lexe wallet.
Exposes simple and ~stable APIs for easy management of a Lexe wallet.
Implementations§
Source§impl LexeWallet<WithDb>
impl LexeWallet<WithDb>
Sourcepub fn fresh(
rng: &mut impl Crng,
env_config: WalletEnvConfig,
credentials: CredentialsRef<'_>,
lexe_data_dir: Option<PathBuf>,
) -> Result<Self>
pub fn fresh( rng: &mut impl Crng, 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.
Sourcepub fn load(
rng: &mut impl Crng,
env_config: WalletEnvConfig,
credentials: CredentialsRef<'_>,
lexe_data_dir: Option<PathBuf>,
) -> Result<Option<Self>>
pub fn load( rng: &mut impl Crng, 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.
Sourcepub fn load_or_fresh(
rng: &mut impl Crng,
env_config: WalletEnvConfig,
credentials: CredentialsRef<'_>,
lexe_data_dir: Option<PathBuf>,
) -> Result<Self>
pub fn load_or_fresh( rng: &mut impl Crng, 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.
Sourcepub fn payments_db(&self) -> &PaymentsDb<DiskFs>
pub fn payments_db(&self) -> &PaymentsDb<DiskFs>
Get a reference to the PaymentsDb.
This is the primary data source for constructing a payments list UI.
Sourcepub async fn sync_payments(&self) -> Result<PaymentSyncSummary>
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.
Only one sync can run at a time. Errors if another sync is already in progress.
Source§impl LexeWallet<WithoutDb>
impl LexeWallet<WithoutDb>
Sourcepub fn without_db(
rng: &mut impl Crng,
env_config: WalletEnvConfig,
credentials: CredentialsRef<'_>,
) -> Result<Self>
pub fn without_db( rng: &mut impl Crng, 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.
Source§impl<D> LexeWallet<D>
impl<D> LexeWallet<D>
Sourcepub async fn signup(
&self,
rng: &mut impl Crng,
root_seed: &RootSeed,
partner_pk: Option<UserPk>,
) -> Result<()>
pub async fn signup( &self, rng: &mut impl Crng, root_seed: &RootSeed, partner_pk: Option<UserPk>, ) -> Result<()>
Registers this user with the Lexe backend, then provisions the node.
This function 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 function once, ever, per user, but it is also okay to call this function even if the user has already been signed up; in other words, this function 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’sUserPkto earn a share of this wallet’s fees.
Sourcepub async fn provision(&self, credentials: CredentialsRef<'_>) -> Result<()>
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.
Sourcepub fn user_config(&self) -> &WalletUserConfig
pub fn user_config(&self) -> &WalletUserConfig
Get a reference to the user’s wallet configuration.
Sourcepub async fn node_info(&self) -> Result<SdkNodeInfo>
pub async fn node_info(&self) -> Result<SdkNodeInfo>
Get information about this Lexe node.
Sourcepub async fn create_invoice(
&self,
req: SdkCreateInvoiceRequest,
) -> Result<SdkCreateInvoiceResponse>
pub async fn create_invoice( &self, req: SdkCreateInvoiceRequest, ) -> Result<SdkCreateInvoiceResponse>
Create a BOLT 11 invoice.
Sourcepub async fn pay_invoice(
&self,
req: SdkPayInvoiceRequest,
) -> Result<SdkPayInvoiceResponse>
pub async fn pay_invoice( &self, req: SdkPayInvoiceRequest, ) -> Result<SdkPayInvoiceResponse>
Pay a BOLT 11 invoice.
Sourcepub async fn get_payment(
&self,
req: SdkGetPaymentRequest,
) -> Result<SdkGetPaymentResponse>
pub async fn get_payment( &self, req: SdkGetPaymentRequest, ) -> Result<SdkGetPaymentResponse>
Get information about a payment by its index.
Sourcepub async fn update_payment_note(&self, req: UpdatePaymentNote) -> Result<()>
pub async fn update_payment_note(&self, req: UpdatePaymentNote) -> Result<()>
Update the note on an existing payment.