diff options
author | Antoine Poinsot <darosior@protonmail.com> | 2022-08-19 18:33:54 +0200 |
---|---|---|
committer | Antoine Poinsot <darosior@protonmail.com> | 2023-08-25 12:40:11 +0200 |
commit | fa7c46b503f0b69630f55dc43021d2099e3515ba (patch) | |
tree | ac592c760fe8d2d4f0391f29a6d419d3d8c6f453 /src/wallet | |
parent | bdba7667d2d65f31484760a8e8420c488fc5f801 (diff) |
descriptor: introduce a method to get the satisfaction size
In the wallet code, we are currently estimating the size of a signed
input by doing a dry run of the signing logic. This is unnecessary as
all outputs we are able to sign for can be represented by a descriptor,
and we can derive the size of a satisfaction ("signature") from the
descriptor itself directly.
In addition, this approach does not scale: getting the size of a
satisfaction through a dry run of the signing logic is only possible for
the most basic scripts.
This commit introduces the computation of the size of satisfaction per
descriptor. It's a bit intricate for 2 main reasons:
- We want to conserve the behaviour of the current dry-run logic used by
the wallet that sometimes assumes ECDSA signatures will be low-r,
sometimes not (when we don't create them).
- We need to account for the witness discount. A single descriptor may
sometimes benefit of it, sometimes not (for instance `pk()` if used as
top-level versus if used inside `wsh()`).
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/test/walletload_tests.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/wallet/test/walletload_tests.cpp b/src/wallet/test/walletload_tests.cpp index 1bd2bf012f..1c6f8c5cba 100644 --- a/src/wallet/test/walletload_tests.cpp +++ b/src/wallet/test/walletload_tests.cpp @@ -31,6 +31,8 @@ public: bool Expand(int pos, const SigningProvider& provider, std::vector<CScript>& output_scripts, FlatSigningProvider& out, DescriptorCache* write_cache = nullptr) const override { return false; }; bool ExpandFromCache(int pos, const DescriptorCache& read_cache, std::vector<CScript>& output_scripts, FlatSigningProvider& out) const override { return false; } void ExpandPrivate(int pos, const SigningProvider& provider, FlatSigningProvider& out) const override {} + std::optional<int64_t> ScriptSize() const override { return {}; } + std::optional<int64_t> MaxSatisfactionWeight(bool) const override { return {}; } }; BOOST_FIXTURE_TEST_CASE(wallet_load_descriptors, TestingSetup) |