Merge PR 'Document that P2PKH weight assumes compressed public keys' (#5329)
What changed, and why it matters
This change only adds a documentation comment explaining that a helper function for creating old-style P2PKH Bitcoin outputs assumes the public key is compressed (33 bytes). The actual code behavior is unchanged; the patch simply warns callers not to use this helper for uncompressed (65-byte) public keys because the resulting transaction fee estimate would be too low. There is no code fix or behavior change.
No immediate action required. Developers using this API should ensure they only pass compressed public keys when relying on the returned satisfaction_weight for fee estimation. Consider adding a runtime check or separate constructor for uncompressed keys if misuse is a concern.
Security signals we found
Documentation-only change with no code logic modification
Clarifies existing assumption about compressed public keys in P2PKH input weight estimation
No patch to behavior; potential underestimation of transaction weight remains if callers misuse the API
Evidence from the diff
The commit modifies Utxo::new_p2pkh in lightning/src/util/wallet_utils.rs. It adds a doc comment clarifying that satisfaction_weight is computed assuming a compressed public key, and renames an inline comment from pubkey to compressed pubkey. The arithmetic and return value are identical to before. This is a documentation-only change; no logic was altered.
Changed components
lightning/src/util/wallet_utils.rsUtxo::new_p2pkhInspect captured patch +6 / −1
### lightning/src/util/wallet_utils.rs
@@ -88,12 +88,17 @@ impl_ser_tlv_based!(Utxo, {
impl Utxo {
/// Returns a `Utxo` with the `satisfaction_weight` estimate for a legacy P2PKH output.
+ ///
+ /// The estimate assumes the output commits to a compressed (33-byte) public key, as spending
+ /// such an output requires a compressed public key. Outputs committing to an uncompressed
+ /// (65-byte) public key will consume more weight than estimated and must not be constructed
+ /// with this method.
pub fn new_p2pkh(outpoint: OutPoint, value: Amount, pubkey_hash: &PubkeyHash) -> Self {
let script_sig_size = 1 /* script_sig length */ +
1 /* OP_PUSH73 */ +
73 /* sig including sighash flag */ +
1 /* OP_PUSH33 */ +
- 33 /* pubkey */;
+ 33 /* compressed pubkey */;
Self {
outpoint,
output: TxOut { value, script_pubkey: ScriptBuf::new_p2pkh(pubkey_hash) },Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.