Skip to content

Commit

Permalink
Fix use the wrong amount to check tlc_minimum_value limit
Browse files Browse the repository at this point in the history
  • Loading branch information
contrun committed Jan 18, 2025
1 parent 5813c8e commit d2b5793
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/fiber/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,9 @@ where
if amount_to_send > channel_info.capacity() {
continue;
}
if amount_to_send < channel_update.tlc_minimum_value {
// We should use next_hop_received_amount because that is the amount to be
// sent over the channel.
if next_hop_received_amount < channel_update.tlc_minimum_value {
continue;
}

Expand Down
21 changes: 21 additions & 0 deletions src/fiber/tests/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3569,6 +3569,27 @@ async fn test_forward_payment_tlc_minimum_value() {
let node_b_pubkey = node_b.pubkey.clone();
let tlc_amount = 99;

// update B's ChannelUpdate in channel_b_c with tlc_minimum_value set to our tlc_amount
// this is used to override the default tlc_minimum_value value.
let update_result = call!(node_b.network_actor, |rpc_reply| {
NetworkActorMessage::Command(NetworkActorCommand::ControlFiberChannel(
ChannelCommandWithId {
channel_id: channel_b_c,
command: ChannelCommand::Update(
UpdateCommand {
enabled: Some(true),
tlc_expiry_delta: None,
tlc_minimum_value: Some(tlc_amount),
tlc_fee_proportional_millionths: None,
},
rpc_reply,
),
},
))
})
.unwrap();
assert!(update_result.is_ok());
// sleep for a while to make sure the Update processed by both party
tokio::time::sleep(tokio::time::Duration::from_millis(1000)).await;

// A -> C now will be with no limit
Expand Down

0 comments on commit d2b5793

Please sign in to comment.