Skip to content

Commit b765be4

Browse files
committed
Use zero fee HTLC transactions for anchor channels
This is based on the assumption that we only support the zero HTLC transacion fee variant of anchor channels.
1 parent 7691397 commit b765be4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lightning/src/ln/chan_utils.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,12 +616,17 @@ pub fn build_htlc_transaction(commitment_txid: &Txid, feerate_per_kw: u32, conte
616616
} else {
617617
htlc_success_tx_weight(opt_anchors)
618618
};
619-
let total_fee = feerate_per_kw as u64 * weight / 1000;
619+
let output_value = if opt_anchors {
620+
htlc.amount_msat / 1000
621+
} else {
622+
let total_fee = feerate_per_kw as u64 * weight / 1000;
623+
htlc.amount_msat / 1000 - total_fee
624+
};
620625

621626
let mut txouts: Vec<TxOut> = Vec::new();
622627
txouts.push(TxOut {
623628
script_pubkey: get_revokeable_redeemscript(revocation_key, contest_delay, broadcaster_delayed_payment_key).to_v0_p2wsh(),
624-
value: htlc.amount_msat / 1000 - total_fee //TODO: BOLT 3 does not specify if we should add amount_msat before dividing or if we should divide by 1000 before subtracting (as we do here)
629+
value: output_value,
625630
});
626631

627632
Transaction {

0 commit comments

Comments
 (0)