diff options
author | Antoine Poinsot <darosior@protonmail.com> | 2022-08-12 11:19:25 +0200 |
---|---|---|
committer | Antoine Poinsot <darosior@protonmail.com> | 2023-02-11 14:12:12 +0100 |
commit | 0a8fc9e200b5018c1efd6f9126eb405ca0beeea3 (patch) | |
tree | 8c1957cfa4eec5087bda4c446ba936b41b490e00 | |
parent | 560e62b1e221832ae99ff8684559a7b8f9df84a7 (diff) |
wallet: check solvability using descriptor in AvailableCoins
This is a workaround for Miniscript descriptors containing hash
challenges. For those we can't mock the signature creator without making
OP_EQUAL mockable in the interpreter, so CalculateMaximumInputSize will
always return -1 and outputs for these descriptors would appear
unsolvable while they actually are.
-rw-r--r-- | src/wallet/spend.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 8c0d56a1cb..565c54d962 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -294,9 +294,7 @@ CoinsResult AvailableCoins(const CWallet& wallet, std::unique_ptr<SigningProvider> provider = wallet.GetSolvingProvider(output.scriptPubKey); int input_bytes = CalculateMaximumSignedInputSize(output, COutPoint(), provider.get(), coinControl); - // Because CalculateMaximumSignedInputSize just uses ProduceSignature and makes a dummy signature, - // it is safe to assume that this input is solvable if input_bytes is greater -1. - bool solvable = input_bytes > -1; + bool solvable = provider ? InferDescriptor(output.scriptPubKey, *provider)->IsSolvable() : false; bool spendable = ((mine & ISMINE_SPENDABLE) != ISMINE_NO) || (((mine & ISMINE_WATCH_ONLY) != ISMINE_NO) && (coinControl && coinControl->fAllowWatchOnly && solvable)); // Filter by spendable outputs only |