diff --git a/components/HistoryTable.qml b/components/HistoryTable.qml index 933c606c..082822d3 100644 --- a/components/HistoryTable.qml +++ b/components/HistoryTable.qml @@ -259,11 +259,11 @@ ListView { //elide: Text.ElideRight font.family: "Arial" font.pixelSize: 13 - color: (confirmations < 10)? "#FF6C3C" : "#545454" + color: (confirmations < confirmationsRequired)? "#FF6C3C" : "#545454" text: { if (!isPending) - if(confirmations < 10) - return blockHeight + " " + qsTr("(%1/10 confirmations)").arg(confirmations) + if(confirmations < confirmationsRequired) + return blockHeight + " " + qsTr("(%1/%2 confirmations)").arg(confirmations).arg(confirmationsRequired) else return blockHeight if (!isOut) diff --git a/src/libwalletqt/TransactionHistory.cpp b/src/libwalletqt/TransactionHistory.cpp index 9cd22bee..31e8952e 100644 --- a/src/libwalletqt/TransactionHistory.cpp +++ b/src/libwalletqt/TransactionHistory.cpp @@ -45,11 +45,12 @@ QList TransactionHistory::getAll() const if (ti->timestamp() <= firstDateTime) { firstDateTime = ti->timestamp(); } + quint64 requiredConfirmations = (ti->blockHeight() < ti->unlockTime()) ? ti->unlockTime() - ti->blockHeight() : 0; // store last tx height - if (ti->confirmations() < 10 && ti->blockHeight() >= lastTxHeight ){ + if (ti->confirmations() < requiredConfirmations && ti->blockHeight() >= lastTxHeight) { lastTxHeight = ti->blockHeight(); // TODO: Fetch block time and confirmations needed from wallet2? - m_minutesToUnlock = (10 - ti->confirmations()) * 2; + m_minutesToUnlock = (requiredConfirmations - ti->confirmations()) * 2; m_locked = true; } diff --git a/src/libwalletqt/TransactionInfo.cpp b/src/libwalletqt/TransactionInfo.cpp index 71df2b02..5ad739bf 100644 --- a/src/libwalletqt/TransactionInfo.cpp +++ b/src/libwalletqt/TransactionInfo.cpp @@ -51,6 +51,11 @@ quint64 TransactionInfo::confirmations() const return m_pimpl->confirmations(); } +quint64 TransactionInfo::unlockTime() const +{ + return m_pimpl->unlockTime(); +} + QString TransactionInfo::hash() const { return QString::fromStdString(m_pimpl->hash()); diff --git a/src/libwalletqt/TransactionInfo.h b/src/libwalletqt/TransactionInfo.h index 30418b88..fa13a3be 100644 --- a/src/libwalletqt/TransactionInfo.h +++ b/src/libwalletqt/TransactionInfo.h @@ -19,6 +19,7 @@ class TransactionInfo : public QObject Q_PROPERTY(QString fee READ fee) Q_PROPERTY(quint64 blockHeight READ blockHeight) Q_PROPERTY(quint64 confirmations READ confirmations) + Q_PROPERTY(quint64 unlockTime READ unlockTime) Q_PROPERTY(QString hash READ hash) Q_PROPERTY(QDateTime timestamp READ timestamp) Q_PROPERTY(QString date READ date) @@ -44,6 +45,7 @@ public: QString fee() const; quint64 blockHeight() const; quint64 confirmations() const; + quint64 unlockTime() const; //! transaction_id QString hash() const; QDateTime timestamp() const; diff --git a/src/model/TransactionHistoryModel.cpp b/src/model/TransactionHistoryModel.cpp index 2e232259..c1f61fa1 100644 --- a/src/model/TransactionHistoryModel.cpp +++ b/src/model/TransactionHistoryModel.cpp @@ -85,6 +85,9 @@ QVariant TransactionHistoryModel::data(const QModelIndex &index, int role) const case TransactionConfirmationsRole: result = tInfo->confirmations(); break; + case TransactionConfirmationsRequiredRole: + result = (tInfo->blockHeight() < tInfo->unlockTime()) ? tInfo->unlockTime() - tInfo->blockHeight() : 0; + break; case TransactionHashRole: result = tInfo->hash(); break; @@ -130,6 +133,7 @@ QHash TransactionHistoryModel::roleNames() const roleNames.insert(TransactionFeeRole, "fee"); roleNames.insert(TransactionBlockHeightRole, "blockHeight"); roleNames.insert(TransactionConfirmationsRole, "confirmations"); + roleNames.insert(TransactionConfirmationsRequiredRole, "confirmationsRequired"); roleNames.insert(TransactionHashRole, "hash"); roleNames.insert(TransactionTimeStampRole, "timeStamp"); roleNames.insert(TransactionPaymentIdRole, "paymentId"); diff --git a/src/model/TransactionHistoryModel.h b/src/model/TransactionHistoryModel.h index 449d8003..a2dbd967 100644 --- a/src/model/TransactionHistoryModel.h +++ b/src/model/TransactionHistoryModel.h @@ -26,6 +26,7 @@ public: TransactionFeeRole, TransactionBlockHeightRole, TransactionConfirmationsRole, + TransactionConfirmationsRequiredRole, TransactionHashRole, TransactionTimeStampRole, TransactionPaymentIdRole,