From: Daniela Brozzoni Date: Tue, 16 Aug 2022 16:37:03 +0000 (+0100) Subject: Fix P2WPKH_SATISFACTION_SIZE in CS tests X-Git-Tag: 0.22.0-rc.1~11^2 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/-sqlite-db-configuration/scripts/struct.CommandStringError.html?a=commitdiff_plain;h=cd078903a7108f86fdd9557b206f25c9611d07d3;p=bdk Fix P2WPKH_SATISFACTION_SIZE in CS tests Our costant for the P2WPKH satisfaction size was wrong: in 7ac87b8f99fc0897753ce57d48ea24adf495a633 we added 1 WU for the script sig len - but actually, that's 4WU! This resulted in P2WPKH_SATISFACTION_SIZE being equal to 109 instead of 112. This also adds a comment for better readability. --- diff --git a/src/wallet/coin_selection.rs b/src/wallet/coin_selection.rs index 21921bc6..0929bd1d 100644 --- a/src/wallet/coin_selection.rs +++ b/src/wallet/coin_selection.rs @@ -734,7 +734,9 @@ mod test { use rand::seq::SliceRandom; use rand::{Rng, SeedableRng}; - const P2WPKH_SATISFACTION_SIZE: usize = 73 + 33 + 2 + 1; + // n. of items on witness (1WU) + signature len (1WU) + signature and sighash (72WU) + // + pubkey len (1WU) + pubkey (33WU) + script sig len (1 byte, 4WU) + const P2WPKH_SATISFACTION_SIZE: usize = 1 + 1 + 72 + 1 + 33 + 4; const FEE_AMOUNT: u64 = 50;