forked from Public/monero-gui
GUI cold signing
This commit is contained in:
@@ -13,7 +13,10 @@ QString PendingTransaction::errorString() const
|
||||
|
||||
bool PendingTransaction::commit()
|
||||
{
|
||||
return m_pimpl->commit();
|
||||
// Save transaction to file if fileName is set.
|
||||
if(!m_fileName.isEmpty())
|
||||
return m_pimpl->commit(m_fileName.toStdString());
|
||||
return m_pimpl->commit(m_fileName.toStdString());
|
||||
}
|
||||
|
||||
quint64 PendingTransaction::amount() const
|
||||
@@ -47,6 +50,11 @@ quint64 PendingTransaction::txCount() const
|
||||
return m_pimpl->txCount();
|
||||
}
|
||||
|
||||
void PendingTransaction::setFilename(const QString &fileName)
|
||||
{
|
||||
m_fileName = fileName;
|
||||
}
|
||||
|
||||
PendingTransaction::PendingTransaction(Monero::PendingTransaction *pt, QObject *parent)
|
||||
: QObject(parent), m_pimpl(pt)
|
||||
{
|
||||
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
quint64 fee() const;
|
||||
QStringList txid() const;
|
||||
quint64 txCount() const;
|
||||
Q_INVOKABLE void setFilename(const QString &fileName);
|
||||
|
||||
private:
|
||||
explicit PendingTransaction(Monero::PendingTransaction * pt, QObject *parent = 0);
|
||||
@@ -51,6 +52,7 @@ private:
|
||||
private:
|
||||
friend class Wallet;
|
||||
Monero::PendingTransaction * m_pimpl;
|
||||
QString m_fileName;
|
||||
};
|
||||
|
||||
#endif // PENDINGTRANSACTION_H
|
||||
|
||||
89
src/libwalletqt/UnsignedTransaction.cpp
Normal file
89
src/libwalletqt/UnsignedTransaction.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
#include "UnsignedTransaction.h"
|
||||
#include <QVector>
|
||||
#include <QDebug>
|
||||
|
||||
UnsignedTransaction::Status UnsignedTransaction::status() const
|
||||
{
|
||||
return static_cast<Status>(m_pimpl->status());
|
||||
}
|
||||
|
||||
QString UnsignedTransaction::errorString() const
|
||||
{
|
||||
return QString::fromStdString(m_pimpl->errorString());
|
||||
}
|
||||
|
||||
quint64 UnsignedTransaction::amount(int index) const
|
||||
{
|
||||
std::vector<uint64_t> arr = m_pimpl->amount();
|
||||
if(index > arr.size() - 1)
|
||||
return 0;
|
||||
return arr[index];
|
||||
}
|
||||
|
||||
quint64 UnsignedTransaction::fee(int index) const
|
||||
{
|
||||
std::vector<uint64_t> arr = m_pimpl->fee();
|
||||
if(index > arr.size() - 1)
|
||||
return 0;
|
||||
return arr[index];
|
||||
}
|
||||
|
||||
quint64 UnsignedTransaction::mixin(int index) const
|
||||
{
|
||||
std::vector<uint64_t> arr = m_pimpl->mixin();
|
||||
if(index > arr.size() - 1)
|
||||
return 0;
|
||||
return arr[index];
|
||||
}
|
||||
|
||||
quint64 UnsignedTransaction::txCount() const
|
||||
{
|
||||
return m_pimpl->txCount();
|
||||
}
|
||||
|
||||
quint64 UnsignedTransaction::minMixinCount() const
|
||||
{
|
||||
return m_pimpl->minMixinCount();
|
||||
}
|
||||
|
||||
QString UnsignedTransaction::confirmationMessage() const
|
||||
{
|
||||
return QString::fromStdString(m_pimpl->confirmationMessage());
|
||||
}
|
||||
|
||||
QStringList UnsignedTransaction::paymentId() const
|
||||
{
|
||||
QList<QString> list;
|
||||
for (const auto &t: m_pimpl->paymentId())
|
||||
list.append(QString::fromStdString(t));
|
||||
return list;
|
||||
}
|
||||
|
||||
QStringList UnsignedTransaction::recipientAddress() const
|
||||
{
|
||||
QList<QString> list;
|
||||
for (const auto &t: m_pimpl->recipientAddress())
|
||||
list.append(QString::fromStdString(t));
|
||||
return list;
|
||||
}
|
||||
|
||||
bool UnsignedTransaction::sign(const QString &fileName) const
|
||||
{
|
||||
return m_pimpl->sign(fileName.toStdString());
|
||||
}
|
||||
|
||||
void UnsignedTransaction::setFilename(const QString &fileName)
|
||||
{
|
||||
m_fileName = fileName;
|
||||
}
|
||||
|
||||
UnsignedTransaction::UnsignedTransaction(Monero::UnsignedTransaction *pt, QObject *parent)
|
||||
: QObject(parent), m_pimpl(pt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
UnsignedTransaction::~UnsignedTransaction()
|
||||
{
|
||||
delete m_pimpl;
|
||||
}
|
||||
58
src/libwalletqt/UnsignedTransaction.h
Normal file
58
src/libwalletqt/UnsignedTransaction.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef UNSIGNEDTRANSACTION_H
|
||||
#define UNSIGNEDTRANSACTION_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <wallet/wallet2_api.h>
|
||||
|
||||
class UnsignedTransaction : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Status status READ status)
|
||||
Q_PROPERTY(QString errorString READ errorString)
|
||||
// Q_PROPERTY(QList<qulonglong> amount READ amount)
|
||||
// Q_PROPERTY(QList<qulonglong> fee READ fee)
|
||||
Q_PROPERTY(quint64 txCount READ txCount)
|
||||
Q_PROPERTY(QString confirmationMessage READ confirmationMessage)
|
||||
Q_PROPERTY(QStringList recipientAddress READ recipientAddress)
|
||||
Q_PROPERTY(QStringList paymentId READ paymentId)
|
||||
Q_PROPERTY(quint64 minMixinCount READ minMixinCount)
|
||||
|
||||
public:
|
||||
enum Status {
|
||||
Status_Ok = Monero::UnsignedTransaction::Status_Ok,
|
||||
Status_Error = Monero::UnsignedTransaction::Status_Error,
|
||||
Status_Critical = Monero::UnsignedTransaction::Status_Critical
|
||||
};
|
||||
Q_ENUM(Status)
|
||||
|
||||
enum Priority {
|
||||
Priority_Low = Monero::UnsignedTransaction::Priority_Low,
|
||||
Priority_Medium = Monero::UnsignedTransaction::Priority_Medium,
|
||||
Priority_High = Monero::UnsignedTransaction::Priority_High
|
||||
};
|
||||
Q_ENUM(Priority)
|
||||
|
||||
Status status() const;
|
||||
QString errorString() const;
|
||||
Q_INVOKABLE quint64 amount(int index) const;
|
||||
Q_INVOKABLE quint64 fee(int index) const;
|
||||
Q_INVOKABLE quint64 mixin(int index) const;
|
||||
QStringList recipientAddress() const;
|
||||
QStringList paymentId() const;
|
||||
quint64 txCount() const;
|
||||
QString confirmationMessage() const;
|
||||
quint64 minMixinCount() const;
|
||||
Q_INVOKABLE bool sign(const QString &fileName) const;
|
||||
Q_INVOKABLE void setFilename(const QString &fileName);
|
||||
|
||||
private:
|
||||
explicit UnsignedTransaction(Monero::UnsignedTransaction * pt, QObject *parent = 0);
|
||||
~UnsignedTransaction();
|
||||
private:
|
||||
friend class Wallet;
|
||||
Monero::UnsignedTransaction * m_pimpl;
|
||||
QString m_fileName;
|
||||
};
|
||||
|
||||
#endif // UNSIGNEDTRANSACTION_H
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "Wallet.h"
|
||||
#include "PendingTransaction.h"
|
||||
#include "UnsignedTransaction.h"
|
||||
#include "TransactionHistory.h"
|
||||
#include "AddressBook.h"
|
||||
#include "model/TransactionHistoryModel.h"
|
||||
@@ -211,7 +212,6 @@ quint64 Wallet::daemonBlockChainHeight() const
|
||||
|
||||
quint64 Wallet::daemonBlockChainTargetHeight() const
|
||||
{
|
||||
|
||||
if (m_daemonBlockChainTargetHeight == 0
|
||||
|| m_daemonBlockChainTargetHeightTime.elapsed() / 1000 > m_daemonBlockChainTargetHeightTtl) {
|
||||
m_daemonBlockChainTargetHeight = m_walletImpl->daemonBlockChainTargetHeight();
|
||||
@@ -323,12 +323,31 @@ void Wallet::createSweepUnmixableTransactionAsync()
|
||||
});
|
||||
}
|
||||
|
||||
UnsignedTransaction * Wallet::loadTxFile(const QString &fileName)
|
||||
{
|
||||
qDebug() << "Trying to sign " << fileName;
|
||||
Monero::UnsignedTransaction * ptImpl = m_walletImpl->loadUnsignedTx(fileName.toStdString());
|
||||
UnsignedTransaction * result = new UnsignedTransaction(ptImpl, this);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Wallet::submitTxFile(const QString &fileName) const
|
||||
{
|
||||
qDebug() << "Trying to submit " << fileName;
|
||||
return m_walletImpl->submitTransaction(fileName.toStdString());
|
||||
}
|
||||
|
||||
void Wallet::disposeTransaction(PendingTransaction *t)
|
||||
{
|
||||
m_walletImpl->disposeTransaction(t->m_pimpl);
|
||||
delete t;
|
||||
}
|
||||
|
||||
void Wallet::disposeTransaction(UnsignedTransaction *t)
|
||||
{
|
||||
delete t;
|
||||
}
|
||||
|
||||
TransactionHistory *Wallet::history() const
|
||||
{
|
||||
return m_history;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "wallet/wallet2_api.h" // we need to have an access to the Monero::Wallet::Status enum here;
|
||||
#include "PendingTransaction.h" // we need to have an access to the PendingTransaction::Priority enum here;
|
||||
#include "UnsignedTransaction.h"
|
||||
|
||||
namespace Monero {
|
||||
class Wallet; // forward declaration
|
||||
@@ -162,9 +163,19 @@ public:
|
||||
//! creates async sweep unmixable transaction
|
||||
Q_INVOKABLE void createSweepUnmixableTransactionAsync();
|
||||
|
||||
//! Sign a transfer from file
|
||||
Q_INVOKABLE UnsignedTransaction * loadTxFile(const QString &fileName);
|
||||
|
||||
//! Submit a transfer from file
|
||||
Q_INVOKABLE bool submitTxFile(const QString &fileName) const;
|
||||
|
||||
|
||||
//! deletes transaction and frees memory
|
||||
Q_INVOKABLE void disposeTransaction(PendingTransaction * t);
|
||||
|
||||
//! deletes unsigned transaction and frees memory
|
||||
Q_INVOKABLE void disposeTransaction(UnsignedTransaction * t);
|
||||
|
||||
//! returns transaction history
|
||||
TransactionHistory * history() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user