diff options
author | Antoine Poinsot <darosior@protonmail.com> | 2022-04-11 14:07:25 +0200 |
---|---|---|
committer | Antoine Poinsot <darosior@protonmail.com> | 2022-04-28 16:44:40 +0200 |
commit | ed45ee3882e69266d550b56ff69388e071f0ad1b (patch) | |
tree | 93f46dab00683b0b15f0ac9048a16934c2c5bdf0 /src/test/miniscript_tests.cpp | |
parent | 1ab8d89fd1bdb3c0f2a506b4a10df6c23ba21c48 (diff) | |
download | bitcoin-ed45ee3882e69266d550b56ff69388e071f0ad1b.tar.xz |
miniscript: use optional instead of bool/outarg
Co-authored-by: Pieter Wuille <pieter.wuille@gmail.com>
Diffstat (limited to 'src/test/miniscript_tests.cpp')
-rw-r--r-- | src/test/miniscript_tests.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/test/miniscript_tests.cpp b/src/test/miniscript_tests.cpp index 930582ea24..212525537a 100644 --- a/src/test/miniscript_tests.cpp +++ b/src/test/miniscript_tests.cpp @@ -84,27 +84,28 @@ struct KeyConverter { //! Parse a public key from a range of hex characters. template<typename I> - bool FromString(I first, I last, CPubKey& key) const { + std::optional<Key> FromString(I first, I last) const { auto bytes = ParseHex(std::string(first, last)); - key.Set(bytes.begin(), bytes.end()); - return key.IsValid(); + Key key{bytes.begin(), bytes.end()}; + if (key.IsValid()) return key; + return {}; } template<typename I> - bool FromPKBytes(I first, I last, CPubKey& key) const { - key.Set(first, last); - return key.IsValid(); + std::optional<Key> FromPKBytes(I first, I last) const { + Key key{first, last}; + if (key.IsValid()) return key; + return {}; } template<typename I> - bool FromPKHBytes(I first, I last, CPubKey& key) const { + std::optional<Key> FromPKHBytes(I first, I last) const { assert(last - first == 20); CKeyID keyid; std::copy(first, last, keyid.begin()); auto it = g_testdata->pkmap.find(keyid); assert(it != g_testdata->pkmap.end()); - key = it->second; - return true; + return it->second; } }; |