Skip to content
Bitcoin Roots

v29.4-roots.3 · Commit 28: [PATCH 28/30] fix(wallet): secure asynchronous sweep cancellation

src/key_io.cpp

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

File metadata
index 6cece47e410397e318d54643d0e459a44f756691..c5bf1a6d943e9700e43a6cf3032d54dcd4e0a7b3 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. The two line-number columns refer to before and after.

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