#include "wallet.h"
#include "base58.h"
-#include "main.h"
+
using namespace std;
return (GetAdjustedTime() - nTime) / 86400;
}
+uint64 KernelRecord::getCoinDay() const
+{
+ int64 nWeight = GetAdjustedTime() - nTime - nStakeMinAge;
+ if( nWeight < 0)
+ return 0;
+ nWeight = min(nWeight, (int64)nStakeMaxAge);
+ uint64 coinAge = (nValue * nWeight ) / (COIN * 86400);
+ return coinAge;
+}
+
+int64 KernelRecord::getPoSReward(int nBits, int minutes)
+{
+ double PoSReward;
+ int64 nWeight = GetAdjustedTime() - nTime + minutes * 60;
+ if( nWeight < nStakeMinAge)
+ return 0;
+ uint64 coinAge = (nValue * nWeight ) / (COIN * 86400);
+ PoSReward = GetProofOfStakeReward(coinAge, nBits, GetAdjustedTime() + minutes * 60);
+ return PoSReward;
+}
+
double KernelRecord::getProbToMintStake(double difficulty, int timeOffset) const
{
//double maxTarget = pow(static_cast<double>(2), 224);
std::string getTxID();
int64 getAge() const;
+ uint64 getCoinDay() const;
double getProbToMintStake(double difficulty, int timeOffset = 0) const;
double getProbToMintWithinNMinutes(double difficulty, int minutes);
+ int64 getPoSReward(int nBits, int timeOffset);
protected:
int prevMinutes;
double prevDifficulty;
QToolBar *toolbar2 = addToolBar(tr("Actions toolbar"));
toolbar2->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
toolbar2->addAction(exportAction);
+ toolbar2->setVisible(false);
+
}
void BitcoinGUI::setClientModel(ClientModel *clientModel)
#define EXPORT_IMAGE_SIZE 256
/* Colors for minting tab for each coin age group */
-#define COLOR_MINT_YOUNG QColor(127, 127, 240)
-#define COLOR_MINT_MATURE QColor(127, 240, 127)
-#define COLOR_MINT_OLD QColor(240, 127, 127)
+#define COLOR_MINT_YOUNG QColor(180, 180, 250)
+#define COLOR_MINT_MATURE QColor(180, 250, 180)
+#define COLOR_MINT_OLD QColor(250, 180, 180)
#endif // GUICONSTANTS_H
<translation>Показывать вероятность найти блок в течение : </translation>
</message>
<message>
- <location filename="../mintingview.cpp" line="62"/>
+ <location filename="../mintingview.cpp" line="63"/>
<source>10 min</source>
<translation>10 минут</translation>
</message>
<message>
- <location filename="../mintingview.cpp" line="63"/>
+ <location filename="../mintingview.cpp" line="64"/>
<source>24 hours</source>
<translation>24 часов</translation>
</message>
<message>
- <location filename="../mintingview.cpp" line="64"/>
+ <location filename="../mintingview.cpp" line="65"/>
+ <source>7 days</source>
+ <translation>7 дней</translation>
+ </message>
+ <message>
+ <location filename="../mintingview.cpp" line="66"/>
<source>30 days</source>
<translation>30 дней</translation>
</message>
<message>
- <location filename="../mintingview.cpp" line="65"/>
+ <location filename="../mintingview.cpp" line="67"/>
+ <source>60 days</source>
+ <translation>60 дней</translation>
+ </message>
+ <message>
+ <location filename="../mintingview.cpp" line="68"/>
<source>90 days</source>
<translation>90 дней</translation>
</message>
<message>
+ <location filename="../mintingview.cpp" line="103"/>
+ <source>Copy transaction ID of input</source>
+ <translation>Скопировать ID транзакции входа</translation>
+ </message>
+ <message>
+ <location filename="../mintingview.cpp" line="104"/>
+ <source>Copy address of input</source>
+ <translation>Скопировать адрес входа</translation>
+ </message>
+ <message>
+ <location filename="../mintingview.cpp" line="105"/>
+ <source>Show/hide 'Address' column</source>
+ <translation>Показать/скрыть столбец 'Адрес'</translation>
+ </message>
+ <message>
+ <location filename="../mintingview.cpp" line="106"/>
+ <source>Show/hide 'Transaction' column</source>
+ <translation>Показать/скрыть столбец 'Транзакция'</translation>
+ </message>
+ <message>
<location filename="../mintingview.cpp" line="167"/>
<source>Export Minting Data</source>
<translation>Экспортировать данные таблицы</translation>
</message>
<message>
<source>Balance</source>
- <translation>Баланс</translation>
+ <translation>Сумма</translation>
</message>
<message>
<source>MintProbability</source>
<translation>Вероятность PoS</translation>
</message>
<message>
+ <source>MintReward</source>
+ <translation>Награда PoS</translation>
+ </message>
+ <message>
<source>minutes</source>
<translation>минут</translation>
</message>
<source>Chance to mint a block within given time interval.</source>
<translation>Шанс найти блок в течение выбранного временного интервала.</translation>
</message>
+ <message>
+ <source>The size of the potential rewards if the block is found at the beginning and the end given time interval.</source>
+ <translation>Размер потенциальной награды если блок найден в начале и конце выбранного временного интервала.</translation>
+ </message>
</context>
<context>
<name>QObject</name>
<message>
+ <source>from %1 to %2</source>
+ <translation>от %1 до %2</translation>
+ </message>
+ <message>
<source>%1 d</source>
<translation>%1 д</translation>
</message>
static int column_alignments[] = {
Qt::AlignLeft|Qt::AlignVCenter,
Qt::AlignLeft|Qt::AlignVCenter,
- Qt::AlignRight|Qt::AlignVCenter,
- Qt::AlignRight|Qt::AlignVCenter,
- Qt::AlignRight|Qt::AlignVCenter,
- Qt::AlignRight|Qt::AlignVCenter
+ Qt::AlignLeft|Qt::AlignVCenter,
+ Qt::AlignLeft|Qt::AlignVCenter,
+ Qt::AlignLeft|Qt::AlignVCenter,
+ Qt::AlignLeft|Qt::AlignVCenter,
+ Qt::AlignLeft|Qt::AlignVCenter
};
struct TxLessThan
KernelRecord::decomposeOutput(wallet, mi->second);
if(!toInsert.empty()) /* only if something to insert */
{
- parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1);
int insert_idx = lowerIndex;
BOOST_FOREACH(const KernelRecord &rec, toInsert)
{
- if(!rec.spent) {
+ if(!rec.spent)
+ {
+ parent->beginInsertRows(QModelIndex(), insert_idx, insert_idx);
cachedWallet.insert(insert_idx, rec);
+ parent->endInsertRows();
insert_idx += 1;
}
}
- parent->endInsertRows();
}
}
else if(!inWallet && inModel)
mintingInterval(10),
priv(new MintingTablePriv(wallet, this))
{
- columns << tr("Transaction") << tr("Address") << tr("Age") << tr("Balance") << tr("CoinDay") << tr("MintProbability");
+ columns << tr("Transaction") << tr("Address") << tr("Balance") << tr("Age") << tr("CoinDay") << tr("MintProbability") << tr("MintReward");
priv->refreshWallet();
QTimer *timer = new QTimer(this);
return formatTxCoinDay(rec);
case MintProbability:
return formatDayToMint(rec);
+ case MintReward:
+ return formatTxPoSReward(rec);
}
break;
case Qt::TextAlignmentRole:
return rec->nValue;
case MintProbability:
return getDayToMint(rec);
+ case MintReward:
+ return formatTxPoSReward(rec);
}
break;
case Qt::BackgroundColorRole:
return description;
}
+QString MintingTableModel::formatTxPoSReward(KernelRecord *wtx) const
+{
+ QString posReward;
+ int nBits = GetLastBlockIndex(pindexBest, true)->nBits;
+ posReward += QString(QObject::tr("from %1 to %2")).arg(BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), wtx->getPoSReward(nBits, 0)),
+ BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), wtx->getPoSReward(nBits, mintingInterval)));
+ return posReward;
+}
+
double MintingTableModel::getDayToMint(KernelRecord *wtx) const
{
const CBlockIndex *p = GetLastBlockIndex(pindexBest, true);
QString MintingTableModel::formatTxCoinDay(const KernelRecord *wtx) const
{
- return QString::number(wtx->coinAge);
+ return QString::number(wtx->getCoinDay());
}
QString MintingTableModel::formatTxAge(const KernelRecord *wtx) const
QString MintingTableModel::formatTxBalance(const KernelRecord *wtx) const
{
- return BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), wtx->nValue);
+ return BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), wtx->nValue);
}
QVariant MintingTableModel::headerData(int section, Qt::Orientation orientation, int role) const
return tr("Coin age in the output.");
case MintProbability:
return tr("Chance to mint a block within given time interval.");
+ case MintReward:
+ return tr("The size of the potential rewards if the block is found at the beginning and the end given time interval.");
}
}
}
return QModelIndex();
}
}
-
enum ColumnIndex {
TxHash = 0,
Address = 1,
- Age = 2,
- Balance = 3,
+ Balance = 2,
+ Age = 3,
CoinDay = 4,
- MintProbability = 5
+ MintProbability = 5,
+ MintReward = 6
};
QString formatTxAge(const KernelRecord *wtx) const;
QString formatTxBalance(const KernelRecord *wtx) const;
QString formatTxCoinDay(const KernelRecord *wtx) const;
+ QString formatTxPoSReward(KernelRecord *wtx) const;
private slots:
void update();
#include <QLineEdit>
#include <QComboBox>
#include <QMessageBox>
+#include <QMenu>
MintingView::MintingView(QWidget *parent) :
QWidget(parent), model(0), mintingView(0)
mintingCombo = new QComboBox();
mintingCombo->addItem(tr("10 min"), Minting10min);
mintingCombo->addItem(tr("24 hours"), Minting1day);
+ mintingCombo->addItem(tr("7 days"), Minting7days);
mintingCombo->addItem(tr("30 days"), Minting30days);
+ mintingCombo->addItem(tr("60 days"), Minting60days);
mintingCombo->addItem(tr("90 days"), Minting90days);
mintingCombo->setFixedWidth(120);
connect(mintingCombo, SIGNAL(activated(int)), this, SLOT(chooseMintingInterval(int)));
+ // Actions
+ QAction *copyTxIDAction = new QAction(tr("Copy transaction ID of input"), this);
+ QAction *copyAddressAction = new QAction(tr("Copy address of input"), this);
+ QAction *showHideAddressAction = new QAction(tr("Show/hide 'Address' column"), this);
+ QAction *showHideTxIDAction = new QAction(tr("Show/hide 'Transaction' column"), this);
+
+ contextMenu = new QMenu();
+ contextMenu->addAction(copyAddressAction);
+ contextMenu->addAction(copyTxIDAction);
+ contextMenu->addAction(showHideAddressAction);
+ contextMenu->addAction(showHideTxIDAction);
+
+ connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress()));
+ connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID()));
+ connect(showHideAddressAction, SIGNAL(triggered()), this, SLOT(showHideAddress()));
+ connect(showHideTxIDAction, SIGNAL(triggered()), this, SLOT(showHideTxID()));
+
+ connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));
}
mintingView->verticalHeader()->hide();
mintingView->horizontalHeader()->resizeSection(
- MintingTableModel::Address, 420);
+ MintingTableModel::Age, 60);
+ mintingView->horizontalHeader()->resizeSection(
+ MintingTableModel::Balance, 80);
+ mintingView->horizontalHeader()->resizeSection(
+ MintingTableModel::CoinDay,60);
+ mintingView->horizontalHeader()->resizeSection(
+ MintingTableModel::MintProbability, 105);
#if QT_VERSION < 0x050000
mintingView->horizontalHeader()->setResizeMode(
- MintingTableModel::TxHash, QHeaderView::Stretch);
+ MintingTableModel::MintReward, QHeaderView::Stretch);
#else
mintingView->horizontalHeader()->setSectionResizeMode(
- MintingTableModel::TxHash, QHeaderView::Stretch);
+ MintingTableModel::MintReward, QHeaderView::Stretch);
#endif
mintingView->horizontalHeader()->resizeSection(
- MintingTableModel::Age, 120);
- mintingView->horizontalHeader()->resizeSection(
- MintingTableModel::Balance, 120);
+ MintingTableModel::Address, 245);
mintingView->horizontalHeader()->resizeSection(
- MintingTableModel::CoinDay,120);
- mintingView->horizontalHeader()->resizeSection(
- MintingTableModel::MintProbability, 160);
+ MintingTableModel::TxHash, 75);
}
}
case Minting1day:
interval = 60*24;
break;
+ case Minting7days:
+ interval = 60*24*7;
+ break;
case Minting30days:
interval = 60*24*30;
break;
+ case Minting60days:
+ interval = 60*24*60;
+ break;
case Minting90days:
interval = 60*24*90;
break;
// name, column, role
writer.setModel(mintingProxyModel);
- writer.addColumn(tr("Address"),0, MintingTableModel::Address);
- writer.addColumn(tr("Transaction"), 0, MintingTableModel::TxHash);
- writer.addColumn(tr("Age"), 0, MintingTableModel::Age);
- writer.addColumn(tr("CoinDay"), 0, MintingTableModel::CoinDay);
- writer.addColumn(tr("Balance"), 0, MintingTableModel::Balance);
- writer.addColumn(tr("MintingProbability"), 0, MintingTableModel::MintProbability);
+ writer.addColumn(tr("Address"),MintingTableModel::Address,0);
+ writer.addColumn(tr("Transaction"),MintingTableModel::TxHash,0);
+ writer.addColumn(tr("Age"), MintingTableModel::Age,0);
+ writer.addColumn(tr("CoinDay"), MintingTableModel::CoinDay,0);
+ writer.addColumn(tr("Balance"), MintingTableModel::Balance,0);
+ writer.addColumn(tr("MintingProbability"), MintingTableModel::MintProbability,0);
+ writer.addColumn(tr("MintingReward"), MintingTableModel::MintReward,0);
if(!writer.write())
{
QMessageBox::Abort, QMessageBox::Abort);
}
}
+
+void MintingView::copyTxID()
+{
+ GUIUtil::copyEntryData(mintingView, MintingTableModel::TxHash, 0);
+}
+
+void MintingView::copyAddress()
+{
+ GUIUtil::copyEntryData(mintingView, MintingTableModel::Address, 0 );
+}
+
+void MintingView::showHideAddress()
+{
+ mintingView->horizontalHeader()->setSectionHidden(MintingTableModel::Address,
+ !(mintingView->horizontalHeader()->isSectionHidden(MintingTableModel::Address)));
+}
+
+void MintingView::showHideTxID()
+{
+ mintingView->horizontalHeader()->setSectionHidden(MintingTableModel::TxHash,
+ !(mintingView->horizontalHeader()->isSectionHidden(MintingTableModel::TxHash)));
+}
+
+void MintingView::contextualMenu(const QPoint &point)
+{
+ QModelIndex index = mintingView->indexAt(point);
+ if(index.isValid())
+ {
+ contextMenu->exec(QCursor::pos());
+ }
+}
\ No newline at end of file
QT_BEGIN_NAMESPACE
class QTableView;
+class QMenu;
QT_END_NAMESPACE
class MintingView : public QWidget
{
Minting10min,
Minting1day,
+ Minting7days,
Minting30days,
+ Minting60days,
Minting90days
};
MintingFilterProxy *mintingProxyModel;
+ QMenu *contextMenu;
+
signals:
public slots:
void exportClicked();
void chooseMintingInterval(int idx);
+ void copyTxID();
+ void copyAddress();
+ void showHideAddress();
+ void showHideTxID();
+ void contextualMenu(const QPoint &point);
};
#endif // MINTINGVIEW_H
int64 CWalletTx::GetTxTime() const
{
- int64 n = nTimeSmart;
- return n ? n : nTimeReceived;
+ return nTime;
}
int CWalletTx::GetRequestCount() const