This commit is contained in:
stoffu
2017-09-12 17:42:00 +09:00
parent da020fd0be
commit d79fe0f457
8 changed files with 285 additions and 133 deletions

View File

@@ -494,6 +494,36 @@ QString Wallet::getTxKey(const QString &txid) const
return QString::fromStdString(m_walletImpl->getTxKey(txid.toStdString()));
}
QString Wallet::checkTxKey(const QString &txid, const QString &tx_key, const QString &address)
{
uint64_t received;
bool in_pool;
uint64_t confirmations;
bool success = m_walletImpl->checkTxKey(txid.toStdString(), tx_key.toStdString(), address.toStdString(), received, in_pool, confirmations);
std::string result = std::string(success ? "true" : "false") + "|" + QString::number(received).toStdString() + "|" + std::string(in_pool ? "true" : "false") + "|" + QString::number(confirmations).toStdString();
return QString::fromStdString(result);
}
QString Wallet::getTxProof(const QString &txid, const QString &address, const QString &message) const
{
std::string error_str;
QString result = QString::fromStdString(m_walletImpl->getTxProof(txid.toStdString(), address.toStdString(), message.toStdString(), error_str));
if (!error_str.empty())
result = QString::fromStdString("error|" + error_str);
return result;
}
QString Wallet::checkTxProof(const QString &txid, const QString &address, const QString &message, const QString &signature)
{
bool good;
uint64_t received;
bool in_pool;
uint64_t confirmations;
bool success = m_walletImpl->checkTxProof(txid.toStdString(), address.toStdString(), message.toStdString(), signature.toStdString(), good, received, in_pool, confirmations);
std::string result = std::string(success ? "true" : "false") + "|" + std::string(good ? "true" : "false") + "|" + QString::number(received).toStdString() + "|" + std::string(in_pool ? "true" : "false") + "|" + QString::number(confirmations).toStdString();
return QString::fromStdString(result);
}
QString Wallet::signMessage(const QString &message, bool filename) const
{
if (filename) {

View File

@@ -232,6 +232,9 @@ public:
Q_INVOKABLE bool setUserNote(const QString &txid, const QString &note);
Q_INVOKABLE QString getUserNote(const QString &txid) const;
Q_INVOKABLE QString getTxKey(const QString &txid) const;
Q_INVOKABLE QString checkTxKey(const QString &txid, const QString &tx_key, const QString &address);
Q_INVOKABLE QString getTxProof(const QString &txid, const QString &address, const QString &message) const;
Q_INVOKABLE QString checkTxProof(const QString &txid, const QString &address, const QString &message, const QString &signature);
// Rescan spent outputs
Q_INVOKABLE bool rescanSpent();

View File

@@ -216,16 +216,6 @@ QString WalletManager::paymentIdFromAddress(const QString &address, bool testnet
return QString::fromStdString(Monero::Wallet::paymentIdFromAddress(address.toStdString(), testnet));
}
QString WalletManager::checkPayment(const QString &address, const QString &txid, const QString &txkey, const QString &daemon_address) const
{
uint64_t received = 0, height = 0;
std::string error = "";
bool ret = m_pimpl->checkPayment(address.toStdString(), txid.toStdString(), txkey.toStdString(), daemon_address.toStdString(), received, height, error);
// bypass qml being unable to pass structures without preposterous complexity
std::string result = std::string(ret ? "true" : "false") + "|" + QString::number(received).toStdString() + "|" + QString::number(height).toStdString() + "|" + error;
return QString::fromStdString(result);
}
void WalletManager::setDaemonAddress(const QString &address)
{
m_pimpl->setDaemonAddress(address.toStdString());

View File

@@ -104,8 +104,6 @@ public:
Q_INVOKABLE QString paymentIdFromAddress(const QString &address, bool testnet) const;
Q_INVOKABLE QString checkPayment(const QString &address, const QString &txid, const QString &txkey, const QString &daemon_address) const;
Q_INVOKABLE void setDaemonAddress(const QString &address);
Q_INVOKABLE bool connected() const;
Q_INVOKABLE quint64 networkDifficulty() const;