aboutsummaryrefslogtreecommitdiff
path: root/src/key_io.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2017-11-22 17:04:48 -0800
committerPieter Wuille <pieter.wuille@gmail.com>2018-03-06 20:28:08 -0800
commit3296a3bb7fc0a6c47b60c79e968dbf8175d6b716 (patch)
treeb62ed5ee923c4c61e8023a91674f8a6e7ab70034 /src/key_io.cpp
parentb225010a808d475cbb53aeed484295f8dc8751c4 (diff)
Generalize ConvertBits
Diffstat (limited to 'src/key_io.cpp')
-rw-r--r--src/key_io.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/key_io.cpp b/src/key_io.cpp
index 20df945d8d..0cc4927679 100644
--- a/src/key_io.cpp
+++ b/src/key_io.cpp
@@ -43,14 +43,14 @@ public:
std::string operator()(const WitnessV0KeyHash& id) const
{
std::vector<unsigned char> data = {0};
- ConvertBits<8, 5, true>(data, id.begin(), id.end());
+ ConvertBits<8, 5, true>([&](unsigned char c) { data.push_back(c); }, id.begin(), id.end());
return bech32::Encode(m_params.Bech32HRP(), data);
}
std::string operator()(const WitnessV0ScriptHash& id) const
{
std::vector<unsigned char> data = {0};
- ConvertBits<8, 5, true>(data, id.begin(), id.end());
+ ConvertBits<8, 5, true>([&](unsigned char c) { data.push_back(c); }, id.begin(), id.end());
return bech32::Encode(m_params.Bech32HRP(), data);
}
@@ -60,7 +60,7 @@ public:
return {};
}
std::vector<unsigned char> data = {(unsigned char)id.version};
- ConvertBits<8, 5, true>(data, id.program, id.program + id.length);
+ ConvertBits<8, 5, true>([&](unsigned char c) { data.push_back(c); }, id.program, id.program + id.length);
return bech32::Encode(m_params.Bech32HRP(), data);
}
@@ -94,7 +94,7 @@ CTxDestination DecodeDestination(const std::string& str, const CChainParams& par
// Bech32 decoding
int version = bech.second[0]; // The first 5 bit symbol is the witness version (0-16)
// The rest of the symbols are converted witness program bytes.
- if (ConvertBits<5, 8, false>(data, bech.second.begin() + 1, bech.second.end())) {
+ if (ConvertBits<5, 8, false>([&](unsigned char c) { data.push_back(c); }, bech.second.begin() + 1, bech.second.end())) {
if (version == 0) {
{
WitnessV0KeyHash keyid;