Bitcoin Core 32.99.0
P2P Digital Currency
Public Member Functions | Private Member Functions | Private Attributes | List of all members
bip352::SilentPaymentsReceiver Class Reference

A silent payments recipient's scanning identity. More...

#include <bip352.h>

Collaboration diagram for bip352::SilentPaymentsReceiver:
[legend]

Public Member Functions

 SilentPaymentsReceiver (const CKey &scan_key, const CPubKey &spend_pubkey, const LabelTweakMap &labels={})
 
 ~SilentPaymentsReceiver ()
 
 SilentPaymentsReceiver (SilentPaymentsReceiver &&)=delete
 
SilentPaymentsReceiver & operator= (SilentPaymentsReceiver &&)=delete
 
 SilentPaymentsReceiver (const SilentPaymentsReceiver &)=delete
 
SilentPaymentsReceiver & operator= (const SilentPaymentsReceiver &)=delete
 
const LabelTweakMap & GetLabels () const
 Get this recipient's registered labels, including the change label. More...
 
SilentPaymentsDestination GenerateLabeledAddress (uint32_t m)
 Register label m (e.g. More...
 
SilentPaymentsDestination GetChangeDestination () const
 Get this recipient's silent payments change destination. More...
 
std::optional< std::vector< SilentPaymentsOutput > > Scan (const PrevoutsSummary &prevouts_summary, const std::vector< XOnlyPubKey > &tx_outputs) const
 Scan a transaction for silent payments outputs. More...
 

Private Member Functions

SilentPaymentsDestination BuildLabeledDestination (const SilentPaymentsLabel &label) const
 

Private Attributes

CKey m_scan_key
 
CPubKey m_spend_pubkey
 
std::unique_ptr< secp256k1_pubkey > m_spend_pubkey_obj
 
LabelTweakMap m_labels
 
LabelTweakMap::const_iterator m_change_it
 

Detailed Description

A silent payments recipient's scanning identity.

Bundles a recipient's scan key, spend public key, and known labels (always including the change label) into a single self-contained object capable of scanning transactions and deriving the recipient's change destination.

The change label is created automatically on construction if one is not supplied through the labels map; additional labels are registered on creation with GenerateLabeledAddress().

Definition at line 239 of file bip352.h.

Constructor & Destructor Documentation

◆ SilentPaymentsReceiver() [1/3]

bip352::SilentPaymentsReceiver::SilentPaymentsReceiver ( const CKey &  scan_key,
const CPubKey &  spend_pubkey,
const LabelTweakMap &  labels = {} 
)

Definition at line 413 of file bip352.cpp.

Here is the call graph for this function:

◆ ~SilentPaymentsReceiver()

bip352::SilentPaymentsReceiver::~SilentPaymentsReceiver ( )
default

◆ SilentPaymentsReceiver() [2/3]

bip352::SilentPaymentsReceiver::SilentPaymentsReceiver ( SilentPaymentsReceiver &&  )
delete

◆ SilentPaymentsReceiver() [3/3]

bip352::SilentPaymentsReceiver::SilentPaymentsReceiver ( const SilentPaymentsReceiver &  )
delete

Member Function Documentation

◆ BuildLabeledDestination()

SilentPaymentsDestination bip352::SilentPaymentsReceiver::BuildLabeledDestination ( const SilentPaymentsLabel &  label) const
private

Definition at line 428 of file bip352.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateLabeledAddress()

SilentPaymentsDestination bip352::SilentPaymentsReceiver::GenerateLabeledAddress ( uint32_t  m)

Register label m (e.g.

for a labeled sub-address to hand out to a payer) and generate the resulting address.

Derives the label from this recipient's own scan key and m, registers it so Scan() can recognize outputs sent to it, and returns the address to hand out.

Parameters
mAn integer m, greater than 0 (m = 0 is reserved for the change label).
Returns
SilentPaymentsDestination The labeled destination, with B_spend -> B_spend + label.

Definition at line 435 of file bip352.cpp.

Here is the call graph for this function:

◆ GetChangeDestination()

SilentPaymentsDestination bip352::SilentPaymentsReceiver::GetChangeDestination ( ) const

Get this recipient's silent payments change destination.

Returns
SilentPaymentsDestination The destination to use for this recipient's own change outputs, i.e. B_spend -> B_spend + change_label.

Definition at line 441 of file bip352.cpp.

Here is the call graph for this function:

◆ GetLabels()

const LabelTweakMap & bip352::SilentPaymentsReceiver::GetLabels ( ) const

Get this recipient's registered labels, including the change label.

Returns
const LabelTweakMap& Each label mapped to its scalar tweak.

Definition at line 424 of file bip352.cpp.

◆ operator=() [1/2]

SilentPaymentsReceiver & bip352::SilentPaymentsReceiver::operator= ( const SilentPaymentsReceiver &  )
delete

◆ operator=() [2/2]

SilentPaymentsReceiver & bip352::SilentPaymentsReceiver::operator= ( SilentPaymentsReceiver &&  )
delete

◆ Scan()

std::optional< std::vector< SilentPaymentsOutput > > bip352::SilentPaymentsReceiver::Scan ( const PrevoutsSummary &  prevouts_summary,
const std::vector< XOnlyPubKey > &  tx_outputs 
) const

Scan a transaction for silent payments outputs.

Scan the transaction for silent payments outputs intended for this recipient. The output, shared secret tweak, and (optionally) label public key is returned for each output found. If the output was sent to a labeled address, the label tweak is added to the shared secret tweak. The shared secret tweak is needed to spend the output, by adding it to the spend secret key. If no outputs are found, this transaction does not contain silent payments outputs for this recipient.

Parameters
prevouts_summaryThe silent payments public data.
tx_outputsThe taproot output public keys.
Returns
The found outputs or std::nullopt in the case of an error.

Definition at line 445 of file bip352.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ m_change_it

LabelTweakMap::const_iterator bip352::SilentPaymentsReceiver::m_change_it
private

Definition at line 245 of file bip352.h.

◆ m_labels

LabelTweakMap bip352::SilentPaymentsReceiver::m_labels
private

Definition at line 244 of file bip352.h.

◆ m_scan_key

CKey bip352::SilentPaymentsReceiver::m_scan_key
private

Definition at line 241 of file bip352.h.

◆ m_spend_pubkey

CPubKey bip352::SilentPaymentsReceiver::m_spend_pubkey
private

Definition at line 242 of file bip352.h.

◆ m_spend_pubkey_obj

std::unique_ptr<secp256k1_pubkey> bip352::SilentPaymentsReceiver::m_spend_pubkey_obj
private

Definition at line 243 of file bip352.h.


The documentation for this class was generated from the following files: