Skip to content

Commit 801a288

Browse files
committed
Tools: Add --fee args
1 parent 848b286 commit 801a288

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

tools/ckb-sphincs-tools/src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ fn get_args() -> Command {
4747
.arg(arg!(--lock_arg <LOCK_ARG>))
4848
.arg(arg!(--sp_tx_hash <LOCK_ARG> "SPHINCS+ Lock transaction hash"))
4949
.arg(arg!(--sp_tx_index <LOCK_ARG> "SPHINCS+ Lock transaction index"))
50+
.arg(arg!(--fee <FEE>).num_args(0..=usize::MAX))
5051
.arg_required_else_help(true),
5152
)
5253
}
@@ -97,6 +98,11 @@ fn main() {
9798
let sp_tx_index = sub_matches
9899
.get_one::<String>("sp_tx_index")
99100
.expect("required");
101+
let fee = sub_matches
102+
.get_one::<String>("fee")
103+
.expect("required")
104+
.parse::<u64>()
105+
.unwrap();
100106

101107
sub_conversion::cc_to_def_lock_script(
102108
sub_gen_key::parse_key_file(PathBuf::from(key_file)),
@@ -106,6 +112,7 @@ fn main() {
106112
&str_to_bytes(&lock_arg),
107113
H256::from_trimmed_str(sp_tx_hash).unwrap(),
108114
sp_tx_index.parse::<u32>().unwrap(),
115+
fee.clone(),
109116
);
110117
}
111118
_ => panic!("Unknow subcommand: {:?}", matches.subcommand()),

tools/ckb-sphincs-tools/src/sub_conversion.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ pub fn cc_to_def_lock_script(
301301
lock_arg: &[u8],
302302
sp_tx_hash: H256,
303303
sp_tx_index: u32,
304+
fee: u64,
304305
) {
305306
let mut ckb_client = CkbRpcClient::new(ckb_rpc);
306307

@@ -379,7 +380,8 @@ pub fn cc_to_def_lock_script(
379380
.build();
380381

381382
let capacity = input_cell.capacity.value() / 100000000;
382-
let fee = (capacity / 1024 + 1) * 1000;
383+
384+
println!("Capacity: {}, Need fee: {}", capacity, fee);
383385
let output_capacity = Capacity::shannons((input_cell.capacity.value() - fee) as u64);
384386
tx_builder = tx_builder
385387
.output(

0 commit comments

Comments
 (0)