pub struct PaymentRequest {
pub payment_details: PaymentDetails,
pub merchant_pubkey: Option<Vec<u8>>,
pub signature: Option<Vec<u8>>,
pub authorized_refund_addresses: Option<Vec<SignedRefundAddress>>,
}Expand description
Payment Request - Main payment protocol message
Fields§
§payment_details: PaymentDetailsPayment details
merchant_pubkey: Option<Vec<u8>>Merchant’s Bitcoin public key (compressed, 33 bytes) Replaces X.509 certificates with on-chain verifiable keys
signature: Option<Vec<u8>>Signature over payment_details by merchant’s Bitcoin key
Pre-authorized refund addresses (signed by merchant) Prevents refund address attacks by requiring merchant signature
Implementations§
Source§impl PaymentRequest
impl PaymentRequest
Sourcepub fn new(network: String, outputs: Vec<PaymentOutput>, time: u64) -> Self
pub fn new(network: String, outputs: Vec<PaymentOutput>, time: u64) -> Self
Create a new payment request
Sourcepub fn with_merchant_key(self, pubkey: [u8; 33]) -> Self
pub fn with_merchant_key(self, pubkey: [u8; 33]) -> Self
Set merchant public key
Add authorized refund address (signed by merchant)
Sourcepub fn with_expires(self, expires: u64) -> Self
pub fn with_expires(self, expires: u64) -> Self
Set expiration time
Sourcepub fn with_payment_url(self, url: String) -> Self
pub fn with_payment_url(self, url: String) -> Self
Set payment URL (where to send Payment message)
Sourcepub fn with_merchant_data(self, data: Vec<u8>) -> Self
pub fn with_merchant_data(self, data: Vec<u8>) -> Self
Set merchant data (opaque customer data)
Sourcepub fn sign(&mut self, private_key: &[u8; 32]) -> Result<(), Bip70Error>
pub fn sign(&mut self, private_key: &[u8; 32]) -> Result<(), Bip70Error>
Sign payment request with merchant’s private key (raw 32-byte scalar).
Sourcepub fn verify_signature(&self) -> Result<(), Bip70Error>
pub fn verify_signature(&self) -> Result<(), Bip70Error>
Verify payment request signature.
Sourcepub fn validate(&self) -> Result<(), Bip70Error>
pub fn validate(&self) -> Result<(), Bip70Error>
Validate payment request
Trait Implementations§
Source§impl Clone for PaymentRequest
impl Clone for PaymentRequest
Source§fn clone(&self) -> PaymentRequest
fn clone(&self) -> PaymentRequest
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PaymentRequest
impl Debug for PaymentRequest
Source§impl<'de> Deserialize<'de> for PaymentRequest
impl<'de> Deserialize<'de> for PaymentRequest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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