Changeset View
Changeset View
Standalone View
Standalone View
src/test/descriptor_tests.cpp
Show All 29 Lines | |||||
// Derivation needs access to private keys | // Derivation needs access to private keys | ||||
constexpr int HARDENED = 2; | constexpr int HARDENED = 2; | ||||
// This descriptor is not expected to be solvable | // This descriptor is not expected to be solvable | ||||
constexpr int UNSOLVABLE = 4; | constexpr int UNSOLVABLE = 4; | ||||
// We can sign with this descriptor (this is not true when actual BIP32 | // We can sign with this descriptor (this is not true when actual BIP32 | ||||
// derivation is used, as that's not integrated in our signing code) | // derivation is used, as that's not integrated in our signing code) | ||||
constexpr int SIGNABLE = 8; | constexpr int SIGNABLE = 8; | ||||
std::string MaybeUseHInsteadOfApostrophy(std::string ret) { | |||||
if (InsecureRandBool()) { | |||||
while (true) { | |||||
auto it = ret.find("'"); | |||||
if (it != std::string::npos) { | |||||
ret[it] = 'h'; | |||||
} else { | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
return ret; | |||||
} | |||||
void Check(const std::string &prv, const std::string &pub, int flags, | void Check(const std::string &prv, const std::string &pub, int flags, | ||||
const std::vector<std::vector<std::string>> &scripts) { | const std::vector<std::vector<std::string>> &scripts) { | ||||
FlatSigningProvider keys_priv, keys_pub; | FlatSigningProvider keys_priv, keys_pub; | ||||
// Check that parsing succeeds. | // Check that parsing succeeds. | ||||
auto parse_priv = Parse(prv, keys_priv); | auto parse_priv = Parse(MaybeUseHInsteadOfApostrophy(prv), keys_priv); | ||||
auto parse_pub = Parse(pub, keys_pub); | auto parse_pub = Parse(MaybeUseHInsteadOfApostrophy(pub), keys_pub); | ||||
BOOST_CHECK(parse_priv); | BOOST_CHECK(parse_priv); | ||||
BOOST_CHECK(parse_pub); | BOOST_CHECK(parse_pub); | ||||
// Check private keys are extracted from the private version but not the | // Check private keys are extracted from the private version but not the | ||||
// public one. | // public one. | ||||
BOOST_CHECK(keys_priv.keys.size()); | BOOST_CHECK(keys_priv.keys.size()); | ||||
BOOST_CHECK(!keys_pub.keys.size()); | BOOST_CHECK(!keys_pub.keys.size()); | ||||
▲ Show 20 Lines • Show All 246 Lines • Show Last 20 Lines |