mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
wallet: use descriptor satisfaction size to estimate inputs size
Instead of using the dummysigner to compute a placeholder satisfaction, infer a descriptor on the scriptPubKey of the coin being spent and use the estimation of the satisfaction size given by the descriptor directly. Note this (almost, see next paragraph) exactly conserves the previous behaviour. For instance CalculateMaximumSignedInputSize was previously assuming the input to be spent in a transaction that spends at least one Segwit coin, since it was always accounting for the serialization of the number of witness elements. In this commit we use a placeholder for the size of the serialization of the witness stack size (1 byte). Since the logic in this commit is already tricky enough to review, and that it is only a very tiny approximation not observable through the existing tests, it is addressed in the next commit.
This commit is contained in:
@@ -152,10 +152,10 @@ void DoCheck(std::string prv, std::string pub, const std::string& norm_pub, int
|
||||
|
||||
// We must be able to estimate the max satisfaction size for any solvable descriptor top descriptor (but combo).
|
||||
const bool is_nontop_or_nonsolvable{!parse_priv->IsSolvable() || !parse_priv->GetOutputType()};
|
||||
for (const bool use_max_sig: {true, false}) {
|
||||
BOOST_CHECK_MESSAGE(parse_priv->MaxSatisfactionWeight(use_max_sig) || is_nontop_or_nonsolvable, prv);
|
||||
BOOST_CHECK_MESSAGE(parse_pub->MaxSatisfactionWeight(use_max_sig) || is_nontop_or_nonsolvable, pub);
|
||||
}
|
||||
const auto max_sat_maxsig{parse_priv->MaxSatisfactionWeight(true)};
|
||||
const auto max_sat_nonmaxsig{parse_priv->MaxSatisfactionWeight(true)};
|
||||
const bool is_input_size_info_set{max_sat_maxsig && max_sat_nonmaxsig};
|
||||
BOOST_CHECK_MESSAGE(is_input_size_info_set || is_nontop_or_nonsolvable, prv);
|
||||
|
||||
// The ScriptSize() must match the size of the Script string. (ScriptSize() is set for all descs but 'combo()'.)
|
||||
const bool is_combo{!parse_priv->IsSingleType()};
|
||||
|
||||
Reference in New Issue
Block a user