Skip to content

Commit 0a8fc9e

Browse files
committed
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.
1 parent 560e62b commit 0a8fc9e

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/wallet/spend.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,7 @@ CoinsResult AvailableCoins(const CWallet& wallet,
294294
std::unique_ptr<SigningProvider> provider = wallet.GetSolvingProvider(output.scriptPubKey);
295295

296296
int input_bytes = CalculateMaximumSignedInputSize(output, COutPoint(), provider.get(), coinControl);
297-
// Because CalculateMaximumSignedInputSize just uses ProduceSignature and makes a dummy signature,
298-
// it is safe to assume that this input is solvable if input_bytes is greater -1.
299-
bool solvable = input_bytes > -1;
297+
bool solvable = provider ? InferDescriptor(output.scriptPubKey, *provider)->IsSolvable() : false;
300298
bool spendable = ((mine & ISMINE_SPENDABLE) != ISMINE_NO) || (((mine & ISMINE_WATCH_ONLY) != ISMINE_NO) && (coinControl && coinControl->fAllowWatchOnly && solvable));
301299

302300
// Filter by spendable outputs only

0 commit comments

Comments
 (0)