mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-30 11:13:13 +00:00
wallet2_api: API to sign and verify a message
This commit is contained in:
parent
e8a55db29d
commit
c441a61ef6
3 changed files with 35 additions and 0 deletions
|
@ -752,6 +752,23 @@ std::string WalletImpl::getTxKey(const std::string &txid) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string WalletImpl::signMessage(const std::string &message)
|
||||||
|
{
|
||||||
|
return m_wallet->sign(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WalletImpl::verifySignedMessage(const std::string &message, const std::string &address, const std::string &signature) const
|
||||||
|
{
|
||||||
|
cryptonote::account_public_address addr;
|
||||||
|
bool has_payment_id;
|
||||||
|
crypto::hash8 payment_id;
|
||||||
|
|
||||||
|
if (!cryptonote::get_account_integrated_address_from_str(addr, has_payment_id, payment_id, m_wallet->testnet(), address))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return m_wallet->verify(message, addr, signature);
|
||||||
|
}
|
||||||
|
|
||||||
bool WalletImpl::connectToDaemon()
|
bool WalletImpl::connectToDaemon()
|
||||||
{
|
{
|
||||||
bool result = m_wallet->check_connection();
|
bool result = m_wallet->check_connection();
|
||||||
|
|
|
@ -101,6 +101,9 @@ public:
|
||||||
virtual std::string getUserNote(const std::string &txid) const;
|
virtual std::string getUserNote(const std::string &txid) const;
|
||||||
virtual std::string getTxKey(const std::string &txid) const;
|
virtual std::string getTxKey(const std::string &txid) const;
|
||||||
|
|
||||||
|
virtual std::string signMessage(const std::string &message);
|
||||||
|
virtual bool verifySignedMessage(const std::string &message, const std::string &address, const std::string &signature) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clearStatus();
|
void clearStatus();
|
||||||
void refreshThreadFunc();
|
void refreshThreadFunc();
|
||||||
|
|
|
@ -362,6 +362,21 @@ struct Wallet
|
||||||
*/
|
*/
|
||||||
virtual std::string getUserNote(const std::string &txid) const = 0;
|
virtual std::string getUserNote(const std::string &txid) const = 0;
|
||||||
virtual std::string getTxKey(const std::string &txid) const = 0;
|
virtual std::string getTxKey(const std::string &txid) const = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* \brief signMessage - sign a message with the spend private key
|
||||||
|
* \param message - the message to sign (arbitrary byte data)
|
||||||
|
* \return the signature
|
||||||
|
*/
|
||||||
|
virtual std::string signMessage(const std::string &message) = 0;
|
||||||
|
/*!
|
||||||
|
* \brief verifySignedMessage - verify a signature matches a given message
|
||||||
|
* \param message - the message (arbitrary byte data)
|
||||||
|
* \param address - the address the signature claims to be made with
|
||||||
|
* \param signature - the signature
|
||||||
|
* \return true if the signature verified, false otherwise
|
||||||
|
*/
|
||||||
|
virtual bool verifySignedMessage(const std::string &message, const std::string &addres, const std::string &signature) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue