pub struct BoltzSession { /* private fields */ }lightning only.Expand description
A session to pay and receive lightning payments.
Lightning payments are done via LBTC swaps using Boltz.
See BoltzSessionBuilder for various options to configure the session.
Implementations§
Source§impl BoltzSession
impl BoltzSession
Sourcepub fn new(network: &Network, client: &AnyClient) -> Result<Self, LwkError>
pub fn new(network: &Network, client: &AnyClient) -> Result<Self, LwkError>
Create the lightning session with default settings
This uses default timeout and generates a random mnemonic.
For custom configuration, use BoltzSession::from_builder() instead.
Sourcepub fn from_builder(builder: BoltzSessionBuilder) -> Result<Self, LwkError>
pub fn from_builder(builder: BoltzSessionBuilder) -> Result<Self, LwkError>
Create the lightning session from a builder
Sourcepub fn prepare_pay(
&self,
lightning_payment: &LightningPayment,
refund_address: &Address,
webhook: Option<Arc<WebHook>>,
) -> Result<PreparePayResponse, LwkError>
pub fn prepare_pay( &self, lightning_payment: &LightningPayment, refund_address: &Address, webhook: Option<Arc<WebHook>>, ) -> Result<PreparePayResponse, LwkError>
Prepare to pay a bolt11 invoice
Sourcepub fn restore_prepare_pay(
&self,
data: &str,
) -> Result<PreparePayResponse, LwkError>
pub fn restore_prepare_pay( &self, data: &str, ) -> Result<PreparePayResponse, LwkError>
Restore a payment from its serialized data see PreparePayResponse::serialize
Sourcepub fn invoice(
&self,
amount: u64,
description: Option<String>,
claim_address: &Address,
webhook: Option<Arc<WebHook>>,
) -> Result<InvoiceResponse, LwkError>
pub fn invoice( &self, amount: u64, description: Option<String>, claim_address: &Address, webhook: Option<Arc<WebHook>>, ) -> Result<InvoiceResponse, LwkError>
Create a new invoice for a given amount and a claim address to receive the payment
Sourcepub fn restore_invoice(&self, data: &str) -> Result<InvoiceResponse, LwkError>
pub fn restore_invoice(&self, data: &str) -> Result<InvoiceResponse, LwkError>
Restore an invoice flow from its serialized data see InvoiceResponse::serialize
Sourcepub fn btc_to_lbtc(
&self,
amount: u64,
refund_address: &BitcoinAddress,
claim_address: &Address,
webhook: Option<Arc<WebHook>>,
) -> Result<LockupResponse, LwkError>
pub fn btc_to_lbtc( &self, amount: u64, refund_address: &BitcoinAddress, claim_address: &Address, webhook: Option<Arc<WebHook>>, ) -> Result<LockupResponse, LwkError>
Create an onchain swap to convert BTC to LBTC
Sourcepub fn lbtc_to_btc(
&self,
amount: u64,
refund_address: &Address,
claim_address: &BitcoinAddress,
webhook: Option<Arc<WebHook>>,
) -> Result<LockupResponse, LwkError>
pub fn lbtc_to_btc( &self, amount: u64, refund_address: &Address, claim_address: &BitcoinAddress, webhook: Option<Arc<WebHook>>, ) -> Result<LockupResponse, LwkError>
Create an onchain swap to convert LBTC to BTC
Sourcepub fn restore_lockup(&self, data: &str) -> Result<LockupResponse, LwkError>
pub fn restore_lockup(&self, data: &str) -> Result<LockupResponse, LwkError>
Restore an onchain swap from its serialized data see LockupResponse::serialize
Sourcepub fn rescue_file(&self) -> Result<String, LwkError>
pub fn rescue_file(&self) -> Result<String, LwkError>
Generate a rescue file with lightning session mnemonic.
The rescue file is a JSON file that contains the swaps mnemonic. It can be used on the Boltz web app to bring non terminated swaps to completition.
Sourcepub fn swap_restore(&self) -> Result<SwapList, LwkError>
pub fn swap_restore(&self) -> Result<SwapList, LwkError>
Returns a the list of all the swaps ever done with the session mnemonic.
The object returned can be converted to a json String with toString()
Sourcepub fn restorable_reverse_swaps(
&self,
swap_list: &SwapList,
claim_address: &Address,
) -> Result<Vec<String>, LwkError>
pub fn restorable_reverse_swaps( &self, swap_list: &SwapList, claim_address: &Address, ) -> Result<Vec<String>, LwkError>
Filter the swap list to only include restorable reverse swaps
Sourcepub fn restorable_submarine_swaps(
&self,
swap_list: &SwapList,
refund_address: &Address,
) -> Result<Vec<String>, LwkError>
pub fn restorable_submarine_swaps( &self, swap_list: &SwapList, refund_address: &Address, ) -> Result<Vec<String>, LwkError>
Filter the swap list to only include restorable submarine swaps
Sourcepub fn restorable_btc_to_lbtc_swaps(
&self,
swap_list: &SwapList,
claim_address: &Address,
refund_address: &BitcoinAddress,
) -> Result<Vec<String>, LwkError>
pub fn restorable_btc_to_lbtc_swaps( &self, swap_list: &SwapList, claim_address: &Address, refund_address: &BitcoinAddress, ) -> Result<Vec<String>, LwkError>
Filter the swap list to only include restorable BTC to LBTC swaps
Sourcepub fn restorable_lbtc_to_btc_swaps(
&self,
swap_list: &SwapList,
claim_address: &BitcoinAddress,
refund_address: &Address,
) -> Result<Vec<String>, LwkError>
pub fn restorable_lbtc_to_btc_swaps( &self, swap_list: &SwapList, claim_address: &BitcoinAddress, refund_address: &Address, ) -> Result<Vec<String>, LwkError>
Filter the swap list to only include restorable LBTC to BTC swaps
Sourcepub fn fetch_swaps_info(&self) -> Result<String, LwkError>
pub fn fetch_swaps_info(&self) -> Result<String, LwkError>
Fetch informations, such as min and max amounts, about the reverse and submarine pairs from the boltz api.
Sourcepub fn next_index_to_use(&self) -> u32
pub fn next_index_to_use(&self) -> u32
Get the next index to use for deriving keypairs
Sourcepub fn set_next_index_to_use(&self, next_index_to_use: u32)
pub fn set_next_index_to_use(&self, next_index_to_use: u32)
Set the next index to use for deriving keypairs
This may be necessary to handle multiple sessions with the same mnemonic.
Trait Implementations§
Source§impl<UT> LiftRef<UT> for BoltzSession
impl<UT> LiftRef<UT> for BoltzSession
type LiftType = Arc<BoltzSession>
Source§impl<UT> LowerError<UT> for BoltzSession
impl<UT> LowerError<UT> for BoltzSession
Source§fn lower_error(obj: Self) -> RustBuffer
fn lower_error(obj: Self) -> RustBuffer
Source§impl<UT> LowerReturn<UT> for BoltzSession
impl<UT> LowerReturn<UT> for BoltzSession
Source§type ReturnType = <Arc<BoltzSession> as LowerReturn<UniFfiTag>>::ReturnType
type ReturnType = <Arc<BoltzSession> as LowerReturn<UniFfiTag>>::ReturnType
Source§fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
Source§fn handle_failed_lift(
error: LiftArgsError,
) -> Result<Self::ReturnType, RustCallError>
fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>
Source§impl<UT> TypeId<UT> for BoltzSession
impl<UT> TypeId<UT> for BoltzSession
Auto Trait Implementations§
impl !Freeze for BoltzSession
impl !RefUnwindSafe for BoltzSession
impl Send for BoltzSession
impl Sync for BoltzSession
impl Unpin for BoltzSession
impl !UnwindSafe for BoltzSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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