pub struct Recipient { /* private fields */ }
Expand description
A struct that a recipient uses to generate a payment code and process notifications. This is invariant with regard to sender and needs to be constructed only once (unique per BIP32 seed).
Implementations§
source§impl Recipient
impl Recipient
sourcepub fn from_seed<C: Signing>(
secp: &Secp256k1<C>,
seed: &[u8],
network: Network,
account: u32,
address_types: HashSet<AddressType>
) -> Result<Self, Error>
pub fn from_seed<C: Signing>(
secp: &Secp256k1<C>,
seed: &[u8],
network: Network,
account: u32,
address_types: HashSet<AddressType>
) -> Result<Self, Error>
Create a recipient side from a BIP32 seed.
sourcepub fn from_master_xprv<C: Signing>(
secp: &Secp256k1<C>,
master: ExtendedPrivKey,
account: u32,
address_types: HashSet<AddressType>
) -> Result<Self, Error>
pub fn from_master_xprv<C: Signing>(
secp: &Secp256k1<C>,
master: ExtendedPrivKey,
account: u32,
address_types: HashSet<AddressType>
) -> Result<Self, Error>
Create a recipient side from a master extended private key. Not supplying a master key here produces an error.
sourcepub fn detect_notification(
&self,
secp: &Secp256k1<All>,
script: &Script
) -> Option<RecipientCommitment>
pub fn detect_notification(
&self,
secp: &Secp256k1<All>,
script: &Script
) -> Option<RecipientCommitment>
Processes a scriptpubkey and tries to find a notification in it. If the notification
isn’t meant for this recipient, None
is returned. Otherwise, the sender’s public key,
along with the sender’s chosen address type, is returned. Note that this has a 1 in ~4.3
billion chance of detecting a spurious notification.
sourcepub fn detect_notification_in_slice(
&self,
secp: &Secp256k1<All>,
data: &[u8]
) -> Option<RecipientCommitment>
pub fn detect_notification_in_slice(
&self,
secp: &Secp256k1<All>,
data: &[u8]
) -> Option<RecipientCommitment>
Processes a byte slice and tries to find a notification in it. If the notification
isn’t meant for this recipient, None
is returned. Otherwise, the sender’s public key,
along with the sender’s chosen address type, is returned. Note that this has a 1 in ~4.3
billion chance of detecting a spurious notification.
sourcepub fn payment_code(&self) -> PaymentCode
pub fn payment_code(&self) -> PaymentCode
Returns the payment code for this recipient.
sourcepub fn key_info(
&self,
secp: &Secp256k1<All>,
commitment: &RecipientCommitment,
address_index: u64
) -> Result<(Address, PublicKey, PrivateKey), Error>
pub fn key_info(
&self,
secp: &Secp256k1<All>,
commitment: &RecipientCommitment,
address_index: u64
) -> Result<(Address, PublicKey, PrivateKey), Error>
Returns the private key for a sender-recipient connection at index c
.