Changeset View
Changeset View
Standalone View
Standalone View
src/test/descriptor_tests.cpp
Show All 24 Lines | |||||
} | } | ||||
constexpr int DEFAULT = 0; | constexpr int DEFAULT = 0; | ||||
// Expected to be ranged descriptor | // Expected to be ranged descriptor | ||||
constexpr int RANGE = 1; | constexpr int RANGE = 1; | ||||
// 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) { | std::string MaybeUseHInsteadOfApostrophy(std::string ret) { | ||||
if (InsecureRandBool()) { | if (InsecureRandBool()) { | ||||
while (true) { | while (true) { | ||||
auto it = ret.find("'"); | auto it = ret.find("'"); | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < max; ++i) { | ||||
FlatSigningProvider script_provider; | FlatSigningProvider script_provider; | ||||
std::vector<CScript> spks; | std::vector<CScript> spks; | ||||
BOOST_CHECK((t ? parse_priv : parse_pub) | BOOST_CHECK((t ? parse_priv : parse_pub) | ||||
->Expand(i, key_provider, spks, script_provider)); | ->Expand(i, key_provider, spks, script_provider)); | ||||
BOOST_CHECK_EQUAL(spks.size(), ref.size()); | BOOST_CHECK_EQUAL(spks.size(), ref.size()); | ||||
for (size_t n = 0; n < spks.size(); ++n) { | for (size_t n = 0; n < spks.size(); ++n) { | ||||
BOOST_CHECK_EQUAL(ref[n], | BOOST_CHECK_EQUAL(ref[n], | ||||
HexStr(spks[n].begin(), spks[n].end())); | HexStr(spks[n].begin(), spks[n].end())); | ||||
BOOST_CHECK_EQUAL( | |||||
IsSolvable(Merge(key_provider, script_provider), spks[n]), | |||||
(flags & UNSOLVABLE) == 0); | |||||
markblundeberg: Note that both in ABC and Core, no tests actually have UNSOLVABLE set, so currently this is… | |||||
deadalnixUnsubmitted Not Done Inline ActionsYes, this is hy it was removed, I don't think this is possible. Or is it? deadalnix: Yes, this is hy it was removed, I don't think this is possible. Or is it? | |||||
markblundebergAuthorUnsubmitted Done Inline ActionsThe distinction is pretty subtle and almost nothing anywhere actually uses the concept of 'solvable'. There is really only one path:
I guess the same thing applies to p2pkh (only importing address, vs. importing pubkey)? Still, I'm not really sure why this concept exists. Anyway, the solvability concept definitely gets probed more in future, see https://github.com/bitcoin/bitcoin/pull/14565 markblundeberg: The distinction is pretty subtle and almost nothing anywhere actually uses the concept of… | |||||
if (flags & SIGNABLE) { | if (flags & SIGNABLE) { | ||||
CMutableTransaction spend; | CMutableTransaction spend; | ||||
spend.vin.resize(1); | spend.vin.resize(1); | ||||
spend.vout.resize(1); | spend.vout.resize(1); | ||||
BOOST_CHECK_MESSAGE( | BOOST_CHECK_MESSAGE( | ||||
SignSignature(Merge(keys_priv, script_provider), | SignSignature(Merge(keys_priv, script_provider), | ||||
spks[n], spend, 0, 1 * COIN, | spks[n], spend, 0, 1 * COIN, | ||||
▲ Show 20 Lines • Show All 199 Lines • Show Last 20 Lines |
Note that both in ABC and Core, no tests actually have UNSOLVABLE set, so currently this is always equivalent to BOOST_CHECK(IsSolvable(Merge(key_provider, script_provider), spks[n])) ... but this is still an important check to do.