Skip to content

Commit af6fae9

Browse files
committed
f: charge routing fee
1 parent 3fe9472 commit af6fae9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6278,6 +6278,16 @@ where
62786278
}
62796279
};
62806280

6281+
let proportional_fee = self.default_configuration.channel_config.forwarding_fee_proportional_millionths as u64 * outgoing_amt_msat / 1_000_000;
6282+
let forwarding_fee = proportional_fee + self.default_configuration.channel_config.forwarding_fee_base_msat as u64;
6283+
let max_total_routing_fee_msat = match incoming_amount.checked_sub(forwarding_fee + outgoing_amt_msat) {
6284+
Some(amount) => amount,
6285+
None => {
6286+
push_trampoline_forwarding_failure(format!("Insufficient fee to forward to the next Trampoline hop {next_node_id}"), htlc_source, None, 0x2000 | 26, Vec::new());
6287+
continue;
6288+
}
6289+
};
6290+
62816291
let usable_channels: Vec<ChannelDetails> = self.list_usable_channels();
62826292
let route = match self.router.find_route(
62836293
&self.node_signer.get_node_id(Recipient::Node).unwrap(),
@@ -6298,7 +6308,7 @@ where
62986308
previously_failed_blinded_path_idxs: vec![],
62996309
},
63006310
final_value_msat: outgoing_amt_msat,
6301-
max_total_routing_fee_msat: Some(incoming_amount - outgoing_amt_msat),
6311+
max_total_routing_fee_msat: Some(max_total_routing_fee_msat),
63026312
},
63036313
Some(&usable_channels.iter().collect::<Vec<_>>()),
63046314
self.compute_inflight_htlcs()

0 commit comments

Comments
 (0)