Skip to content
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e39ff92
fix comment
mariocynicys Jun 14, 2025
facae9d
add a todo regarind session proposal response
mariocynicys Jun 14, 2025
638fe3f
add a todo related to ledger connection detection in wallet connect
mariocynicys Jun 14, 2025
a5b5909
rename send_proposal_request for clarity and add a todo
mariocynicys Jun 14, 2025
ab0edba
add a todo regarding a possible mis-use of session properties
mariocynicys Jun 15, 2025
42ddeb1
rename PersonalSign to EthPersonalSign to signify it's eth specific m…
mariocynicys Jun 15, 2025
fd0c6ab
add btc/utxo wallet connect method names
mariocynicys Jun 15, 2025
803d8f5
recognize that the conversion from PrivKeyBuildPolicy to the eth coun…
mariocynicys Jun 16, 2025
9799ec9
add a PrivKeyBuildPolicy::WalletConnect to be used for UTXO
mariocynicys Jun 17, 2025
72e845b
dont store address not pubkey in EthPrivKeyBuildPolicy::WalletConnect
mariocynicys Jun 18, 2025
9a03495
dont store address not pubkey in PrivKeyBuildPolicy::WalletConnect
mariocynicys Jun 18, 2025
3769d41
free UtxoCoinBuilder of the trait hell
mariocynicys Jun 18, 2025
bc796a2
impl wallet connection activation for btc
mariocynicys Jun 21, 2025
f15163f
add bip122 to WcChainId struct
mariocynicys Jun 21, 2025
735403d
merge with origin/dev
mariocynicys Jun 23, 2025
6dd49c1
fix ci clippy error
mariocynicys Jun 24, 2025
31d9edc
merge with origin dev
mariocynicys Jun 24, 2025
a665b55
strongtype wallet connect error
mariocynicys Jun 25, 2025
028ff49
move a note to a todo to not forget about it later
mariocynicys Jun 25, 2025
b892571
review(onur): rename the generic UtxoAddress struct
mariocynicys Jun 30, 2025
ca8e1a0
merge with origin/dev
mariocynicys Jul 2, 2025
2c72ad6
turn the TryFrom back to From
mariocynicys Jul 3, 2025
98f9d5f
manually convert PrivKeyBuildPoilcy to the ETH counterpart in legacy …
mariocynicys Jul 3, 2025
17bf308
refactor sign_message_hash for better usability
mariocynicys Jul 9, 2025
eee71ca
impl msg signing and pubkey recovery with walletconnect
mariocynicys Jul 9, 2025
16aa656
use signMessage for pubkey recovery as a fallback
mariocynicys Jul 9, 2025
f3451fe
fix error in activated_key_or_err() call when walletconnect is used
mariocynicys Jul 9, 2025
4587a1d
fix linting issues
mariocynicys Jul 9, 2025
af1cc4b
merge with origin/dev
mariocynicys Jul 10, 2025
c86a2bf
review(onur): add more spaces here and there for readability
mariocynicys Jul 10, 2025
87bb907
refine the todo regarding ledger connectino detection
mariocynicys Jul 14, 2025
480ad38
review(onur): rename build_..._iguana_secret to build_..._iguana_priv…
mariocynicys Jul 14, 2025
9bf308a
review(onur): reduce the size of `build_utxo_fields_with_walletconnec…
mariocynicys Jul 14, 2025
4149627
review(onur): use a specilizied struct for session_topic parameters (…
mariocynicys Jul 14, 2025
a22b14b
review(onur): let kdf_walletconnect-rust use &Topic instead of &str f…
mariocynicys Jul 14, 2025
35d7353
merge with origin/dev
mariocynicys Jul 25, 2025
f17f300
try to decode the signature response as hex first
mariocynicys Jul 28, 2025
6521246
move sign_message_hash to mm2_bitcoin
mariocynicys Jul 29, 2025
84f3f0b
review(shamardy): report the correct error when tron is used with wal…
mariocynicys Jul 30, 2025
e893297
review(shamardy): move chain_id inside protocol data for utxo
mariocynicys Jul 30, 2025
33868a6
Merge remote-tracking branch 'origin/dev' into btc-walletconnect
mariocynicys Jul 30, 2025
f0719d6
merge with origin/dev
mariocynicys Jul 30, 2025
821a5dd
fix failing tests
mariocynicys Jul 30, 2025
188424a
actually fix tests
mariocynicys Jul 30, 2025
0947655
merge with origin/dev
shamardy Jul 31, 2025
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
31 changes: 19 additions & 12 deletions mm2src/coins/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ use web3::{self, Web3};

cfg_wasm32! {
use crypto::MetamaskArc;
use ethereum_types::H520;
use mm2_metamask::MetamaskError;
use web3::types::TransactionRequest;
}
Expand Down Expand Up @@ -866,9 +865,7 @@ pub enum EthPrivKeyBuildPolicy {
Metamask(MetamaskArc),
Trezor,
WalletConnect {
address: Address,
public_key_uncompressed: H520,
session_topic: String,
session_topic: kdf_walletconnect::WcTopic,
},
}

Expand All @@ -889,11 +886,14 @@ impl EthPrivKeyBuildPolicy {
}

impl From<PrivKeyBuildPolicy> for EthPrivKeyBuildPolicy {
fn from(policy: PrivKeyBuildPolicy) -> Self {
fn from(policy: PrivKeyBuildPolicy) -> EthPrivKeyBuildPolicy {
match policy {
PrivKeyBuildPolicy::IguanaPrivKey(iguana) => EthPrivKeyBuildPolicy::IguanaPrivKey(iguana),
PrivKeyBuildPolicy::GlobalHDAccount(global_hd) => EthPrivKeyBuildPolicy::GlobalHDAccount(global_hd),
PrivKeyBuildPolicy::Trezor => EthPrivKeyBuildPolicy::Trezor,
PrivKeyBuildPolicy::WalletConnect { session_topic } => {
EthPrivKeyBuildPolicy::WalletConnect { session_topic }
},
}
}
}
Expand Down Expand Up @@ -2992,8 +2992,7 @@ async fn sign_raw_eth_tx(coin: &EthCoin, args: &SignEthTransactionParams) -> Raw
.map_to_mm(|err| RawTransactionError::TransactionError(err.get_plain_text_format()))
},
EthPrivKeyPolicy::WalletConnect { .. } => {
// NOTE: doesn't work with wallets that doesn't support `eth_signTransaction`.
// e.g Metamask
// NOTE: doesn't work with wallets that doesn't support `eth_signTransaction`. e.g TrustWallet
let wc = {
let ctx = MmArc::from_weak(&coin.ctx).expect("No context");
WalletConnectCtx::from_ctx(&ctx)
Expand Down Expand Up @@ -6565,8 +6564,15 @@ pub async fn eth_coin_from_conf_and_request(
}
}

// Convert `PrivKeyBuildPolicy` to `EthPrivKeyBuildPolicy` if it's possible.
let priv_key_policy = From::from(priv_key_policy);
// Convert `PrivKeyBuildPolicy` to `EthPrivKeyBuildPolicy`.
let priv_key_policy = match priv_key_policy {
PrivKeyBuildPolicy::IguanaPrivKey(iguana) => EthPrivKeyBuildPolicy::IguanaPrivKey(iguana),
PrivKeyBuildPolicy::GlobalHDAccount(global_hd) => EthPrivKeyBuildPolicy::GlobalHDAccount(global_hd),
PrivKeyBuildPolicy::Trezor => EthPrivKeyBuildPolicy::Trezor,
PrivKeyBuildPolicy::WalletConnect { .. } => {
return ERR!("WalletConnect private key policy is not supported for legacy ETH coin activation");
},
};

let mut urls: Vec<String> = try_s!(json::from_value(req["urls"].clone()));
if urls.is_empty() {
Expand All @@ -6591,8 +6597,9 @@ pub async fn eth_coin_from_conf_and_request(
req["path_to_address"].clone()
))
.unwrap_or_default();
let (key_pair, derivation_method) =
try_s!(build_address_and_priv_key_policy(ctx, ticker, conf, priv_key_policy, &path_to_address, None).await);
let (key_pair, derivation_method) = try_s!(
build_address_and_priv_key_policy(ctx, ticker, conf, priv_key_policy, &path_to_address, None, None).await
);

let mut web3_instances = vec![];
let event_handlers = rpc_event_handlers_for_eth_transport(ctx, ticker.to_string());
Expand Down Expand Up @@ -6870,7 +6877,7 @@ pub async fn get_eth_address(
.into();

let (_, derivation_method) =
build_address_and_priv_key_policy(ctx, ticker, conf, priv_key_policy, path_to_address, None)
build_address_and_priv_key_policy(ctx, ticker, conf, priv_key_policy, path_to_address, None, None)
.await
.map_mm_err()?;
let my_address = derivation_method.single_addr_or_err().await.map_mm_err()?;
Expand Down
23 changes: 17 additions & 6 deletions mm2src/coins/eth/v2_activation.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::*;
use crate::eth::erc20::{get_enabled_erc20_by_platform_and_contract, get_token_decimals};
use crate::eth::wallet_connect::eth_request_wc_personal_sign;
use crate::eth::web3_transport::http_transport::HttpTransport;
use crate::hd_wallet::{
load_hd_accounts_from_storage, HDAccountsMutex, HDPathAccountToAddressId, HDWalletCoinStorage,
Expand All @@ -17,6 +18,7 @@ use crypto::{trezor::TrezorError, Bip32Error, CryptoCtxError, HwError};
use enum_derives::EnumFromTrait;
use ethereum_types::H264;
use kdf_walletconnect::error::WalletConnectError;
use kdf_walletconnect::WcTopic;
use mm2_err_handle::common_errors::WithInternal;
#[cfg(target_arch = "wasm32")]
use mm2_metamask::{from_metamask_error, MetamaskError, MetamaskRpcError, WithMetamaskRpcError};
Expand Down Expand Up @@ -201,7 +203,7 @@ pub enum EthPrivKeyActivationPolicy {
#[cfg(target_arch = "wasm32")]
Metamask,
WalletConnect {
session_topic: String,
session_topic: WcTopic,
},
}

Expand Down Expand Up @@ -681,6 +683,7 @@ pub async fn eth_coin_from_conf_and_request_v2(
priv_key_build_policy,
&req.path_to_address,
req.gap_limit,
Some(&chain_spec),
)
.await?;

Expand Down Expand Up @@ -781,6 +784,7 @@ pub(crate) async fn build_address_and_priv_key_policy(
priv_key_build_policy: EthPrivKeyBuildPolicy,
path_to_address: &HDPathAccountToAddressId,
gap_limit: Option<u32>,
chain_spec: Option<&ChainSpec>,
) -> MmResult<(EthPrivKeyPolicy, EthDerivationMethod), EthActivationV2Error> {
match priv_key_build_policy {
EthPrivKeyBuildPolicy::IguanaPrivKey(iguana) => {
Expand Down Expand Up @@ -875,11 +879,18 @@ pub(crate) async fn build_address_and_priv_key_policy(
DerivationMethod::SingleAddress(address),
))
},
EthPrivKeyBuildPolicy::WalletConnect {
address,
public_key_uncompressed,
session_topic,
} => {
EthPrivKeyBuildPolicy::WalletConnect { session_topic } => {
let wc = WalletConnectCtx::from_ctx(ctx).map_err(|e| {
EthActivationV2Error::WalletConnectError(format!("Failed to get WalletConnect context: {e}"))
})?;
let chain_spec = chain_spec.ok_or(EthActivationV2Error::ChainIdNotSet)?;
let chain_id = chain_spec.chain_id().ok_or(EthActivationV2Error::UnsupportedChain {
chain: chain_spec.kind().to_string(),
feature: "WalletConnect".to_string(),
})?;
let (public_key_uncompressed, address) = eth_request_wc_personal_sign(&wc, &session_topic, chain_id)
.await
.mm_err(|err| EthActivationV2Error::WalletConnectError(err.to_string()))?;
let public_key = compress_public_key(public_key_uncompressed)?;
Ok((
EthPrivKeyPolicy::WalletConnect {
Expand Down
8 changes: 4 additions & 4 deletions mm2src/coins/eth/wallet_connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use ethereum_types::{Address, Public, H160, H520, U256};
use ethkey::{public_to_address, Message, Signature};
use kdf_walletconnect::chain::{WcChainId, WcRequestMethods};
use kdf_walletconnect::error::WalletConnectError;
use kdf_walletconnect::{WalletConnectCtx, WalletConnectOps};
use kdf_walletconnect::{WalletConnectCtx, WalletConnectOps, WcTopic};
use mm2_err_handle::prelude::*;
use secp256k1::recovery::{RecoverableSignature, RecoveryId};
use secp256k1::{PublicKey, Secp256k1};
Expand Down Expand Up @@ -180,7 +180,7 @@ impl WalletConnectOps for EthCoin {
Ok((signed_tx, tx_hex))
}

fn session_topic(&self) -> Result<&str, Self::Error> {
fn session_topic(&self) -> Result<&WcTopic, Self::Error> {
if let EthPrivKeyPolicy::WalletConnect { ref session_topic, .. } = &self.priv_key_policy {
return Ok(session_topic);
}
Expand All @@ -194,7 +194,7 @@ impl WalletConnectOps for EthCoin {

pub async fn eth_request_wc_personal_sign(
wc: &WalletConnectCtx,
session_topic: &str,
session_topic: &WcTopic,
chain_id: u64,
) -> MmResult<(H520, Address), EthWalletConnectError> {
let chain_id = WcChainId::new_eip155(chain_id.to_string());
Expand All @@ -211,7 +211,7 @@ pub async fn eth_request_wc_personal_sign(
json!(&[&message_hex, &account_str])
};
let data = wc
.send_session_request_and_wait::<String>(session_topic, &chain_id, WcRequestMethods::PersonalSign, params)
.send_session_request_and_wait::<String>(session_topic, &chain_id, WcRequestMethods::EthPersonalSign, params)
.await
.map_mm_err()?;

Expand Down
2 changes: 1 addition & 1 deletion mm2src/coins/hd_wallet/pubkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ where
.or_mm_err(|| HDExtractPubkeyError::HwContextNotInitialized)?;

let trezor_message_type = match coin_protocol {
CoinProtocol::UTXO => TrezorMessageType::Bitcoin,
CoinProtocol::UTXO { .. } => TrezorMessageType::Bitcoin,
CoinProtocol::QTUM => TrezorMessageType::Bitcoin,
CoinProtocol::ETH { .. } | CoinProtocol::ERC20 { .. } => TrezorMessageType::Ethereum,
_ => return Err(MmError::new(HDExtractPubkeyError::CoinDoesntSupportTrezor)),
Expand Down
34 changes: 27 additions & 7 deletions mm2src/coins/lp_coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4294,11 +4294,14 @@ impl CoinsContext {
}

/// This enum is used in coin activation requests.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Default)]
#[derive(Clone, Debug, Deserialize, Serialize, Default)]
pub enum PrivKeyActivationPolicy {
#[default]
ContextPrivKey,
Trezor,
WalletConnect {
session_topic: kdf_walletconnect::WcTopic,
},
}

impl PrivKeyActivationPolicy {
Expand Down Expand Up @@ -4356,10 +4359,16 @@ pub enum PrivKeyPolicy<T> {
/// - `public_key`: Compressed public key, represented as [H264].
/// - `public_key_uncompressed`: Uncompressed public key, represented as [H520].
/// - `session_topic`: WalletConnect session that was used to activate this coin.
// TODO: We want to have different variants of WalletConnect policy for different coin types:
// - ETH uses the structure found here.
// - Tendermint doesn't use this variant all together. Tendermint generalizes one level on top of PrivKeyPolicy by having a different activation policy
// structure that is either Priv(PrivKeyPolicy) or Pubkey(PublicKey) and when activated via wallet connect it uses the Pubkey(PublicKey) variant.
// - UTXO coins on the otherhand need to keep a list of all the addresses activated in the wallet and not just a single account.
// - Note: We need to have a way to select which account and address are the active ones (WalletConnect just spams us with all the addresses in every account).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, we might not go the active address route for UTXO walletconnect, specially for ledger support to make sense. This is of course for next PRs.

WalletConnect {
public_key: H264,
public_key_uncompressed: H520,
session_topic: String,
session_topic: kdf_walletconnect::WcTopic,
},
}

Expand Down Expand Up @@ -4502,6 +4511,7 @@ pub enum PrivKeyBuildPolicy {
IguanaPrivKey(IguanaPrivKey),
GlobalHDAccount(GlobalHDAccountArc),
Trezor,
WalletConnect { session_topic: kdf_walletconnect::WcTopic },
}

impl PrivKeyBuildPolicy {
Expand Down Expand Up @@ -4677,11 +4687,21 @@ pub trait IguanaBalanceOps {
async fn iguana_balances(&self) -> BalanceResult<Self::BalanceObject>;
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
/// Information about the UTXO protocol used by a coin.
pub struct UtxoProtocolInfo {
/// A CAIP-2 compliant chain ID. Starts with `b122:`
/// This is used to identify the blockchain when using WalletConnect.
/// https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-4.md
chain_id: String,
}

Comment on lines +4696 to +4704
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should start adding this to coins configs and docs @mariocynicys please open an issue in coins repo and in docs repo. c.c. @cipig @smk762

#[allow(clippy::upper_case_acronyms)]
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "type", content = "protocol_data")]
pub enum CoinProtocol {
UTXO,
// TODO: Nest this option deep into the innert struct fields when more fields are added to the UTXO protocol info.
UTXO(Option<UtxoProtocolInfo>),
QTUM,
QRC20 {
platform: String,
Expand Down Expand Up @@ -4758,7 +4778,7 @@ impl CoinProtocol {
CoinProtocol::TENDERMINTTOKEN(info) => Some(&info.platform),
#[cfg(not(target_arch = "wasm32"))]
CoinProtocol::LIGHTNING { platform, .. } => Some(platform),
CoinProtocol::UTXO
CoinProtocol::UTXO { .. }
| CoinProtocol::QTUM
| CoinProtocol::ETH { .. }
| CoinProtocol::TRX { .. }
Expand All @@ -4777,7 +4797,7 @@ impl CoinProtocol {
Some(contract_address)
},
CoinProtocol::SLPTOKEN { .. }
| CoinProtocol::UTXO
| CoinProtocol::UTXO { .. }
| CoinProtocol::QTUM
| CoinProtocol::ETH { .. }
| CoinProtocol::TRX { .. }
Expand Down Expand Up @@ -5069,7 +5089,7 @@ pub async fn lp_coininit(ctx: &MmArc, ticker: &str, req: &Json) -> Result<MmCoin
let protocol: CoinProtocol = try_s!(json::from_value(coins_en["protocol"].clone()));

let coin: MmCoinEnum = match &protocol {
CoinProtocol::UTXO => {
CoinProtocol::UTXO { .. } => {
let params = try_s!(UtxoActivationParams::from_legacy_req(req));
try_s!(utxo_standard_coin_with_policy(ctx, ticker, &coins_en, &params, priv_key_policy).await).into()
},
Expand Down Expand Up @@ -5742,7 +5762,7 @@ pub fn address_by_coin_conf_and_pubkey_str(
},
// Todo: implement TRX address generation
CoinProtocol::TRX { .. } => ERR!("TRX address generation is not implemented yet"),
CoinProtocol::UTXO | CoinProtocol::QTUM | CoinProtocol::QRC20 { .. } | CoinProtocol::BCH { .. } => {
CoinProtocol::UTXO { .. } | CoinProtocol::QTUM | CoinProtocol::QRC20 { .. } | CoinProtocol::BCH { .. } => {
utxo::address_by_conf_and_pubkey_str(coin, conf, pubkey, addr_format)
},
CoinProtocol::SLPTOKEN { platform, .. } => {
Expand Down
39 changes: 21 additions & 18 deletions mm2src/coins/qrc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use crate::utxo::rpc_clients::{
#[cfg(not(target_arch = "wasm32"))]
use crate::utxo::tx_cache::{UtxoVerboseCacheOps, UtxoVerboseCacheShared};
use crate::utxo::utxo_builder::{
UtxoCoinBuildError, UtxoCoinBuildResult, UtxoCoinBuilder, UtxoCoinBuilderCommonOps, UtxoFieldsWithGlobalHDBuilder,
UtxoFieldsWithHardwareWalletBuilder, UtxoFieldsWithIguanaSecretBuilder,
build_utxo_fields_with_global_hd, build_utxo_fields_with_iguana_priv_key, UtxoCoinBuildError, UtxoCoinBuildResult,
UtxoCoinBuilder, UtxoCoinBuilderCommonOps,
};
use crate::utxo::utxo_common::{self, big_decimal_from_sat, check_all_utxo_inputs_signed_by_pub, UtxoTxBuilder};
use crate::utxo::{
Expand All @@ -35,7 +35,7 @@ use crate::{
WithdrawResult,
};
use async_trait::async_trait;
use bitcrypto::{dhash160, sha256};
use bitcrypto::{dhash160, sha256, sign_message_hash};
use chain::TransactionOutput;
use common::executor::{AbortableSystem, AbortedError, Timer};
use common::jsonrpc_client::{JsonRpcClient, JsonRpcRequest, RpcRes};
Expand Down Expand Up @@ -299,14 +299,6 @@ impl UtxoCoinBuilderCommonOps for Qrc20CoinBuilder<'_> {
}
}

impl UtxoFieldsWithIguanaSecretBuilder for Qrc20CoinBuilder<'_> {}

impl UtxoFieldsWithGlobalHDBuilder for Qrc20CoinBuilder<'_> {}

/// Although, `Qrc20Coin` doesn't support [`PrivKeyBuildPolicy::Trezor`] yet,
/// `UtxoCoinBuilder` trait requires `UtxoFieldsWithHardwareWalletBuilder` to be implemented.
impl UtxoFieldsWithHardwareWalletBuilder for Qrc20CoinBuilder<'_> {}

#[async_trait]
impl UtxoCoinBuilder for Qrc20CoinBuilder<'_> {
type ResultCoin = Qrc20Coin;
Expand All @@ -316,17 +308,27 @@ impl UtxoCoinBuilder for Qrc20CoinBuilder<'_> {
self.priv_key_policy.clone()
}

async fn build(self) -> MmResult<Self::ResultCoin, Self::Error> {
let utxo = match self.priv_key_policy() {
PrivKeyBuildPolicy::IguanaPrivKey(priv_key) => self.build_utxo_fields_with_iguana_secret(priv_key).await?,
async fn build_utxo_fields(&self) -> UtxoCoinBuildResult<UtxoCoinFields> {
match self.priv_key_policy() {
PrivKeyBuildPolicy::IguanaPrivKey(priv_key) => build_utxo_fields_with_iguana_priv_key(self, priv_key).await,
PrivKeyBuildPolicy::GlobalHDAccount(global_hd_ctx) => {
self.build_utxo_fields_with_global_hd(global_hd_ctx).await?
build_utxo_fields_with_global_hd(self, global_hd_ctx).await
},
PrivKeyBuildPolicy::Trezor => {
let priv_key_err = PrivKeyPolicyNotAllowed::HardwareWalletNotSupported;
return MmError::err(UtxoCoinBuildError::PrivKeyPolicyNotAllowed(priv_key_err));
MmError::err(UtxoCoinBuildError::PrivKeyPolicyNotAllowed(priv_key_err))
},
};
PrivKeyBuildPolicy::WalletConnect { .. } => {
let priv_key_err = PrivKeyPolicyNotAllowed::UnsupportedMethod(
"WalletConnect is not available for QRC20 coin".to_string(),
);
MmError::err(UtxoCoinBuildError::PrivKeyPolicyNotAllowed(priv_key_err))
},
}
}

async fn build(self) -> MmResult<Self::ResultCoin, Self::Error> {
let utxo = self.build_utxo_fields().await?;

let inner = Qrc20CoinFields {
utxo,
Expand Down Expand Up @@ -1102,7 +1104,8 @@ impl MarketCoinOps for Qrc20Coin {
}

fn sign_message_hash(&self, message: &str) -> Option<[u8; 32]> {
utxo_common::sign_message_hash(self.as_ref(), message)
let prefix = self.as_ref().conf.sign_message_prefix.as_ref()?;
Some(sign_message_hash(prefix, message))
}

fn sign_message(&self, message: &str, address: Option<HDAddressSelector>) -> SignatureResult<String> {
Expand Down
3 changes: 2 additions & 1 deletion mm2src/coins/rpc_command/init_create_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ impl RpcTask for InitCreateAccountTask {
self.task_state.clone(),
task_handle,
utxo.is_trezor(),
CoinProtocol::UTXO,
// Note that the actual UtxoProtocolInfo isn't needed by trezor XPUB extractor.
CoinProtocol::UTXO(Default::default()),
)
.await?,
)),
Expand Down
2 changes: 1 addition & 1 deletion mm2src/coins/rpc_command/offline_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn extract_prefix_values(

match protocol {
CoinProtocol::ETH { .. } | CoinProtocol::ERC20 { .. } | CoinProtocol::NFT { .. } => Ok(None),
CoinProtocol::UTXO | CoinProtocol::QTUM | CoinProtocol::QRC20 { .. } | CoinProtocol::BCH { .. } => {
CoinProtocol::UTXO { .. } | CoinProtocol::QTUM | CoinProtocol::QRC20 { .. } | CoinProtocol::BCH { .. } => {
let wif_type = coin_conf["wiftype"]
.as_u64()
.ok_or_else(|| OfflineKeysError::MissingPrefixValue {
Expand Down
Loading
Loading