mirror of
https://github.com/monero-project/monero.git
synced 2026-01-13 05:16:48 -08:00
wallet_api: signMessage: add sign with subaddress
This commit is contained in:
@@ -2063,9 +2063,24 @@ bool WalletImpl::checkReserveProof(const std::string &address, const std::string
|
||||
}
|
||||
}
|
||||
|
||||
std::string WalletImpl::signMessage(const std::string &message)
|
||||
std::string WalletImpl::signMessage(const std::string &message, const std::string &address)
|
||||
{
|
||||
return m_wallet->sign(message, tools::wallet2::sign_with_spend_key);
|
||||
if (address.empty()) {
|
||||
return m_wallet->sign(message, tools::wallet2::sign_with_spend_key);
|
||||
}
|
||||
|
||||
cryptonote::address_parse_info info;
|
||||
if (!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), address)) {
|
||||
setStatusError(tr("Failed to parse address"));
|
||||
return "";
|
||||
}
|
||||
auto index = m_wallet->get_subaddress_index(info.address);
|
||||
if (!index) {
|
||||
setStatusError(tr("Address doesn't belong to the wallet"));
|
||||
return "";
|
||||
}
|
||||
|
||||
return m_wallet->sign(message, tools::wallet2::sign_with_spend_key, *index);
|
||||
}
|
||||
|
||||
bool WalletImpl::verifySignedMessage(const std::string &message, const std::string &address, const std::string &signature) const
|
||||
|
||||
Reference in New Issue
Block a user