Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
251if (data.size() == BIP32_EXTKEY_SIZE + prefix.size() && std::equal(prefix.begin(), prefix.end(), data.begin())) {252key.Decode(data.data() + prefix.size());253}254}255return key;256}258std::string EncodeExtPubKey(const CExtPubKey& key)259{260std::vector<unsigned char> data = Params().Base58Prefix(CChainParams::EXT_PUBLIC_KEY);261size_t size = data.size();262data.resize(size + BIP32_EXTKEY_SIZE);263key.Encode(data.data() + size);264std::string ret = EncodeBase58Check(data);265return ret;266}268CExtKey DecodeExtKey(const std::string& str)269{270CExtKey key;271std::vector<unsigned char> data;272if (DecodeBase58Check(str, data, 78)) {273const std::vector<unsigned char>& prefix = Params().Base58Prefix(CChainParams::EXT_SECRET_KEY);274if (data.size() == BIP32_EXTKEY_SIZE + prefix.size() && std::equal(prefix.begin(), prefix.end(), data.begin())) {275key.Decode(data.data() + prefix.size());276}277}278if (!data.empty()) {279memory_cleanse(data.data(), data.size());280}281return key;282}284std::string EncodeExtKey(const CExtKey& key)285{286std::vector<unsigned char> data = Params().Base58Prefix(CChainParams::EXT_SECRET_KEY);287size_t size = data.size();288data.resize(size + BIP32_EXTKEY_SIZE);289key.Encode(data.data() + size);290std::string ret = EncodeBase58Check(data);291memory_cleanse(data.data(), data.size());292return ret;293}295std::string EncodeDestination(const CTxDestination& dest)296{297return std::visit(DestinationEncoder(Params()), dest);298}300CTxDestination DecodeDestination(const std::string& str, std::string& error_msg, std::vector<int>* error_locations)301{302return DecodeDestination(str, Params(), error_msg, error_locations);303}305CTxDestination DecodeDestination(const std::string& str)306{307std::string error_msg;308return DecodeDestination(str, error_msg);309}311bool IsValidDestinationString(const std::string& str, const CChainParams& params)312{313std::string error_msg;314return IsValidDestination(DecodeDestination(str, params, error_msg, nullptr));315}317bool IsValidDestinationString(const std::string& str)318{319return IsValidDestinationString(str, Params());320}