mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-06 14:19:59 -05:00
wallet: Use CalculateMaximumSignedInputSize to indicate solvability
In AvailableCoins, we need to know whether we can solve for an output. This was done by using IsSolvable, which just calls ProduceSignature and produces a dummy signature. However, we already do that in order to get the size of the input by using CalculateMaximumSignedInputSize. As this function returns -1 if ProduceSignature fails, we can just remove the use of IsSolvable and check that input_bytes is not -1 to determine the solvability of an output.
This commit is contained in:
parent
5871b5b5ab
commit
8a105ecd1a
1 changed files with 4 additions and 2 deletions
|
@ -213,7 +213,10 @@ CoinsResult AvailableCoins(const CWallet& wallet,
|
||||||
|
|
||||||
std::unique_ptr<SigningProvider> provider = wallet.GetSolvingProvider(output.scriptPubKey);
|
std::unique_ptr<SigningProvider> provider = wallet.GetSolvingProvider(output.scriptPubKey);
|
||||||
|
|
||||||
bool solvable = provider ? IsSolvable(*provider, output.scriptPubKey) : false;
|
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 spendable = ((mine & ISMINE_SPENDABLE) != ISMINE_NO) || (((mine & ISMINE_WATCH_ONLY) != ISMINE_NO) && (coinControl && coinControl->fAllowWatchOnly && solvable));
|
bool spendable = ((mine & ISMINE_SPENDABLE) != ISMINE_NO) || (((mine & ISMINE_WATCH_ONLY) != ISMINE_NO) && (coinControl && coinControl->fAllowWatchOnly && solvable));
|
||||||
|
|
||||||
// Filter by spendable outputs only
|
// Filter by spendable outputs only
|
||||||
|
@ -243,7 +246,6 @@ CoinsResult AvailableCoins(const CWallet& wallet,
|
||||||
type = Solver(output.scriptPubKey, return_values_unused);
|
type = Solver(output.scriptPubKey, return_values_unused);
|
||||||
}
|
}
|
||||||
|
|
||||||
int input_bytes = CalculateMaximumSignedInputSize(output, COutPoint(), provider.get(), coinControl);
|
|
||||||
COutput coin(outpoint, output, nDepth, input_bytes, spendable, solvable, safeTx, wtx.GetTxTime(), tx_from_me, feerate);
|
COutput coin(outpoint, output, nDepth, input_bytes, spendable, solvable, safeTx, wtx.GetTxTime(), tx_from_me, feerate);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TxoutType::WITNESS_UNKNOWN:
|
case TxoutType::WITNESS_UNKNOWN:
|
||||||
|
|
Loading…
Add table
Reference in a new issue