Document that P2PKH weight assumes compressed public keys
What changed, and why it matters
This commit only adds a documentation comment to a Rust helper function. It clarifies that the function's built-in fee estimate assumes a compressed public key, and should not be used with older uncompressed keys because the transaction fee estimate would be too low. No code behavior changes, so there is no direct exploit. The practical risk is that a developer who ignores the new warning could create a transaction with insufficient fees if they spend an uncompressed-key P2PKH output.
No immediate action required. Treat as a documentation improvement. Developers using `Utxo::new_p2pkh` should confirm they are spending compressed-public-key P2PKH outputs. If uncompressed keys must be supported, a separate fee-estimation path should be added.
Security signals we found
Documentation-only change
Clarifies an existing fee-estimation assumption
No code path or cryptographic change
Potential downstream misuse if documentation is ignored
Evidence from the diff
The change is a rustdoc update in lightning/src/util/wallet_utils.rs for Utxo::new_p2pkh. The function hard-codes a 33-byte public key size when computing satisfaction_weight for legacy P2PKH inputs. Uncompressed public keys are 65 bytes, adding 32 bytes (128 weight units) to the scriptSig. The patch documents that only compressed public keys are supported by this estimator. No logic, constants, or API signatures are modified.
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 18/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.