MCPcopy Create free account
hub / github.com/citp/BlockSci / encode

Function encode

src/scripts/bitcoin_bech32.cpp:105–114  ·  view source on GitHub ↗

Encode a Bech32 string. */

Source from the content-addressed store, hash-verified

103
104/** Encode a Bech32 string. */
105std::string encode(const std::string& hrp, const bech32_data& values) {
106 bech32_data checksum = create_checksum(hrp, values);
107 bech32_data combined = cat(values, checksum);
108 std::string ret = hrp + '1';
109 ret.reserve(ret.size() + combined.size());
110 for (size_t i = 0; i < combined.size(); ++i) {
111 ret += charset[combined[i]];
112 }
113 return ret;
114}
115
116/** Decode a Bech32 string. */
117std::pair<std::string, bech32_data> decode(const std::string& str) {

Callers 2

addressStringMethod · 0.70
addressStringMethod · 0.70

Calls 3

create_checksumFunction · 0.85
catFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected