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 UDT auto accept funding amount issue #171

Merged
merged 2 commits into from
Sep 19, 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
5 changes: 4 additions & 1 deletion src/fiber/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2503,7 +2503,10 @@ impl ChannelActorState {
};

let channel_outpoint = self.get_funding_transaction_outpoint();
let capacity = self.to_local_amount + self.to_remote_amount;
let capacity = self.to_local_amount
+ self.to_remote_amount
+ self.local_reserved_ckb_amount as u128
+ self.remote_reserved_ckb_amount as u128;

let (node_1_id, node_2_id) = if self.local_is_node_1() {
(self.local_pubkey, self.remote_pubkey)
Expand Down
11 changes: 7 additions & 4 deletions src/fiber/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ where
{
Ok(()) => {
let auto_accept = if let Some(udt_type_script) =
open_channel.funding_udt_type_script
open_channel.funding_udt_type_script.as_ref()
{
is_udt_type_auto_accept(&udt_type_script, open_channel.funding_amount)
} else {
Expand All @@ -521,8 +521,11 @@ where
if auto_accept {
let accept_channel = AcceptChannelCommand {
temp_channel_id,
funding_amount: state.auto_accept_channel_ckb_funding_amount
as u128,
funding_amount: if open_channel.funding_udt_type_script.is_some() {
0
} else {
state.auto_accept_channel_ckb_funding_amount as u128
},
};
state.create_inbound_channel(accept_channel).await?;
}
Expand Down Expand Up @@ -1673,7 +1676,7 @@ where
)));
}
let capacity: u128 = u64::from(output.capacity).into();
if channel_announcement.udt_type_script.is_some()
if channel_announcement.udt_type_script.is_none()
&& capacity != channel_announcement.capacity
{
return Err(Error::InvalidParameter(format!(
Expand Down
Loading