Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ add_library(bitcoin_common STATIC EXCLUDE_FROM_ALL
coins.cpp
common/args.cpp
common/bloom.cpp
common/bip352.cpp
common/config.cpp
common/init.cpp
common/interfaces.cpp
Expand Down Expand Up @@ -236,6 +237,7 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL
httpserver.cpp
i2p.cpp
index/base.cpp
index/bip352.cpp
index/blockfilterindex.cpp
index/coinstatsindex.cpp
index/txindex.cpp
Expand Down Expand Up @@ -324,6 +326,7 @@ target_link_libraries(bitcoin_node
$<TARGET_NAME_IF_EXISTS:bitcoin_zmq>
leveldb
minisketch
secp256k1
univalue
Boost::headers
$<TARGET_NAME_IF_EXISTS:libevent::core>
Expand Down
7 changes: 7 additions & 0 deletions src/addresstype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ namespace {
class CScriptVisitor
{
public:
CScript operator()(const V0SilentPaymentDestination& dest) const
{
return CScript();
}
CScript operator()(const CNoDestination& dest) const
{
return dest.GetScript();
Expand Down Expand Up @@ -156,6 +160,9 @@ class ValidDestinationVisitor
bool operator()(const PubKeyDestination& dest) const { return false; }
bool operator()(const PKHash& dest) const { return true; }
bool operator()(const ScriptHash& dest) const { return true; }
// silent payment addresses are not valid until sending support has been implemented
// TODO: set this to true once sending is implemented
bool operator()(const V0SilentPaymentDestination& dest) const { return false; }
bool operator()(const WitnessV0KeyHash& dest) const { return true; }
bool operator()(const WitnessV0ScriptHash& dest) const { return true; }
bool operator()(const WitnessV1Taproot& dest) const { return true; }
Expand Down
21 changes: 20 additions & 1 deletion src/addresstype.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@ struct PayToAnchor : public WitnessUnknown
};
};

struct V0SilentPaymentDestination
{
CPubKey m_scan_pubkey;
CPubKey m_spend_pubkey;

friend bool operator==(const V0SilentPaymentDestination& a, const V0SilentPaymentDestination& b) {
if (a.m_scan_pubkey != b.m_scan_pubkey) return false;
if (a.m_spend_pubkey != b.m_spend_pubkey) return false;
return true;
}

friend bool operator<(const V0SilentPaymentDestination& a, const V0SilentPaymentDestination& b) {
if (a.m_scan_pubkey < b.m_scan_pubkey) return true;
if (a.m_scan_pubkey > b.m_scan_pubkey) return false;
if (a.m_spend_pubkey < b.m_spend_pubkey) return true;
return false;
}
};

/**
* A txout script categorized into standard templates.
* * CNoDestination: Optionally a script, no corresponding address.
Expand All @@ -140,7 +159,7 @@ struct PayToAnchor : public WitnessUnknown
* * WitnessUnknown: TxoutType::WITNESS_UNKNOWN destination (P2W??? address)
* A CTxDestination is the internal data type encoded in a bitcoin address
*/
using CTxDestination = std::variant<CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown>;
using CTxDestination = std::variant<CNoDestination, V0SilentPaymentDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown>;

/** Check whether a CTxDestination corresponds to one with an address. */
bool IsValidDestination(const CTxDestination& dest);
Expand Down
1 change: 1 addition & 0 deletions src/bech32.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum class Encoding {
* and we would never encode an address with such a massive value */
enum CharLimit : size_t {
BECH32 = 90, //!< BIP173/350 imposed character limit for Bech32(m) encoded addresses. This guarantees finding up to 4 errors.
SILENT_PAYMENTS = 1024, //!< BIP352 imposed 1024 character limit on Bech32m encoded silent payment addresses. This guarantees finding up to 3 errors
};

/** Encode a Bech32 or Bech32m string. If hrp contains uppercase characters, this will cause an
Expand Down
Loading