5#ifndef BITCOIN_COMMON_BIP352_H
6#define BITCOIN_COMMON_BIP352_H
39using PubKey = std::variant<CPubKey, XOnlyPubKey>;
81 std::span<const unsigned char> extension_data = {}
82 ) : m_version(version), m_scan_pubkey(scan_pubkey),
83 m_spend_pubkey(spend_pubkey),
84 m_extension_data(extension_data.begin(), extension_data.end()) {};
86 static std::optional<SilentPaymentsDestination> From(
90 std::span<const unsigned char> extension_data = {}
107 std::unique_ptr<secp256k1_silentpayments_label>
m_label;
112 static std::optional<SilentPaymentsLabel> FromBytes(std::span<const unsigned char, CPubKey::COMPRESSED_SIZE> vch);
143 template <
typename Stream>
149 template <
typename Stream>
152 std::array<unsigned char, CPubKey::COMPRESSED_SIZE> vch;
154 return FromBytes(std::span{vch});
163 std::optional<SilentPaymentsLabel>
label;
302 std::optional<std::vector<SilentPaymentsOutput>> Scan(
const PrevoutsSummary& prevouts_summary,
const std::vector<XOnlyPubKey>& tx_outputs)
const;
BSWAP_CONSTEXPR uint32_t internal_bswap_32(uint32_t x)
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
An encapsulated private key.
An outpoint - a combination of a transaction hash and an index n into its vout.
An encapsulated public key.
static constexpr unsigned int COMPRESSED_SIZE
Serialized script, used inside transaction inputs and outputs.
An input of a transaction.
std::unique_ptr< secp256k1_silentpayments_prevouts_summary > m_prevouts_summary
PrevoutsSummary(const secp256k1_silentpayments_prevouts_summary &prevouts_summary)
PrevoutsSummary(PrevoutsSummary &&) noexcept
const secp256k1_silentpayments_prevouts_summary * Get() const LIFETIMEBOUND
std::unique_ptr< secp256k1_silentpayments_label > m_label
static std::optional< SilentPaymentsLabel > Unserialize(Stream &s)
unsigned char m_vch[CPubKey::COMPRESSED_SIZE]
friend bool operator<(const SilentPaymentsLabel &a, std::span< const unsigned char, CPubKey::COMPRESSED_SIZE > b)
Transparent comparisons against a raw 33-byte compressed label key, so a LabelTweakMap can be looked ...
friend bool operator<(std::span< const unsigned char, CPubKey::COMPRESSED_SIZE > a, const SilentPaymentsLabel &b)
SilentPaymentsLabel(SilentPaymentsLabel &&) noexcept
friend bool operator>(const SilentPaymentsLabel &a, const SilentPaymentsLabel &b)
void Serialize(Stream &s) const
friend bool operator<(const SilentPaymentsLabel &a, const SilentPaymentsLabel &b)
A silent payments recipient's scanning identity.
~SilentPaymentsReceiver()
SilentPaymentsReceiver(SilentPaymentsReceiver &&)=delete
LabelTweakMap::const_iterator m_change_it
SilentPaymentsReceiver & operator=(SilentPaymentsReceiver &&)=delete
SilentPaymentsReceiver(const SilentPaymentsReceiver &)=delete
SilentPaymentsReceiver & operator=(const SilentPaymentsReceiver &)=delete
std::unique_ptr< secp256k1_pubkey > m_spend_pubkey_obj
The util::Expected class provides a standard way for low-level functions to return either error value...
util::Expected< PrevoutsSummary, PrevoutsSummaryError > GetSilentPaymentsPrevoutsSummary(const std::vector< CTxIn > &vin, const std::map< COutPoint, Coin > &coins)
Get silent payments public data from transaction inputs.
std::optional< PubKey > GetPubKeyFromInput(const CTxIn &txin, const CScript &spk)
Get the public key from an input.
std::optional< std::map< size_t, WitnessV1Taproot > > GenerateSilentPaymentsTaprootDestinations(const std::map< size_t, SilentPaymentsDestination > &sp_dests, const std::vector< CKey > &plain_keys, const std::vector< KeyPair > &taproot_keys, const COutPoint &smallest_outpoint)
Generate silent payments taproot destinations.
@ NOT_ELIGIBLE
This transaction is not eligible to be scanned for silent payments outputs: either none of its inputs...
@ MISSING_COIN
A prevout referenced by an input in vin has no corresponding entry in coins.
util::Expected< SilentPaymentsDestination, std::string > DecodeSilentPaymentsAddress(const std::string &str, const CChainParams ¶ms)
Decode a BIP352 "sp1..." address. Returns the destination, or an error message on failure.
std::map< SilentPaymentsLabel, uint256, std::less<> > LabelTweakMap
std::variant< CPubKey, XOnlyPubKey > PubKey
static unsigned char smallest_outpoint[36]
bool operator()(const COutPoint &a, const COutPoint &b) const
bool operator==(const SilentPaymentsDestination &) const =default
const CPubKey & GetSpendPubKey() const
uint8_t GetVersion() const
std::span< const unsigned char > GetExtensionData() const
SilentPaymentsDestination(uint8_t version, const CPubKey &scan_pubkey, const CPubKey &spend_pubkey, std::span< const unsigned char > extension_data={})
std::vector< unsigned char > m_extension_data
const CPubKey & GetScanPubKey() const
std::optional< SilentPaymentsLabel > label
Opaque data structure that holds a parsed and valid public key.
Opaque data structure that holds a Silent Payments label.
Opaque data structure that holds Silent Payments prevouts summary data.