Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs in channel announcement #158

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/fiber/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,21 +596,33 @@ where
let amount_to_send = next_hop_received_amount + fee;

info!(
"fee_rate: {:?} next_hop_received_amount: {:?}, fee: {:?} amount_to_send: {:?} amount+fee: {:?} channel_capacity: {:?}",
fee_rate, next_hop_received_amount, fee, amount_to_send, amount + max_fee_amount, channel_info.capacity()
"fee_rate: {:?} next_hop_received_amount: {:?}, fee: {:?} amount_to_send: {:?} amount+fee: {:?} channel_capacity: {:?} htlc_max_value: {:?}",
fee_rate, next_hop_received_amount, fee, amount_to_send, amount + max_fee_amount, channel_info.capacity(), channel_update.htlc_maximum_value
);

// if the amount to send is greater than the amount we have, skip this edge
if amount_to_send > amount + max_fee_amount {
continue;
}
// check to make sure the current hop can send the amount
// if `htlc_maximum_value` equals 0, it means there is no limit
if amount_to_send > channel_info.capacity()
|| amount_to_send > channel_update.htlc_maximum_value
|| (channel_update.htlc_maximum_value != 0
&& amount_to_send > channel_update.htlc_maximum_value)
{
info!(
"amount_to_send is greater than channel capacity: {:?} capacity: {:?}, htlc_max_value: {:?}",
amount_to_send,
channel_info.capacity(),
channel_update.htlc_maximum_value
);
continue;
}
if amount_to_send < channel_update.htlc_minimum_value {
info!(
"amount_to_send is less than htlc_minimum_value: {:?} min_value: {:?}",
amount_to_send, channel_update.htlc_minimum_value
);
continue;
}
let incomming_cltv = cur_hop.incoming_cltv_height
Expand Down
2 changes: 1 addition & 1 deletion src/fiber/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,7 @@ where
debug!("Channel announcement transaction found: {:?}", &tx);

let pubkey = channel_announcement.ckb_key.serialize();
let pubkey_hash = blake2b_256(pubkey.as_slice());
let pubkey_hash = &blake2b_256(pubkey.as_slice())[0..20];
match tx.inner.outputs.first() {
None => {
return Err(Error::InvalidParameter(format!(
Expand Down
Loading