mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
Merge #14477: Add ability to convert solvability info to descriptor
109699dd33Add release notes (Pieter Wuille)b65326b562Add matching descriptors to scantxoutset output + tests (Pieter Wuille)16203d5df7Add descriptors to listunspent and getaddressinfo + tests (Pieter Wuille)9b2a25b13fAdd tests for InferDescriptor and Descriptor::IsSolvable (Pieter Wuille)225bf3e3b0Add Descriptor::IsSolvable() to distinguish addr/raw from others (Pieter Wuille)4d78bd93b5Add support for inferring descriptors from scripts (Pieter Wuille) Pull request description: This PR adds functionality to convert a script to a descriptor, given a `SigningProvider` with the relevant information about public keys and redeemscripts/witnessscripts. The feature is exposed in `listunspent`, `getaddressinfo`, and `scantxoutset` whenever these calls are applied to solvable outputs/addresses. This is not very useful on its own, though when we add RPCs to import descriptors, or sign PSBTs using descriptors, these strings become a compact and standalone way of conveying everything necessary to sign an output (excluding private keys). Unit tests and rudimentary RPC tests are included (more relevant tests can be added once RPCs support descriptors). Fixes #14503. Tree-SHA512: cb36b84a3e0200375b7e06a98c7e750cfaf95cf5de132cad59f7ec3cbd201f739427de0dc108f515be7aca203652089fbf5f24ed283d4553bddf23a3224ab31f
This commit is contained in:
@@ -102,7 +102,19 @@ void Check(const std::string& prv, const std::string& pub, int flags, const std:
|
||||
spend.vout.resize(1);
|
||||
BOOST_CHECK_MESSAGE(SignSignature(Merge(keys_priv, script_provider), spks[n], spend, 0, 1, SIGHASH_ALL), prv);
|
||||
}
|
||||
|
||||
/* Infer a descriptor from the generated script, and verify its solvability and that it roundtrips. */
|
||||
auto inferred = InferDescriptor(spks[n], script_provider);
|
||||
BOOST_CHECK_EQUAL(inferred->IsSolvable(), !(flags & UNSOLVABLE));
|
||||
std::vector<CScript> spks_inferred;
|
||||
FlatSigningProvider provider_inferred;
|
||||
BOOST_CHECK(inferred->Expand(0, provider_inferred, spks_inferred, provider_inferred));
|
||||
BOOST_CHECK_EQUAL(spks_inferred.size(), 1);
|
||||
BOOST_CHECK(spks_inferred[0] == spks[n]);
|
||||
BOOST_CHECK_EQUAL(IsSolvable(provider_inferred, spks_inferred[0]), !(flags & UNSOLVABLE));
|
||||
BOOST_CHECK(provider_inferred.origins == script_provider.origins);
|
||||
}
|
||||
|
||||
// Test whether the observed key path is present in the 'paths' variable (which contains expected, unobserved paths),
|
||||
// and then remove it from that set.
|
||||
for (const auto& origin : script_provider.origins) {
|
||||
|
||||
Reference in New Issue
Block a user