aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2021-06-24 14:06:13 -0500
committerluigi1111 <luigi1111w@gmail.com>2021-06-24 14:06:13 -0500
commit99aa45fd34ef7c5a7a105dc7ed1131b734a296f1 (patch)
treeca930ea2d3c3545a3ff7b0dd54d7140baaefb60a /src/wallet
parentMerge pull request #7742 (diff)
parentwallet_api: signMessage: add sign with subaddress (diff)
downloadmonero-99aa45fd34ef7c5a7a105dc7ed1131b734a296f1.tar.xz
Merge pull request #7746
1aa1850 wallet_api: signMessage: add sign with subaddress (tobtoht)
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/api/wallet.cpp19
-rw-r--r--src/wallet/api/wallet.h2
-rw-r--r--src/wallet/api/wallet2_api.h2
3 files changed, 19 insertions, 4 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 31d772457..e9586c163 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -2058,9 +2058,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
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h
index dbbcda500..459990830 100644
--- a/src/wallet/api/wallet.h
+++ b/src/wallet/api/wallet.h
@@ -196,7 +196,7 @@ public:
virtual bool checkSpendProof(const std::string &txid, const std::string &message, const std::string &signature, bool &good) const override;
virtual std::string getReserveProof(bool all, uint32_t account_index, uint64_t amount, const std::string &message) const override;
virtual bool checkReserveProof(const std::string &address, const std::string &message, const std::string &signature, bool &good, uint64_t &total, uint64_t &spent) const override;
- virtual std::string signMessage(const std::string &message) override;
+ virtual std::string signMessage(const std::string &message, const std::string &address) override;
virtual bool verifySignedMessage(const std::string &message, const std::string &address, const std::string &signature) const override;
virtual std::string signMultisigParticipant(const std::string &message) const override;
virtual bool verifyMessageWithPublicKey(const std::string &message, const std::string &publicKey, const std::string &signature) const override;
diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h
index 755e32bfd..4e10a8d03 100644
--- a/src/wallet/api/wallet2_api.h
+++ b/src/wallet/api/wallet2_api.h
@@ -993,7 +993,7 @@ struct Wallet
* \param message - the message to sign (arbitrary byte data)
* \return the signature
*/
- virtual std::string signMessage(const std::string &message) = 0;
+ virtual std::string signMessage(const std::string &message, const std::string &address = "") = 0;
/*!
* \brief verifySignedMessage - verify a signature matches a given message
* \param message - the message (arbitrary byte data)