mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-23 10:08:33 +02:00
implement sign() and verify()
This commit is contained in:
@@ -1322,6 +1322,35 @@ namespace monero {
|
||||
}
|
||||
}
|
||||
|
||||
string MoneroWallet::sign(const string& msg) const {
|
||||
return wallet2->sign(msg);
|
||||
}
|
||||
|
||||
bool MoneroWallet::verify(const string& msg, const string& address, const string& signature) const {
|
||||
|
||||
// validate and parse address or url
|
||||
cryptonote::address_parse_info info;
|
||||
string err;
|
||||
if (!get_account_address_from_str_or_url(info, wallet2->nettype(), address,
|
||||
[&err](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid)->std::string {
|
||||
if (!dnssec_valid) {
|
||||
err = std::string("Invalid DNSSEC for ") + url;
|
||||
return {};
|
||||
}
|
||||
if (addresses.empty()) {
|
||||
err = std::string("No Monero address found at ") + url;
|
||||
return {};
|
||||
}
|
||||
return addresses[0];
|
||||
}))
|
||||
{
|
||||
throw runtime_error(err);
|
||||
}
|
||||
|
||||
// verify and return result
|
||||
return wallet2->verify(msg, info.address, signature);
|
||||
}
|
||||
|
||||
string MoneroWallet::createPaymentUri(const MoneroSendRequest& request) const {
|
||||
cout << "createPaymentUri()" << endl;
|
||||
|
||||
|
||||
+18
-18
@@ -791,24 +791,24 @@ namespace monero {
|
||||
*/
|
||||
void setTxNotes(const vector<string>& txIds, const vector<string>& notes);
|
||||
|
||||
// /**
|
||||
// * Sign a message.
|
||||
// *
|
||||
// * @param msg is the message to sign
|
||||
// * @return the signature
|
||||
// */
|
||||
// public string sign(string msg);
|
||||
//
|
||||
// /**
|
||||
// * Verify a signature on a message.
|
||||
// *
|
||||
// * @param msg is the signed message
|
||||
// * @param address is the signing address
|
||||
// * @param signature is the signature
|
||||
// * @return true if the signature is good, false otherwise
|
||||
// */
|
||||
// public boolean verify(string msg, string address, string signature);
|
||||
//
|
||||
/**
|
||||
* Sign a message.
|
||||
*
|
||||
* @param msg is the message to sign
|
||||
* @return the signature
|
||||
*/
|
||||
string sign(const string& msg) const;
|
||||
|
||||
/**
|
||||
* Verify a signature on a message.
|
||||
*
|
||||
* @param msg is the signed message
|
||||
* @param address is the signing address
|
||||
* @param signature is the signature
|
||||
* @return true if the signature is good, false otherwise
|
||||
*/
|
||||
bool verify(const string& msg, const string& address, const string& signature) const;
|
||||
|
||||
// /**
|
||||
// * Get a transaction's secret key from its id.
|
||||
// *
|
||||
|
||||
Reference in New Issue
Block a user