From ecb64e62385ab6c099b8b480eec688f81d6cd6fc Mon Sep 17 00:00:00 2001 From: keroro520 Date: Fri, 8 Nov 2019 17:02:41 +0800 Subject: [PATCH 1/8] feat: Convert singlesig addr to multisig-1of1 addr --- ckb-sdk/src/basic.rs | 2 + ckb-sdk/src/lib.rs | 2 + ckb-sdk/src/multisig_addr.rs | 84 ++++++++++++++++++++++++++++++++++++ src/subcommands/util.rs | 79 ++++++++++++++++++++++++++++++++- 4 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 ckb-sdk/src/multisig_addr.rs diff --git a/ckb-sdk/src/basic.rs b/ckb-sdk/src/basic.rs index 082c7629..dc647507 100644 --- a/ckb-sdk/src/basic.rs +++ b/ckb-sdk/src/basic.rs @@ -78,6 +78,8 @@ impl fmt::Display for NetworkType { #[repr(u8)] pub enum AddressType { Default = 0x01, + FullPayloadWithDataHash = 0x02, + FullPayloadWithTypeHash = 0x04, } #[derive(Hash, Eq, PartialEq, Debug, Clone, Copy, Serialize, Deserialize)] diff --git a/ckb-sdk/src/lib.rs b/ckb-sdk/src/lib.rs index 3bcd22b7..ebf3b501 100644 --- a/ckb-sdk/src/lib.rs +++ b/ckb-sdk/src/lib.rs @@ -1,6 +1,7 @@ mod basic; mod chain; mod error; +mod multisig_addr; mod rpc; mod transaction; @@ -12,6 +13,7 @@ pub use chain::{ TransferTransactionBuilder, MIN_SECP_CELL_CAPACITY, ONE_CKB, }; pub use error::Error; +pub use multisig_addr::MultisigAddress; pub use rpc::HttpRpcClient; pub use transaction::{ MockCellDep, MockInfo, MockInput, MockResourceLoader, MockTransaction, MockTransactionHelper, diff --git a/ckb-sdk/src/multisig_addr.rs b/ckb-sdk/src/multisig_addr.rs new file mode 100644 index 00000000..845d2a48 --- /dev/null +++ b/ckb-sdk/src/multisig_addr.rs @@ -0,0 +1,84 @@ +use crate::basic::AddressType; +use crate::NetworkType; +use bech32::{convert_bits, Bech32, ToBase32}; +use ckb_hash::blake2b_256; +use ckb_types::{H160, H256}; +use serde_derive::{Deserialize, Serialize}; +use std::str::FromStr; + +// NOTE: The present implementation only provide 1of1 multisig address +// in full payload format, with ty == FullPayloadWithTypeHash. + +const ADDRESS_TYPE: AddressType = AddressType::FullPayloadWithTypeHash; + +#[derive(Hash, Eq, PartialEq, Debug, Clone, Serialize, Deserialize)] +pub struct MultisigAddress { + code_hash: H256, + hash: H160, + since: u64, +} + +impl MultisigAddress { + pub fn new(code_hash: H256, pubkey_hash: H160, since: u64) -> Result { + let mut multi_script = vec![1u8, 1, 1, 1]; // [S, R, M, N] + multi_script.extend_from_slice(pubkey_hash.0.as_ref()); + let hash = + H160::from_slice(&blake2b_256(multi_script)[..20]).map_err(|err| err.to_string())?; + + Ok(Self { + code_hash, + hash, + since, + }) + } + + pub fn from_input(input: &str) -> Result<(NetworkType, Self), String> { + let value = Bech32::from_str(input).map_err(|err| err.to_string())?; + let network_type = NetworkType::from_prefix(value.hrp()) + .ok_or_else(|| format!("Invalid hrp: {}", value.hrp()))?; + let data = convert_bits(value.data(), 5, 8, false).unwrap(); + if data.len() != 61 { + return Err(format!( + "Invalid input data length, expected: {}, actual: {}", + 61, + data.len() + )); + } + if data[0] != ADDRESS_TYPE as u8 { + return Err(format!( + "Invalid address type, expected: {}, actual: {}", + ADDRESS_TYPE as u8, data[0] + )); + } + + let code_hash = H256::from_slice(&data[1..33]).map_err(|err| err.to_string())?; + let hash = H160::from_slice(&data[33..53]).map_err(|err| err.to_string())?; + let since = { + let mut bytes = [0u8; 8]; + bytes.copy_from_slice(&data[53..61]); + u64::from_le_bytes(bytes) + }; + Ok(( + network_type, + Self { + code_hash, + hash, + since, + }, + )) + } + + pub fn display(&self, network_type: NetworkType) -> String { + let hrp = network_type.to_prefix(); + let mut data = [0u8; 61]; + + data[0] = ADDRESS_TYPE as u8; + data[1..33].copy_from_slice(self.code_hash.0.as_ref()); + data[33..53].copy_from_slice(self.hash.0.as_ref()); + data[53..61].copy_from_slice(self.since.to_le_bytes().as_ref()); + + let value = Bech32::new(hrp.to_string(), data.to_vec().to_base32()) + .unwrap_or_else(|_| panic!("Encode MultisigAddress failed: {:?}", self,)); + format!("{}", value) + } +} diff --git a/src/subcommands/util.rs b/src/subcommands/util.rs index 87624cd3..f164a2c4 100644 --- a/src/subcommands/util.rs +++ b/src/subcommands/util.rs @@ -1,9 +1,10 @@ +use chrono::{NaiveDate, NaiveDateTime}; use ckb_crypto::secp::SECP256K1; use ckb_hash::blake2b_256; use ckb_jsonrpc_types::{Script as RpcScript, Transaction as RpcTransaction}; -use ckb_sdk::{Address, GenesisInfo, HttpRpcClient, NetworkType, OldAddress}; +use ckb_sdk::{Address, GenesisInfo, HttpRpcClient, MultisigAddress, NetworkType, OldAddress}; use ckb_types::{ - packed, + h256, packed, prelude::*, utilities::{compact_to_difficulty, difficulty_to_compact}, H160, H256, U256, @@ -22,6 +23,7 @@ use crate::utils::{ other::{get_address, get_genesis_info}, printer::{OutputFormat, Printable}, }; +use ckb_types::core::{EpochNumber, EpochNumberWithFraction}; pub struct UtilSubCommand<'a> { rpc_client: &'a mut HttpRpcClient, @@ -141,6 +143,22 @@ impl<'a> UtilSubCommand<'a> { .required(true) .help("The difficulty value") ), + SubCommand::with_name("single-to-multisig-addr") + .about("Convert address in single signature format to multisig format") + .arg( + Arg::with_name("address") + .long("address") + .required(true) + .takes_value(true) + .help("The address in single signature format") + ) + .arg( + Arg::with_name("locktime") + .long("locktime") + .required(true) + .takes_value(true) + .help("The locktime in UTC format") + ) ]) } } @@ -279,7 +297,64 @@ message = "0x" }); Ok(resp.render(format, color)) } + ("single-to-multisig-addr", Some(m)) => { + const FINAL_TESTNET_EPOCH_NUMBER: EpochNumber = 89; + const FINAL_TESTNET_END_TIMESTAMP: u64 = 1_573_862_400; // 2019-11-16T00:00:00+0000 + const FLAG_SINCE_EPOCH_NUMBER: u64 = + 0b010_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000; + + let locktime = m.value_of("locktime").unwrap(); + let address: Address = AddressParser.from_matches_opt(m, "address", true)?.unwrap(); + + #[allow(non_snake_case)] + let S: u64 = FINAL_TESTNET_END_TIMESTAMP; + #[allow(non_snake_case)] + let E: u64 = FINAL_TESTNET_EPOCH_NUMBER; + #[allow(non_snake_case)] + let T: u64 = to_timestamp(locktime)?; + #[allow(non_snake_case)] + let since = if T > S && ((T - S) / (4 * 60 * 60)) + 89 >= E { + let P = T - S; + let epoch_number: u64 = (P / (4 * 60 * 60)) + 89 - E; + let epoch_length: u64 = 1800; + let epoch_index: u64 = (P % (4 * 60 * 60)) * epoch_length / (4 * 60 * 60); + let epoch_fraction = + EpochNumberWithFraction::new(epoch_number, epoch_index, epoch_length); + FLAG_SINCE_EPOCH_NUMBER | epoch_fraction.full_value() + } else { + let epoch_fraction = EpochNumberWithFraction::new(0, 0, 1); + FLAG_SINCE_EPOCH_NUMBER | epoch_fraction.full_value() + }; + + // TODO: is it ok hard-code here? + let code_hash = + h256!("0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8"); + let maddr = MultisigAddress::new(code_hash, address.hash().clone(), since)?; + assert_eq!( + MultisigAddress::from_input(&maddr.display(NetworkType::MainNet)) + .unwrap() + .1, + maddr + ); + let resp = format!( + "{},{},{}", + address.to_string(NetworkType::MainNet), + locktime, + maddr.display(NetworkType::MainNet), + ); + Ok(serde_json::json!(resp).render(format, color)) + } _ => Err(matches.usage().to_owned()), } } } + +fn to_timestamp(input: &str) -> Result { + let date = NaiveDate::parse_from_str(input, "%Y-%m-%d").map_err(|err| format!("{:?}", err))?; + let date = NaiveDateTime::parse_from_str( + &format!("{} 00:00:00", date.to_string()), + "%Y-%m-%d %H:%M:%S", + ) + .map_err(|err| format!("{:?}", err))?; + Ok(date.timestamp() as u64) +} From 01a51faf42bcb20e0a5f1408e069b38a2f808a6d Mon Sep 17 00:00:00 2001 From: keroro520 Date: Sun, 10 Nov 2019 18:21:54 +0800 Subject: [PATCH 2/8] chore: Correct multi-script S/R --- ckb-sdk/src/multisig_addr.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ckb-sdk/src/multisig_addr.rs b/ckb-sdk/src/multisig_addr.rs index 845d2a48..abf8a941 100644 --- a/ckb-sdk/src/multisig_addr.rs +++ b/ckb-sdk/src/multisig_addr.rs @@ -2,7 +2,9 @@ use crate::basic::AddressType; use crate::NetworkType; use bech32::{convert_bits, Bech32, ToBase32}; use ckb_hash::blake2b_256; -use ckb_types::{H160, H256}; +use ckb_types::bytes::Bytes; +use ckb_types::prelude::Pack; +use ckb_types::{packed, H160, H256}; use serde_derive::{Deserialize, Serialize}; use std::str::FromStr; @@ -20,7 +22,7 @@ pub struct MultisigAddress { impl MultisigAddress { pub fn new(code_hash: H256, pubkey_hash: H160, since: u64) -> Result { - let mut multi_script = vec![1u8, 1, 1, 1]; // [S, R, M, N] + let mut multi_script = vec![0u8, 0, 1, 1]; // [S, R, M, N] multi_script.extend_from_slice(pubkey_hash.0.as_ref()); let hash = H160::from_slice(&blake2b_256(multi_script)[..20]).map_err(|err| err.to_string())?; @@ -32,6 +34,12 @@ impl MultisigAddress { }) } + pub fn lock_arg(&self) -> packed::Bytes { + let mut buf = self.hash.0.to_vec(); + buf.extend(self.since.to_le_bytes().iter()); + Bytes::from(buf).pack() + } + pub fn from_input(input: &str) -> Result<(NetworkType, Self), String> { let value = Bech32::from_str(input).map_err(|err| err.to_string())?; let network_type = NetworkType::from_prefix(value.hrp()) From 9e104db05a1fc36726929c4d4bd5149b44f6a0b2 Mon Sep 17 00:00:00 2001 From: keroro520 Date: Sun, 10 Nov 2019 18:23:23 +0800 Subject: [PATCH 3/8] feat: Remove hard-coding parameters 1. Print details if debug enabled(exec ckb-cli with `--debug` flag) 2. Aquire genesis_timestamp from genesis_block via RPC 3. Estimate target epoch number --- src/subcommands/util.rs | 57 ++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/src/subcommands/util.rs b/src/subcommands/util.rs index f164a2c4..4667befe 100644 --- a/src/subcommands/util.rs +++ b/src/subcommands/util.rs @@ -23,7 +23,7 @@ use crate::utils::{ other::{get_address, get_genesis_info}, printer::{OutputFormat, Printable}, }; -use ckb_types::core::{EpochNumber, EpochNumberWithFraction}; +use ckb_types::core::EpochNumberWithFraction; pub struct UtilSubCommand<'a> { rpc_client: &'a mut HttpRpcClient, @@ -143,7 +143,7 @@ impl<'a> UtilSubCommand<'a> { .required(true) .help("The difficulty value") ), - SubCommand::with_name("single-to-multisig-addr") + SubCommand::with_name("to-multisig-addr") .about("Convert address in single signature format to multisig format") .arg( Arg::with_name("address") @@ -169,7 +169,7 @@ impl<'a> CliSubCommand for UtilSubCommand<'a> { matches: &ArgMatches, format: OutputFormat, color: bool, - _debug: bool, + debug: bool, ) -> Result { match matches.subcommand() { ("key-info", Some(m)) => { @@ -297,39 +297,31 @@ message = "0x" }); Ok(resp.render(format, color)) } - ("single-to-multisig-addr", Some(m)) => { - const FINAL_TESTNET_EPOCH_NUMBER: EpochNumber = 89; - const FINAL_TESTNET_END_TIMESTAMP: u64 = 1_573_862_400; // 2019-11-16T00:00:00+0000 + ("to-multisig-addr", Some(m)) => { const FLAG_SINCE_EPOCH_NUMBER: u64 = 0b010_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000; + const EPOCH_LENGTH: u64 = 1800; + const EPOCH_PERIOD: u64 = EPOCH_LENGTH * 8 * 1000; // 4h in millis let locktime = m.value_of("locktime").unwrap(); let address: Address = AddressParser.from_matches_opt(m, "address", true)?.unwrap(); - #[allow(non_snake_case)] - let S: u64 = FINAL_TESTNET_END_TIMESTAMP; - #[allow(non_snake_case)] - let E: u64 = FINAL_TESTNET_EPOCH_NUMBER; - #[allow(non_snake_case)] - let T: u64 = to_timestamp(locktime)?; - #[allow(non_snake_case)] - let since = if T > S && ((T - S) / (4 * 60 * 60)) + 89 >= E { - let P = T - S; - let epoch_number: u64 = (P / (4 * 60 * 60)) + 89 - E; - let epoch_length: u64 = 1800; - let epoch_index: u64 = (P % (4 * 60 * 60)) * epoch_length / (4 * 60 * 60); - let epoch_fraction = - EpochNumberWithFraction::new(epoch_number, epoch_index, epoch_length); - FLAG_SINCE_EPOCH_NUMBER | epoch_fraction.full_value() - } else { - let epoch_fraction = EpochNumberWithFraction::new(0, 0, 1); - FLAG_SINCE_EPOCH_NUMBER | epoch_fraction.full_value() + let genesis_timestamp = get_genesis_info(&mut self.genesis_info, self.rpc_client)? + .header() + .timestamp(); + let target_timestamp = to_timestamp(locktime)?; + let elapsed = target_timestamp.saturating_sub(genesis_timestamp); + let epoch_fraction = { + let epoch_number = elapsed / EPOCH_PERIOD; + let epoch_index = + (elapsed - epoch_number * EPOCH_PERIOD) * EPOCH_LENGTH / EPOCH_PERIOD; + EpochNumberWithFraction::new(epoch_number, epoch_index, EPOCH_LENGTH) }; + let since = FLAG_SINCE_EPOCH_NUMBER | epoch_fraction.full_value(); - // TODO: is it ok hard-code here? let code_hash = h256!("0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8"); - let maddr = MultisigAddress::new(code_hash, address.hash().clone(), since)?; + let maddr = MultisigAddress::new(code_hash.clone(), address.hash().clone(), since)?; assert_eq!( MultisigAddress::from_input(&maddr.display(NetworkType::MainNet)) .unwrap() @@ -342,6 +334,17 @@ message = "0x" locktime, maddr.display(NetworkType::MainNet), ); + if debug { + println!( + "[DEBUG] genesis_time: {}, target_time: {}, elapsed_in_secs: {}, target_epoch: {}, lock_arg: {}, code_hash: {:#x}", + NaiveDateTime::from_timestamp(genesis_timestamp as i64 / 1000, 0), + NaiveDateTime::from_timestamp(target_timestamp as i64 / 1000, 0), + elapsed / 1000, + epoch_fraction, + maddr.lock_arg(), + code_hash, + ); + } Ok(serde_json::json!(resp).render(format, color)) } _ => Err(matches.usage().to_owned()), @@ -356,5 +359,5 @@ fn to_timestamp(input: &str) -> Result { "%Y-%m-%d %H:%M:%S", ) .map_err(|err| format!("{:?}", err))?; - Ok(date.timestamp() as u64) + Ok(date.timestamp_millis() as u64) } From 122e4b0b321c119fc0e7c728cc22bd4bfa662a78 Mon Sep 17 00:00:00 2001 From: keroro520 Date: Sun, 10 Nov 2019 21:29:44 +0800 Subject: [PATCH 4/8] chore: Hidden the args of to-multisig-addr --- src/subcommands/util.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/subcommands/util.rs b/src/subcommands/util.rs index 4667befe..00ca3418 100644 --- a/src/subcommands/util.rs +++ b/src/subcommands/util.rs @@ -150,6 +150,7 @@ impl<'a> UtilSubCommand<'a> { .long("address") .required(true) .takes_value(true) + .hidden(true) .help("The address in single signature format") ) .arg( @@ -157,6 +158,7 @@ impl<'a> UtilSubCommand<'a> { .long("locktime") .required(true) .takes_value(true) + .hidden(true) .help("The locktime in UTC format") ) ]) @@ -330,7 +332,7 @@ message = "0x" ); let resp = format!( "{},{},{}", - address.to_string(NetworkType::MainNet), + address.display_with_prefix(NetworkType::MainNet), locktime, maddr.display(NetworkType::MainNet), ); From 567644f1b4627bba1a82738efd3494e42c5602b3 Mon Sep 17 00:00:00 2001 From: keroro520 Date: Sun, 10 Nov 2019 21:55:30 +0800 Subject: [PATCH 5/8] feat: Disallow ckt address and non-mainnet node --- src/subcommands/util.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/subcommands/util.rs b/src/subcommands/util.rs index 00ca3418..1480a164 100644 --- a/src/subcommands/util.rs +++ b/src/subcommands/util.rs @@ -1,7 +1,7 @@ use chrono::{NaiveDate, NaiveDateTime}; use ckb_crypto::secp::SECP256K1; use ckb_hash::blake2b_256; -use ckb_jsonrpc_types::{Script as RpcScript, Transaction as RpcTransaction}; +use ckb_jsonrpc_types::{ChainInfo, Script as RpcScript, Transaction as RpcTransaction}; use ckb_sdk::{Address, GenesisInfo, HttpRpcClient, MultisigAddress, NetworkType, OldAddress}; use ckb_types::{ h256, packed, @@ -305,8 +305,24 @@ message = "0x" const EPOCH_LENGTH: u64 = 1800; const EPOCH_PERIOD: u64 = EPOCH_LENGTH * 8 * 1000; // 4h in millis + let chain_info: ChainInfo = self + .rpc_client + .get_blockchain_info() + .call() + .map_err(|err| format!("RPC get_blockchain_info error: {:?}", err))?; + if &chain_info.chain != "ckb" { + return Err("Node is not in mainnet spec".to_owned()); + } + let locktime = m.value_of("locktime").unwrap(); - let address: Address = AddressParser.from_matches_opt(m, "address", true)?.unwrap(); + let address = { + let input = m.value_of("address").unwrap(); + let prefix = input.chars().take(3).collect::(); + if prefix != NetworkType::MainNet.to_prefix() { + return Err("Address is not mainnet address".to_owned()); + } + AddressParser.parse(input)? + }; let genesis_timestamp = get_genesis_info(&mut self.genesis_info, self.rpc_client)? .header() From 556aa3bf3ee91bba90bf72e00b2d3d1569e49a88 Mon Sep 17 00:00:00 2001 From: Qian Linfeng Date: Sat, 16 Nov 2019 23:39:23 +0800 Subject: [PATCH 6/8] fix: Fix select immature live cell bug --- ckb-index/src/index/types.rs | 2 +- ckb-sdk/src/basic.rs | 5 +++ ckb-sdk/src/chain.rs | 23 +++++++++---- ckb-sdk/src/lib.rs | 2 +- src/subcommands/wallet/mod.rs | 64 +++++++++++++++++++++++++++++++---- 5 files changed, 81 insertions(+), 15 deletions(-) diff --git a/ckb-index/src/index/types.rs b/ckb-index/src/index/types.rs index 2abe2425..c2fb4d64 100644 --- a/ckb-index/src/index/types.rs +++ b/ckb-index/src/index/types.rs @@ -592,7 +592,7 @@ pub struct LiveCellInfo { pub lock_hash: H256, // Type script's code_hash and script_hash pub type_hashes: Option<(H256, H256)>, - // Secp256k1 address + // Capacity pub capacity: u64, // Block number pub number: u64, diff --git a/ckb-sdk/src/basic.rs b/ckb-sdk/src/basic.rs index 082c7629..a2359583 100644 --- a/ckb-sdk/src/basic.rs +++ b/ckb-sdk/src/basic.rs @@ -21,6 +21,7 @@ const PREFIX_TESTNET: &str = "ckt"; pub enum NetworkType { MainNet = 0, TestNet = 1, + Staging = 254, Dev = 255, } @@ -29,6 +30,7 @@ impl NetworkType { match v { 0 => Some(NetworkType::MainNet), 1 => Some(NetworkType::TestNet), + 254 => Some(NetworkType::Staging), 255 => Some(NetworkType::Dev), _ => None, } @@ -46,6 +48,7 @@ impl NetworkType { match self { NetworkType::MainNet => PREFIX_MAINNET, NetworkType::TestNet => PREFIX_TESTNET, + NetworkType::Staging => PREFIX_TESTNET, NetworkType::Dev => PREFIX_TESTNET, } } @@ -54,6 +57,7 @@ impl NetworkType { match value { "ckb" => Some(NetworkType::MainNet), "ckb_testnet" => Some(NetworkType::TestNet), + "ckb_staging" => Some(NetworkType::Staging), "ckb_dev" => Some(NetworkType::Dev), _ => None, } @@ -63,6 +67,7 @@ impl NetworkType { match self { NetworkType::MainNet => "ckb", NetworkType::TestNet => "ckb_testnet", + NetworkType::Staging => "ckb_staging", NetworkType::Dev => "ckb_dev", } } diff --git a/ckb-sdk/src/chain.rs b/ckb-sdk/src/chain.rs index f5a2e2b8..b2b80dfe 100644 --- a/ckb-sdk/src/chain.rs +++ b/ckb-sdk/src/chain.rs @@ -5,8 +5,8 @@ use ckb_resource::{CODE_HASH_DAO, CODE_HASH_SECP256K1_BLAKE160_SIGHASH_ALL}; use ckb_types::{ bytes::Bytes, core::{ - BlockView, Capacity, DepType, HeaderView, ScriptHashType, TransactionBuilder, - TransactionView, + BlockView, Capacity, DepType, EpochNumberWithFraction, HeaderView, ScriptHashType, + TransactionBuilder, TransactionView, }, packed::{Byte32, CellDep, CellInput, CellOutput, OutPoint, Script, ScriptOpt, WitnessArgs}, prelude::*, @@ -15,6 +15,8 @@ use ckb_types::{ use secp256k1::recovery::RecoverableSignature; pub const ONE_CKB: u64 = 100_000_000; +pub const CELLBASE_MATURITY: EpochNumberWithFraction = + EpochNumberWithFraction::new_unchecked(4, 0, 1); lazy_static::lazy_static! { pub static ref MIN_SECP_CELL_CAPACITY: u64 = { @@ -222,7 +224,7 @@ impl<'a> TransferTransactionBuilder<'a> { { self.cell_deps.extend(vec![genesis_info.secp_dep()]); self.build_outputs(genesis_info); - self.build_changes(genesis_info); + self.build_changes(genesis_info)?; self.build_secp_witnesses(build_witness)?; Ok(self.build_transaction()) } @@ -238,7 +240,7 @@ impl<'a> TransferTransactionBuilder<'a> { self.cell_deps .extend(vec![genesis_info.secp_dep(), genesis_info.dao_dep()]); self.build_outputs(genesis_info); - self.build_changes(genesis_info); + self.build_changes(genesis_info)?; self.build_dao_type(genesis_info); self.build_secp_witnesses(build_witness)?; Ok(self.build_transaction()) @@ -260,7 +262,7 @@ impl<'a> TransferTransactionBuilder<'a> { self.header_deps .extend(input_header_hashes.into_iter().map(|h| h.pack())); self.build_outputs(genesis_info); - self.build_changes(genesis_info); + self.build_changes(genesis_info)?; self.build_dao_witnesses(); self.build_secp_witnesses(build_witness)?; Ok(self.build_transaction()) @@ -326,7 +328,11 @@ impl<'a> TransferTransactionBuilder<'a> { } // Exchange back to sender if the rest is enough to pay for a cell - fn build_changes(&mut self, genesis_info: &GenesisInfo) { + fn build_changes(&mut self, genesis_info: &GenesisInfo) -> Result<(), String> { + if self.tx_fee > ONE_CKB { + return Err("Transaction fee can not more than 1.0 CKB".to_string()); + } + let rest_capacity = self.from_capacity - self.to_capacity - self.tx_fee; if rest_capacity >= *MIN_SECP_CELL_CAPACITY { // The rest send back to sender @@ -339,6 +345,11 @@ impl<'a> TransferTransactionBuilder<'a> { .build(); let change_data = Bytes::default(); self.changes.push((change, change_data)); + Ok(()) + } else if self.tx_fee + rest_capacity > ONE_CKB { + Err("Transaction fee can not more than 1.0 CKB, please change to-capacity value to adjust".to_string()) + } else { + Ok(()) } } diff --git a/ckb-sdk/src/lib.rs b/ckb-sdk/src/lib.rs index 3bcd22b7..adcf5136 100644 --- a/ckb-sdk/src/lib.rs +++ b/ckb-sdk/src/lib.rs @@ -9,7 +9,7 @@ pub mod wallet; pub use basic::{Address, NetworkType, OldAddress, OldAddressFormat}; pub use chain::{ blake2b_args, build_witness_with_key, serialize_signature, GenesisInfo, - TransferTransactionBuilder, MIN_SECP_CELL_CAPACITY, ONE_CKB, + TransferTransactionBuilder, CELLBASE_MATURITY, MIN_SECP_CELL_CAPACITY, ONE_CKB, }; pub use error::Error; pub use rpc::HttpRpcClient; diff --git a/src/subcommands/wallet/mod.rs b/src/subcommands/wallet/mod.rs index 6f81f1c8..e897dc49 100644 --- a/src/subcommands/wallet/mod.rs +++ b/src/subcommands/wallet/mod.rs @@ -5,10 +5,10 @@ use std::io::Read; use std::path::PathBuf; use ckb_hash::blake2b_256; -use ckb_jsonrpc_types::{BlockNumber, CellWithStatus}; +use ckb_jsonrpc_types::{BlockNumber, CellWithStatus, EpochNumber}; use ckb_types::{ bytes::Bytes, - core::{BlockView, TransactionView}, + core::{BlockView, EpochNumberWithFraction, TransactionView}, prelude::*, H160, H256, }; @@ -28,8 +28,8 @@ use ckb_index::{with_index_db, IndexDatabase, LiveCellInfo}; use ckb_sdk::{ blake2b_args, build_witness_with_key, serialize_signature, wallet::{KeyStore, KeyStoreError}, - Address, GenesisInfo, HttpRpcClient, TransferTransactionBuilder, MIN_SECP_CELL_CAPACITY, - ONE_CKB, SECP256K1, + Address, GenesisInfo, HttpRpcClient, TransferTransactionBuilder, CELLBASE_MATURITY, + MIN_SECP_CELL_CAPACITY, ONE_CKB, SECP256K1, }; pub use index::{ start_index_thread, CapacityResult, IndexController, IndexRequest, IndexResponse, @@ -170,6 +170,7 @@ impl<'a> WalletSubCommand<'a> { check_address_prefix(m.value_of("to-address").unwrap(), network_type)?; // For check index database is ready self.with_db(|_| ())?; + let min_immature_number = get_min_immature_number(self.rpc_client)?; let index_dir = self.index_dir.clone(); let genesis_hash = genesis_info.header().hash(); let genesis_info_clone = genesis_info.clone(); @@ -181,7 +182,7 @@ impl<'a> WalletSubCommand<'a> { .get_live_cell(out_point.into(), true) .call() .expect("get_live_cell by RPC call failed"); - if is_live_cell(&resp) && is_secp_cell(&resp) { + if is_live_cell(&resp) && is_secp_cell(&resp) && is_mature(info, min_immature_number) { total_capacity += info.capacity; (total_capacity >= capacity + tx_fee, true) } else { @@ -209,7 +210,7 @@ impl<'a> WalletSubCommand<'a> { if total_capacity < capacity + tx_fee { return Err(format!( - "Capacity not enough: {} => {}", + "Capacity(mature) not enough: {} => {}", from_address.display_with_prefix(network_type), total_capacity, )); @@ -370,9 +371,16 @@ impl<'a> CliSubCommand for WalletSubCommand<'a> { }; (infos, total_capacity) })?; + let min_immature_number = get_min_immature_number(self.rpc_client)?; let resp = serde_json::json!({ "live_cells": infos.into_iter().map(|info| { - serde_json::to_value(&info).unwrap() + let mut value = serde_json::to_value(&info).unwrap(); + let mature = serde_json::Value::Bool(is_mature(&info, min_immature_number)); + value + .as_object_mut() + .unwrap() + .insert("mature".to_string(), mature); + value }).collect::>(), "total_capacity": total_capacity, }); @@ -424,6 +432,48 @@ fn check_capacity(capacity: u64, to_data_len: usize) -> Result<(), String> { Ok(()) } +// Get min immature block number +fn get_min_immature_number(client: &mut HttpRpcClient) -> Result { + let tip_epoch = client + .get_tip_header() + .call() + .map(|header| EpochNumberWithFraction::from_full_value(header.inner.epoch.value())) + .map_err(|err| err.to_string())?; + let tip_epoch_number = tip_epoch.number(); + if tip_epoch_number < 4 { + // No cellbase live cell is mature + return Ok(0); + } + let max_mature_epoch = client + .get_epoch_by_number(EpochNumber::from(tip_epoch_number - 3)) + .call() + .map_err(|err| err.to_string())? + .0 + .ok_or_else(|| "Can not get epoch less than current epoch number".to_string())?; + for index in 0..max_mature_epoch.length.value() { + let epoch = EpochNumberWithFraction::new( + max_mature_epoch.number.value(), + index, + max_mature_epoch.length.value(), + ); + if epoch.to_rational() + CELLBASE_MATURITY.to_rational() > tip_epoch.to_rational() { + return Ok(max_mature_epoch.start_number.value() + index); + } + } + Err(format!( + "Can not found min immature block number in epoch {}", + max_mature_epoch.number.value() + )) +} + +fn is_mature(info: &LiveCellInfo, min_immature_number: u64) -> bool { + // Not cellbase cell + info.index.tx_index > 0 + // Live cells in genesis are all mature + || info.number == 0 + || info.number < min_immature_number +} + fn is_live_cell(cell: &CellWithStatus) -> bool { if cell.status != "live" { eprintln!( From 8aabddcbab51f12a9d7fcf7f9355f6cd57ada4bb Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 17 Nov 2019 06:27:30 +0800 Subject: [PATCH 7/8] chore: static link openssl in macOS package Keep consistent with ckb. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dbc4fc48..8bcf1a8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -92,7 +92,7 @@ matrix: before_cache: - rm -rf $HOME/.cargo/registry script: - - make prod + - make OPENSSL_STATIC=1 OPENSSL_LIB_DIR=/usr/local/opt/openssl@1.1/lib OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl@1.1/include prod - openssl aes-256-cbc -K $encrypted_2e21ee7c4b13_key -iv $encrypted_2e21ee7c4b13_iv -in devtools/ci/travis-secret.asc.enc -out devtools/ci/travis-secret.asc -d - gpg --import devtools/ci/travis-secret.asc - devtools/ci/package.sh target/release/ckb-cli From e64de8a12aed8dbea0d78d7c9fdfb30ad6655f3e Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 17 Nov 2019 08:24:58 +0800 Subject: [PATCH 8/8] chore: bump to v0.25.2 --- Cargo.lock | 254 +++++++++++++++++++-------------------- Cargo.toml | 2 +- ckb-index/Cargo.toml | 2 +- ckb-sdk-types/Cargo.toml | 2 +- ckb-sdk/Cargo.toml | 2 +- test/Cargo.toml | 4 +- 6 files changed, 133 insertions(+), 133 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c500616f..bcfdac5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -325,23 +325,23 @@ dependencies = [ [[package]] name = "ckb-build-info" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" [[package]] name = "ckb-chain-spec" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" -dependencies = [ - "ckb-crypto 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-dao-utils 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-error 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-hash 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-jsonrpc-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-pow 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-rational 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-resource 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" +dependencies = [ + "ckb-crypto 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-dao-utils 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-error 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-hash 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-jsonrpc-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-pow 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-rational 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-resource 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", @@ -350,20 +350,20 @@ dependencies = [ [[package]] name = "ckb-cli" -version = "0.25.0" +version = "0.25.2" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "ckb-build-info 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-crypto 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-hash 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-index 0.25.0", - "ckb-jsonrpc-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-resource 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-sdk 0.25.0", - "ckb-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-util 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-build-info 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-crypto 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-hash 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-index 0.25.2", + "ckb-jsonrpc-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-resource 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-sdk 0.25.2", + "ckb-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-util 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "colored 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -392,10 +392,10 @@ dependencies = [ [[package]] name = "ckb-crypto" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ - "ckb-fixed-hash 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-fixed-hash 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "faster-hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -405,40 +405,40 @@ dependencies = [ [[package]] name = "ckb-dao-utils" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ckb-error 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-error 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "enum-display-derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ckb-error" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ - "ckb-occupied-capacity 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-occupied-capacity 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "enum-display-derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ckb-fixed-hash" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ - "ckb-fixed-hash-core 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-fixed-hash-hack 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-fixed-hash-core 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-fixed-hash-hack 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ckb-fixed-hash-core" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "faster-hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -447,10 +447,10 @@ dependencies = [ [[package]] name = "ckb-fixed-hash-hack" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ - "ckb-fixed-hash-core 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-fixed-hash-core 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -459,19 +459,19 @@ dependencies = [ [[package]] name = "ckb-hash" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ "blake2b-rs 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ckb-index" -version = "0.25.0" +version = "0.25.2" dependencies = [ "bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ckb-sdk 0.25.0", - "ckb-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-sdk 0.25.2", + "ckb-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rocksdb 0.12.2 (git+https://github.com/nervosnetwork/rust-rocksdb?rev=14d2991)", @@ -481,10 +481,10 @@ dependencies = [ [[package]] name = "ckb-jsonrpc-types" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ - "ckb-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "faster-hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", @@ -494,8 +494,8 @@ dependencies = [ [[package]] name = "ckb-logger" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -513,18 +513,18 @@ dependencies = [ [[package]] name = "ckb-occupied-capacity" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ - "ckb-occupied-capacity-core 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-occupied-capacity-macros 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-occupied-capacity-core 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-occupied-capacity-macros 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ckb-occupied-capacity-core" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", @@ -532,10 +532,10 @@ dependencies = [ [[package]] name = "ckb-occupied-capacity-macros" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ - "ckb-occupied-capacity-core 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-occupied-capacity-core 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", @@ -543,11 +543,11 @@ dependencies = [ [[package]] name = "ckb-pow" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ckb-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "eaglesong 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", @@ -555,19 +555,19 @@ dependencies = [ [[package]] name = "ckb-rational" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ "numext-fixed-uint 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ckb-resource" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ "ckb-system-scripts 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ckb-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "includedir 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "includedir_codegen 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -579,16 +579,16 @@ dependencies = [ [[package]] name = "ckb-script" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ckb-chain-spec 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-error 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-hash 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-logger 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-script-data-loader 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-chain-spec 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-error 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-hash 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-logger 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-script-data-loader 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "ckb-vm 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "faster-hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -598,28 +598,28 @@ dependencies = [ [[package]] name = "ckb-script-data-loader" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ - "ckb-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", ] [[package]] name = "ckb-sdk" -version = "0.25.0" +version = "0.25.2" dependencies = [ "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "bech32 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitcoin_hashes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "ckb-crypto 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-hash 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-jsonrpc-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-resource 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-script 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-sdk-types 0.25.0", - "ckb-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-crypto 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-hash 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-jsonrpc-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-resource 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-script 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-sdk-types 0.25.2", + "ckb-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "faster-hex 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -639,14 +639,14 @@ dependencies = [ [[package]] name = "ckb-sdk-types" -version = "0.25.0" -dependencies = [ - "ckb-crypto 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-error 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-hash 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-jsonrpc-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-script 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", +version = "0.25.2" +dependencies = [ + "ckb-crypto 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-error 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-hash 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-jsonrpc-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-script 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -665,16 +665,16 @@ dependencies = [ [[package]] name = "ckb-types" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ "bit-vec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "ckb-error 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-fixed-hash 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-hash 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-occupied-capacity 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", - "ckb-rational 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-error 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-fixed-hash 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-hash 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-occupied-capacity 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", + "ckb-rational 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)", "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "merkle-cbt 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -684,8 +684,8 @@ dependencies = [ [[package]] name = "ckb-util" -version = "0.25.0-pre" -source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#be5470f5e19bd3d0a73e850ba9d93d986d2aec6e" +version = "0.25.2" +source = "git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25#4ad5a6108969bdb4331e71c35f80deb9efcf6017" dependencies = [ "linked-hash-map 0.5.1 (git+https://github.com/nervosnetwork/linked-hash-map?rev=df27f21)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3341,28 +3341,28 @@ dependencies = [ "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum cgmath 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "64a4b57c8f4e3a2e9ac07e0f6abc9c24b6fc9e1b54c3478cfb598f3d0023e51c" "checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" -"checksum ckb-build-info 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-chain-spec 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-crypto 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-dao-utils 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-error 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-fixed-hash 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-fixed-hash-core 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-fixed-hash-hack 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-hash 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-jsonrpc-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-logger 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-occupied-capacity 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-occupied-capacity-core 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-occupied-capacity-macros 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-pow 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-rational 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-resource 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-script 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-script-data-loader 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-build-info 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-chain-spec 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-crypto 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-dao-utils 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-error 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-fixed-hash 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-fixed-hash-core 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-fixed-hash-hack 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-hash 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-jsonrpc-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-logger 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-occupied-capacity 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-occupied-capacity-core 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-occupied-capacity-macros 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-pow 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-rational 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-resource 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-script 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-script-data-loader 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" "checksum ckb-system-scripts 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "261dd95a93c09ea24397c85b4fbca061e1da2d6573189749aeb99fe840aaf0c9" -"checksum ckb-types 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" -"checksum ckb-util 0.25.0-pre (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-types 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" +"checksum ckb-util 0.25.2 (git+https://github.com/nervosnetwork/ckb?branch=rc/v0.25)" = "" "checksum ckb-vm 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "410eca836e677ea70f73358b53220c284836c3cbb3ecf9ee531606d926881f59" "checksum ckb-vm-definitions 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "201ab0ce4cf5644b3f0cacc9d772011f66c132d5e62ab35918413d9a6c29e6a7" "checksum clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81de550971c976f176130da4b2978d3b524eaa0fd9ac31f3ceb5ae1231fb4853" diff --git a/Cargo.toml b/Cargo.toml index f5265ad0..20ed7990 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-cli" -version = "0.25.0" +version = "0.25.2" license = "MIT" authors = ["Linfeng Qian ", "Nervos Core Dev "] edition = "2018" diff --git a/ckb-index/Cargo.toml b/ckb-index/Cargo.toml index b7b4e6b2..55621961 100644 --- a/ckb-index/Cargo.toml +++ b/ckb-index/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-index" -version = "0.25.0" +version = "0.25.2" authors = ["Linfeng Qian ", "Nervos Core Dev "] edition = "2018" license = "MIT" diff --git a/ckb-sdk-types/Cargo.toml b/ckb-sdk-types/Cargo.toml index 065d6168..14862371 100644 --- a/ckb-sdk-types/Cargo.toml +++ b/ckb-sdk-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-sdk-types" -version = "0.25.0" +version = "0.25.2" authors = ["Linfeng Qian ", "Nervos Core Dev "] edition = "2018" license = "MIT" diff --git a/ckb-sdk/Cargo.toml b/ckb-sdk/Cargo.toml index 1caecf52..26248f3d 100644 --- a/ckb-sdk/Cargo.toml +++ b/ckb-sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ckb-sdk" -version = "0.25.0" +version = "0.25.2" authors = ["Linfeng Qian ", "Nervos Core Dev "] edition = "2018" license = "MIT" diff --git a/test/Cargo.toml b/test/Cargo.toml index 3d1c85ce..5ab932a5 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cli-test" -version = "0.1.0" +version = "0.25.2" authors = ["Linfeng Qian "] edition = "2018" @@ -14,4 +14,4 @@ env_logger = "0.6" # Prevent this from interfering with workspaces [workspace] -members = ["."] \ No newline at end of file +members = ["."]