MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / DestBinToAddr

Function DestBinToAddr

src/i2p.cpp:90–104  ·  view source on GitHub ↗

* Derive the .b32.i2p address of an I2P destination (binary). * @param[in] dest I2P destination. * @return the address that corresponds to `dest` * @throw std::runtime_error if conversion fails */

Source from the content-addressed store, hash-verified

88 * @throw std::runtime_error if conversion fails
89 */
90static CNetAddr DestBinToAddr(const Binary& dest)
91{
92 CSHA256 hasher;
93 hasher.Write(dest.data(), dest.size());
94 unsigned char hash[CSHA256::OUTPUT_SIZE];
95 hasher.Finalize(hash);
96
97 CNetAddr addr;
98 const std::string addr_str = EncodeBase32(hash, false) + ".b32.i2p";
99 if (!addr.SetSpecial(addr_str)) {
100 throw std::runtime_error(strprintf("Cannot parse I2P address: \"%s\"", addr_str));
101 }
102
103 return addr;
104}
105
106/**
107 * Derive the .b32.i2p address of an I2P destination (I2P-style Base64).

Callers 2

DestB64ToAddrFunction · 0.85

Calls 6

EncodeBase32Function · 0.85
SetSpecialMethod · 0.80
WriteMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
FinalizeMethod · 0.45

Tested by

no test coverage detected