From 91c0b9419a644cb6f72d05711fcfec5aeb348f3f Mon Sep 17 00:00:00 2001 From: fsb4000 Date: Mon, 17 Nov 2014 19:12:23 +0600 Subject: [PATCH] PosTab MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Перенесена PoSTab из Peerunity кошелька. + перевод на русский Вот коммиты которые переносил: https://github.com/Peerunity/Peerunity/commit/c8eda6083428b7375cc7792664acbba0e485cf8c https://github.com/Peerunity/Peerunity/commit/941474511107ac9f827fdd12c635c96907b4a394 https://github.com/Peerunity/Peerunity/commit/e645dda155ba55f7d9e0062a991a338918c1719a https://github.com/Peerunity/Peerunity/commit/7d19131208be800bede5b4a78c0032d28ad34b6e https://github.com/Peerunity/Peerunity/commit/93c9c036695b4b886f682597f73432f8b0aa4e36 --- MSVC/mynovacoinqt/mynovacoinqt.vcxproj | 63 ++++- MSVC/mynovacoinqt/mynovacoinqt.vcxproj.filters | 32 ++ novacoin-qt.pro | 8 + src/kernelrecord.cpp | 116 ++++++ src/kernelrecord.h | 52 +++ src/qt/bitcoingui.cpp | 31 ++- src/qt/bitcoingui.h | 6 + src/qt/guiconstants.h | 5 + src/qt/locale/bitcoin_ru.ts | 140 ++++++++ src/qt/mintingfilterproxy.cpp | 7 + src/qt/mintingfilterproxy.h | 13 + src/qt/mintingtablemodel.cpp | 450 ++++++++++++++++++++++++ src/qt/mintingtablemodel.h | 60 ++++ src/qt/mintingview.cpp | 188 ++++++++++ src/qt/mintingview.h | 45 +++ src/qt/walletmodel.cpp | 7 + src/qt/walletmodel.h | 3 + src/wallet.cpp | 1 + src/wallet.h | 1 + 19 files changed, 1226 insertions(+), 2 deletions(-) create mode 100644 src/kernelrecord.cpp create mode 100644 src/kernelrecord.h create mode 100644 src/qt/mintingfilterproxy.cpp create mode 100644 src/qt/mintingfilterproxy.h create mode 100644 src/qt/mintingtablemodel.cpp create mode 100644 src/qt/mintingtablemodel.h create mode 100644 src/qt/mintingview.cpp create mode 100644 src/qt/mintingview.h diff --git a/MSVC/mynovacoinqt/mynovacoinqt.vcxproj b/MSVC/mynovacoinqt/mynovacoinqt.vcxproj index 719d122..7780327 100644 --- a/MSVC/mynovacoinqt/mynovacoinqt.vcxproj +++ b/MSVC/mynovacoinqt/mynovacoinqt.vcxproj @@ -1,4 +1,4 @@ - + @@ -292,6 +292,9 @@ C:\MyProjects\Deps\qt-everywhere-opensource-src-5.3.2-64\qtbase\bin\lrelease C:\ + + + @@ -725,6 +728,61 @@ C:\MyProjects\Deps\qt-everywhere-opensource-src-5.3.2-64\qtbase\bin\lrelease C:\ build\moc_qrcodedialog.cpp;%(Outputs) build\moc_qrcodedialog.cpp;%(Outputs) + + + ..\..\src\qt\mintingfilterproxy.h;%(AdditionalInputs) + ..\..\src\qt\mintingfilterproxy.h;%(AdditionalInputs) + C:\MyProjects\Deps\qt-everywhere-opensource-src-5.3.2\qtbase\bin\moc.exe -DUNICODE -DWIN32 -DQT_GUI -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1700 -D_WIN32 -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/mkspecs/win32-msvc2012 -IC:/MyProjects/Novacoin/MSVC/mynovacoinqt -IC:/MyProjects/Novacoin/src -IC:/MyProjects/Novacoin/src/json -IC:/MyProjects/Novacoin/src/qt -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtWidgets -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtNetwork -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtGui -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtCore ..\..\src\qt\mintingfilterproxy.h -o build\moc_mintingfilterproxy.cpp + C:\MyProjects\Deps\qt-everywhere-opensource-src-5.3.2-64\qtbase\bin\moc.exe -DUNICODE -DWIN32 -DQT_GUI -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1700 -D_WIN32 -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/mkspecs/win32-msvc2012 -IC:/MyProjects/Novacoin/MSVC/mynovacoinqt -IC:/MyProjects/Novacoin/src -IC:/MyProjects/Novacoin/src/json -IC:/MyProjects/Novacoin/src/qt -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtWidgets -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtNetwork -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtGui -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtCore ..\..\src\qt\mintingfilterproxy.h -o build\moc_mintingfilterproxy.cpp + MOC ..\..\src\qt\mintingfilterproxy.h + MOC ..\..\src\qt\mintingfilterproxy.h + build\moc_mintingfilterproxy.cpp;%(Outputs) + build\moc_mintingfilterproxy.cpp;%(Outputs) + ..\..\src\qt\mintingfilterproxy.h;%(AdditionalInputs) + ..\..\src\qt\mintingfilterproxy.h;%(AdditionalInputs) + C:\MyProjects\Deps\qt-everywhere-opensource-src-5.3.2\qtbase\bin\moc.exe -DUNICODE -DWIN32 -DQT_GUI -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1700 -D_WIN32 -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/mkspecs/win32-msvc2012 -IC:/MyProjects/Novacoin/MSVC/mynovacoinqt -IC:/MyProjects/Novacoin/src -IC:/MyProjects/Novacoin/src/json -IC:/MyProjects/Novacoin/src/qt -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtWidgets -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtNetwork -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtGui -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtCore ..\..\src\qt\mintingfilterproxy.h -o build\moc_mintingfilterproxy.cpp + C:\MyProjects\Deps\qt-everywhere-opensource-src-5.3.2-64\qtbase\bin\moc.exe -DUNICODE -DWIN32 -DQT_GUI -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1700 -D_WIN32 -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/mkspecs/win32-msvc2012 -IC:/MyProjects/Novacoin/MSVC/mynovacoinqt -IC:/MyProjects/Novacoin/src -IC:/MyProjects/Novacoin/src/json -IC:/MyProjects/Novacoin/src/qt -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtWidgets -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtNetwork -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtGui -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtCore ..\..\src\qt\mintingfilterproxy.h -o build\moc_mintingfilterproxy.cpp + MOC ..\..\src\qt\mintingfilterproxy.h + MOC ..\..\src\qt\mintingfilterproxy.h + build\moc_mintingfilterproxy.cpp;%(Outputs) + build\moc_mintingfilterproxy.cpp;%(Outputs) + + + ..\..\src\qt\mintingtablemodel.h;%(AdditionalInputs) + ..\..\src\qt\mintingtablemodel.h;%(AdditionalInputs) + C:\MyProjects\Deps\qt-everywhere-opensource-src-5.3.2\qtbase\bin\moc.exe -DUNICODE -DWIN32 -DQT_GUI -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1700 -D_WIN32 -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/mkspecs/win32-msvc2012 -IC:/MyProjects/Novacoin/MSVC/mynovacoinqt -IC:/MyProjects/Novacoin/src -IC:/MyProjects/Novacoin/src/json -IC:/MyProjects/Novacoin/src/qt -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtWidgets -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtNetwork -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtGui -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtCore ..\..\src\qt\mintingtablemodel.h -o build\moc_mintingtablemodel.cpp + C:\MyProjects\Deps\qt-everywhere-opensource-src-5.3.2-64\qtbase\bin\moc.exe -DUNICODE -DWIN32 -DQT_GUI -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1700 -D_WIN32 -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/mkspecs/win32-msvc2012 -IC:/MyProjects/Novacoin/MSVC/mynovacoinqt -IC:/MyProjects/Novacoin/src -IC:/MyProjects/Novacoin/src/json -IC:/MyProjects/Novacoin/src/qt -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtWidgets -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtNetwork -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtGui -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtCore ..\..\src\qt\mintingtablemodel.h -o build\moc_mintingtablemodel.cpp + MOC ..\..\src\qt\mintingtablemodel.h + MOC ..\..\src\qt\mintingtablemodel.h + build\moc_mintingtablemodel.cpp;%(Outputs) + build\moc_mintingtablemodel.cpp;%(Outputs) + ..\..\src\qt\mintingtablemodel.h;%(AdditionalInputs) + ..\..\src\qt\mintingtablemodel.h;%(AdditionalInputs) + C:\MyProjects\Deps\qt-everywhere-opensource-src-5.3.2\qtbase\bin\moc.exe -DUNICODE -DWIN32 -DQT_GUI -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1700 -D_WIN32 -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/mkspecs/win32-msvc2012 -IC:/MyProjects/Novacoin/MSVC/mynovacoinqt -IC:/MyProjects/Novacoin/src -IC:/MyProjects/Novacoin/src/json -IC:/MyProjects/Novacoin/src/qt -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtWidgets -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtNetwork -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtGui -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtCore ..\..\src\qt\mintingtablemodel.h -o build\moc_mintingtablemodel.cpp + C:\MyProjects\Deps\qt-everywhere-opensource-src-5.3.2-64\qtbase\bin\moc.exe -DUNICODE -DWIN32 -DQT_GUI -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1700 -D_WIN32 -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/mkspecs/win32-msvc2012 -IC:/MyProjects/Novacoin/MSVC/mynovacoinqt -IC:/MyProjects/Novacoin/src -IC:/MyProjects/Novacoin/src/json -IC:/MyProjects/Novacoin/src/qt -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtWidgets -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtNetwork -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtGui -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtCore ..\..\src\qt\mintingtablemodel.h -o build\moc_mintingtablemodel.cpp + MOC ..\..\src\qt\mintingtablemodel.h + MOC ..\..\src\qt\mintingtablemodel.h + build\moc_mintingtablemodel.cpp;%(Outputs) + build\moc_mintingtablemodel.cpp;%(Outputs) + + + ..\..\src\qt\mintingview.h;%(AdditionalInputs) + ..\..\src\qt\mintingview.h;%(AdditionalInputs) + C:\MyProjects\Deps\qt-everywhere-opensource-src-5.3.2\qtbase\bin\moc.exe -DUNICODE -DWIN32 -DQT_GUI -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1700 -D_WIN32 -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/mkspecs/win32-msvc2012 -IC:/MyProjects/Novacoin/MSVC/mynovacoinqt -IC:/MyProjects/Novacoin/src -IC:/MyProjects/Novacoin/src/json -IC:/MyProjects/Novacoin/src/qt -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtWidgets -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtNetwork -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtGui -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtCore ..\..\src\qt\mintingview.h -o build\moc_mintingview.cpp + C:\MyProjects\Deps\qt-everywhere-opensource-src-5.3.2-64\qtbase\bin\moc.exe -DUNICODE -DWIN32 -DQT_GUI -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1700 -D_WIN32 -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/mkspecs/win32-msvc2012 -IC:/MyProjects/Novacoin/MSVC/mynovacoinqt -IC:/MyProjects/Novacoin/src -IC:/MyProjects/Novacoin/src/json -IC:/MyProjects/Novacoin/src/qt -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtWidgets -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtNetwork -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtGui -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtCore ..\..\src\qt\mintingview.h -o build\moc_mintingview.cpp + MOC ..\..\src\qt\mintingview.h + MOC ..\..\src\qt\mintingview.h + build\moc_mintingview.cpp;%(Outputs) + build\moc_mintingview.cpp;%(Outputs) + ..\..\src\qt\mintingview.h;%(AdditionalInputs) + ..\..\src\qt\mintingview.h;%(AdditionalInputs) + C:\MyProjects\Deps\qt-everywhere-opensource-src-5.3.2\qtbase\bin\moc.exe -DUNICODE -DWIN32 -DQT_GUI -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1700 -D_WIN32 -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/mkspecs/win32-msvc2012 -IC:/MyProjects/Novacoin/MSVC/mynovacoinqt -IC:/MyProjects/Novacoin/src -IC:/MyProjects/Novacoin/src/json -IC:/MyProjects/Novacoin/src/qt -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtWidgets -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtNetwork -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtGui -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2/qtbase/include/QtCore ..\..\src\qt\mintingview.h -o build\moc_mintingview.cpp + C:\MyProjects\Deps\qt-everywhere-opensource-src-5.3.2-64\qtbase\bin\moc.exe -DUNICODE -DWIN32 -DQT_GUI -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1700 -D_WIN32 -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/mkspecs/win32-msvc2012 -IC:/MyProjects/Novacoin/MSVC/mynovacoinqt -IC:/MyProjects/Novacoin/src -IC:/MyProjects/Novacoin/src/json -IC:/MyProjects/Novacoin/src/qt -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtWidgets -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtNetwork -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtGui -IC:/MyProjects/Deps/qt-everywhere-opensource-src-5.3.2-64/qtbase/include/QtCore ..\..\src\qt\mintingview.h -o build\moc_mintingview.cpp + MOC ..\..\src\qt\mintingview.h + MOC ..\..\src\qt\mintingview.h + build\moc_mintingview.cpp;%(Outputs) + build\moc_mintingview.cpp;%(Outputs) + ..\..\src\qt\qvalidatedlineedit.h;%(AdditionalInputs) @@ -990,6 +1048,9 @@ C:\MyProjects\Deps\qt-everywhere-opensource-src-5.3.2-64\qtbase\bin\lrelease C:\ + + + Document ..\..\src\qt\overviewpage.cpp;%(AdditionalInputs) diff --git a/MSVC/mynovacoinqt/mynovacoinqt.vcxproj.filters b/MSVC/mynovacoinqt/mynovacoinqt.vcxproj.filters index d2a612d..e5b1238 100644 --- a/MSVC/mynovacoinqt/mynovacoinqt.vcxproj.filters +++ b/MSVC/mynovacoinqt/mynovacoinqt.vcxproj.filters @@ -177,6 +177,24 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Generated Files + + + Generated Files + + + Generated Files + @@ -431,6 +449,15 @@ Header Files + + Header Files + + + Header Files + + + Header Files + @@ -802,4 +829,9 @@ Resource Files + + + Header Files + + \ No newline at end of file diff --git a/novacoin-qt.pro b/novacoin-qt.pro index 51ba8b1..2552e53 100644 --- a/novacoin-qt.pro +++ b/novacoin-qt.pro @@ -185,6 +185,10 @@ HEADERS += src/qt/bitcoingui.h \ src/qt/aboutdialog.h \ src/qt/editaddressdialog.h \ src/qt/bitcoinaddressvalidator.h \ + src/qt/mintingfilterproxy.h \ + src/qt/mintingtablemodel.h \ + src/qt/mintingview.h \ + src/kernelrecord.h \ src/alert.h \ src/addrman.h \ src/base58.h \ @@ -269,6 +273,10 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \ src/qt/editaddressdialog.cpp \ src/qt/bitcoinaddressvalidator.cpp \ src/qt/trafficgraphwidget.cpp \ + src/qt/mintingfilterproxy.cpp \ + src/qt/mintingtablemodel.cpp \ + src/qt/mintingview.cpp \ + src/kernelrecord.cpp \ src/alert.cpp \ src/version.cpp \ src/sync.cpp \ diff --git a/src/kernelrecord.cpp b/src/kernelrecord.cpp new file mode 100644 index 0000000..eb68dd4 --- /dev/null +++ b/src/kernelrecord.cpp @@ -0,0 +1,116 @@ +#include "kernelrecord.h" + +#include "wallet.h" +#include "base58.h" +#include "main.h" + +using namespace std; + +bool KernelRecord::showTransaction(const CWalletTx &wtx) +{ + if (wtx.IsCoinBase()) + { + if (wtx.GetDepthInMainChain() < 2) + { + return false; + } + } + + if(!wtx.IsTrusted()) + { + return false; + } + + return true; +} + +/* + * Decompose CWallet transaction to model kernel records. + */ +vector KernelRecord::decomposeOutput(const CWallet *wallet, const CWalletTx &wtx) +{ + vector parts; + int64 nTime = wtx.GetTxTime(); + uint256 hash = wtx.GetHash(); + std::map mapValue = wtx.mapValue; + int64 nDayWeight = (min((GetAdjustedTime() - nTime), (int64)(nStakeMaxAge+nStakeMinAge)) - nStakeMinAge); // DayWeight * 86400, ÷òîáû áûë + // ïðàâèëüíûé ðàñ÷¸ò CoinAge + if (showTransaction(wtx)) + { + for (int nOut = 0; nOut < wtx.vout.size(); nOut++) + { + CTxOut txOut = wtx.vout[nOut]; + if( wallet->IsMine(txOut) ) { + CTxDestination address; + std::string addrStr; + + uint64 coinAge = max( (txOut.nValue * nDayWeight) / (COIN * 86400), (int64)0); + + if (ExtractDestination(txOut.scriptPubKey, address)) + { + // Sent to Bitcoin Address + addrStr = CBitcoinAddress(address).ToString(); + } + else + { + // Sent to IP, or other non-address transaction like OP_EVAL + addrStr = mapValue["to"]; + } + + parts.push_back(KernelRecord(hash, nTime, addrStr, txOut.nValue, wtx.IsSpent(nOut), coinAge)); + } + } + } + + return parts; +} + +std::string KernelRecord::getTxID() +{ + return hash.ToString() + strprintf("-%03d", idx); +} + +int64 KernelRecord::getAge() const +{ + return (GetAdjustedTime() - nTime) / 86400; +} + +double KernelRecord::getProbToMintStake(double difficulty, int timeOffset) const +{ + double maxTarget = pow(static_cast(2), 224); + double target = maxTarget / difficulty; + int dayWeight = (min((GetAdjustedTime() - nTime) + timeOffset, (int64)(nStakeMinAge+nStakeMaxAge)) - nStakeMinAge) / 86400; + uint64 coinAge = max(nValue * dayWeight / COIN, (int64)0); + return target * coinAge / pow(static_cast(2), 256); +} + +double KernelRecord::getProbToMintWithinNMinutes(double difficulty, int minutes) +{ + if(difficulty != prevDifficulty || minutes != prevMinutes) + { + double prob = 1; + double p; + int d = minutes / (60 * 24); // Number of full days + int m = minutes % (60 * 24); // Number of minutes in the last day + int i, timeOffset; + + // Probabilities for the first d days + for(i = 0; i < d; i++) + { + timeOffset = i * 86400; + p = pow(1 - getProbToMintStake(difficulty, timeOffset), 86400); + prob *= p; + } + + // Probability for the m minutes of the last day + timeOffset = d * 86400; + p = pow(1 - getProbToMintStake(difficulty, timeOffset), 60 * m); + prob *= p; + + prob = 1 - prob; + prevProbability = prob; + prevDifficulty = difficulty; + prevMinutes = minutes; + } + return prevProbability; +} diff --git a/src/kernelrecord.h b/src/kernelrecord.h new file mode 100644 index 0000000..d54e551 --- /dev/null +++ b/src/kernelrecord.h @@ -0,0 +1,52 @@ +#ifndef KERNELRECORD_H +#define KERNELRECORD_H + +#include "uint256.h" + +class CWallet; +class CWalletTx; + +class KernelRecord +{ +public: + KernelRecord(): + hash(), nTime(0), address(""), nValue(0), idx(0), spent(false), coinAge(0), prevMinutes(0), prevDifficulty(0), prevProbability(0) + { + } + + KernelRecord(uint256 hash, int64 nTime): + hash(hash), nTime(nTime), address(""), nValue(0), idx(0), spent(false), coinAge(0), prevMinutes(0), prevDifficulty(0), prevProbability(0) + { + } + + KernelRecord(uint256 hash, int64 nTime, + const std::string &address, + int64 nValue, bool spent, int64 coinAge): + hash(hash), nTime(nTime), address(address), nValue(nValue), + idx(0), spent(spent), coinAge(coinAge), prevMinutes(0), prevDifficulty(0), prevProbability(0) + { + } + + static bool showTransaction(const CWalletTx &wtx); + static std::vector decomposeOutput(const CWallet *wallet, const CWalletTx &wtx); + + + uint256 hash; + int64 nTime; + std::string address; + int64 nValue; + int idx; + bool spent; + int64 coinAge; + + std::string getTxID(); + int64 getAge() const; + double getProbToMintStake(double difficulty, int timeOffset = 0) const; + double getProbToMintWithinNMinutes(double difficulty, int minutes); +protected: + int prevMinutes; + double prevDifficulty; + double prevProbability; +}; + +#endif // KERNELRECORD_H diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index d7bc458..5db27fe 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -26,6 +26,7 @@ #include "guiutil.h" #include "ui_interface.h" #include "rpcconsole.h" +#include "mintingview.h" #ifdef Q_OS_MAC #include "macdockiconhandler.h" @@ -116,6 +117,12 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): vbox->addWidget(transactionView); transactionsPage->setLayout(vbox); + mintingPage = new QWidget(this); + QVBoxLayout *vboxMinting = new QVBoxLayout(); + mintingView = new MintingView(this); + vboxMinting->addWidget(mintingView); + mintingPage->setLayout(vboxMinting); + addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab); receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab); @@ -127,6 +134,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): centralWidget = new QStackedWidget(this); centralWidget->addWidget(overviewPage); centralWidget->addWidget(transactionsPage); + centralWidget->addWidget(mintingPage); centralWidget->addWidget(addressBookPage); centralWidget->addWidget(receiveCoinsPage); centralWidget->addWidget(sendCoinsPage); @@ -234,10 +242,16 @@ void BitcoinGUI::createActions() historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4)); tabGroup->addAction(historyAction); + mintingAction = new QAction(QIcon(":/icons/history"), tr("&Minting"), this); + mintingAction->setToolTip(tr("Show your minting capacity")); + mintingAction->setCheckable(true); + mintingAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5)); + tabGroup->addAction(mintingAction); + addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Address Book"), this); addressBookAction->setToolTip(tr("Edit the list of stored addresses and labels")); addressBookAction->setCheckable(true); - addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5)); + addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6)); tabGroup->addAction(addressBookAction); connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); @@ -248,6 +262,8 @@ void BitcoinGUI::createActions() connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage())); connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage())); + connect(mintingAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(mintingAction, SIGNAL(triggered()), this, SLOT(gotoMintingPage())); connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage())); @@ -363,6 +379,7 @@ void BitcoinGUI::createToolBars() toolbar->addAction(sendCoinsAction); toolbar->addAction(receiveCoinsAction); toolbar->addAction(historyAction); + toolbar->addAction(mintingAction); toolbar->addAction(addressBookAction); QToolBar *toolbar2 = addToolBar(tr("Actions toolbar")); @@ -422,6 +439,7 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel) // Put transaction list in tabs transactionView->setModel(walletModel); + mintingView->setModel(walletModel); overviewPage->setModel(walletModel); addressBookPage->setModel(walletModel->getAddressTableModel()); @@ -845,6 +863,17 @@ void BitcoinGUI::gotoHistoryPage() connect(exportAction, SIGNAL(triggered()), transactionView, SLOT(exportClicked())); } +void BitcoinGUI::gotoMintingPage() +{ + mintingAction->setChecked(true); + centralWidget->setCurrentWidget(mintingPage); + + exportAction->setEnabled(true); + disconnect(exportAction, SIGNAL(triggered()), 0, 0); + connect(exportAction, SIGNAL(triggered()), mintingView, SLOT(exportClicked())); +} + + void BitcoinGUI::gotoAddressBookPage() { addressBookAction->setChecked(true); diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 0f85654..df5d93e 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -8,6 +8,7 @@ class TransactionTableModel; class ClientModel; class WalletModel; class TransactionView; +class MintingView; class OverviewPage; class AddressBookPage; class SendCoinsDialog; @@ -61,6 +62,7 @@ private: OverviewPage *overviewPage; QWidget *transactionsPage; + QWidget *mintingPage; AddressBookPage *addressBookPage; AddressBookPage *receiveCoinsPage; SendCoinsDialog *sendCoinsPage; @@ -76,6 +78,7 @@ private: QMenuBar *appMenuBar; QAction *overviewAction; QAction *historyAction; + QAction *mintingAction; QAction *quitAction; QAction *sendCoinsAction; QAction *addressBookAction; @@ -100,6 +103,7 @@ private: QSystemTrayIcon *trayIcon; Notificator *notificator; TransactionView *transactionView; + MintingView *mintingView; RPCConsole *rpcConsole; QMovie *syncIconMovie; @@ -146,6 +150,8 @@ private slots: void gotoOverviewPage(); /** Switch to history (transactions) page */ void gotoHistoryPage(); + /** Switch to minting page */ + void gotoMintingPage(); /** Switch to address book page */ void gotoAddressBookPage(); /** Switch to receive coins page */ diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h index 405ba39..da18c83 100644 --- a/src/qt/guiconstants.h +++ b/src/qt/guiconstants.h @@ -31,4 +31,9 @@ static const int MAX_URI_LENGTH = 255; /* QRCodeDialog -- size of exported QR Code image */ #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) + #endif // GUICONSTANTS_H diff --git a/src/qt/locale/bitcoin_ru.ts b/src/qt/locale/bitcoin_ru.ts index 3543764..2cd4930 100644 --- a/src/qt/locale/bitcoin_ru.ts +++ b/src/qt/locale/bitcoin_ru.ts @@ -2,6 +2,136 @@ UTF-8 + + MintingView + + + transaction is too young + транзакция молода для PoS + + + + transaction is mature + зрелая транзакция + + + + transaction has reached maximum probability + транзакция достигла максимальной вероятности + + + + Display minting probability within : + Показывать вероятность найти блок в течение : + + + + 10 min + 10 минут + + + + 24 hours + 24 часов + + + + 30 days + 30 дней + + + + 90 days + 90 дней + + + + Export Minting Data + Экспортировать данные таблицы + + + + Comma separated file (*.csv) + Текст, разделённый запятыми (*.csv) + + + + Error exporting + Ошибка экспорта + + + + Could not write to file %1. + Невозможно записать в файл %1. + + + + MintingTableModel + + Address + Адрес + + + Transaction + Транзакция + + + Age + Возраст + + + CoinDay + Вес + + + Balance + Баланс + + + MintProbability + Вероятность PoS + + + minutes + минут + + + hours + часа + + + days + дней + + + You have %1 chance to find a POS block if you mint %2 %3 at current difficulty. + У вас есть %1 шанс найти PoS блок, если вы будете майнить %2 %3 при текущей сложности. + + + Destination address of the output. + Адрес который получил эту транзакцию. + + + Original transaction id. + Исходный ID транзакции. + + + Age of the transaction in days. + Возраст транзакции в днях. + + + Balance of the output. + Баланс выхода. + + + Coin age in the output. + CoinDayWeight выхода. + + + Chance to mint a block within given time interval. + Шанс найти блок в течение выбранного временного интервала. + + QObject @@ -341,6 +471,16 @@ Copyright © 2012-2014 The NovaCoin developers Показать историю транзакций + + &Minting + &PoS + + + + Show your minting capacity + Показать ваш PoS потенциал + + &Address Book &Адресная книга diff --git a/src/qt/mintingfilterproxy.cpp b/src/qt/mintingfilterproxy.cpp new file mode 100644 index 0000000..664cbe7 --- /dev/null +++ b/src/qt/mintingfilterproxy.cpp @@ -0,0 +1,7 @@ +#include "mintingfilterproxy.h" + +MintingFilterProxy::MintingFilterProxy(QObject * parent) : + QSortFilterProxyModel(parent) +{ + +} diff --git a/src/qt/mintingfilterproxy.h b/src/qt/mintingfilterproxy.h new file mode 100644 index 0000000..26c4abf --- /dev/null +++ b/src/qt/mintingfilterproxy.h @@ -0,0 +1,13 @@ +#ifndef MINTINGFILTERPROXY_H +#define MINTINGFILTERPROXY_H + +#include + +class MintingFilterProxy : public QSortFilterProxyModel +{ + Q_OBJECT +public: + explicit MintingFilterProxy(QObject *parent = 0); +}; + +#endif // MINTINGFILTERPROXY_H diff --git a/src/qt/mintingtablemodel.cpp b/src/qt/mintingtablemodel.cpp new file mode 100644 index 0000000..4973480 --- /dev/null +++ b/src/qt/mintingtablemodel.cpp @@ -0,0 +1,450 @@ +#include "mintingtablemodel.h" +#include "transactiontablemodel.h" +#include "guiutil.h" +#include "kernelrecord.h" +#include "guiconstants.h" +#include "transactiondesc.h" +#include "walletmodel.h" +#include "optionsmodel.h" +#include "addresstablemodel.h" +#include "bitcoinunits.h" +#include "util.h" +#include "kernel.h" + +#include "wallet.h" + +#include +#include +#include +#include +#include +#include +#include + +extern double GetDifficulty(const CBlockIndex* blockindex); + +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 +}; + +struct TxLessThan +{ + bool operator()(const KernelRecord &a, const KernelRecord &b) const + { + return a.hash < b.hash; + } + bool operator()(const KernelRecord &a, const uint256 &b) const + { + return a.hash < b; + } + bool operator()(const uint256 &a, const KernelRecord &b) const + { + return a < b.hash; + } +}; + +class MintingTablePriv +{ +public: + MintingTablePriv(CWallet *wallet, MintingTableModel *parent): + wallet(wallet), + parent(parent) + { + } + CWallet *wallet; + MintingTableModel *parent; + + QList cachedWallet; + + void refreshWallet() + { +#ifdef WALLET_UPDATE_DEBUG + qDebug() << "refreshWallet"; +#endif + cachedWallet.clear(); + { + LOCK(wallet->cs_wallet); + for(std::map::iterator it = wallet->mapWallet.begin(); it != wallet->mapWallet.end(); ++it) + { + std::vector txList = KernelRecord::decomposeOutput(wallet, it->second); + BOOST_FOREACH(KernelRecord& kr, txList) { + if(!kr.spent) { + cachedWallet.append(kr); + } + } + + } + } + } + + /* Update our model of the wallet incrementally, to synchronize our model of the wallet + with that of the core. + + Call with list of hashes of transactions that were added, removed or changed. + */ + void updateWallet(const QList &updated) + { + // Walk through updated transactions, update model as needed. +#ifdef WALLET_UPDATE_DEBUG + qDebug() << "updateWallet"; +#endif + // Sort update list, and iterate through it in reverse, so that model updates + // can be emitted from end to beginning (so that earlier updates will not influence + // the indices of latter ones). + QList updated_sorted = updated; + qSort(updated_sorted); + + { + LOCK(wallet->cs_wallet); + for(int update_idx = updated_sorted.size()-1; update_idx >= 0; --update_idx) + { + const uint256 &hash = updated_sorted.at(update_idx); + // Find transaction in wallet + std::map::iterator mi = wallet->mapWallet.find(hash); + bool inWallet = mi != wallet->mapWallet.end(); + // Find bounds of this transaction in model + QList::iterator lower = qLowerBound( + cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan()); + QList::iterator upper = qUpperBound( + cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan()); + int lowerIndex = (lower - cachedWallet.begin()); + int upperIndex = (upper - cachedWallet.begin()); + + // Determine if transaction is in model already + bool inModel = false; + if(lower != upper) + { + inModel = true; + } + +#ifdef WALLET_UPDATE_DEBUG + qDebug() << " " << QString::fromStdString(hash.ToString()) << inWallet << " " << inModel + << lowerIndex << "-" << upperIndex; +#endif + + if(inWallet && !inModel) + { + // Added -- insert at the right position + std::vector toInsert = + 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) { + cachedWallet.insert(insert_idx, rec); + insert_idx += 1; + } + } + parent->endInsertRows(); + } + } + else if(!inWallet && inModel) + { + // Removed -- remove entire transaction from table + parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1); + cachedWallet.erase(lower, upper); + parent->endRemoveRows(); + } + else if(inWallet && inModel) + { + // Updated -- nothing to do, status update will take care of this + } + } + } + } + + int size() + { + return cachedWallet.size(); + } + + KernelRecord *index(int idx) + { + if(idx >= 0 && idx < cachedWallet.size()) + { + KernelRecord *rec = &cachedWallet[idx]; + return rec; + } + else + { + return 0; + } + } + + QString describe(KernelRecord *rec) + { + { + LOCK(wallet->cs_wallet); + std::map::iterator mi = wallet->mapWallet.find(rec->hash); + if(mi != wallet->mapWallet.end()) + { + return TransactionDesc::toHTML(wallet, mi->second); + } + } + return QString(""); + } + +}; + + +MintingTableModel::MintingTableModel(CWallet *wallet, WalletModel *parent): + QAbstractTableModel(parent), + wallet(wallet), + walletModel(parent), + mintingInterval(10), + priv(new MintingTablePriv(wallet, this)) +{ + columns << tr("Transaction") << tr("Address") << tr("Age") << tr("Balance") << tr("CoinDay") << tr("MintProbability"); + priv->refreshWallet(); + + QTimer *timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(update())); + timer->start(MODEL_UPDATE_DELAY); +} + +MintingTableModel::~MintingTableModel() +{ + delete priv; +} + +void MintingTableModel::update() +{ + QList updated; + + // Check if there are changes to wallet map + { + TRY_LOCK(wallet->cs_wallet, lockWallet); + if (lockWallet && !wallet->vMintingWalletUpdated.empty()) + { + BOOST_FOREACH(uint256 hash, wallet->vMintingWalletUpdated) + { + updated.append(hash); + } + wallet->vMintingWalletUpdated.clear(); + } + } + + if(!updated.empty()) + { + priv->updateWallet(updated); + } +} + +int MintingTableModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return priv->size(); +} + +int MintingTableModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return columns.length(); +} + +QVariant MintingTableModel::data(const QModelIndex &index, int role) const +{ + if(!index.isValid()) + return QVariant(); + KernelRecord *rec = static_cast(index.internalPointer()); + + switch(role) + { + case Qt::DisplayRole: + switch(index.column()) + { + case Address: + return formatTxAddress(rec, false); + case TxHash: + return formatTxHash(rec); + case Age: + return formatTxAge(rec); + case Balance: + return formatTxBalance(rec); + case CoinDay: + return formatTxCoinDay(rec); + case MintProbability: + return formatDayToMint(rec); + } + break; + case Qt::TextAlignmentRole: + return column_alignments[index.column()]; + break; + case Qt::ToolTipRole: + switch(index.column()) + { + case MintProbability: + int interval = this->mintingInterval; + QString unit = tr("minutes"); + + int hours = interval / 60; + int days = hours / 24; + + if(hours > 1) { + interval = hours; + unit = tr("hours"); + } + if(days > 1) { + interval = days; + unit = tr("days"); + } + + QString str = QString(tr("You have %1 chance to find a POS block if you mint %2 %3 at current difficulty.")); + return str.arg(index.data().toString().toUtf8().constData()).arg(interval).arg(unit); + } + break; + case Qt::EditRole: + switch(index.column()) + { + case Address: + return formatTxAddress(rec, false); + case TxHash: + return formatTxHash(rec); + case Age: + return rec->getAge(); + case CoinDay: + return rec->coinAge; + case Balance: + return rec->nValue; + case MintProbability: + return getDayToMint(rec); + } + break; + case Qt::BackgroundColorRole: + int minAge = nStakeMinAge / 60 / 60 / 24; + int maxAge = nStakeMaxAge / 60 / 60 / 24; + if(rec->getAge() < minAge) + { + return COLOR_MINT_YOUNG; + } + else if (rec->getAge() >= minAge && rec->getAge() < (maxAge + minAge)) + { + return COLOR_MINT_MATURE; + } + else + { + return COLOR_MINT_OLD; + } + break; + + } + return QVariant(); +} + +void MintingTableModel::setMintingInterval(int interval) +{ + mintingInterval = interval; +} + +QString MintingTableModel::lookupAddress(const std::string &address, bool tooltip) const +{ + QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(address)); + QString description; + if(!label.isEmpty()) + { + description += label + QString(" "); + } + if(label.isEmpty() || walletModel->getOptionsModel()->getDisplayAddresses() || tooltip) + { + description += QString("(") + QString::fromStdString(address) + QString(")"); + } + return description; +} + +double MintingTableModel::getDayToMint(KernelRecord *wtx) const +{ + const CBlockIndex *p = GetLastBlockIndex(pindexBest, true); + double difficulty = GetDifficulty(p); + + double prob = wtx->getProbToMintWithinNMinutes(difficulty, mintingInterval); + prob = prob * 100; + return prob; +} + +QString MintingTableModel::formatDayToMint(KernelRecord *wtx) const +{ + double prob = getDayToMint(wtx); + return QString::number(prob, 'f', 3) + "%"; +} + +QString MintingTableModel::formatTxAddress(const KernelRecord *wtx, bool tooltip) const +{ + return QString::fromStdString(wtx->address); +} + +QString MintingTableModel::formatTxHash(const KernelRecord *wtx) const +{ + return QString::fromStdString(wtx->hash.ToString()); +} + +QString MintingTableModel::formatTxCoinDay(const KernelRecord *wtx) const +{ + return QString::number(wtx->coinAge); +} + +QString MintingTableModel::formatTxAge(const KernelRecord *wtx) const +{ + int64 nAge = wtx->getAge(); + return QString::number(nAge); +} + +QString MintingTableModel::formatTxBalance(const KernelRecord *wtx) const +{ + return BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), wtx->nValue); +} + +QVariant MintingTableModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if(orientation == Qt::Horizontal) + { + if(role == Qt::DisplayRole) + { + return columns[section]; + } + else if (role == Qt::TextAlignmentRole) + { + return column_alignments[section]; + } else if (role == Qt::ToolTipRole) + { + switch(section) + { + case Address: + return tr("Destination address of the output."); + case TxHash: + return tr("Original transaction id."); + case Age: + return tr("Age of the transaction in days."); + case Balance: + return tr("Balance of the output."); + case CoinDay: + return tr("Coin age in the output."); + case MintProbability: + return tr("Chance to mint a block within given time interval."); + } + } + } + return QVariant(); +} + +QModelIndex MintingTableModel::index(int row, int column, const QModelIndex &parent) const +{ + Q_UNUSED(parent); + KernelRecord *data = priv->index(row); + if(data) + { + return createIndex(row, column, priv->index(row)); + } + else + { + return QModelIndex(); + } +} + diff --git a/src/qt/mintingtablemodel.h b/src/qt/mintingtablemodel.h new file mode 100644 index 0000000..c265ce5 --- /dev/null +++ b/src/qt/mintingtablemodel.h @@ -0,0 +1,60 @@ +#ifndef MINTINGTABLEMODEL_H +#define MINTINGTABLEMODEL_H + + +#include +#include + +class CWallet; +class MintingTablePriv; +class KernelRecord; +class WalletModel; + +class MintingTableModel : public QAbstractTableModel +{ + Q_OBJECT +public: + explicit MintingTableModel(CWallet * wallet, WalletModel *parent = 0); + ~MintingTableModel(); + + enum ColumnIndex { + TxHash = 0, + Address = 1, + Age = 2, + Balance = 3, + CoinDay = 4, + MintProbability = 5 + }; + + + int rowCount(const QModelIndex &parent) const; + int columnCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; + + void setMintingInterval(int interval); + +private: + CWallet* wallet; + WalletModel *walletModel; + QStringList columns; + int mintingInterval; + MintingTablePriv *priv; + + QString lookupAddress(const std::string &address, bool tooltip) const; + + double getDayToMint(KernelRecord *wtx) const; + QString formatDayToMint(KernelRecord *wtx) const; + QString formatTxAddress(const KernelRecord *wtx, bool tooltip) const; + QString formatTxHash(const KernelRecord *wtx) const; + QString formatTxAge(const KernelRecord *wtx) const; + QString formatTxBalance(const KernelRecord *wtx) const; + QString formatTxCoinDay(const KernelRecord *wtx) const; +private slots: + void update(); + + friend class MintingTablePriv; +}; + +#endif // MINTINGTABLEMODEL_H diff --git a/src/qt/mintingview.cpp b/src/qt/mintingview.cpp new file mode 100644 index 0000000..07ecadf --- /dev/null +++ b/src/qt/mintingview.cpp @@ -0,0 +1,188 @@ +#include "mintingview.h" +#include "mintingfilterproxy.h" +#include "transactionrecord.h" +#include "mintingtablemodel.h" +#include "walletmodel.h" +#include "guiconstants.h" +#include "guiutil.h" +#include "csvmodelwriter.h" + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +MintingView::MintingView(QWidget *parent) : + QWidget(parent), model(0), mintingView(0) +{ + QHBoxLayout *hlayout = new QHBoxLayout(); + hlayout->setContentsMargins(0,0,0,0); + + QString legendBoxStyle = "background-color: rgb(%1,%2,%3); border: 1px solid black;"; + + QLabel *youngColor = new QLabel(" "); + youngColor->setMaximumHeight(15); + youngColor->setMaximumWidth(10); + youngColor->setStyleSheet(legendBoxStyle.arg(COLOR_MINT_YOUNG.red()).arg(COLOR_MINT_YOUNG.green()).arg(COLOR_MINT_YOUNG.blue())); + QLabel *youngLegend = new QLabel(tr("transaction is too young")); + youngLegend->setContentsMargins(5,0,15,0); + + QLabel *matureColor = new QLabel(" "); + matureColor->setMaximumHeight(15); + matureColor->setMaximumWidth(10); + matureColor->setStyleSheet(legendBoxStyle.arg(COLOR_MINT_MATURE.red()).arg(COLOR_MINT_MATURE.green()).arg(COLOR_MINT_MATURE.blue())); + QLabel *matureLegend = new QLabel(tr("transaction is mature")); + matureLegend->setContentsMargins(5,0,15,0); + + QLabel *oldColor = new QLabel(" "); + oldColor->setMaximumHeight(15); + oldColor->setMaximumWidth(10); + oldColor->setStyleSheet(legendBoxStyle.arg(COLOR_MINT_OLD.red()).arg(COLOR_MINT_OLD.green()).arg(COLOR_MINT_OLD.blue())); + QLabel *oldLegend = new QLabel(tr("transaction has reached maximum probability")); + oldLegend->setContentsMargins(5,0,15,0); + + QHBoxLayout *legendLayout = new QHBoxLayout(); + legendLayout->setContentsMargins(10,10,0,0); + legendLayout->addWidget(youngColor); + legendLayout->addWidget(youngLegend); + legendLayout->addWidget(matureColor); + legendLayout->addWidget(matureLegend); + legendLayout->addWidget(oldColor); + legendLayout->addWidget(oldLegend); + legendLayout->insertStretch(-1); + + QLabel *mintingLabel = new QLabel(tr("Display minting probability within : ")); + mintingCombo = new QComboBox(); + mintingCombo->addItem(tr("10 min"), Minting10min); + mintingCombo->addItem(tr("24 hours"), Minting1day); + mintingCombo->addItem(tr("30 days"), Minting30days); + mintingCombo->addItem(tr("90 days"), Minting90days); + mintingCombo->setFixedWidth(120); + + + hlayout->insertStretch(0); + hlayout->addWidget(mintingLabel); + hlayout->addWidget(mintingCombo); + + QVBoxLayout *vlayout = new QVBoxLayout(this); + vlayout->setContentsMargins(0,0,0,0); + vlayout->setSpacing(0); + + QTableView *view = new QTableView(this); + vlayout->addLayout(hlayout); + vlayout->addWidget(view); + vlayout->addLayout(legendLayout); + + vlayout->setSpacing(0); + int width = view->verticalScrollBar()->sizeHint().width(); + // Cover scroll bar width with spacing +#ifdef Q_WS_MAC + hlayout->addSpacing(width+2); +#else + hlayout->addSpacing(width); +#endif + // Always show scroll bar + view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + view->setTabKeyNavigation(false); + view->setContextMenuPolicy(Qt::CustomContextMenu); + + mintingView = view; + + connect(mintingCombo, SIGNAL(activated(int)), this, SLOT(chooseMintingInterval(int))); + +} + + +void MintingView::setModel(WalletModel *model) +{ + this->model = model; + if(model) + { + mintingProxyModel = new MintingFilterProxy(this); + mintingProxyModel->setSourceModel(model->getMintingTableModel()); + mintingProxyModel->setDynamicSortFilter(true); + mintingProxyModel->setSortRole(Qt::EditRole); + + mintingView->setModel(mintingProxyModel); + mintingView->setAlternatingRowColors(true); + mintingView->setSelectionBehavior(QAbstractItemView::SelectRows); + mintingView->setSelectionMode(QAbstractItemView::ExtendedSelection); + mintingView->setSortingEnabled(true); + mintingView->sortByColumn(MintingTableModel::CoinDay, Qt::DescendingOrder); + mintingView->verticalHeader()->hide(); + + mintingView->horizontalHeader()->resizeSection( + MintingTableModel::Address, 420); +#if QT_VERSION < 0x050000 + mintingView->horizontalHeader()->setResizeMode( + MintingTableModel::TxHash, QHeaderView::Stretch); +#else + mintingView->horizontalHeader()->setSectionResizeMode( + MintingTableModel::TxHash, QHeaderView::Stretch); +#endif + mintingView->horizontalHeader()->resizeSection( + MintingTableModel::Age, 120); + mintingView->horizontalHeader()->resizeSection( + MintingTableModel::Balance, 120); + mintingView->horizontalHeader()->resizeSection( + MintingTableModel::CoinDay,120); + mintingView->horizontalHeader()->resizeSection( + MintingTableModel::MintProbability, 160); + } +} + +void MintingView::chooseMintingInterval(int idx) +{ + int interval = 10; + switch(mintingCombo->itemData(idx).toInt()) + { + case Minting10min: + interval = 10; + break; + case Minting1day: + interval = 60*24; + break; + case Minting30days: + interval = 60*24*30; + break; + case Minting90days: + interval = 60*24*90; + break; + } + model->getMintingTableModel()->setMintingInterval(interval); + mintingProxyModel->invalidate(); +} + +void MintingView::exportClicked() +{ + // CSV is currently the only supported format + QString filename = GUIUtil::getSaveFileName( + this, + tr("Export Minting Data"), QString(), + tr("Comma separated file (*.csv)")); + + if (filename.isNull()) return; + + CSVModelWriter writer(filename); + + // 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); + + if(!writer.write()) + { + QMessageBox::critical(this, tr("Error exporting"), tr("Could not write to file %1.").arg(filename), + QMessageBox::Abort, QMessageBox::Abort); + } +} diff --git a/src/qt/mintingview.h b/src/qt/mintingview.h new file mode 100644 index 0000000..452deaa --- /dev/null +++ b/src/qt/mintingview.h @@ -0,0 +1,45 @@ +#ifndef MINTINGVIEW_H +#define MINTINGVIEW_H + +#include +#include +#include "mintingfilterproxy.h" + +class WalletModel; + + +QT_BEGIN_NAMESPACE +class QTableView; +QT_END_NAMESPACE + +class MintingView : public QWidget +{ + Q_OBJECT +public: + explicit MintingView(QWidget *parent = 0); + void setModel(WalletModel *model); + + enum MintingEnum + { + Minting10min, + Minting1day, + Minting30days, + Minting90days + }; + +private: + WalletModel *model; + QTableView *mintingView; + + QComboBox *mintingCombo; + + MintingFilterProxy *mintingProxyModel; + +signals: + +public slots: + void exportClicked(); + void chooseMintingInterval(int idx); +}; + +#endif // MINTINGVIEW_H diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index ad954de..b8e5236 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -2,6 +2,7 @@ #include "guiconstants.h" #include "optionsmodel.h" #include "addresstablemodel.h" +#include "mintingtablemodel.h" #include "transactiontablemodel.h" #include "ui_interface.h" @@ -21,6 +22,7 @@ WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *p cachedNumBlocks(0) { addressTableModel = new AddressTableModel(wallet, this); + mintingTableModel = new MintingTableModel(wallet, this); transactionTableModel = new TransactionTableModel(wallet, this); // This timer will be fired repeatedly to update the balance @@ -252,6 +254,11 @@ AddressTableModel *WalletModel::getAddressTableModel() return addressTableModel; } +MintingTableModel *WalletModel::getMintingTableModel() +{ + return mintingTableModel; +} + TransactionTableModel *WalletModel::getTransactionTableModel() { return transactionTableModel; diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index f155006..caeeb97 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -10,6 +10,7 @@ class OptionsModel; class AddressTableModel; class TransactionTableModel; +class MintingTableModel; class CWallet; class CKeyID; class CPubKey; @@ -61,6 +62,7 @@ public: OptionsModel *getOptionsModel(); AddressTableModel *getAddressTableModel(); + MintingTableModel *getMintingTableModel(); TransactionTableModel *getTransactionTableModel(); qint64 getBalance() const; @@ -141,6 +143,7 @@ private: OptionsModel *optionsModel; AddressTableModel *addressTableModel; + MintingTableModel *mintingTableModel; TransactionTableModel *transactionTableModel; // Cache some values to be able to detect changes diff --git a/src/wallet.cpp b/src/wallet.cpp index dc1000c..3aed377 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -2722,6 +2722,7 @@ void CWallet::UpdatedTransaction(const uint256 &hashTx) map::const_iterator mi = mapWallet.find(hashTx); if (mi != mapWallet.end()) NotifyTransactionChanged(this, hashTx, CT_UPDATED); + vMintingWalletUpdated.push_back(hashTx); } } diff --git a/src/wallet.h b/src/wallet.h index 3522cc8..7f6159c 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -118,6 +118,7 @@ public: } std::map mapWallet; + std::vector vMintingWalletUpdated; int64 nOrderPosNext; std::map mapRequestCount; -- 1.7.1