diff options
author | Antoine Poinsot <darosior@protonmail.com> | 2022-08-19 18:35:00 +0200 |
---|---|---|
committer | Antoine Poinsot <darosior@protonmail.com> | 2023-08-25 12:40:12 +0200 |
commit | 9b7ec393b82ca9d7ada77d06e0835df0386a8b85 (patch) | |
tree | 0dff0706ac09071268796037f366d29c437517d1 /src/test | |
parent | 8d870a98731e8db5ecc614bb5f7c064cbf30c7f4 (diff) |
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.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/descriptor_tests.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/test/descriptor_tests.cpp b/src/test/descriptor_tests.cpp index 62e436f34b..c2c3988f0d 100644 --- a/src/test/descriptor_tests.cpp +++ b/src/test/descriptor_tests.cpp @@ -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()}; |