Struct webln::WebLN

source ·
pub struct WebLN { /* private fields */ }
Expand description

WebLN instance

Implementations§

source§

impl WebLN

source

pub fn new() -> Result<Self, Error>

Compose new WebLN instance

source

pub async fn is_enabled(&self) -> Result<bool, Error>

Check if webln is enabled without explicitly enabling it through webln.enable() (which may cause a confirmation popup in some providers)

source

pub async fn enable(&self) -> Result<(), Error>

To begin interacting with WebLN APIs you’ll first need to enable the provider. Calling webln.enable() will prompt the user for permission to use the WebLN capabilities of the browser. After that you are free to call any of the other API methods.

source

pub async fn get_info(&self) -> Result<GetInfoResponse, Error>

Get information about the connected node and what WebLN methods it supports.

source

pub async fn keysend( &self, args: &KeysendArgs ) -> Result<SendPaymentResponse, Error>

Request the user to send a keysend payment. This is a spontaneous payment that does not require an invoice and only needs a destination public key and and amount.

source

pub async fn make_invoice( &self, args: &RequestInvoiceArgs ) -> Result<RequestInvoiceResponse, Error>

Request that the user creates an invoice to be used by the web app

source

pub async fn send_payment( &self, invoice: &str ) -> Result<SendPaymentResponse, Error>

Request that the user sends a payment for an invoice.

source

pub async fn send_multi_payment<I, S>( &self, invoices: I ) -> Result<SendMultiPaymentResponse, Error>
where I: IntoIterator<Item = S>, S: AsRef<str>,

Request that the user sends multiple payments.

source

pub async fn send_payment_async(&self, invoice: &str) -> Result<(), Error>

Request that the user sends a payment for an invoice. The payment will only be initiated and will not wait for a preimage to be returned. This is useful when paying HOLD Invoices. There is no guarantee that the payment will be successfully sent to the receiver. It’s up to the receiver to check whether or not the invoice has been paid.

source

pub async fn sign_message( &self, message: &str ) -> Result<SignMessageResponse, Error>

Request that the user signs an arbitrary string message.

source

pub async fn get_balance(&self) -> Result<BalanceResponse, Error>

Fetch the balance of the current account.

Trait Implementations§

source§

impl Clone for WebLN

source§

fn clone(&self) -> WebLN

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for WebLN

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for WebLN

§

impl RefUnwindSafe for WebLN

§

impl !Send for WebLN

§

impl !Sync for WebLN

§

impl Unpin for WebLN

§

impl UnwindSafe for WebLN

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
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, 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.