History: Support coinbase txs

requires #2247
This commit is contained in:
Jaquee 2017-08-03 21:43:01 +02:00
parent c68c317776
commit a7f52db613
6 changed files with 18 additions and 5 deletions

View File

@ -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)

View File

@ -45,11 +45,12 @@ QList<TransactionInfo *> 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;
}

View File

@ -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());

View File

@ -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;

View File

@ -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<int, QByteArray> 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");

View File

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