uniffi_lipalightninglib

Struct Swap

source
pub struct Swap { /* private fields */ }

Implementations§

source§

impl Swap

source

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

source

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

source

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 prepared
  • destination - the destination address to which funds will be sent. Can be obtained using Util::decode_data

Requires network: yes

source

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 using Swap::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

source

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:

Returns the txid of the sweeping tx.

Requires network: yes

source

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

source

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§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

§

impl<T> AsAny for T
where T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

§

fn type_name(&self) -> &'static str

Gets the type name of self
§

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

§

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

§

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

§

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
§

impl<T> Downcast for T
where T: AsAny + ?Sized,

§

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T. Read more
§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.
§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
§

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

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
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
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T