18class DestinationEncoder {
26 std::string operator()(
const PKHash &
id)
const {
27 std::vector<uint8_t> data =
29 data.insert(data.end(),
id.begin(),
id.end());
33 std::string operator()(
const ScriptHash &
id)
const {
34 std::vector<uint8_t> data =
36 data.insert(data.end(),
id.begin(),
id.end());
45 std::vector<uint8_t> data;
83 std::vector<uint8_t> data;
88 (data.size() == 33 +
privkey_prefix.size() && data.back() == 1)) &&
109 data.insert(data.end(), key.
begin(), key.
end());
120 std::vector<uint8_t> data;
122 const std::vector<uint8_t> &
prefix =
125 std::equal(
prefix.begin(),
prefix.end(), data.begin())) {
133 std::vector<uint8_t> data =
135 size_t size = data.size();
137 key.
Encode(data.data() + size);
144 std::vector<uint8_t> data;
146 const std::vector<uint8_t> &
prefix =
149 std::equal(
prefix.begin(),
prefix.end(), data.begin())) {
157 std::vector<uint8_t> data =
159 size_t size = data.size();
161 key.
Encode(data.data() + size);
190 return std::visit(DestinationEncoder(params), dest);
std::string EncodeBase58Check(Span< const uint8_t > input)
Encode a byte span into a base58-encoded string, including checksum.
static bool DecodeBase58Check(const char *psz, std::vector< uint8_t > &vchRet, int max_ret_len)
std::string EncodeCashAddr(const CTxDestination &dst, const CChainParams ¶ms)
CTxDestination DecodeCashAddr(const std::string &addr, const CChainParams ¶ms)
const CChainParams & Params()
Return the currently selected parameters.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
const std::vector< uint8_t > & Base58Prefix(Base58Type type) const
Return the list of hostnames to look up for DNS seeds.
An encapsulated secp256k1 private key.
bool IsValid() const
Check whether this private key is valid.
const uint8_t * begin() const
bool IsCompressed() const
Check whether the public key corresponding to this private key is (to be) compressed.
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
const uint8_t * end() const
virtual bool UseCashAddrEncoding() const =0
virtual const CChainParams & GetChainParams() const =0
unsigned int size() const
void memory_cleanse(void *ptr, size_t len)
Secure overwrite a buffer (possibly containing secret data) with zero-bytes.
std::string EncodeDestination(const CTxDestination &dest, const Config &config)
bool IsValidDestinationString(const std::string &str, const CChainParams ¶ms)
std::string EncodeExtKey(const CExtKey &key)
CExtPubKey DecodeExtPubKey(const std::string &str)
std::string EncodeSecret(const CKey &key)
CTxDestination DecodeDestination(const std::string &addr, const CChainParams ¶ms)
CKey DecodeSecret(const std::string &str)
std::string EncodeExtPubKey(const CExtPubKey &key)
CTxDestination DecodeLegacyAddr(const std::string &str, const CChainParams ¶ms)
std::string EncodeLegacyAddr(const CTxDestination &dest, const CChainParams ¶ms)
CExtKey DecodeExtKey(const std::string &str)
const CChainParams & m_params
const unsigned int BIP32_EXTKEY_SIZE
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
void Encode(uint8_t code[BIP32_EXTKEY_SIZE]) const
void Decode(const uint8_t code[BIP32_EXTKEY_SIZE])
void Encode(uint8_t code[BIP32_EXTKEY_SIZE]) const
void Decode(const uint8_t code[BIP32_EXTKEY_SIZE])