From 60fdcb527743efacf1ef9ac5b9543fcbd597b1ce Mon Sep 17 00:00:00 2001 From: Linfeng Qian Date: Fri, 18 Nov 2022 17:20:32 +0800 Subject: [PATCH 1/2] fix: transaction fee round --- src/tx_builder/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tx_builder/mod.rs b/src/tx_builder/mod.rs index 41fcf1fe..ae26f0f8 100644 --- a/src/tx_builder/mod.rs +++ b/src/tx_builder/mod.rs @@ -455,10 +455,12 @@ pub fn balance_tx_capacity( // * second 4 bytes if for output data offset // * third 4 bytes is for output offset let output_header_extra = 4 + 4 + 4; + // NOTE: extra_min_fee +1 is for `FeeRate::fee` round let extra_min_fee = balancer .fee_rate .fee(base_change_output.as_slice().len() + output_header_extra) - .as_u64(); + .as_u64() + + 1; // The extra capacity (delta - extra_min_fee) is enough to hold the change cell. if delta >= base_change_occupied_capacity + extra_min_fee { // next loop round must return new_tx; @@ -506,7 +508,9 @@ pub fn balance_tx_capacity( } } // fee is positive and `fee < min_fee` - Ok(_fee) => {} + Ok(fee) => { + need_more_capacity = min_fee - fee; + } Err(TransactionFeeError::CapacityOverflow(delta)) => { need_more_capacity = delta + min_fee; } From 85627042146f248ab53c28841f204aba43bceace Mon Sep 17 00:00:00 2001 From: Linfeng Qian Date: Sun, 20 Nov 2022 10:35:57 +0800 Subject: [PATCH 2/2] chore: bump up to v2.3.1 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 05c6f4c8..fb3447eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-sdk" -version = "2.3.0" +version = "2.3.1" authors = ["Linfeng Qian ", "Nervos Core Dev "] edition = "2018" license = "MIT"