Skip to content

Commit 58c47cf

Browse files
committed
f: charge routing fee
1 parent 8554b8e commit 58c47cf

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
@@ -6293,6 +6293,16 @@ where
62936293
}
62946294
};
62956295

6296+
let proportional_fee = self.default_configuration.channel_config.forwarding_fee_proportional_millionths as u64 * outgoing_amt_msat / 1_000_000;
6297+
let forwarding_fee = proportional_fee + self.default_configuration.channel_config.forwarding_fee_base_msat as u64;
6298+
let max_total_routing_fee_msat = match incoming_amount.checked_sub(forwarding_fee + outgoing_amt_msat) {
6299+
Some(amount) => amount,
6300+
None => {
6301+
push_trampoline_forwarding_failure(format!("Insufficient fee to forward to the next Trampoline hop {next_node_id}"), htlc_source, None, 0x2000 | 26, Vec::new());
6302+
continue;
6303+
}
6304+
};
6305+
62966306
let usable_channels: Vec<ChannelDetails> = self.list_usable_channels();
62976307
let route = match self.router.find_route(
62986308
&self.node_signer.get_node_id(Recipient::Node).unwrap(),
@@ -6313,7 +6323,7 @@ where
63136323
previously_failed_blinded_path_idxs: vec![],
63146324
},
63156325
final_value_msat: outgoing_amt_msat,
6316-
max_total_routing_fee_msat: Some(incoming_amount - outgoing_amt_msat),
6326+
max_total_routing_fee_msat: Some(max_total_routing_fee_msat),
63176327
},
63186328
Some(&usable_channels.iter().collect::<Vec<_>>()),
63196329
self.compute_inflight_htlcs()

0 commit comments

Comments
 (0)