Skip to content
Bitcoin Roots

v30.3-roots.1 · Commit 28: [PATCH 28/68] fix(wallet): secure asynchronous sweep cancellation

src/key_io.cpp

Before: src/key_io.cpp · After: src/key_io.cpp

File metadata
index 3726d22233f6b828232d5eec6f0c8762e0d31616..a8b90bcd05f857a3ab77857c34e3d50bce9f0399 100644

Download original patch · Release notes

Diff rows 1–24 of 24. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.

src/key_io.cpp CHANGED
@@ -210,10 +210,12 @@ CTxDestination DecodeDestination(const std::string& str, const CChainParams& par
210
  }
211
  } // namespace
212
 
213
- CKey DecodeSecret(const std::string& str)
 
 
214
  {
215
  CKey key;
216
- std::vector<unsigned char> data;
217
  if (DecodeBase58Check(str, data, 34)) {
218
  const std::vector<unsigned char>& privkey_prefix = Params().Base58Prefix(CChainParams::SECRET_KEY);
219
  if ((data.size() == 32 + privkey_prefix.size() || (data.size() == 33 + privkey_prefix.size() && data.back() == 1)) &&
@@ -227,6 +229,10 @@ CKey DecodeSecret(const std::string& str)
227
  }
228
  return key;
229
  }
 
 
 
 
230
 
231
  std::string EncodeSecret(const CKey& key)
232
  {
 
210
  }
211
  } // namespace
212
 
213
+ namespace {
214
+ template <typename String, typename Allocator = std::allocator<unsigned char>>
215
+ CKey DecodeSecretImpl(const String& str)
216
  {
217
  CKey key;
218
+ std::vector<unsigned char, Allocator> data;
219
  if (DecodeBase58Check(str, data, 34)) {
220
  const std::vector<unsigned char>& privkey_prefix = Params().Base58Prefix(CChainParams::SECRET_KEY);
221
  if ((data.size() == 32 + privkey_prefix.size() || (data.size() == 33 + privkey_prefix.size() && data.back() == 1)) &&
 
229
  }
230
  return key;
231
  }
232
+ } // namespace
233
+
234
+ CKey DecodeSecret(const std::string& str) { return DecodeSecretImpl(str); }
235
+ CKey DecodeSecret(const SecureString& str) { return DecodeSecretImpl<SecureString, secure_allocator<unsigned char>>(str); }
236
 
237
  std::string EncodeSecret(const CKey& key)
238
  {