pub struct PaymentRequest { /* private fields */ }Expand description
NUT-18 Payment Request
A payment request that can be shared to request Cashu tokens.
Encoded as a string with the creqA prefix.
Implementations§
Source§impl PaymentRequest
impl PaymentRequest
Sourcepub fn from_string(encoded: String) -> Result<Arc<Self>, FfiError>
pub fn from_string(encoded: String) -> Result<Arc<Self>, FfiError>
Parse a payment request from its encoded string representation
Sourcepub fn to_string_encoded(&self) -> String
pub fn to_string_encoded(&self) -> String
Encode the payment request to a string
Sourcepub fn to_bech32_string(&self) -> Result<String, FfiError>
pub fn to_bech32_string(&self) -> Result<String, FfiError>
Encode the payment request to a NUT-26 bech32m string (creqB prefix)
Sourcepub fn to_bip321(
&self,
bolt11: Option<String>,
bolt12: Option<String>,
) -> Result<String, FfiError>
pub fn to_bip321( &self, bolt11: Option<String>, bolt12: Option<String>, ) -> Result<String, FfiError>
Convert this payment request to a BIP 321 bitcoin: URI string.
The cashu payment request is encoded as a NUT-26 bech32m CREQB1...
string in the creq= query parameter. Optionally include a BOLT11
invoice (lightning=) and/or BOLT12 offer (lno=) as fallback
payment methods for wallets that don’t support cashu.
val request = PaymentRequest.fromString("CREQB1...")
val uri = request.toBip321(
bolt11 = "lnbc100n1p...",
bolt12 = "lno1qgsq..."
)
// => "bitcoin:?creq=CREQB1...&lightning=lnbc100n1p...&lno=lno1qgsq..."Sourcepub fn payment_id(&self) -> Option<String>
pub fn payment_id(&self) -> Option<String>
Get the payment ID
Sourcepub fn unit(&self) -> Option<CurrencyUnit>
pub fn unit(&self) -> Option<CurrencyUnit>
Get the currency unit
Sourcepub fn single_use(&self) -> Option<bool>
pub fn single_use(&self) -> Option<bool>
Get whether this is a single-use request
Sourcepub fn description(&self) -> Option<String>
pub fn description(&self) -> Option<String>
Get the description
Sourcepub fn transports(&self) -> Vec<Transport>
pub fn transports(&self) -> Vec<Transport>
Get the transports for delivering the payment
Trait Implementations§
Source§impl Debug for PaymentRequest
impl Debug for PaymentRequest
Source§impl<UT> LiftRef<UT> for PaymentRequest
impl<UT> LiftRef<UT> for PaymentRequest
type LiftType = Arc<PaymentRequest>
Source§impl<UT> LowerError<UT> for PaymentRequest
impl<UT> LowerError<UT> for PaymentRequest
Source§fn lower_error(obj: Self) -> RustBuffer
fn lower_error(obj: Self) -> RustBuffer
Lower this value for scaffolding function return Read more
Source§impl<UT> LowerReturn<UT> for PaymentRequest
impl<UT> LowerReturn<UT> for PaymentRequest
Source§type ReturnType = <Arc<PaymentRequest> as LowerReturn<UniFfiTag>>::ReturnType
type ReturnType = <Arc<PaymentRequest> as LowerReturn<UniFfiTag>>::ReturnType
The type that should be returned by scaffolding functions for this type. Read more
Source§fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
Lower the return value from an scaffolding call Read more
Source§fn handle_failed_lift(
error: LiftArgsError,
) -> Result<Self::ReturnType, RustCallError>
fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>
Lower the return value for failed argument lifts Read more
Source§impl<UT> TypeId<UT> for PaymentRequest
impl<UT> TypeId<UT> for PaymentRequest
Auto Trait Implementations§
impl Freeze for PaymentRequest
impl RefUnwindSafe for PaymentRequest
impl Send for PaymentRequest
impl Sync for PaymentRequest
impl Unpin for PaymentRequest
impl UnsafeUnpin for PaymentRequest
impl UnwindSafe for PaymentRequest
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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 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> ⓘ
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