Skip to content

Commit b39bc9a

Browse files
committed
Adjust HTLC_{SUCCESS,TIMEOUT}_TX_WEIGHT when anchors used.
1 parent 0e3c95c commit b39bc9a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lightning/src/ln/chan_utils.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -600,11 +600,9 @@ pub fn build_htlc_transaction(commitment_txid: &Txid, feerate_per_kw: u32, conte
600600
witness: Vec::new(),
601601
});
602602

603-
let total_fee = if htlc.offered {
604-
feerate_per_kw as u64 * HTLC_TIMEOUT_TX_WEIGHT / 1000
605-
} else {
606-
feerate_per_kw as u64 * HTLC_SUCCESS_TX_WEIGHT / 1000
607-
};
603+
let mut weight = if htlc.offered { HTLC_TIMEOUT_TX_WEIGHT } else { HTLC_SUCCESS_TX_WEIGHT };
604+
if opt_anchors { weight += 3; }
605+
let total_fee = feerate_per_kw as u64 * weight / 1000;
608606

609607
let mut txouts: Vec<TxOut> = Vec::new();
610608
txouts.push(TxOut {

0 commit comments

Comments
 (0)