diff --git a/src/ckb/channel.rs b/src/ckb/channel.rs index 923b0f73..1caf52fc 100644 --- a/src/ckb/channel.rs +++ b/src/ckb/channel.rs @@ -2,7 +2,7 @@ use bitflags::bitflags; use ckb_hash::{blake2b_256, new_blake2b}; use ckb_sdk::Since; use ckb_types::{ - core::{TransactionBuilder, TransactionView}, + core::{FeeRate, TransactionBuilder, TransactionView}, packed::{Bytes, CellInput, CellOutput, OutPoint, Script, Transaction}, prelude::{AsTransactionBuilder, IntoTransactionView, Pack, Unpack}, }; @@ -28,15 +28,19 @@ use tokio::sync::oneshot; use std::{borrow::Borrow, collections::BTreeMap}; use crate::{ - ckb::types::Shutdown, + ckb::{ + config::{DEFAULT_UDT_MINIMAL_CKB_AMOUNT, MIN_OCCUPIED_CAPACITY}, + types::Shutdown, + }, ckb_chain::{ contracts::{get_cell_deps, get_script_by_contract, Contract}, - FundingRequest, FundingUdtInfo, + FundingRequest, }, NetworkServiceEvent, }; use super::{ + config::{DEFAULT_CHANNEL_MINIMAL_CKB_AMOUNT, MIN_UDT_OCCUPIED_CAPACITY}, key::blake2b_hash_with_salt, network::CFNMessageWithPeerId, serde_utils::EntityHex, @@ -90,7 +94,7 @@ pub enum ChannelCommand { #[derive(Debug)] pub enum TxCollaborationCommand { TxUpdate(TxUpdateCommand), - TxComplete(TxCompleteCommand), + TxComplete(), } #[derive(Debug)] @@ -110,7 +114,7 @@ pub struct RemoveTlcCommand { #[derive(Debug)] pub struct ShutdownCommand { pub close_script: Script, - pub fee: u128, + pub fee_rate: FeeRate, } fn get_random_preimage() -> Hash256 { @@ -125,37 +129,45 @@ pub struct ChannelCommandWithId { pub command: ChannelCommand, } -pub const DEFAULT_FEE_RATE: u64 = 0; -pub const DEFAULT_COMMITMENT_FEE_RATE: u64 = 0; +pub const DEFAULT_FEE_RATE: u64 = 1_000; +pub const DEFAULT_COMMITMENT_FEE_RATE: u64 = 1_000; pub const DEFAULT_MAX_TLC_VALUE_IN_FLIGHT: u128 = u128::MAX; pub const DEFAULT_MAX_ACCEPT_TLCS: u64 = u64::MAX; pub const DEFAULT_MIN_TLC_VALUE: u128 = 0; pub const DEFAULT_TO_LOCAL_DELAY_BLOCKS: u64 = 10; -pub const DEFAULT_UDT_MINIMAL_CKB_AMOUNT: u64 = 200 * 100_000_000; // 200 CKB #[derive(Debug)] pub struct TxUpdateCommand { pub transaction: Transaction, } -#[derive(Debug)] -pub struct TxCompleteCommand {} +pub struct OpenChannelParameter { + pub funding_amount: u128, + pub seed: [u8; 32], + pub funding_udt_type_script: Option