diff options
author | stoffu <stoffu@protonmail.ch> | 2017-08-29 00:34:17 +0900 |
---|---|---|
committer | stoffu <stoffu@protonmail.ch> | 2017-11-21 16:49:16 +0900 |
commit | b0b7e0f09a7b7e8c8dcd7b668f3504d73a6914fe (patch) | |
tree | 95e5c1c96123b479df56493eda6c83ab7b1c12e6 /src/wallet/api | |
parent | Merge pull request #2783 (diff) | |
download | monero-b0b7e0f09a7b7e8c8dcd7b668f3504d73a6914fe.tar.xz |
Spend proof without txkey
Diffstat (limited to 'src/wallet/api')
-rw-r--r-- | src/wallet/api/wallet.cpp | 46 | ||||
-rw-r--r-- | src/wallet/api/wallet.h | 2 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index db8911042..e0326db84 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -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); diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h index ecf540f22..38e167516 100644 --- a/src/wallet/api/wallet.h +++ b/src/wallet/api/wallet.h @@ -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, std::string &error_str) 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(); |