Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cold address #615

Merged
merged 3 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runtime/chainx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("chainx"),
impl_name: create_runtime_str!("chainx-net"),
authoring_version: 1,
spec_version: 14,
spec_version: 15,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 4,
Expand Down
2 changes: 1 addition & 1 deletion runtime/dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("chainx"),
impl_name: create_runtime_str!("chainx-dev"),
authoring_version: 1,
spec_version: 14,
spec_version: 15,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 4,
Expand Down
2 changes: 1 addition & 1 deletion runtime/malan/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("chainx"),
impl_name: create_runtime_str!("chainx-malan"),
authoring_version: 1,
spec_version: 14,
spec_version: 15,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 4,
Expand Down
2 changes: 1 addition & 1 deletion xpallets/gateway/Trustee.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To become a trust, you must first be elected as a council member or runners up.
- hot_entity: Btc public key. Such as `0x043858204f15d385da76fcbdf019debde624689e296c5ac53f6437491528857617691fe85c5c529b692bd75e361a9d0995dbd3e20a81e949642dfb74095520d981`.
- cold_entity: Btc public key. Such as `0x043858204f15d385da76fcbdf019debde624689e296c5ac53f6437491528857617691fe85c5c529b692bd75e361a9d0995dbd3e20a81e949642dfb74095520d981`.

The hot public key is obtained through **Coming** and used in **Coming**, and the cold public key is obtained through the hardware wallet and used in the [hardware wallet script](https://github.com/chainx-org/trustee-cli-ts/tree/upgrade-taproot).
The hot public key is obtained through **Coming** and used in **Coming**, and the cold addresses are also obtained through Coming but with a different mnemonic.

# Reward distribution

Expand Down
2 changes: 0 additions & 2 deletions xpallets/gateway/TrusteeAdmin.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ Call through the council to vote for the election. The voting threshold needs to

##### 1. Trustee administrator is required to create hot multi-signature addresses in the ComingChat trustee group in time for the election, and teach other trustees to obtain and use the hardware wallet signature script.

Trustee Cold Wallet Signature Script Repository: https://github.com/chainx-org/trustee-cli-ts/tree/upgrade-taproot

##### 2. Trustee administrator needs to identify problematic trustees in a timely manner and move them into a small black house for transition.

Call to move to the little black house
Expand Down
28 changes: 19 additions & 9 deletions xpallets/gateway/bitcoin/src/trustee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,20 @@ impl<T: Config> TrusteeForChain<T::AccountId, T::BlockNumber, BtcTrusteeType, Bt
.parse()
.map_err(|_| Error::<T>::InvalidAddress)?;

// Set cold address for taproot threshold address
let cold_pks = cold_keys
.into_iter()
.map(|k| k.try_into().map_err(|_| Error::<T>::InvalidPublicKey))
.collect::<Result<Vec<_>, Error<T>>>()?;

let cold_mast = Mast::new(cold_pks, sig_num).map_err(|_| Error::<T>::InvalidAddress)?;

let cold_threshold_addr: Address = cold_mast
.generate_address(&Pallet::<T>::network_id().to_string())
.map_err(|_| Error::<T>::InvalidAddress)?
.parse()
.map_err(|_| Error::<T>::InvalidAddress)?;

// Aggregate public key script and corresponding personal public key index
let mut agg_pubkeys: Vec<Vec<u8>> = vec![];
let mut personal_accounts: Vec<Vec<T::AccountId>> = vec![];
Expand All @@ -243,15 +257,10 @@ impl<T: Config> TrusteeForChain<T::AccountId, T::BlockNumber, BtcTrusteeType, Bt
redeem_script: vec![],
};

let cold_trustee_addr_info: BtcTrusteeAddrInfo =
create_multi_address::<T>(&cold_keys, sig_num).ok_or_else(|| {
log!(
error,
"[generate_trustee_session_info] Create cold_addr error, cold_keys:{:?}",
cold_keys
);
Error::<T>::GenerateMultisigFailed
})?;
let cold_trustee_addr_info: BtcTrusteeAddrInfo = BtcTrusteeAddrInfo {
addr: cold_threshold_addr.to_string().into_bytes(),
redeem_script: vec![],
};

log!(
info,
Expand Down Expand Up @@ -378,6 +387,7 @@ pub fn get_sig_num<T: Config>() -> (u32, u32) {
(two_thirds_unsafe(trustee_num), trustee_num)
}

#[allow(dead_code)]
pub(crate) fn create_multi_address<T: Config>(
pubkeys: &[Public],
sig_num: u32,
Expand Down