diff --git a/src/fiber/channel.rs b/src/fiber/channel.rs index 6df4b61bb..8b52cfe90 100644 --- a/src/fiber/channel.rs +++ b/src/fiber/channel.rs @@ -67,7 +67,7 @@ use tentacle::secio::PeerId; use thiserror::Error; use tokio::sync::oneshot; -use super::types::ForwardTlcResult; +use super::{graph::ChannelUpdateInfo, types::ForwardTlcResult}; use std::{ collections::HashSet, fmt::{self, Debug}, @@ -76,6 +76,8 @@ use std::{ u128, }; +use super::types::{ChannelUpdateChannelFlags, ChannelUpdateMessageFlags, UpdateTlcInfo}; + // - `empty_witness_args`: 16 bytes, fixed to 0x10000000100000001000000010000000, for compatibility with the xudt // - `pubkey`: 32 bytes, x only aggregated public key // - `signature`: 64 bytes, aggregated signature @@ -93,17 +95,6 @@ pub const COMMITMENT_CELL_WITNESS_LEN: usize = 16 + 1 + 32 + 64; // is funded or not. pub const INITIAL_COMMITMENT_NUMBER: u64 = 0; -// Whether we are receiving a channel update from node1 or node2. -// If the flag is set, it means the channel update is from node1, otherwise it is from node2. -pub const MESSAGE_OF_NODE1_FLAG: u32 = 0; - -// Whether we are receiving a channel update from node1 or node2. -// If the flag is set, it means the channel update is from node2, otherwise it is from node1. -pub const MESSAGE_OF_NODE2_FLAG: u32 = 1; - -// The channel is disabled, and no more tlcs can be added to the channel. -pub const CHANNEL_DISABLED_FLAG: u32 = 1; - const RETRYABLE_TLC_OPS_INTERVAL: Duration = Duration::from_millis(1000); #[derive(Debug)] @@ -150,7 +141,22 @@ pub enum ChannelCommand { Update(UpdateCommand, RpcReplyPort>), ForwardTlcResult(ForwardTlcResult), #[cfg(test)] - ReloadState(), + ReloadState(ReloadParams), +} + +#[cfg(test)] +#[derive(Debug)] +pub struct ReloadParams { + pub notify_changes: bool, +} + +#[cfg(test)] +impl Default for ReloadParams { + fn default() -> Self { + Self { + notify_changes: true, + } + } } #[derive(Debug)] @@ -223,6 +229,7 @@ pub struct TxUpdateCommand { pub struct OpenChannelParameter { pub funding_amount: u128, pub seed: [u8; 32], + pub tlc_info: ChannelTlcInfo, pub public_channel_info: Option, pub funding_udt_type_script: Option