}
});
+ connect(m_wallet, &Wallet::transactionProofVerified, this, &VerifyProofDialog::onTxProofVerified);
+ connect(m_wallet, &Wallet::spendProofVerified, this, &VerifyProofDialog::onSpendProofVerified);
+
ui->input_formattedProof->setFont(ModelUtils::getMonospaceFont());
}
void VerifyProofDialog::checkTxProof(const QString &txId, const QString &address, const QString &message,
const QString &signature) {
- TxProofResult r = m_wallet->checkTxProof(txId, address, message, signature);
-
- if (!r.success) {
- this->proofStatus(false, m_wallet->errorString());
- return;
- }
-
- if (!r.good) {
- this->proofStatus(false, "Proof is invalid");
- return;
- }
-
- this->proofStatus(true, QString("Proof is valid.\n\nThis address received %1 XMR, with %2 confirmation(s)").arg(WalletManager::displayAmount(r.received), QString::number(r.confirmations)));
+ ui->btn_verifyFormattedProof->setEnabled(false);
+ ui->btn_verify->setEnabled(false);
+ m_wallet->checkTxProofAsync(txId, address, message, signature);
}
void VerifyProofDialog::checkSpendProof(const QString &txId, const QString &message, const QString &signature) {
- auto r = m_wallet->checkSpendProof(txId, message, signature);
-
- if (!r.first) {
- this->proofStatus(false, m_wallet->errorString());
- return;
- }
-
- r.second ? this->proofStatus(true, "Proof is valid")
- : this->proofStatus(false, "Proof is invalid");
+ ui->btn_verifyFormattedProof->setEnabled(false);
+ ui->btn_verify->setEnabled(false);
+ m_wallet->checkSpendProofAsync(txId, message, signature);
}
void VerifyProofDialog::checkOutProof() {
ui->frame_status->show();
ui->label_icon->setPixmap(success ? m_success : m_failure);
ui->label_status->setText(message);
+ ui->btn_verifyFormattedProof->setEnabled(true);
}
else {
+ ui->btn_verify->setEnabled(true);
success ? QMessageBox::information(this, "Information", message)
: QMessageBox::warning(this, "Warning", message);
}
}
+void VerifyProofDialog::onTxProofVerified(TxProofResult r) {
+ if (!r.success) {
+ this->proofStatus(false, m_wallet->errorString());
+ return;
+ }
+
+ if (!r.good) {
+ this->proofStatus(false, "Proof is invalid");
+ return;
+ }
+
+ this->proofStatus(true, QString("Proof is valid.\n\nThis address received %1 XMR, with %2 confirmation(s)").arg(WalletManager::displayAmount(r.received), QString::number(r.confirmations)));
+}
+
+void VerifyProofDialog::onSpendProofVerified(QPair<bool, bool> r) {
+ if (!r.first) {
+ this->proofStatus(false, m_wallet->errorString());
+ return;
+ }
+
+ r.second ? this->proofStatus(true, "Proof is valid")
+ : this->proofStatus(false, "Proof is invalid");
+}
+
VerifyProofDialog::~VerifyProofDialog() = default;
\ No newline at end of file
void checkInProof();
void checkFormattedProof();
void proofStatus(bool success, const QString &message);
+ void onTxProofVerified(TxProofResult result);
+ void onSpendProofVerified(QPair<bool, bool> result);
QScopedPointer<Ui::VerifyProofDialog> ui;
Wallet *m_wallet;
return {success, good, received, in_pool, confirmations};
}
+void Wallet::checkTxProofAsync(const QString &txid, const QString &address, const QString &message,
+ const QString &signature) {
+ m_scheduler.run([this, txid, address, message, signature] {
+ auto result = this->checkTxProof(txid, address, message, signature);
+ emit transactionProofVerified(result);
+ });
+}
+
Q_INVOKABLE TxProof Wallet::getSpendProof(const QString &txid, const QString &message) const
{
std::string result = m_walletImpl->getSpendProof(txid.toStdString(), message.toStdString());
return {success, good};
}
+void Wallet::checkSpendProofAsync(const QString &txid, const QString &message, const QString &signature) {
+ m_scheduler.run([this, txid, message, signature] {
+ auto result = this->checkSpendProof(txid, message, signature);
+ emit spendProofVerified(result);
+ });
+}
+
QString Wallet::signMessage(const QString &message, bool filename, const QString &address) const
{
if (filename) {
class CoinsModel;
struct TxProofResult {
+ TxProofResult() {}
TxProofResult(bool success, bool good, uint64_t received, bool in_pool, uint64_t confirmations)
: success(success), good(good), received(received), in_pool(in_pool), confirmations(confirmations){}
// void getTxProofAsync(const QString &txid, const QString &address, const QString &message, const QJSValue &callback);
//QString checkTxProof(const QString &txid, const QString &address, const QString &message, const QString &signature);
TxProofResult checkTxProof(const QString &txid, const QString &address, const QString &message, const QString &signature);
+ void checkTxProofAsync(const QString &txid, const QString &address, const QString &message, const QString &signature);
TxProof getSpendProof(const QString &txid, const QString &message) const;
// void getSpendProofAsync(const QString &txid, const QString &message, const QJSValue &callback);
QPair<bool, bool> checkSpendProof(const QString &txid, const QString &message, const QString &signature) const;
+ void checkSpendProofAsync(const QString &txid, const QString &message, const QString &signature);
// Rescan spent outputs
bool rescanSpent();
void transactionCommitted(bool status, PendingTransaction *t, const QStringList& txid);
void heightRefreshed(quint64 walletHeight, quint64 daemonHeight, quint64 targetHeight) const;
void deviceShowAddressShowed();
+ void transactionProofVerified(TxProofResult result);
+ void spendProofVerified(QPair<bool, bool> result);
// emitted when transaction is created async
void transactionCreated(PendingTransaction * transaction, QVector<QString> address);
qInstallMessageHandler(Utils::applicationLogHandler);
qRegisterMetaType<QVector<QString>>();
+ qRegisterMetaType<TxProofResult>("TxProofResult");
+ qRegisterMetaType<QPair<bool, bool>>();
WindowManager windowManager;