pub struct Swap { /* private fields */ }
Implementations§
source§impl Swap
impl Swap
sourcepub fn create(&self) -> Result<SwapAddressInfo, ReceiveOnchainError>
pub fn create(&self) -> Result<SwapAddressInfo, ReceiveOnchainError>
Generates a Bitcoin on-chain address that can be used to topup the local LN wallet from an external on-chain wallet.
Funds sent to this address should conform to the min and max values provided within
SwapAddressInfo
.
If a swap is in progress, this method will return an error.
Parameters:
Requires network: yes
sourcepub fn determine_resolving_fees(
&self,
failed_swap_info: FailedSwapInfo,
) -> Result<Option<OnchainResolvingFees>>
pub fn determine_resolving_fees( &self, failed_swap_info: FailedSwapInfo, ) -> Result<Option<OnchainResolvingFees>>
Returns the fees for resolving a failed swap if there are enough funds to pay for fees.
Must only be called when the failed swap is unresolved.
Returns the fee information for the available resolving options.
Requires network: yes
sourcepub fn prepare_sweep(
&self,
failed_swap_info: FailedSwapInfo,
destination: BitcoinAddressData,
) -> Result<SweepFailedSwapInfo>
pub fn prepare_sweep( &self, failed_swap_info: FailedSwapInfo, destination: BitcoinAddressData, ) -> Result<SweepFailedSwapInfo>
Prepares the sweep transaction for failed swap in order to know how much will be recovered and how much will be paid in on-chain fees.
Parameters:
failed_swap_info
- the failed swap that will be prepareddestination
- the destination address to which funds will be sent. Can be obtained usingUtil::decode_data
Requires network: yes
sourcepub fn sweep(
&self,
sweep_failed_swap_info: SweepFailedSwapInfo,
) -> Result<String>
pub fn sweep( &self, sweep_failed_swap_info: SweepFailedSwapInfo, ) -> Result<String>
Creates and broadcasts a sweeping transaction to recover funds from a failed swap. Existing
failed swaps can be listed using ActionsRequired::list
and preparing
the resolution of a failed swap can be done using Swap::prepare_sweep
.
Parameters:
sweep_failed_swap_info
- Information needed to sweep the failed swap. Can be obtained usingSwap::prepare_sweep
.
Returns the txid of the resolving transaction.
Paid on-chain fees can be known in advance using Swap::prepare_sweep
.
Requires network: yes
sourcepub fn swap(
&self,
failed_swap_info: FailedSwapInfo,
sats_per_vbyte: u32,
) -> Result<String>
pub fn swap( &self, failed_swap_info: FailedSwapInfo, sats_per_vbyte: u32, ) -> Result<String>
Automatically swaps failed swap funds back to lightning.
If a swap is in progress, this method will return an error.
If the current balance doesn’t fulfill the limits, this method will return an error.
Before using this method use Swap::determine_resolving_fees
to validate a swap is available.
Parameters:
sat_per_vbyte
- the fee rate to use for the on-chain transaction. Can be obtained withSwap::determine_resolving_fees
.
Returns the txid of the sweeping tx.
Requires network: yes
sourcepub fn calculate_lsp_fee_for_amount(
&self,
amount_sat: u64,
) -> Result<CalculateLspFeeResponseV2>
pub fn calculate_lsp_fee_for_amount( &self, amount_sat: u64, ) -> Result<CalculateLspFeeResponseV2>
Calculate the actual LSP fee for the given amount of a swap. If the already existing inbound capacity is enough, no new channel is required.
Parameters:
amount_sat
- amount in sats to compute LSP fee for
Requires network: yes
sourcepub fn get_lsp_fee(&self) -> Result<LspFee>
pub fn get_lsp_fee(&self) -> Result<LspFee>
When receiving swaps, a new channel MAY be required. A fee will be charged to the user. Get information about the fee charged by the LSP for opening new channels
Requires network: no
Auto Trait Implementations§
impl Freeze for Swap
impl !RefUnwindSafe for Swap
impl Send for Swap
impl Sync for Swap
impl Unpin for Swap
impl !UnwindSafe for Swap
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Any
.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Any
.§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request