diff --git a/wallet/core/src/runtime/account/variants/multisig.rs b/wallet/core/src/runtime/account/variants/multisig.rs index ba7ff8d3b6..5f0ab1b984 100644 --- a/wallet/core/src/runtime/account/variants/multisig.rs +++ b/wallet/core/src/runtime/account/variants/multisig.rs @@ -77,13 +77,13 @@ impl Account for MultiSig { fn as_storable(&self) -> Result { let settings = self.context().settings.clone().unwrap_or_default(); - let multisig = storage::MultiSig { - xpub_keys: self.xpub_keys.clone(), - ecdsa: self.ecdsa, - cosigner_index: self.cosigner_index, - minimum_signatures: self.minimum_signatures, - prv_key_data_ids: self.prv_key_data_ids.clone(), - }; + let multisig = storage::MultiSig::new( + self.xpub_keys.clone(), + self.prv_key_data_ids.clone(), + self.cosigner_index, + self.minimum_signatures, + self.ecdsa, + ); let account = storage::Account::new(*self.id(), None, settings, storage::AccountData::MultiSig(multisig)); diff --git a/wallet/core/src/runtime/wallet.rs b/wallet/core/src/runtime/wallet.rs index ac64ecd565..639a78efdf 100644 --- a/wallet/core/src/runtime/wallet.rs +++ b/wallet/core/src/runtime/wallet.rs @@ -486,13 +486,13 @@ impl Wallet { runtime::MultiSig::try_new( self, settings, - MultiSig { - xpub_keys: Arc::new(xpub_keys), - prv_key_data_ids: Some(Arc::new(prv_key_data_ids)), - cosigner_index: Some(min_cosigner_index), - minimum_signatures: args.minimum_signatures, - ecdsa: false, - }, + MultiSig::new( + Arc::new(xpub_keys), + Some(Arc::new(prv_key_data_ids)), + Some(min_cosigner_index), + args.minimum_signatures, + false, + ), None, ) .await?, @@ -502,13 +502,7 @@ impl Wallet { runtime::MultiSig::try_new( self, settings, - MultiSig { - xpub_keys: Arc::new(xpub_keys), - prv_key_data_ids: None, - cosigner_index: None, - minimum_signatures: args.minimum_signatures, - ecdsa: false, - }, + MultiSig::new(Arc::new(xpub_keys), None, None, args.minimum_signatures, false), None, ) .await?, @@ -892,13 +886,13 @@ impl Wallet { runtime::MultiSig::try_new( self, storage::Settings::default(), - MultiSig { - xpub_keys: Arc::new(xpub_keys), - prv_key_data_ids: Some(Arc::new(prv_key_data_ids)), - cosigner_index: Some(min_cosigner_index), + MultiSig::new( + Arc::new(xpub_keys), + Some(Arc::new(prv_key_data_ids)), + Some(min_cosigner_index), minimum_signatures, - ecdsa: false, - }, + false, + ), None, ) .await?, diff --git a/wallet/core/src/secret.rs b/wallet/core/src/secret.rs index 7a1873c4bf..3e6d079bba 100644 --- a/wallet/core/src/secret.rs +++ b/wallet/core/src/secret.rs @@ -1,6 +1,6 @@ use zeroize::Zeroize; -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct Secret(Vec); impl Secret { diff --git a/wallet/core/src/storage/account.rs b/wallet/core/src/storage/account.rs index 0a14ead2d9..3d90fd718f 100644 --- a/wallet/core/src/storage/account.rs +++ b/wallet/core/src/storage/account.rs @@ -59,6 +59,18 @@ pub struct MultiSig { pub ecdsa: bool, } +impl MultiSig { + pub fn new( + xpub_keys: Arc>, + prv_key_data_ids: Option>>, + cosigner_index: Option, + minimum_signatures: u16, + ecdsa: bool, + ) -> Self { + Self { version: MULTISIG_ACCOUNT_VERSION, xpub_keys, prv_key_data_ids, cosigner_index, minimum_signatures, ecdsa } + } +} + const KEYPAIR_ACCOUNT_VERSION: u16 = 0; #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "lowercase")]