MCPcopy Create free account
hub / github.com/ElementsProject/elements / DestBinToAddr

Function DestBinToAddr

src/i2p.cpp:86–100  ·  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

84 * @throw std::runtime_error if conversion fails
85 */
86static CNetAddr DestBinToAddr(const Binary& dest)
87{
88 CSHA256 hasher;
89 hasher.Write(dest.data(), dest.size());
90 unsigned char hash[CSHA256::OUTPUT_SIZE];
91 hasher.Finalize(hash);
92
93 CNetAddr addr;
94 const std::string addr_str = EncodeBase32(hash, false) + ".b32.i2p";
95 if (!addr.SetSpecial(addr_str)) {
96 throw std::runtime_error(strprintf("Cannot parse I2P address: \"%s\"", addr_str));
97 }
98
99 return addr;
100}
101
102/**
103 * 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