diff options
| author | reemuru <rimuru@hiahatf.org> | 2022-01-18 16:10:56 -0500 |
|---|---|---|
| committer | reemuru <rimuru@hiahatf.org> | 2022-01-20 20:21:11 -0500 |
| commit | 0f67580e8fc1d98a67298ecc1d70ef926521657a (patch) | |
| tree | 713879567b1f4be71318b66ab66c557dd25680b5 /src/libwalletqt | |
| parent | a959919b8ad798d1384f83c5bf3ed7a2d16dc8aa (diff) | |
| download | monzero-gui-0f67580e8fc1d98a67298ecc1d70ef926521657a.tar.gz monzero-gui-0f67580e8fc1d98a67298ecc1d70ef926521657a.tar.xz monzero-gui-0f67580e8fc1d98a67298ecc1d70ef926521657a.zip | |
Advanced: ReserveProof: Add support for reserve proof
This change adds the ability to prove and check a reserve proof
to this existing "Prove/check" advanced menu. If the amount line has
a valid amount less than that of the current account index this input
will drive the logic for generating a reserve proof. Checking a reserve
proof is accomplished by validating the address and verifying that
signature.indexOf("ReserveProofV") === 0. The result displays the total
and spent amount of the proof.
Diffstat (limited to 'src/libwalletqt')
| -rw-r--r-- | src/libwalletqt/Wallet.cpp | 19 | ||||
| -rw-r--r-- | src/libwalletqt/Wallet.h | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index e19a810c..6c22c91a 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -844,6 +844,25 @@ Q_INVOKABLE QString Wallet::checkSpendProof(const QString &txid, const QString & return QString::fromStdString(result); } +Q_INVOKABLE QString Wallet::getReserveProof(bool all, quint32 account_index, quint64 amount, const QString &message) const +{ + qDebug("Generating reserve proof"); + std::string result = m_walletImpl->getReserveProof(all, account_index, amount, message.toStdString()); + if (result.empty()) + result = "error|" + m_walletImpl->errorString(); + return QString::fromStdString(result); +} + +Q_INVOKABLE QString Wallet::checkReserveProof(const QString &address, const QString &message, const QString &signature) const +{ + bool good; + u_int64_t total; + u_int64_t spent; + bool success = m_walletImpl->checkReserveProof(address.toStdString(), message.toStdString(), signature.toStdString(), good, total, spent); + std::string result = std::string(success ? "true" : "false") + "|" + std::string(good ? "true" : "false") + "|" + QString::number(total).toStdString() + "|" + QString::number(spent).toStdString(); + return QString::fromStdString(result); +} + QString Wallet::signMessage(const QString &message, bool filename) const { if (filename) { diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index 9b5bdd46..a81b4555 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -318,6 +318,8 @@ public: Q_INVOKABLE QString getSpendProof(const QString &txid, const QString &message) const; Q_INVOKABLE void getSpendProofAsync(const QString &txid, const QString &message, const QJSValue &callback); Q_INVOKABLE QString checkSpendProof(const QString &txid, const QString &message, const QString &signature) const; + Q_INVOKABLE QString getReserveProof(bool all, quint32 account_index, quint64 amount, const QString &message) const; + Q_INVOKABLE QString checkReserveProof(const QString &address, const QString &message, const QString &signature) const; // Rescan spent outputs Q_INVOKABLE bool rescanSpent(); |
