Skip to content

Commit 30c6469

Browse files
LLFournevanlinjin
authored andcommitted
Include the SPK length field weight in TXOUT_BASE_weight
it's inconsistent to not include it and I confused myself.
1 parent 4e51d18 commit 30c6469

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

nursery/coin_select/src/lib.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,18 @@ pub mod change_policy;
2828
/// length.
2929
pub const TXIN_BASE_WEIGHT: u32 = (32 + 4 + 4 + 1) * 4;
3030

31-
/// The weight of a TXOUT without the `scriptPubkey` (and script pubkey length field).
32-
/// Just the weight of the value field.
33-
pub const TXOUT_BASE_WEIGHT: u32 = 4 * core::mem::size_of::<u64>() as u32; // just the value
34-
31+
/// The weight of a TXOUT with a zero length `scriptPubkey`
32+
pub const TXOUT_BASE_WEIGHT: u32 =
33+
// The value
34+
4 * core::mem::size_of::<u64>() as u32
35+
// The spk length
36+
+ (4 * 1);
37+
38+
/// The additional weight over [`TXIN_BASE_WEIGHT`] incurred by satisfying an input with a keyspend
39+
/// and the default sighash.
3540
pub const TR_KEYSPEND_SATISFACTION_WEIGHT: u32 = 66;
3641

37-
/// The weight of a taproot script pubkey
42+
/// The additional weight of an output with segwit `v1` (taproot) script pubkey over a blank output (i.e. with weight [`TXOUT_BASE_WEIGHT`]).
3843
pub const TR_SPK_WEIGHT: u32 = (1 + 1 + 32) * 4; // version + push + key
3944

4045
/// Helper to calculate varint size. `v` is the value the varint represents.

0 commit comments

Comments
 (0)