From 30c6469a54a3e8cb57622ed0963d26acbf7cf3b6 Mon Sep 17 00:00:00 2001 From: LLFourn Date: Wed, 21 Jun 2023 12:35:40 +0800 Subject: [PATCH] Include the SPK length field weight in TXOUT_BASE_weight it's inconsistent to not include it and I confused myself. --- nursery/coin_select/src/lib.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/nursery/coin_select/src/lib.rs b/nursery/coin_select/src/lib.rs index b38b3a985d..30b2db9179 100644 --- a/nursery/coin_select/src/lib.rs +++ b/nursery/coin_select/src/lib.rs @@ -28,13 +28,18 @@ pub mod change_policy; /// length. pub const TXIN_BASE_WEIGHT: u32 = (32 + 4 + 4 + 1) * 4; -/// The weight of a TXOUT without the `scriptPubkey` (and script pubkey length field). -/// Just the weight of the value field. -pub const TXOUT_BASE_WEIGHT: u32 = 4 * core::mem::size_of::() as u32; // just the value - +/// The weight of a TXOUT with a zero length `scriptPubkey` +pub const TXOUT_BASE_WEIGHT: u32 = + // The value + 4 * core::mem::size_of::() as u32 + // The spk length + + (4 * 1); + +/// The additional weight over [`TXIN_BASE_WEIGHT`] incurred by satisfying an input with a keyspend +/// and the default sighash. pub const TR_KEYSPEND_SATISFACTION_WEIGHT: u32 = 66; -/// The weight of a taproot script pubkey +/// The additional weight of an output with segwit `v1` (taproot) script pubkey over a blank output (i.e. with weight [`TXOUT_BASE_WEIGHT`]). pub const TR_SPK_WEIGHT: u32 = (1 + 1 + 32) * 4; // version + push + key /// Helper to calculate varint size. `v` is the value the varint represents.