Merge pull request #2368

b0b7e0f0 Spend proof without txkey (stoffu)
This commit is contained in:
Riccardo Spagni 2017-11-25 19:48:56 +02:00
commit 539f511eb1
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
10 changed files with 473 additions and 0 deletions

View file

@ -1530,6 +1530,52 @@ bool WalletImpl::checkTxProof(const std::string &txid_str, const std::string &ad
}
}
std::string WalletImpl::getSpendProof(const std::string &txid_str, const std::string &message) const {
crypto::hash txid;
if(!epee::string_tools::hex_to_pod(txid_str, txid))
{
m_status = Status_Error;
m_errorString = tr("Failed to parse txid");
return "";
}
try
{
m_status = Status_Ok;
return m_wallet->get_spend_proof(txid, message);
}
catch (const std::exception &e)
{
m_status = Status_Error;
m_errorString = e.what();
return "";
}
}
bool WalletImpl::checkSpendProof(const std::string &txid_str, const std::string &message, const std::string &signature, bool &good) const {
good = false;
crypto::hash txid;
if(!epee::string_tools::hex_to_pod(txid_str, txid))
{
m_status = Status_Error;
m_errorString = tr("Failed to parse txid");
return false;
}
try
{
m_status = Status_Ok;
good = m_wallet->check_spend_proof(txid, message, signature);
return true;
}
catch (const std::exception &e)
{
m_status = Status_Error;
m_errorString = e.what();
return false;
}
}
std::string WalletImpl::signMessage(const std::string &message)
{
return m_wallet->sign(message);

View file

@ -140,6 +140,8 @@ public:
virtual bool checkTxKey(const std::string &txid, std::string tx_key, const std::string &address, uint64_t &received, bool &in_pool, uint64_t &confirmations);
virtual std::string getTxProof(const std::string &txid, const std::string &address, const std::string &message) const;
virtual bool checkTxProof(const std::string &txid, const std::string &address, const std::string &message, const std::string &signature, bool &good, uint64_t &received, bool &in_pool, uint64_t &confirmations);
virtual std::string getSpendProof(const std::string &txid, const std::string &message) const;
virtual bool checkSpendProof(const std::string &txid, const std::string &message, const std::string &signature, bool &good) 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;
virtual void startRefresh();