Merge pull request #807

a7f52db History: Support coinbase txs requires #2247 (Jaquee)
This commit is contained in:
Riccardo Spagni 2017-08-23 21:22:50 +02:00
commit c04417d37b
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
6 changed files with 18 additions and 5 deletions

View file

@ -259,11 +259,11 @@ ListView {
//elide: Text.ElideRight //elide: Text.ElideRight
font.family: "Arial" font.family: "Arial"
font.pixelSize: 13 font.pixelSize: 13
color: (confirmations < 10)? "#FF6C3C" : "#545454" color: (confirmations < confirmationsRequired)? "#FF6C3C" : "#545454"
text: { text: {
if (!isPending) if (!isPending)
if(confirmations < 10) if(confirmations < confirmationsRequired)
return blockHeight + " " + qsTr("(%1/10 confirmations)").arg(confirmations) return blockHeight + " " + qsTr("(%1/%2 confirmations)").arg(confirmations).arg(confirmationsRequired)
else else
return blockHeight return blockHeight
if (!isOut) if (!isOut)

View file

@ -45,11 +45,12 @@ QList<TransactionInfo *> TransactionHistory::getAll() const
if (ti->timestamp() <= firstDateTime) { if (ti->timestamp() <= firstDateTime) {
firstDateTime = ti->timestamp(); firstDateTime = ti->timestamp();
} }
quint64 requiredConfirmations = (ti->blockHeight() < ti->unlockTime()) ? ti->unlockTime() - ti->blockHeight() : 0;
// store last tx height // store last tx height
if (ti->confirmations() < 10 && ti->blockHeight() >= lastTxHeight ){ if (ti->confirmations() < requiredConfirmations && ti->blockHeight() >= lastTxHeight) {
lastTxHeight = ti->blockHeight(); lastTxHeight = ti->blockHeight();
// TODO: Fetch block time and confirmations needed from wallet2? // TODO: Fetch block time and confirmations needed from wallet2?
m_minutesToUnlock = (10 - ti->confirmations()) * 2; m_minutesToUnlock = (requiredConfirmations - ti->confirmations()) * 2;
m_locked = true; m_locked = true;
} }

View file

@ -51,6 +51,11 @@ quint64 TransactionInfo::confirmations() const
return m_pimpl->confirmations(); return m_pimpl->confirmations();
} }
quint64 TransactionInfo::unlockTime() const
{
return m_pimpl->unlockTime();
}
QString TransactionInfo::hash() const QString TransactionInfo::hash() const
{ {
return QString::fromStdString(m_pimpl->hash()); return QString::fromStdString(m_pimpl->hash());

View file

@ -19,6 +19,7 @@ class TransactionInfo : public QObject
Q_PROPERTY(QString fee READ fee) Q_PROPERTY(QString fee READ fee)
Q_PROPERTY(quint64 blockHeight READ blockHeight) Q_PROPERTY(quint64 blockHeight READ blockHeight)
Q_PROPERTY(quint64 confirmations READ confirmations) Q_PROPERTY(quint64 confirmations READ confirmations)
Q_PROPERTY(quint64 unlockTime READ unlockTime)
Q_PROPERTY(QString hash READ hash) Q_PROPERTY(QString hash READ hash)
Q_PROPERTY(QDateTime timestamp READ timestamp) Q_PROPERTY(QDateTime timestamp READ timestamp)
Q_PROPERTY(QString date READ date) Q_PROPERTY(QString date READ date)
@ -44,6 +45,7 @@ public:
QString fee() const; QString fee() const;
quint64 blockHeight() const; quint64 blockHeight() const;
quint64 confirmations() const; quint64 confirmations() const;
quint64 unlockTime() const;
//! transaction_id //! transaction_id
QString hash() const; QString hash() const;
QDateTime timestamp() const; QDateTime timestamp() const;

View file

@ -85,6 +85,9 @@ QVariant TransactionHistoryModel::data(const QModelIndex &index, int role) const
case TransactionConfirmationsRole: case TransactionConfirmationsRole:
result = tInfo->confirmations(); result = tInfo->confirmations();
break; break;
case TransactionConfirmationsRequiredRole:
result = (tInfo->blockHeight() < tInfo->unlockTime()) ? tInfo->unlockTime() - tInfo->blockHeight() : 0;
break;
case TransactionHashRole: case TransactionHashRole:
result = tInfo->hash(); result = tInfo->hash();
break; break;
@ -130,6 +133,7 @@ QHash<int, QByteArray> TransactionHistoryModel::roleNames() const
roleNames.insert(TransactionFeeRole, "fee"); roleNames.insert(TransactionFeeRole, "fee");
roleNames.insert(TransactionBlockHeightRole, "blockHeight"); roleNames.insert(TransactionBlockHeightRole, "blockHeight");
roleNames.insert(TransactionConfirmationsRole, "confirmations"); roleNames.insert(TransactionConfirmationsRole, "confirmations");
roleNames.insert(TransactionConfirmationsRequiredRole, "confirmationsRequired");
roleNames.insert(TransactionHashRole, "hash"); roleNames.insert(TransactionHashRole, "hash");
roleNames.insert(TransactionTimeStampRole, "timeStamp"); roleNames.insert(TransactionTimeStampRole, "timeStamp");
roleNames.insert(TransactionPaymentIdRole, "paymentId"); roleNames.insert(TransactionPaymentIdRole, "paymentId");

View file

@ -26,6 +26,7 @@ public:
TransactionFeeRole, TransactionFeeRole,
TransactionBlockHeightRole, TransactionBlockHeightRole,
TransactionConfirmationsRole, TransactionConfirmationsRole,
TransactionConfirmationsRequiredRole,
TransactionHashRole, TransactionHashRole,
TransactionTimeStampRole, TransactionTimeStampRole,
TransactionPaymentIdRole, TransactionPaymentIdRole,