Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/bitcoin-qt.pro ppcoin-0.3.0-linux/src/bitcoin-qt.pro
- --- ppcoin-0.2.2ppc-linux/src/bitcoin-qt.pro 2012-11-12 13:41:49.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/bitcoin-qt.pro 2013-02-16 21:33:40.000000000 -0800
- @@ -1,5 +1,5 @@
- TEMPLATE = app
- -TARGET =
- +TARGET = ppcoin-qt
- VERSION = 0.6.3.0
- INCLUDEPATH += src src/json src/qt
- DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
- @@ -158,7 +158,8 @@
- src/qt/notificator.h \
- src/qt/qtipcserver.h \
- src/allocators.h \
- - src/ui_interface.h
- + src/ui_interface.h \
- + src/kernel.h
- SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
- src/qt/transactiontablemodel.cpp \
- @@ -212,7 +213,8 @@
- src/qt/askpassphrasedialog.cpp \
- src/protocol.cpp \
- src/qt/notificator.cpp \
- - src/qt/qtipcserver.cpp
- + src/qt/qtipcserver.cpp \
- + src/kernel.cpp
- RESOURCES += \
- src/qt/bitcoin.qrc
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/contrib/gitian-descriptors/gitian-win32.yml ppcoin-0.3.0-linux/src/contrib/gitian-descriptors/gitian-win32.yml
- --- ppcoin-0.2.2ppc-linux/src/contrib/gitian-descriptors/gitian-win32.yml 2012-11-12 13:41:48.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/contrib/gitian-descriptors/gitian-win32.yml 2013-02-16 21:33:42.000000000 -0800
- @@ -15,16 +15,16 @@
- - "url": "https://github.com/ppcoin/ppcoin.git"
- "dir": "ppcoin"
- files:
- -#- "qt-win32-4.7.4-gitian.zip"
- +- "qt-win32-4.7.4-gitian.zip"
- - "boost-win32-1.47.0-gitian.zip"
- - "ppcoin-deps-0.0.1.zip"
- script: |
- #
- - #mkdir $HOME/qt
- - #cd $HOME/qt
- - #unzip ../build/qt-win32-4.7.4-gitian.zip
- - cd $HOME/build
- - #export PATH=$PATH:$HOME/qt/bin/
- + mkdir $HOME/qt
- + cd $HOME/qt
- + unzip ../build/qt-win32-4.7.4-gitian.zip
- + cd $HOME/build/
- + export PATH=$PATH:$HOME/qt/bin/
- #
- mkdir boost_1_47_0
- cd boost_1_47_0
- @@ -51,9 +51,9 @@
- export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
- export FAKETIME=$REFERENCE_DATETIME
- export TZ=UTC
- - #$HOME/qt/src/bin/qmake -spec unsupported/win32-g++-cross MINIUPNPC_LIB_PATH=$HOME/build/miniupnpc MINIUPNPC_INCLUDE_PATH=$HOME/build/ BDB_LIB_PATH=$HOME/build/db-4.8.30.NC/build_unix BDB_INCLUDE_PATH=$HOME/build/db-4.8.30.NC/build_unix BOOST_LIB_PATH=$HOME/build/boost_1_47_0/stage/lib BOOST_INCLUDE_PATH=$HOME/build/boost_1_47_0 BOOST_LIB_SUFFIX=-mt-s BOOST_THREAD_LIB_SUFFIX=_win32-mt-s OPENSSL_LIB_PATH=$HOME/build/openssl-1.0.1b OPENSSL_INCLUDE_PATH=$HOME/build/openssl-1.0.1b/include QRENCODE_LIB_PATH=$HOME/build/qrencode-3.2.0/.libs QRENCODE_INCLUDE_PATH=$HOME/build/qrencode-3.2.0 USE_QRCODE=1 INCLUDEPATH=$HOME/build DEFINES=BOOST_THREAD_USE_LIB BITCOIN_NEED_QT_PLUGINS=1 QMAKE_LRELEASE=lrelease QMAKE_CXXFLAGS=-frandom-seed=ppcoin QMAKE_LFLAGS=-frandom-seed=ppcoin USE_BUILD_INFO=1
- - #make $MAKEOPTS
- - #cp release/bitcoin-qt.exe $OUTDIR/
- + $HOME/qt/src/bin/qmake -spec unsupported/win32-g++-cross MINIUPNPC_LIB_PATH=$HOME/build/miniupnpc MINIUPNPC_INCLUDE_PATH=$HOME/build/ BDB_LIB_PATH=$HOME/build/db-4.8.30.NC/build_unix BDB_INCLUDE_PATH=$HOME/build/db-4.8.30.NC/build_unix BOOST_LIB_PATH=$HOME/build/boost_1_47_0/stage/lib BOOST_INCLUDE_PATH=$HOME/build/boost_1_47_0 BOOST_LIB_SUFFIX=-mt-s BOOST_THREAD_LIB_SUFFIX=_win32-mt-s OPENSSL_LIB_PATH=$HOME/build/openssl-1.0.1b OPENSSL_INCLUDE_PATH=$HOME/build/openssl-1.0.1b/include QRENCODE_LIB_PATH=$HOME/build/qrencode-3.2.0/.libs QRENCODE_INCLUDE_PATH=$HOME/build/qrencode-3.2.0 USE_QRCODE=1 INCLUDEPATH=$HOME/build DEFINES=BOOST_THREAD_USE_LIB BITCOIN_NEED_QT_PLUGINS=1 QMAKE_LRELEASE=lrelease QMAKE_CXXFLAGS=-frandom-seed=ppcoin QMAKE_LFLAGS=-frandom-seed=ppcoin USE_BUILD_INFO=1
- + make $MAKEOPTS
- + cp release/ppcoin-qt.exe $OUTDIR/
- #
- cd src
- export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
- @@ -68,7 +68,7 @@
- git archive HEAD | tar -x -C nsis
- cd nsis/src
- mkdir ../release
- - #cp ../../release/* ../release/
- + cp ../../release/* ../release/
- cp ../../src/*.exe .
- makensis ../share/setup.nsi
- cp ../share/ppcoin-*-win32-setup.exe $OUTDIR/
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/contrib/gitian-descriptors/gitian.yml ppcoin-0.3.0-linux/src/contrib/gitian-descriptors/gitian.yml
- --- ppcoin-0.2.2ppc-linux/src/contrib/gitian-descriptors/gitian.yml 2012-11-12 13:41:48.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/contrib/gitian-descriptors/gitian.yml 2013-02-16 21:33:42.000000000 -0800
- @@ -49,8 +49,8 @@
- make -f makefile.unix STATIC=1 OPENSSL_INCLUDE_PATH="$INSTDIR/include" OPENSSL_LIB_PATH="$INSTDIR/lib" $MAKEOPTS ppcoind USE_UPNP=1 DEBUGFLAGS=
- mkdir -p $OUTDIR/bin/$GBUILD_BITS
- install -s ppcoind $OUTDIR/bin/$GBUILD_BITS
- -#Do not build qt gui client for now
- -# cd ..
- -# qmake INCLUDEPATH="$INSTDIR/include" LIBS="-L$INSTDIR/lib" RELEASE=1 USE_QRCODE=1
- -# make $MAKEOPTS
- -# install bitcoin-qt $OUTDIR/bin/$GBUILD_BITS
- + #
- + cd ..
- + qmake INCLUDEPATH="$INSTDIR/include" LIBS="-L$INSTDIR/lib" RELEASE=1 USE_QRCODE=1
- + make $MAKEOPTS
- + install ppcoin-qt $OUTDIR/bin/$GBUILD_BITS
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/doc/README ppcoin-0.3.0-linux/src/doc/README
- --- ppcoin-0.2.2ppc-linux/src/doc/README 2012-11-12 13:41:49.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/doc/README 2013-02-16 21:33:41.000000000 -0800
- @@ -1,6 +1,6 @@
- -PPCoin 0.2.2 BETA
- +PPCoin 0.3.0 BETA
- -Copyright (c) 2011-2012 PPCoin Developers
- +Copyright (c) 2011-2013 PPCoin Developers
- Distributed under the MIT/X11 software license, see the accompanying
- file license.txt or http://www.opensource.org/licenses/mit-license.php.
- This product includes software developed by the OpenSSL Project for use in
- @@ -19,7 +19,9 @@
- Setup
- -----
- Unpack the files into a directory and run:
- + bin/32/ppcoin-qt (GUI, 32-bit)
- bin/32/ppcoind (headless, 32-bit)
- + bin/64/ppcoin-qt (GUI, 64-bit)
- bin/64/ppcoind (headless, 64-bit)
- The software automatically finds other nodes to connect to. You can
- @@ -31,12 +33,13 @@
- Upgrade
- -------
- -All you existing coins/transactions should be intact with the upgrade.
- +All your existing coins/transactions should be intact with the upgrade.
- To upgrade from 0.2, first backup wallet
- ppcoind backupwallet <destination_backup_file>
- Then shutdown ppcoind by
- ppcoind stop
- -Start up the new ppcoind (0.2.2).
- +Remove files inside wallet directory other than wallet.dat and ppcoin.conf
- +Start up the new ppcoind (0.3.0). It would start re-download of block chain.
- See the documentation/wiki at the ppcoin website:
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/doc/README_windows.txt ppcoin-0.3.0-linux/src/doc/README_windows.txt
- --- ppcoin-0.2.2ppc-linux/src/doc/README_windows.txt 2012-11-12 13:41:49.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/doc/README_windows.txt 2013-02-16 21:33:41.000000000 -0800
- @@ -1,6 +1,6 @@
- -PPCoin 0.2.2 BETA
- +PPCoin 0.3.0 BETA
- -Copyright (c) 2011-2012 PPCoin Developers
- +Copyright (c) 2011-2013 PPCoin Developers
- Distributed under the MIT/X11 software license, see the accompanying
- file license.txt or http://www.opensource.org/licenses/mit-license.php.
- This product includes software developed by the OpenSSL Project for use in
- @@ -18,11 +18,12 @@
- Setup
- -----
- -After completing windows setup then run windows command line (cmd)
- +After completing windows setup then run ppcoin-qt.
- +Alternatively you can run windows command line (cmd) in ppcoin program dir.
- cd daemon
- ppcoind
- You would need to create a configuration file ppcoin.conf in the default
- -wallet directory. Grant access to ppcoind.exe in anti-virus and firewall
- +wallet directory. Grant access to ppcoind/ppcoin-qt in anti-virus and firewall
- applications if necessary.
- The software automatically finds other nodes to connect to. You can
- @@ -34,12 +35,13 @@
- Upgrade
- -------
- -All you existing coins/transactions should be intact with the upgrade.
- +All your existing coins/transactions should be intact with the upgrade.
- To upgrade from 0.2, first backup wallet
- ppcoind backupwallet <destination_backup_file>
- Then shutdown ppcoind by
- ppcoind stop
- -Start up the new ppcoind (0.2.2).
- +Remove files inside wallet directory other than wallet.dat and ppcoin.conf
- +Start up the new ppcoin-qt (0.3.0). It would start re-download of block chain.
- See the documentation/wiki at the ppcoin website:
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/share/setup.nsi ppcoin-0.3.0-linux/src/share/setup.nsi
- --- ppcoin-0.2.2ppc-linux/src/share/setup.nsi 2012-11-12 13:41:49.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/share/setup.nsi 2013-02-16 21:33:51.000000000 -0800
- @@ -5,7 +5,7 @@
- # General Symbol Definitions
- !define REGKEY "SOFTWARE\$(^Name)"
- -!define VERSION 0.2.2
- +!define VERSION 0.3.0
- !define COMPANY "PPCoin project"
- !define URL http://www.ppcoin.org/
- @@ -20,7 +20,7 @@
- !define MUI_STARTMENUPAGE_REGISTRY_KEY ${REGKEY}
- !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuGroup
- !define MUI_STARTMENUPAGE_DEFAULTFOLDER PPCoin
- -#!define MUI_FINISHPAGE_RUN $INSTDIR\bitcoin-qt.exe
- +!define MUI_FINISHPAGE_RUN $INSTDIR\ppcoin-qt.exe
- !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
- !define MUI_UNWELCOMEFINISHPAGE_BITMAP "../share/pixmaps/nsis-wizard.bmp"
- !define MUI_UNFINISHPAGE_NOAUTOCLOSE
- @@ -45,13 +45,13 @@
- !insertmacro MUI_LANGUAGE English
- # Installer attributes
- -OutFile ppcoin-0.2.2-win32-setup.exe
- +OutFile ppcoin-0.3.0-win32-setup.exe
- InstallDir $PROGRAMFILES\PPCoin
- CRCCheck on
- XPStyle on
- BrandingText " "
- ShowInstDetails show
- -VIProductVersion 0.2.2.0
- +VIProductVersion 0.3.0.0
- VIAddVersionKey ProductName PPCoin
- VIAddVersionKey ProductVersion "${VERSION}"
- VIAddVersionKey CompanyName "${COMPANY}"
- @@ -66,7 +66,7 @@
- Section -Main SEC0000
- SetOutPath $INSTDIR
- SetOverwrite on
- - #File ../release/bitcoin-qt.exe
- + File ../release/ppcoin-qt.exe
- File /oname=license.txt ../COPYING
- File /oname=readme.txt ../doc/README_windows.txt
- SetOutPath $INSTDIR\daemon
- @@ -87,7 +87,7 @@
- WriteUninstaller $INSTDIR\uninstall.exe
- !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
- CreateDirectory $SMPROGRAMS\$StartMenuGroup
- - #CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Bitcoin.lnk" $INSTDIR\bitcoin-qt.exe
- + CreateShortcut "$SMPROGRAMS\$StartMenuGroup\PPCoin.lnk" $INSTDIR\ppcoin-qt.exe
- CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall PPCoin.lnk" $INSTDIR\uninstall.exe
- !insertmacro MUI_STARTMENU_WRITE_END
- WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
- @@ -121,7 +121,7 @@
- # Uninstaller sections
- Section /o -un.Main UNSEC0000
- - #Delete /REBOOTOK $INSTDIR\bitcoin-qt.exe
- + Delete /REBOOTOK $INSTDIR\ppcoin-qt.exe
- Delete /REBOOTOK $INSTDIR\license.txt
- Delete /REBOOTOK $INSTDIR\readme.txt
- RMDir /r /REBOOTOK $INSTDIR\daemon
- @@ -132,8 +132,8 @@
- Section -un.post UNSEC0001
- DeleteRegKey HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
- Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall PPCoin.lnk"
- - #Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Bitcoin.lnk"
- - #Delete /REBOOTOK "$SMSTARTUP\Bitcoin.lnk"
- + Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\PPCoin.lnk"
- + Delete /REBOOTOK "$SMSTARTUP\PPCoin.lnk"
- Delete /REBOOTOK $INSTDIR\uninstall.exe
- Delete /REBOOTOK $INSTDIR\debug.log
- Delete /REBOOTOK $INSTDIR\db.log
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/base58.h ppcoin-0.3.0-linux/src/src/base58.h
- --- ppcoin-0.2.2ppc-linux/src/src/base58.h 2012-11-12 13:41:36.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/base58.h 2013-02-16 21:33:43.000000000 -0800
- @@ -365,7 +365,7 @@
- void SetSecret(const CSecret& vchSecret, bool fCompressed)
- {
- assert(vchSecret.size() == 32);
- - SetData(fTestNet ? 239 : 128, &vchSecret[0], vchSecret.size());
- + SetData(128 + (fTestNet ? CBitcoinAddress::PUBKEY_ADDRESS_TEST : CBitcoinAddress::PUBKEY_ADDRESS), &vchSecret[0], vchSecret.size());
- if (fCompressed)
- vchData.push_back(1);
- }
- @@ -384,10 +384,10 @@
- bool fExpectTestNet = false;
- switch(nVersion)
- {
- - case 128:
- + case (128 + CBitcoinAddress::PUBKEY_ADDRESS):
- break;
- - case 239:
- + case (128 + CBitcoinAddress::PUBKEY_ADDRESS_TEST):
- fExpectTestNet = true;
- break;
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/bitcoinrpc.cpp ppcoin-0.3.0-linux/src/src/bitcoinrpc.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/bitcoinrpc.cpp 2012-11-12 13:41:37.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/bitcoinrpc.cpp 2013-02-16 21:33:51.000000000 -0800
- @@ -1,6 +1,6 @@
- // Copyright (c) 2010 Satoshi Nakamoto
- // Copyright (c) 2009-2012 The Bitcoin developers
- -// Copyright (c) 2011-2012 The PPCoin developers
- +// Copyright (c) 2011-2013 The PPCoin developers
- // Distributed under the MIT/X11 software license, see the accompanying
- // file COPYING or http://www.opensource.org/licenses/mit-license.php.
- @@ -153,6 +153,11 @@
- result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
- if (blockindex->pnext)
- result.push_back(Pair("nextblockhash", blockindex->pnext->GetBlockHash().GetHex()));
- + result.push_back(Pair("flags", strprintf("%s%s", blockindex->IsProofOfStake()? "proof-of-stake" : "proof-of-work", blockindex->GeneratedStakeModifier()? " stake-modifier": "")));
- + result.push_back(Pair("proofhash", blockindex->IsProofOfStake()? blockindex->hashProofOfStake.GetHex() : blockindex->GetBlockHash().GetHex()));
- + result.push_back(Pair("entropybit", (int)blockindex->GetStakeEntropyBit()));
- + result.push_back(Pair("modifier", strprintf("%016"PRI64x, blockindex->nStakeModifier)));
- + result.push_back(Pair("modifierchecksum", strprintf("%08x", blockindex->nStakeModifierChecksum)));
- Array txinfo;
- BOOST_FOREACH (const CTransaction& tx, block.vtx)
- {
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/checkpoints.cpp ppcoin-0.3.0-linux/src/src/checkpoints.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/checkpoints.cpp 2012-11-12 13:41:44.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/checkpoints.cpp 2013-02-16 21:33:43.000000000 -0800
- @@ -1,5 +1,5 @@
- // Copyright (c) 2009-2012 The Bitcoin developers
- -// Copyright (c) 2011-2012 The PPCoin developers
- +// Copyright (c) 2011-2013 The PPCoin developers
- // Distributed under the MIT/X11 software license, see the accompanying
- // file COPYING or http://www.opensource.org/licenses/mit-license.php.
- @@ -26,7 +26,9 @@
- static MapCheckpoints mapCheckpoints =
- boost::assign::map_list_of
- ( 0, hashGenesisBlockOfficial )
- - ; // ppcoin: no checkpoint yet; to be created in future releases
- + ( 19080, uint256("0x000000000000bca54d9ac17881f94193fd6a270c1bb21c3bf0b37f588a40dbd7"))
- + ( 30583, uint256("0xd39d1481a7eecba48932ea5913be58ad3894c7ee6d5a8ba8abeb772c66a6696e"))
- + ;
- bool CheckHardened(int nHeight, const uint256& hash)
- {
- @@ -351,6 +353,16 @@
- return (nBestHeight >= pindexSync->nHeight + nCoinbaseMaturity ||
- pindexSync->GetBlockTime() + nStakeMinAge < GetAdjustedTime());
- }
- +
- + // Is the sync-checkpoint too old?
- + bool IsSyncCheckpointTooOld(unsigned int nSeconds)
- + {
- + LOCK(cs_hashSyncCheckpoint);
- + // sync-checkpoint should always be accepted block
- + assert(mapBlockIndex.count(hashSyncCheckpoint));
- + const CBlockIndex* pindexSync = mapBlockIndex[hashSyncCheckpoint];
- + return (pindexSync->GetBlockTime() + nSeconds < GetAdjustedTime());
- + }
- }
- // ppcoin: sync-checkpoint master key
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/checkpoints.h ppcoin-0.3.0-linux/src/src/checkpoints.h
- --- ppcoin-0.2.2ppc-linux/src/src/checkpoints.h 2012-11-12 13:41:36.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/checkpoints.h 2013-02-16 21:33:43.000000000 -0800
- @@ -1,5 +1,5 @@
- // Copyright (c) 2009-2012 The Bitcoin developers
- -// Copyright (c) 2011-2012 The PPCoin developers
- +// Copyright (c) 2011-2013 The PPCoin developers
- // Distributed under the MIT/X11 software license, see the accompanying
- // file COPYING or http://www.opensource.org/licenses/mit-license.php.
- #ifndef BITCOIN_CHECKPOINT_H
- @@ -9,8 +9,6 @@
- #include "net.h"
- #include "util.h"
- -#define STAKE_MIN_AGE (60 * 60 * 24 * 30) // minimum age 30 days for coin age
- -#define STAKE_MAX_AGE (60 * 60 * 24 * 90) // stake age for full weight
- #define CHECKPOINT_MAX_SPAN (60 * 60 * 4) // max 4 hours before latest block
- class uint256;
- @@ -47,6 +45,7 @@
- bool SetCheckpointPrivKey(std::string strPrivKey);
- bool SendSyncCheckpoint(uint256 hashCheckpoint);
- bool IsMatureSyncCheckpoint();
- + bool IsSyncCheckpointTooOld(unsigned int nSeconds);
- }
- // ppcoin: synchronized checkpoint
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/db.cpp ppcoin-0.3.0-linux/src/src/db.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/db.cpp 2012-11-12 13:41:45.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/db.cpp 2013-02-16 21:33:45.000000000 -0800
- @@ -1,6 +1,6 @@
- // Copyright (c) 2009-2010 Satoshi Nakamoto
- // Copyright (c) 2009-2012 The Bitcoin developers
- -// Copyright (c) 2011-2012 The PPCoin developers
- +// Copyright (c) 2011-2013 The PPCoin developers
- // Distributed under the MIT/X11 software license, see the accompanying
- // file COPYING or http://www.opensource.org/licenses/mit-license.php.
- @@ -9,6 +9,7 @@
- #include "checkpoints.h"
- #include "util.h"
- #include "main.h"
- +#include "kernel.h"
- #include <boost/version.hpp>
- #include <boost/filesystem.hpp>
- #include <boost/filesystem/fstream.hpp>
- @@ -580,8 +581,11 @@
- pindexNew->nHeight = diskindex.nHeight;
- pindexNew->nMint = diskindex.nMint;
- pindexNew->nMoneySupply = diskindex.nMoneySupply;
- - pindexNew->fProofOfStake = diskindex.fProofOfStake;
- + pindexNew->nFlags = diskindex.nFlags;
- + pindexNew->nStakeModifier = diskindex.nStakeModifier;
- pindexNew->prevoutStake = diskindex.prevoutStake;
- + pindexNew->nStakeTime = diskindex.nStakeTime;
- + pindexNew->hashProofOfStake = diskindex.hashProofOfStake;
- pindexNew->nVersion = diskindex.nVersion;
- pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot;
- pindexNew->nTime = diskindex.nTime;
- @@ -596,7 +600,7 @@
- return error("LoadBlockIndex() : CheckIndex failed at %d", pindexNew->nHeight);
- // ppcoin: build setStakeSeen
- - if (pindexNew->fProofOfStake)
- + if (pindexNew->IsProofOfStake())
- setStakeSeen.insert(make_pair(pindexNew->prevoutStake, pindexNew->nStakeTime));
- }
- else
- @@ -626,6 +630,10 @@
- {
- CBlockIndex* pindex = item.second;
- pindex->bnChainTrust = (pindex->pprev ? pindex->pprev->bnChainTrust : 0) + pindex->GetBlockTrust();
- + // ppcoin: calculate stake modifier checksum
- + pindex->nStakeModifierChecksum = GetStakeModifierChecksum(pindex);
- + if (!CheckStakeModifierCheckpoints(pindex->nHeight, pindex->nStakeModifierChecksum))
- + return error("CTxDB::LoadBlockIndex() : Failed stake modifier checkpoint height=%d, modifier=0x%016"PRI64x, pindex->nHeight, pindex->nStakeModifier);
- }
- // Load hashBestChain pointer to end of best chain
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/init.cpp ppcoin-0.3.0-linux/src/src/init.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/init.cpp 2012-11-12 13:41:45.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/init.cpp 2013-02-16 21:33:51.000000000 -0800
- @@ -1,6 +1,6 @@
- // Copyright (c) 2009-2010 Satoshi Nakamoto
- // Copyright (c) 2009-2012 The Bitcoin developers
- -// Copyright (c) 2011-2012 The PPCoin developers
- +// Copyright (c) 2011-2013 The PPCoin developers
- // Distributed under the MIT/X11 software license, see the accompanying
- // file COPYING or http://www.opensource.org/licenses/mit-license.php.
- #include "db.h"
- @@ -449,7 +449,7 @@
- if (walletdb.ReadBestBlock(locator))
- pindexRescan = locator.GetBlockIndex();
- }
- - if (pindexBest != pindexRescan)
- + if (pindexBest != pindexRescan && pindexBest && pindexRescan && pindexBest->nHeight > pindexRescan->nHeight)
- {
- InitMessage(_("Rescanning..."));
- printf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight);
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/kernel.cpp ppcoin-0.3.0-linux/src/src/kernel.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/kernel.cpp 1969-12-31 16:00:00.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/kernel.cpp 2013-02-16 21:33:43.000000000 -0800
- @@ -0,0 +1,403 @@
- +// Copyright (c) 2012-2013 The PPCoin developers
- +// Distributed under the MIT/X11 software license, see the accompanying
- +// file COPYING or http://www.opensource.org/licenses/mit-license.php.
- +
- +#include <boost/assign/list_of.hpp>
- +
- +#include "kernel.h"
- +#include "db.h"
- +
- +using namespace std;
- +
- +// Protocol switch time of v0.3 kernel protocol
- +unsigned int nProtocolV03SwitchTime = 1363800000;
- +unsigned int nProtocolV03TestSwitchTime = 1359781000;
- +
- +// Modifier interval: time to elapse before new modifier is computed
- +// Set to 6-hour for production network and 20-minute for test network
- +unsigned int nModifierInterval = MODIFIER_INTERVAL;
- +
- +// Hard checkpoints of stake modifiers to ensure they are deterministic
- +static std::map<int, unsigned int> mapStakeModifierCheckpoints =
- + boost::assign::map_list_of
- + ( 0, 0x0e00670bu )
- + ( 19080, 0xad4e4d29u )
- + ( 30583, 0xdc7bf136u )
- + ;
- +
- +// Whether the given coinstake is subject to new v0.3 protocol
- +bool IsProtocolV03(unsigned int nTimeCoinStake)
- +{
- + return (nTimeCoinStake >= (fTestNet? nProtocolV03TestSwitchTime : nProtocolV03SwitchTime));
- +}
- +
- +// Get the last stake modifier and its generation time from a given block
- +static bool GetLastStakeModifier(const CBlockIndex* pindex, uint64& nStakeModifier, int64& nModifierTime)
- +{
- + if (!pindex)
- + return error("GetLastStakeModifier: null pindex");
- + while (pindex && pindex->pprev && !pindex->GeneratedStakeModifier())
- + pindex = pindex->pprev;
- + if (!pindex->GeneratedStakeModifier())
- + return error("GetLastStakeModifier: no generation at genesis block");
- + nStakeModifier = pindex->nStakeModifier;
- + nModifierTime = pindex->GetBlockTime();
- + return true;
- +}
- +
- +// Get selection interval section (in seconds)
- +static int64 GetStakeModifierSelectionIntervalSection(int nSection)
- +{
- + assert (nSection >= 0 && nSection < 64);
- + return (nModifierInterval * 63 / (63 + ((63 - nSection) * (MODIFIER_INTERVAL_RATIO - 1))));
- +}
- +
- +// Get stake modifier selection interval (in seconds)
- +static int64 GetStakeModifierSelectionInterval()
- +{
- + int64 nSelectionInterval = 0;
- + for (int nSection=0; nSection<64; nSection++)
- + nSelectionInterval += GetStakeModifierSelectionIntervalSection(nSection);
- + return nSelectionInterval;
- +}
- +
- +// select a block from the candidate blocks in vSortedByTimestamp, excluding
- +// already selected blocks in vSelectedBlocks, and with timestamp up to
- +// nSelectionIntervalStop.
- +static bool SelectBlockFromCandidates(
- + vector<pair<int64, uint256> >& vSortedByTimestamp,
- + map<uint256, const CBlockIndex*>& mapSelectedBlocks,
- + int64 nSelectionIntervalStop, uint64 nStakeModifierPrev,
- + const CBlockIndex** pindexSelected)
- +{
- + bool fSelected = false;
- + uint256 hashBest = 0;
- + *pindexSelected = (const CBlockIndex*) 0;
- + BOOST_FOREACH(const PAIRTYPE(int64, uint256)& item, vSortedByTimestamp)
- + {
- + if (!mapBlockIndex.count(item.second))
- + return error("SelectBlockFromCandidates: failed to find block index for candidate block %s", item.second.ToString().c_str());
- + const CBlockIndex* pindex = mapBlockIndex[item.second];
- + if (fSelected && pindex->GetBlockTime() > nSelectionIntervalStop)
- + break;
- + if (mapSelectedBlocks.count(pindex->GetBlockHash()) > 0)
- + continue;
- + // compute the selection hash by hashing its proof-hash and the
- + // previous proof-of-stake modifier
- + uint256 hashProof = pindex->IsProofOfStake()? pindex->hashProofOfStake : pindex->GetBlockHash();
- + CDataStream ss(SER_GETHASH, 0);
- + ss << hashProof << nStakeModifierPrev;
- + uint256 hashSelection = Hash(ss.begin(), ss.end());
- + // the selection hash is divided by 2**32 so that proof-of-stake block
- + // is always favored over proof-of-work block. this is to preserve
- + // the energy efficiency property
- + if (pindex->IsProofOfStake())
- + hashSelection >>= 32;
- + if (fSelected && hashSelection < hashBest)
- + {
- + hashBest = hashSelection;
- + *pindexSelected = (const CBlockIndex*) pindex;
- + }
- + else if (!fSelected)
- + {
- + fSelected = true;
- + hashBest = hashSelection;
- + *pindexSelected = (const CBlockIndex*) pindex;
- + }
- + }
- + if (fDebug && GetBoolArg("-printstakemodifier"))
- + printf("SelectBlockFromCandidates: selection hash=%s\n", hashBest.ToString().c_str());
- + return fSelected;
- +}
- +
- +// Stake Modifier (hash modifier of proof-of-stake):
- +// The purpose of stake modifier is to prevent a txout (coin) owner from
- +// computing future proof-of-stake generated by this txout at the time
- +// of transaction confirmation. To meet kernel protocol, the txout
- +// must hash with a future stake modifier to generate the proof.
- +// Stake modifier consists of bits each of which is contributed from a
- +// selected block of a given block group in the past.
- +// The selection of a block is based on a hash of the block's proof-hash and
- +// the previous stake modifier.
- +// Stake modifier is recomputed at a fixed time interval instead of every
- +// block. This is to make it difficult for an attacker to gain control of
- +// additional bits in the stake modifier, even after generating a chain of
- +// blocks.
- +bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64& nStakeModifier, bool& fGeneratedStakeModifier)
- +{
- + nStakeModifier = 0;
- + fGeneratedStakeModifier = false;
- + if (!pindexPrev)
- + {
- + fGeneratedStakeModifier = true;
- + return true; // genesis block's modifier is 0
- + }
- + // First find current stake modifier and its generation block time
- + // if it's not old enough, return the same stake modifier
- + int64 nModifierTime = 0;
- + if (!GetLastStakeModifier(pindexPrev, nStakeModifier, nModifierTime))
- + return error("ComputeNextStakeModifier: unable to get last modifier");
- + if (fDebug)
- + {
- + printf("ComputeNextStakeModifier: prev modifier=0x%016"PRI64x" time=%s\n", nStakeModifier, DateTimeStrFormat(nModifierTime).c_str());
- + }
- + if (nModifierTime / nModifierInterval >= pindexPrev->GetBlockTime() / nModifierInterval)
- + return true;
- +
- + // Sort candidate blocks by timestamp
- + vector<pair<int64, uint256> > vSortedByTimestamp;
- + vSortedByTimestamp.reserve(64 * nModifierInterval / STAKE_TARGET_SPACING);
- + int64 nSelectionInterval = GetStakeModifierSelectionInterval();
- + int64 nSelectionIntervalStart = (pindexPrev->GetBlockTime() / nModifierInterval) * nModifierInterval - nSelectionInterval;
- + const CBlockIndex* pindex = pindexPrev;
- + while (pindex && pindex->GetBlockTime() >= nSelectionIntervalStart)
- + {
- + vSortedByTimestamp.push_back(make_pair(pindex->GetBlockTime(), pindex->GetBlockHash()));
- + pindex = pindex->pprev;
- + }
- + int nHeightFirstCandidate = pindex ? (pindex->nHeight + 1) : 0;
- + reverse(vSortedByTimestamp.begin(), vSortedByTimestamp.end());
- + sort(vSortedByTimestamp.begin(), vSortedByTimestamp.end());
- +
- + // Select 64 blocks from candidate blocks to generate stake modifier
- + uint64 nStakeModifierNew = 0;
- + int64 nSelectionIntervalStop = nSelectionIntervalStart;
- + map<uint256, const CBlockIndex*> mapSelectedBlocks;
- + for (int nRound=0; nRound<min(64, (int)vSortedByTimestamp.size()); nRound++)
- + {
- + // add an interval section to the current selection round
- + nSelectionIntervalStop += GetStakeModifierSelectionIntervalSection(nRound);
- + // select a block from the candidates of current round
- + if (!SelectBlockFromCandidates(vSortedByTimestamp, mapSelectedBlocks, nSelectionIntervalStop, nStakeModifier, &pindex))
- + return error("ComputeNextStakeModifier: unable to select block at round %d", nRound);
- + // write the entropy bit of the selected block
- + nStakeModifierNew |= (((uint64)pindex->GetStakeEntropyBit()) << nRound);
- + // add the selected block from candidates to selected list
- + mapSelectedBlocks.insert(make_pair(pindex->GetBlockHash(), pindex));
- + if (fDebug && GetBoolArg("-printstakemodifier"))
- + printf("ComputeNextStakeModifier: selected round %d stop=%s height=%d bit=%d\n",
- + nRound, DateTimeStrFormat(nSelectionIntervalStop).c_str(), pindex->nHeight, pindex->GetStakeEntropyBit());
- + }
- +
- + // Print selection map for visualization of the selected blocks
- + if (fDebug && GetBoolArg("-printstakemodifier"))
- + {
- + string strSelectionMap = "";
- + // '-' indicates proof-of-work blocks not selected
- + strSelectionMap.insert(0, pindexPrev->nHeight - nHeightFirstCandidate + 1, '-');
- + pindex = pindexPrev;
- + while (pindex && pindex->nHeight >= nHeightFirstCandidate)
- + {
- + // '=' indicates proof-of-stake blocks not selected
- + if (pindex->IsProofOfStake())
- + strSelectionMap.replace(pindex->nHeight - nHeightFirstCandidate, 1, "=");
- + pindex = pindex->pprev;
- + }
- + BOOST_FOREACH(const PAIRTYPE(uint256, const CBlockIndex*)& item, mapSelectedBlocks)
- + {
- + // 'S' indicates selected proof-of-stake blocks
- + // 'W' indicates selected proof-of-work blocks
- + strSelectionMap.replace(item.second->nHeight - nHeightFirstCandidate, 1, item.second->IsProofOfStake()? "S" : "W");
- + }
- + printf("ComputeNextStakeModifier: selection height [%d, %d] map %s\n", nHeightFirstCandidate, pindexPrev->nHeight, strSelectionMap.c_str());
- + }
- + if (fDebug)
- + {
- + printf("ComputeNextStakeModifier: new modifier=0x%016"PRI64x" time=%s\n", nStakeModifierNew, DateTimeStrFormat(pindexPrev->GetBlockTime()).c_str());
- + }
- +
- + nStakeModifier = nStakeModifierNew;
- + fGeneratedStakeModifier = true;
- + return true;
- +}
- +
- +// The stake modifier used to hash for a stake kernel is chosen as the stake
- +// modifier about a selection interval later than the coin generating the kernel
- +static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64& nStakeModifier, int& nStakeModifierHeight, int64& nStakeModifierTime, bool fPrintProofOfStake)
- +{
- + nStakeModifier = 0;
- + if (!mapBlockIndex.count(hashBlockFrom))
- + return error("GetKernelStakeModifier() : block not indexed");
- + const CBlockIndex* pindexFrom = mapBlockIndex[hashBlockFrom];
- + nStakeModifierHeight = pindexFrom->nHeight;
- + nStakeModifierTime = pindexFrom->GetBlockTime();
- + int64 nStakeModifierSelectionInterval = GetStakeModifierSelectionInterval();
- + const CBlockIndex* pindex = pindexFrom;
- + // loop to find the stake modifier later by a selection interval
- + while (nStakeModifierTime < pindexFrom->GetBlockTime() + nStakeModifierSelectionInterval)
- + {
- + if (!pindex->pnext)
- + { // reached best block; may happen if node is behind on block chain
- + if (fPrintProofOfStake || (pindex->GetBlockTime() + nStakeMinAge - nStakeModifierSelectionInterval > GetAdjustedTime()))
- + return error("GetKernelStakeModifier() : reached best block %s at height %d from block %s",
- + pindex->GetBlockHash().ToString().c_str(), pindex->nHeight, hashBlockFrom.ToString().c_str());
- + else
- + return false;
- + }
- + pindex = pindex->pnext;
- + if (pindex->GeneratedStakeModifier())
- + {
- + nStakeModifierHeight = pindex->nHeight;
- + nStakeModifierTime = pindex->GetBlockTime();
- + }
- + }
- + nStakeModifier = pindex->nStakeModifier;
- + return true;
- +}
- +
- +// ppcoin kernel protocol
- +// coinstake must meet hash target according to the protocol:
- +// kernel (input 0) must meet the formula
- +// hash(nStakeModifier + txPrev.block.nTime + txPrev.offset + txPrev.nTime + txPrev.vout.n + nTime) < bnTarget * nCoinDayWeight
- +// this ensures that the chance of getting a coinstake is proportional to the
- +// amount of coin age one owns.
- +// The reason this hash is chosen is the following:
- +// nStakeModifier:
- +// (v0.3) scrambles computation to make it very difficult to precompute
- +// future proof-of-stake at the time of the coin's confirmation
- +// (v0.2) nBits (deprecated): encodes all past block timestamps
- +// txPrev.block.nTime: prevent nodes from guessing a good timestamp to
- +// generate transaction for future advantage
- +// txPrev.offset: offset of txPrev inside block, to reduce the chance of
- +// nodes generating coinstake at the same time
- +// txPrev.nTime: reduce the chance of nodes generating coinstake at the same
- +// time
- +// txPrev.vout.n: output number of txPrev, to reduce the chance of nodes
- +// generating coinstake at the same time
- +// block/tx hash should not be used here as they can be generated in vast
- +// quantities so as to generate blocks faster, degrading the system back into
- +// a proof-of-work situation.
- +//
- +bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned int nTxPrevOffset, const CTransaction& txPrev, const COutPoint& prevout, unsigned int nTimeTx, uint256& hashProofOfStake, bool fPrintProofOfStake)
- +{
- + if (nTimeTx < txPrev.nTime) // Transaction timestamp violation
- + return error("CheckStakeKernelHash() : nTime violation");
- +
- + unsigned int nTimeBlockFrom = blockFrom.GetBlockTime();
- + if (nTimeBlockFrom + nStakeMinAge > nTimeTx) // Min age requirement
- + return error("CheckStakeKernelHash() : min age violation");
- +
- + CBigNum bnTargetPerCoinDay;
- + bnTargetPerCoinDay.SetCompact(nBits);
- + int64 nValueIn = txPrev.vout[prevout.n].nValue;
- + // v0.3 protocol kernel hash weight starts from 0 at the 30-day min age
- + // this change increases active coins participating the hash and helps
- + // to secure the network when proof-of-stake difficulty is low
- + int64 nTimeWeight = min((int64)nTimeTx - txPrev.nTime, (int64)STAKE_MAX_AGE) - (IsProtocolV03(nTimeTx)? nStakeMinAge : 0);
- + CBigNum bnCoinDayWeight = CBigNum(nValueIn) * nTimeWeight / COIN / (24 * 60 * 60);
- + // Calculate hash
- + CDataStream ss(SER_GETHASH, 0);
- + uint64 nStakeModifier = 0;
- + int nStakeModifierHeight = 0;
- + int64 nStakeModifierTime = 0;
- + if (IsProtocolV03(nTimeTx)) // v0.3 protocol
- + {
- + if (!GetKernelStakeModifier(blockFrom.GetHash(), nStakeModifier, nStakeModifierHeight, nStakeModifierTime, fPrintProofOfStake))
- + return false;
- + ss << nStakeModifier;
- + }
- + else // v0.2 protocol
- + {
- + ss << nBits;
- + }
- +
- + ss << nTimeBlockFrom << nTxPrevOffset << txPrev.nTime << prevout.n << nTimeTx;
- + hashProofOfStake = Hash(ss.begin(), ss.end());
- + if (fPrintProofOfStake)
- + {
- + if (IsProtocolV03(nTimeTx))
- + printf("CheckStakeKernelHash() : using modifier 0x%016"PRI64x" at height=%d timestamp=%s for block from height=%d timestamp=%s\n",
- + nStakeModifier, nStakeModifierHeight,
- + DateTimeStrFormat(nStakeModifierTime).c_str(),
- + mapBlockIndex[blockFrom.GetHash()]->nHeight,
- + DateTimeStrFormat(blockFrom.GetBlockTime()).c_str());
- + printf("CheckStakeKernelHash() : check protocol=%s modifier=0x%016"PRI64x" nTimeBlockFrom=%u nTxPrevOffset=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n",
- + IsProtocolV03(nTimeTx)? "0.3" : "0.2",
- + IsProtocolV03(nTimeTx)? nStakeModifier : (uint64) nBits,
- + nTimeBlockFrom, nTxPrevOffset, txPrev.nTime, prevout.n, nTimeTx,
- + hashProofOfStake.ToString().c_str());
- + }
- +
- + // Now check if proof-of-stake hash meets target protocol
- + if (CBigNum(hashProofOfStake) > bnCoinDayWeight * bnTargetPerCoinDay)
- + return false;
- + if (fDebug && !fPrintProofOfStake)
- + {
- + if (IsProtocolV03(nTimeTx))
- + printf("CheckStakeKernelHash() : using modifier 0x%016"PRI64x" at height=%d timestamp=%s for block from height=%d timestamp=%s\n",
- + nStakeModifier, nStakeModifierHeight,
- + DateTimeStrFormat(nStakeModifierTime).c_str(),
- + mapBlockIndex[blockFrom.GetHash()]->nHeight,
- + DateTimeStrFormat(blockFrom.GetBlockTime()).c_str());
- + printf("CheckStakeKernelHash() : pass protocol=%s modifier=0x%016"PRI64x" nTimeBlockFrom=%u nTxPrevOffset=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n",
- + IsProtocolV03(nTimeTx)? "0.3" : "0.2",
- + IsProtocolV03(nTimeTx)? nStakeModifier : (uint64) nBits,
- + nTimeBlockFrom, nTxPrevOffset, txPrev.nTime, prevout.n, nTimeTx,
- + hashProofOfStake.ToString().c_str());
- + }
- + return true;
- +}
- +
- +// Check kernel hash target and coinstake signature
- +bool CheckProofOfStake(const CTransaction& tx, unsigned int nBits, uint256& hashProofOfStake)
- +{
- + if (!tx.IsCoinStake())
- + return error("CheckProofOfStake() : called on non-coinstake %s", tx.GetHash().ToString().c_str());
- +
- + // Kernel (input 0) must match the stake hash target per coin age (nBits)
- + const CTxIn& txin = tx.vin[0];
- +
- + // First try finding the previous transaction in database
- + CTxDB txdb("r");
- + CTransaction txPrev;
- + CTxIndex txindex;
- + if (!txPrev.ReadFromDisk(txdb, txin.prevout, txindex))
- + return tx.DoS(1, error("CheckProofOfStake() : INFO: read txPrev failed")); // previous transaction not in main chain, may occur during initial download
- + txdb.Close();
- +
- + // Verify signature
- + if (!VerifySignature(txPrev, tx, 0, true, 0))
- + return tx.DoS(100, error("CheckProofOfStake() : VerifySignature failed on coinstake %s", tx.GetHash().ToString().c_str()));
- +
- + // Read block header
- + CBlock block;
- + if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false))
- + return fDebug? error("CheckProofOfStake() : read block failed") : false; // unable to read block of previous transaction
- +
- + if (!CheckStakeKernelHash(nBits, block, txindex.pos.nTxPos - txindex.pos.nBlockPos, txPrev, txin.prevout, tx.nTime, hashProofOfStake, fDebug))
- + return tx.DoS(1, error("CheckProofOfStake() : INFO: check kernel failed on coinstake %s, hashProof=%s", tx.GetHash().ToString().c_str(), hashProofOfStake.ToString().c_str())); // may occur during initial download or if behind on block chain sync
- +
- + return true;
- +}
- +
- +// Check whether the coinstake timestamp meets protocol
- +bool CheckCoinStakeTimestamp(int64 nTimeBlock, int64 nTimeTx)
- +{
- + if (IsProtocolV03(nTimeTx)) // v0.3 protocol
- + return (nTimeBlock == nTimeTx);
- + else // v0.2 protocol
- + return ((nTimeTx <= nTimeBlock) && (nTimeBlock <= nTimeTx + nMaxClockDrift));
- +}
- +
- +// Get stake modifier checksum
- +unsigned int GetStakeModifierChecksum(const CBlockIndex* pindex)
- +{
- + assert (pindex->pprev || pindex->GetBlockHash() == hashGenesisBlock);
- + // Hash previous checksum with flags, hashProofOfStake and nStakeModifier
- + CDataStream ss(SER_GETHASH, 0);
- + if (pindex->pprev)
- + ss << pindex->pprev->nStakeModifierChecksum;
- + ss << pindex->nFlags << pindex->hashProofOfStake << pindex->nStakeModifier;
- + uint256 hashChecksum = Hash(ss.begin(), ss.end());
- + hashChecksum >>= (256 - 32);
- + return hashChecksum.Get64();
- +}
- +
- +// Check stake modifier hard checkpoints
- +bool CheckStakeModifierCheckpoints(int nHeight, unsigned int nStakeModifierChecksum)
- +{
- + if (fTestNet) return true; // Testnet has no checkpoints
- + if (mapStakeModifierCheckpoints.count(nHeight))
- + return nStakeModifierChecksum == mapStakeModifierCheckpoints[nHeight];
- + return true;
- +}
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/kernel.h ppcoin-0.3.0-linux/src/src/kernel.h
- --- ppcoin-0.2.2ppc-linux/src/src/kernel.h 1969-12-31 16:00:00.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/kernel.h 2013-02-16 21:33:44.000000000 -0800
- @@ -0,0 +1,44 @@
- +// Copyright (c) 2012-2013 The PPCoin developers
- +// Distributed under the MIT/X11 software license, see the accompanying
- +// file COPYING or http://www.opensource.org/licenses/mit-license.php.
- +#ifndef PPCOIN_KERNEL_H
- +#define PPCOIN_KERNEL_H
- +
- +#include "main.h"
- +
- +// MODIFIER_INTERVAL: time to elapse before new modifier is computed
- +static const unsigned int MODIFIER_INTERVAL = 6 * 60 * 60;
- +extern unsigned int nModifierInterval;
- +
- +// MODIFIER_INTERVAL_RATIO:
- +// ratio of group interval length between the last group and the first group
- +static const int MODIFIER_INTERVAL_RATIO = 3;
- +
- +// Protocol switch time of v0.3 kernel protocol
- +extern unsigned int nProtocolV03SwitchTime;
- +extern unsigned int nProtocolV03TestSwitchTime;
- +
- +// Whether a given coinstake is subject to new v0.3 protocol
- +bool IsProtocolV03(unsigned int nTimeCoinStake);
- +
- +// Compute the hash modifier for proof-of-stake
- +bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64& nStakeModifier, bool& fGeneratedStakeModifier);
- +
- +// Check whether stake kernel meets hash target
- +// Sets hashProofOfStake on success return
- +bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned int nTxPrevOffset, const CTransaction& txPrev, const COutPoint& prevout, unsigned int nTimeTx, uint256& hashProofOfStake, bool fPrintProofOfStake=false);
- +
- +// Check kernel hash target and coinstake signature
- +// Sets hashProofOfStake on success return
- +bool CheckProofOfStake(const CTransaction& tx, unsigned int nBits, uint256& hashProofOfStake);
- +
- +// Check whether the coinstake timestamp meets protocol
- +bool CheckCoinStakeTimestamp(int64 nTimeBlock, int64 nTimeTx);
- +
- +// Get stake modifier checksum
- +unsigned int GetStakeModifierChecksum(const CBlockIndex* pindex);
- +
- +// Check stake modifier hard checkpoints
- +bool CheckStakeModifierCheckpoints(int nHeight, unsigned int nStakeModifierChecksum);
- +
- +#endif // PPCOIN_KERNEL_H
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/main.cpp ppcoin-0.3.0-linux/src/src/main.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/main.cpp 2012-11-12 13:41:36.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/main.cpp 2013-02-16 21:33:45.000000000 -0800
- @@ -1,6 +1,6 @@
- // Copyright (c) 2009-2010 Satoshi Nakamoto
- // Copyright (c) 2009-2012 The Bitcoin developers
- -// Copyright (c) 2011-2012 The PPCoin developers
- +// Copyright (c) 2011-2013 The PPCoin developers
- // Distributed under the MIT/X11 software license, see the accompanying
- // file COPYING or http://www.opensource.org/licenses/mit-license.php.
- @@ -9,6 +9,7 @@
- #include "net.h"
- #include "init.h"
- #include "ui_interface.h"
- +#include "kernel.h"
- #include <boost/algorithm/string/replace.hpp>
- #include <boost/filesystem.hpp>
- #include <boost/filesystem/fstream.hpp>
- @@ -48,6 +49,7 @@
- map<uint256, CBlock*> mapOrphanBlocks;
- multimap<uint256, CBlock*> mapOrphanBlocksByPrev;
- set<pair<COutPoint, unsigned int> > setStakeSeenOrphan;
- +map<uint256, uint256> mapProofOfStake;
- map<uint256, CDataStream*> mapOrphanTransactions;
- map<uint256, map<uint256, CDataStream*> > mapOrphanTransactionsByPrev;
- @@ -867,8 +869,7 @@
- }
- static const int64 nTargetTimespan = 7 * 24 * 60 * 60; // one week
- -static const int64 nTargetSpacingStake = 10 * 60; // ten minutes
- -static const int64 nTargetSpacingWorkMax = 2 * 60 * 60; // two hours
- +static const int64 nTargetSpacingWorkMax = 12 * STAKE_TARGET_SPACING; // 2-hour
- //
- // minimum amount of work that could possibly be required nTime after
- @@ -916,7 +917,7 @@
- // ppcoin: retarget with exponential moving toward target spacing
- CBigNum bnNew;
- bnNew.SetCompact(pindexPrev->nBits);
- - int64 nTargetSpacing = fProofOfStake? nTargetSpacingStake : min(nTargetSpacingWorkMax, nTargetSpacingStake * (1 + pindexLast->nHeight - pindexPrev->nHeight));
- + int64 nTargetSpacing = fProofOfStake? STAKE_TARGET_SPACING : min(nTargetSpacingWorkMax, (int64) STAKE_TARGET_SPACING * (1 + pindexLast->nHeight - pindexPrev->nHeight));
- int64 nInterval = nTargetTimespan / nTargetSpacing;
- bnNew *= ((nInterval - 1) * nTargetSpacing + nActualSpacing + nActualSpacing);
- bnNew /= ((nInterval + 1) * nTargetSpacing);
- @@ -1675,69 +1676,6 @@
- }
- -// ppcoin: coinstake must meet hash target according to the protocol:
- -// kernel (input 0) must meet the formula
- -// hash(nBits + txPrev.block.nTime + txPrev.offset + txPrev.nTime + txPrev.vout.n + nTime) < bnTarget * nCoinDay
- -// this ensures that the chance of getting a coinstake is proportional to the
- -// amount of coin age one owns.
- -// The reason this hash is chosen is the following:
- -// nBits: encodes all past block timestamps, making computing hash in advance
- -// more difficult
- -// txPrev.block.nTime: prevent nodes from guessing a good timestamp to
- -// generate transaction for future advantage
- -// txPrev.offset: offset of txPrev inside block, to reduce the chance of
- -// nodes generating coinstake at the same time
- -// txPrev.nTime: reduce the chance of nodes generating coinstake at the same
- -// time
- -// txPrev.vout.n: output number of txPrev, to reduce the chance of nodes
- -// generating coinstake at the same time
- -// block/tx hash should not be used here as they can be generated in vast
- -// quantities so as to generate blocks faster, degrading the system back into
- -// a proof-of-work situation.
- -//
- -bool CTransaction::CheckProofOfStake(unsigned int nBits) const
- -{
- - CBigNum bnTargetPerCoinDay;
- - bnTargetPerCoinDay.SetCompact(nBits);
- -
- - if (!IsCoinStake())
- - return true;
- -
- - // Kernel (input 0) must match the stake hash target per coin age (nBits)
- - const CTxIn& txin = vin[0];
- -
- - // First try finding the previous transaction in database
- - CTxDB txdb("r");
- - CTransaction txPrev;
- - CTxIndex txindex;
- - if (!txPrev.ReadFromDisk(txdb, txin.prevout, txindex))
- - return false; // previous transaction not in main chain
- - txdb.Close();
- - if (nTime < txPrev.nTime)
- - return false; // Transaction timestamp violation
- -
- - // Verify signature
- - if (!VerifySignature(txPrev, *this, 0, true, 0))
- - return DoS(100, error("CheckProofOfStake() : VerifySignature failed on coinstake %s", GetHash().ToString().c_str()));
- -
- - // Read block header
- - CBlock block;
- - if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false))
- - return false; // unable to read block of previous transaction
- - if (block.GetBlockTime() + nStakeMinAge > nTime)
- - return false; // only count coins meeting min age requirement
- -
- - int64 nValueIn = txPrev.vout[txin.prevout.n].nValue;
- - CBigNum bnCoinDay = CBigNum(nValueIn) * min(nTime-txPrev.nTime, (unsigned int)STAKE_MAX_AGE) / COIN / (24 * 60 * 60);
- - // Calculate hash
- - CDataStream ss(SER_GETHASH, 0);
- - ss << nBits << block.nTime << (txindex.pos.nTxPos - txindex.pos.nBlockPos) << txPrev.nTime << txin.prevout.n << nTime;
- - if (CBigNum(Hash(ss.begin(), ss.end())) <= bnCoinDay * bnTargetPerCoinDay)
- - return true;
- - else
- - return DoS(100, error("CheckProofOfStake() : check target failed on coinstake %s", GetHash().ToString().c_str()));
- -}
- -
- // ppcoin: total coin age spent in transaction, in the unit of coin-days.
- // Only those coins meeting minimum age requirement counts. As those
- // transactions not in main chain are not currently indexed so we
- @@ -1818,11 +1756,8 @@
- CBlockIndex* pindexNew = new CBlockIndex(nFile, nBlockPos, *this);
- if (!pindexNew)
- return error("AddToBlockIndex() : new CBlockIndex failed");
- - map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
- - if (pindexNew->fProofOfStake)
- - setStakeSeen.insert(make_pair(pindexNew->prevoutStake, pindexNew->nStakeTime));
- - pindexNew->phashBlock = &((*mi).first);
- + pindexNew->phashBlock = &hash;
- map<uint256, CBlockIndex*>::iterator miPrev = mapBlockIndex.find(hashPrevBlock);
- if (miPrev != mapBlockIndex.end())
- {
- @@ -1833,6 +1768,35 @@
- // ppcoin: compute chain trust score
- pindexNew->bnChainTrust = (pindexNew->pprev ? pindexNew->pprev->bnChainTrust : 0) + pindexNew->GetBlockTrust();
- + // ppcoin: compute stake entropy bit for stake modifier
- + if (!pindexNew->SetStakeEntropyBit(GetStakeEntropyBit()))
- + return error("AddToBlockIndex() : SetStakeEntropyBit() failed");
- +
- + // ppcoin: record proof-of-stake hash value
- + if (pindexNew->IsProofOfStake())
- + {
- + if (!mapProofOfStake.count(hash))
- + return error("AddToBlockIndex() : hashProofOfStake not found in map");
- + pindexNew->hashProofOfStake = mapProofOfStake[hash];
- + }
- +
- + // ppcoin: compute stake modifier
- + uint64 nStakeModifier = 0;
- + bool fGeneratedStakeModifier = false;
- + if (!ComputeNextStakeModifier(pindexNew->pprev, nStakeModifier, fGeneratedStakeModifier))
- + return error("AddToBlockIndex() : ComputeNextStakeModifier() failed");
- + pindexNew->SetStakeModifier(nStakeModifier, fGeneratedStakeModifier);
- + pindexNew->nStakeModifierChecksum = GetStakeModifierChecksum(pindexNew);
- + if (!CheckStakeModifierCheckpoints(pindexNew->nHeight, pindexNew->nStakeModifierChecksum))
- + return error("AddToBlockIndex() : Rejected by stake modifier checkpoint height=%d, modifier=0x%016"PRI64x, pindexNew->nHeight, nStakeModifier);
- +
- + // Add to mapBlockIndex
- + map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
- + if (pindexNew->IsProofOfStake())
- + setStakeSeen.insert(make_pair(pindexNew->prevoutStake, pindexNew->nStakeTime));
- + pindexNew->phashBlock = &((*mi).first);
- +
- + // Write to disk block index
- CTxDB txdb;
- if (!txdb.TxnBegin())
- return false;
- @@ -1900,8 +1864,8 @@
- return DoS(50, error("CheckBlock() : coinbase timestamp is too early"));
- // Check coinstake timestamp
- - if (IsProofOfStake() && GetBlockTime() > (int64)vtx[1].nTime + nMaxClockDrift)
- - return DoS(50, error("CheckBlock() : coinstake timestamp is too early"));
- + if (IsProofOfStake() && !CheckCoinStakeTimestamp(GetBlockTime(), (int64)vtx[1].nTime))
- + return DoS(50, error("CheckBlock() : coinstake timestamp violation nTimeBlock=%u nTimeTx=%u", GetBlockTime(), vtx[1].nTime));
- // Check coinbase reward
- if (vtx[0].GetValueOut() > (IsProofOfWork()? (GetProofOfWorkReward(nBits) - vtx[0].GetMinFee() + MIN_TX_FEE) : 0))
- @@ -2029,10 +1993,16 @@
- return error("ProcessBlock() : CheckBlock FAILED");
- // ppcoin: verify hash target and signature of coinstake tx
- - if (pblock->IsProofOfStake() && !pblock->vtx[1].CheckProofOfStake(pblock->nBits))
- + if (pblock->IsProofOfStake())
- {
- - printf("WARNING: ProcessBlock(): check proof-of-stake failed for block %s\n", hash.ToString().c_str());
- - return false; // do not error here as we expect this during initial block download
- + uint256 hashProofOfStake = 0;
- + if (!CheckProofOfStake(pblock->vtx[1], pblock->nBits, hashProofOfStake))
- + {
- + printf("WARNING: ProcessBlock(): check proof-of-stake failed for block %s\n", hash.ToString().c_str());
- + return false; // do not error here as we expect this during initial block download
- + }
- + if (!mapProofOfStake.count(hash)) // add to mapProofOfStake
- + mapProofOfStake.insert(make_pair(hash, hashProofOfStake));
- }
- CBlockIndex* pcheckpoint = Checkpoints::GetLastSyncCheckpoint();
- @@ -2241,10 +2211,11 @@
- nStakeMinAge = 60 * 60 * 24; // test net min age is 1 day
- nCoinbaseMaturity = 60;
- bnInitialHashTarget = CBigNum(~uint256(0) >> 29);
- + nModifierInterval = 60 * 20; // test net modifier interval is 20 minutes
- }
- - printf("%s Network: genesis=0x%s nBitsLimit=0x%08x nBitsInitial=0x%08x nStakeMinAge=%d nCoinbaseMaturity=%d\n",
- - fTestNet? "Test" : "PPCoin", hashGenesisBlock.ToString().substr(0, 20).c_str(), bnProofOfWorkLimit.GetCompact(), bnInitialHashTarget.GetCompact(), nStakeMinAge, nCoinbaseMaturity);
- + printf("%s Network: genesis=0x%s nBitsLimit=0x%08x nBitsInitial=0x%08x nStakeMinAge=%d nCoinbaseMaturity=%d nModifierInterval=%d\n",
- + fTestNet? "Test" : "PPCoin", hashGenesisBlock.ToString().substr(0, 20).c_str(), bnProofOfWorkLimit.GetCompact(), bnInitialHashTarget.GetCompact(), nStakeMinAge, nCoinbaseMaturity, nModifierInterval);
- //
- // Load block index
- @@ -2284,7 +2255,7 @@
- block.nVersion = 1;
- block.nTime = 1345084287;
- block.nBits = bnProofOfWorkLimit.GetCompact();
- - block.nNonce = 2179302059;
- + block.nNonce = 2179302059u;
- if (fTestNet)
- {
- @@ -2454,11 +2425,11 @@
- }
- // ppcoin: should not enter safe mode for longer invalid chain
- - // ppcoin: if sync-checkpoint too old enter safe mode
- - if (Checkpoints::IsMatureSyncCheckpoint() && !fTestNet)
- + // ppcoin: if sync-checkpoint is too old do not enter safe mode
- + if (Checkpoints::IsSyncCheckpointTooOld(60 * 60 * 24 * 10) && !fTestNet)
- {
- - nPriority = 2000;
- - strStatusBar = strRPC = "WARNING: Checkpoint is too old. Wait for block chain to download, or notify developers of the issue.";
- + nPriority = 100;
- + strStatusBar = "WARNING: Checkpoint is too old. Wait for block chain to download, or notify developers of the issue.";
- }
- // ppcoin: if detected invalid checkpoint enter safe mode
- @@ -3623,13 +3594,18 @@
- {
- pblock->nBits = GetNextTargetRequired(pindexPrev, true);
- CTransaction txCoinStake;
- - int64 nSearchTime = GetAdjustedTime();
- + int64 nSearchTime = txCoinStake.nTime; // search to current time
- if (nSearchTime > nLastCoinStakeSearchTime)
- {
- if (pwallet->CreateCoinStake(*pwallet, pblock->nBits, nSearchTime-nLastCoinStakeSearchTime, txCoinStake))
- {
- - pblock->vtx.push_back(txCoinStake);
- - pblock->vtx[0].vout[0].SetEmpty();
- + if (txCoinStake.nTime >= max(pindexPrev->GetMedianTimePast()+1, pindexPrev->GetBlockTime() - nMaxClockDrift))
- + { // make sure coinstake would meet timestamp protocol
- + // as it would be the same as the block timestamp
- + pblock->vtx[0].vout[0].SetEmpty();
- + pblock->vtx[0].nTime = txCoinStake.nTime;
- + pblock->vtx.push_back(txCoinStake);
- + }
- }
- nLastCoinStakeSearchInterval = nSearchTime - nLastCoinStakeSearchTime;
- nLastCoinStakeSearchTime = nSearchTime;
- @@ -3724,7 +3700,7 @@
- continue;
- // Timestamp limit
- - if (tx.nTime > GetAdjustedTime())
- + if (tx.nTime > GetAdjustedTime() || (pblock->IsProofOfStake() && tx.nTime > pblock->vtx[1].nTime))
- continue;
- // ppcoin: simplify transaction fee - allow free = false
- @@ -3786,9 +3762,12 @@
- // Fill in header
- pblock->hashPrevBlock = pindexPrev->GetBlockHash();
- pblock->hashMerkleRoot = pblock->BuildMerkleTree();
- + if (pblock->IsProofOfStake())
- + pblock->nTime = pblock->vtx[1].nTime; //same as coinstake timestamp
- pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, pblock->GetMaxTransactionTime());
- pblock->nTime = max(pblock->GetBlockTime(), pindexPrev->GetBlockTime() - nMaxClockDrift);
- - pblock->UpdateTime(pindexPrev);
- + if (pblock->IsProofOfWork())
- + pblock->UpdateTime(pindexPrev);
- pblock->nNonce = 0;
- return pblock.release();
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/main.h ppcoin-0.3.0-linux/src/src/main.h
- --- ppcoin-0.2.2ppc-linux/src/src/main.h 2012-11-12 13:41:45.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/main.h 2013-02-16 21:33:43.000000000 -0800
- @@ -1,6 +1,6 @@
- // Copyright (c) 2009-2010 Satoshi Nakamoto
- // Copyright (c) 2009-2012 The Bitcoin developers
- -// Copyright (c) 2011-2012 The PPCoin developers
- +// Copyright (c) 2011-2013 The PPCoin developers
- // Distributed under the MIT/X11 software license, see the accompanying
- // file COPYING or http://www.opensource.org/licenses/mit-license.php.
- #ifndef BITCOIN_MAIN_H
- @@ -41,6 +41,10 @@
- static const int COINBASE_MATURITY_PPC = 500;
- // Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
- static const int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
- +static const int STAKE_TARGET_SPACING = 10 * 60; // 10-minute block spacing
- +static const int STAKE_MIN_AGE = 60 * 60 * 24 * 30; // minimum age for coin age
- +static const int STAKE_MAX_AGE = 60 * 60 * 24 * 90; // stake age of full weight
- +
- #ifdef USE_UPNP
- static const int fHaveUPnP = true;
- #else
- @@ -743,7 +747,6 @@
- bool CheckTransaction() const;
- bool AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL);
- bool GetCoinAge(CTxDB& txdb, uint64& nCoinAge) const; // ppcoin: get transaction coin age
- - bool CheckProofOfStake(unsigned int nBits) const;
- protected:
- const CTxOut& GetOutputFor(const CTxIn& input, const MapPrevTx& inputs) const;
- @@ -956,6 +959,18 @@
- void UpdateTime(const CBlockIndex* pindexPrev);
- + // ppcoin: entropy bit for stake modifier if chosen by modifier
- + unsigned int GetStakeEntropyBit() const
- + {
- + uint160 hashSig = Hash160(vchBlockSig);
- + if (fDebug && GetBoolArg("-printstakemodifier"))
- + printf("GetStakeEntropyBit: hashSig=%s", hashSig.ToString().c_str());
- + hashSig >>= 159; // take the first bit of the hash
- + if (fDebug && GetBoolArg("-printstakemodifier"))
- + printf(" entropybit=%d\n", hashSig.Get64());
- + return hashSig.Get64();
- + }
- +
- // ppcoin: two types of block: proof-of-work or proof-of-stake
- bool IsProofOfStake() const
- {
- @@ -1155,9 +1170,22 @@
- int nHeight;
- int64 nMint;
- int64 nMoneySupply;
- - bool fProofOfStake; // ppcoin: is the block of proof-of-stake type
- +
- + unsigned int nFlags; // ppcoin: block index flags
- + enum
- + {
- + BLOCK_PROOF_OF_STAKE = (1 << 0), // is proof-of-stake block
- + BLOCK_STAKE_ENTROPY = (1 << 1), // entropy bit for stake modifier
- + BLOCK_STAKE_MODIFIER = (1 << 2), // regenerated stake modifier
- + };
- +
- + uint64 nStakeModifier; // hash modifier for proof-of-stake
- + unsigned int nStakeModifierChecksum; // checksum of index; in-memeory only
- +
- + // proof-of-stake specific fields
- COutPoint prevoutStake;
- unsigned int nStakeTime;
- + uint256 hashProofOfStake;
- // block header
- int nVersion;
- @@ -1178,7 +1206,10 @@
- bnChainTrust = 0;
- nMint = 0;
- nMoneySupply = 0;
- - fProofOfStake = true;
- + nFlags = 0;
- + nStakeModifier = 0;
- + nStakeModifierChecksum = 0;
- + hashProofOfStake = 0;
- prevoutStake.SetNull();
- nStakeTime = 0;
- @@ -1200,9 +1231,13 @@
- bnChainTrust = 0;
- nMint = 0;
- nMoneySupply = 0;
- - fProofOfStake = block.IsProofOfStake();
- - if (fProofOfStake)
- + nFlags = 0;
- + nStakeModifier = 0;
- + nStakeModifierChecksum = 0;
- + hashProofOfStake = 0;
- + if (block.IsProofOfStake())
- {
- + SetProofOfStake();
- prevoutStake = block.vtx[1].vin[0].prevout;
- nStakeTime = block.vtx[1].nTime;
- }
- @@ -1248,7 +1283,7 @@
- bnTarget.SetCompact(nBits);
- if (bnTarget <= 0)
- return 0;
- - return (fProofOfStake? (CBigNum(1)<<256) / (bnTarget+1) : 1);
- + return (IsProofOfStake()? (CBigNum(1)<<256) / (bnTarget+1) : 1);
- }
- bool IsInMainChain() const
- @@ -1306,20 +1341,53 @@
- bool IsProofOfWork() const
- {
- - return !fProofOfStake;
- + return !(nFlags & BLOCK_PROOF_OF_STAKE);
- }
- bool IsProofOfStake() const
- {
- - return fProofOfStake;
- + return (nFlags & BLOCK_PROOF_OF_STAKE);
- + }
- +
- + void SetProofOfStake()
- + {
- + nFlags |= BLOCK_PROOF_OF_STAKE;
- + }
- +
- + unsigned int GetStakeEntropyBit() const
- + {
- + return ((nFlags & BLOCK_STAKE_ENTROPY) >> 1);
- + }
- +
- + bool SetStakeEntropyBit(unsigned int nEntropyBit)
- + {
- + if (nEntropyBit > 1)
- + return false;
- + nFlags |= (nEntropyBit? BLOCK_STAKE_ENTROPY : 0);
- + return true;
- + }
- +
- + bool GeneratedStakeModifier() const
- + {
- + return (nFlags & BLOCK_STAKE_MODIFIER);
- + }
- +
- + void SetStakeModifier(uint64 nModifier, bool fGeneratedStakeModifier)
- + {
- + nStakeModifier = nModifier;
- + if (fGeneratedStakeModifier)
- + nFlags |= BLOCK_STAKE_MODIFIER;
- }
- std::string ToString() const
- {
- - return strprintf("CBlockIndex(nprev=%08x, pnext=%08x, nFile=%d, nBlockPos=%-6d nHeight=%d, nMint=%s, nMoneySupply=%s, fProofOfStake=%d prevoutStake=(%s), nStakeTime=%d merkle=%s, hashBlock=%s)",
- + return strprintf("CBlockIndex(nprev=%08x, pnext=%08x, nFile=%d, nBlockPos=%-6d nHeight=%d, nMint=%s, nMoneySupply=%s, nFlags=(%s)(%d)(%s), nStakeModifier=%016"PRI64x", nStakeModifierChecksum=%08x, hashProofOfStake=%s, prevoutStake=(%s), nStakeTime=%d merkle=%s, hashBlock=%s)",
- pprev, pnext, nFile, nBlockPos, nHeight,
- FormatMoney(nMint).c_str(), FormatMoney(nMoneySupply).c_str(),
- - fProofOfStake, prevoutStake.ToString().c_str(), nStakeTime,
- + GeneratedStakeModifier() ? "MOD" : "-", GetStakeEntropyBit(), IsProofOfStake()? "PoS" : "PoW",
- + nStakeModifier, nStakeModifierChecksum,
- + hashProofOfStake.ToString().c_str(),
- + prevoutStake.ToString().c_str(), nStakeTime,
- hashMerkleRoot.ToString().substr(0,10).c_str(),
- GetBlockHash().ToString().substr(0,20).c_str());
- }
- @@ -1362,16 +1430,19 @@
- READWRITE(nHeight);
- READWRITE(nMint);
- READWRITE(nMoneySupply);
- - READWRITE(fProofOfStake);
- - if (fProofOfStake)
- + READWRITE(nFlags);
- + READWRITE(nStakeModifier);
- + if (IsProofOfStake())
- {
- READWRITE(prevoutStake);
- READWRITE(nStakeTime);
- + READWRITE(hashProofOfStake);
- }
- else if (fRead)
- {
- const_cast<CDiskBlockIndex*>(this)->prevoutStake.SetNull();
- const_cast<CDiskBlockIndex*>(this)->nStakeTime = 0;
- + const_cast<CDiskBlockIndex*>(this)->hashProofOfStake = 0;
- }
- // block header
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/makefile.linux-mingw ppcoin-0.3.0-linux/src/src/makefile.linux-mingw
- --- ppcoin-0.2.2ppc-linux/src/src/makefile.linux-mingw 2012-11-12 13:41:45.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/makefile.linux-mingw 2013-02-16 21:33:51.000000000 -0800
- @@ -64,7 +64,8 @@
- obj/util.o \
- obj/wallet.o \
- obj/walletdb.o \
- - obj/noui.o
- + obj/noui.o \
- + obj/kernel.o
- all: ppcoind.exe
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/makefile.mingw ppcoin-0.3.0-linux/src/src/makefile.mingw
- --- ppcoin-0.2.2ppc-linux/src/src/makefile.mingw 2012-11-12 13:41:45.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/makefile.mingw 2013-02-16 21:33:44.000000000 -0800
- @@ -118,7 +118,8 @@
- obj/util.o \
- obj/wallet.o \
- obj/walletdb.o \
- - obj/noui.o
- + obj/noui.o \
- + obj/kernel.o
- all: ppcoind.exe
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/makefile.unix ppcoin-0.3.0-linux/src/src/makefile.unix
- --- ppcoin-0.2.2ppc-linux/src/src/makefile.unix 2012-11-12 13:41:44.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/makefile.unix 2013-02-16 21:33:51.000000000 -0800
- @@ -1,5 +1,5 @@
- # Copyright (c) 2009-2010 Satoshi Nakamoto
- -# Copyright (c) 2011 The PPCoin developers
- +# Copyright (c) 2011-2012 The PPCoin developers
- # Distributed under the MIT/X11 software license, see the accompanying
- # file license.txt or http://www.opensource.org/licenses/mit-license.php.
- @@ -107,7 +107,8 @@
- obj/util.o \
- obj/wallet.o \
- obj/walletdb.o \
- - obj/noui.o
- + obj/noui.o \
- + obj/kernel.o
- all: ppcoind
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/net.cpp ppcoin-0.3.0-linux/src/src/net.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/net.cpp 2012-11-12 13:41:45.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/net.cpp 2013-02-16 21:33:45.000000000 -0800
- @@ -1,6 +1,6 @@
- // Copyright (c) 2009-2010 Satoshi Nakamoto
- // Copyright (c) 2009-2012 The Bitcoin developers
- -// Copyright (c) 2011-2012 The PPCoin developers
- +// Copyright (c) 2011-2013 The PPCoin developers
- // Distributed under the MIT/X11 software license, see the accompanying
- // file COPYING or http://www.opensource.org/licenses/mit-license.php.
- @@ -1050,7 +1050,7 @@
- unsigned int pnSeed[] =
- {
- - 0xd749a5bc, 0xf649a5bc,
- + 0x231621b2,
- };
- void DumpAddresses()
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/qt/bitcoinamountfield.cpp ppcoin-0.3.0-linux/src/src/qt/bitcoinamountfield.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/qt/bitcoinamountfield.cpp 2012-11-12 13:41:37.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/qt/bitcoinamountfield.cpp 2013-02-16 21:33:48.000000000 -0800
- @@ -22,7 +22,7 @@
- amount->setDecimals(8);
- amount->installEventFilter(this);
- amount->setMaximumWidth(170);
- - amount->setSingleStep(0.001);
- + amount->setSingleStep(1.0);
- QHBoxLayout *layout = new QHBoxLayout(this);
- layout->addWidget(amount);
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/qt/bitcoin.cpp ppcoin-0.3.0-linux/src/src/qt/bitcoin.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/qt/bitcoin.cpp 2012-11-12 13:41:44.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/qt/bitcoin.cpp 2013-02-16 21:33:48.000000000 -0800
- @@ -1,5 +1,6 @@
- /*
- * W.J. van der Laan 2011-2012
- + * The PPCoin Developers 2013
- */
- #include "bitcoingui.h"
- #include "clientmodel.h"
- @@ -177,12 +178,12 @@
- // Application identification (must be set before OptionsModel is initialized,
- // as it is used to locate QSettings)
- - app.setOrganizationName("Bitcoin");
- - app.setOrganizationDomain("bitcoin.org");
- + app.setOrganizationName("PPCoin");
- + app.setOrganizationDomain("ppcoin.org");
- if(GetBoolArg("-testnet")) // Separate UI settings for testnet
- - app.setApplicationName("Bitcoin-Qt-testnet");
- + app.setApplicationName("PPCoin-Qt-testnet");
- else
- - app.setApplicationName("Bitcoin-Qt");
- + app.setApplicationName("PPCoin-Qt");
- // ... then GUI settings:
- OptionsModel optionsModel;
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/qt/bitcoingui.cpp ppcoin-0.3.0-linux/src/src/qt/bitcoingui.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/qt/bitcoingui.cpp 2012-11-12 13:41:44.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/qt/bitcoingui.cpp 2013-02-16 21:33:50.000000000 -0800
- @@ -3,7 +3,7 @@
- *
- * W.J. van der Laan 2011-2012
- * The Bitcoin Developers 2011-2012
- - * The PPCoin Developers 2011-2012
- + * The PPCoin Developers 2011-2013
- */
- #include "bitcoingui.h"
- #include "transactiontablemodel.h"
- @@ -25,6 +25,7 @@
- #include "askpassphrasedialog.h"
- #include "notificator.h"
- #include "guiutil.h"
- +#include "wallet.h"
- #ifdef Q_WS_MAC
- #include "macdockiconhandler.h"
- @@ -70,7 +71,7 @@
- resize(850, 550);
- setWindowTitle(tr("PPCoin Wallet"));
- #ifndef Q_WS_MAC
- - setWindowIcon(QIcon(":icons/bitcoin"));
- + setWindowIcon(QIcon(":icons/ppcoin"));
- #else
- setUnifiedTitleAndToolBarOnMac(true);
- QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
- @@ -227,17 +228,17 @@
- quitAction->setToolTip(tr("Quit application"));
- quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
- quitAction->setMenuRole(QAction::QuitRole);
- - aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About %1").arg(qApp->applicationName()), this);
- - aboutAction->setToolTip(tr("Show information about Bitcoin"));
- + aboutAction = new QAction(QIcon(":/icons/ppcoin"), tr("&About %1").arg(qApp->applicationName()), this);
- + aboutAction->setToolTip(tr("Show information about PPCoin"));
- aboutAction->setMenuRole(QAction::AboutRole);
- aboutQtAction = new QAction(tr("About &Qt"), this);
- aboutQtAction->setToolTip(tr("Show information about Qt"));
- aboutQtAction->setMenuRole(QAction::AboutQtRole);
- optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
- - optionsAction->setToolTip(tr("Modify configuration options for bitcoin"));
- + optionsAction->setToolTip(tr("Modify configuration options for ppcoin"));
- optionsAction->setMenuRole(QAction::PreferencesRole);
- - toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("Show/Hide &Bitcoin"), this);
- - toggleHideAction->setToolTip(tr("Show or hide the Bitcoin window"));
- + toggleHideAction = new QAction(QIcon(":/icons/ppcoin"), tr("Show/Hide &PPCoin"), this);
- + toggleHideAction->setToolTip(tr("Show or hide the PPCoin window"));
- exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this);
- exportAction->setToolTip(tr("Export the data in the current tab to a file"));
- encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet"), this);
- @@ -317,9 +318,9 @@
- QString title_testnet = windowTitle() + QString(" ") + tr("[testnet]");
- setWindowTitle(title_testnet);
- #ifndef Q_WS_MAC
- - setWindowIcon(QIcon(":icons/bitcoin_testnet"));
- + setWindowIcon(QIcon(":icons/ppcoin_testnet"));
- #else
- - MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet"));
- + MacDockIconHandler::instance()->setIcon(QIcon(":icons/ppcoin_testnet"));
- #endif
- if(trayIcon)
- {
- @@ -376,7 +377,7 @@
- trayIcon = new QSystemTrayIcon(this);
- trayIconMenu = new QMenu(this);
- trayIcon->setContextMenu(trayIconMenu);
- - trayIcon->setToolTip(tr("Bitcoin client"));
- + trayIcon->setToolTip(tr("PPCoin client"));
- trayIcon->setIcon(QIcon(":/icons/toolbar"));
- connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
- this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
- @@ -403,7 +404,7 @@
- trayIconMenu->addAction(quitAction);
- #endif
- - notificator = new Notificator(tr("bitcoin-qt"), trayIcon);
- + notificator = new Notificator(tr("ppcoin-qt"), trayIcon);
- }
- #ifndef Q_WS_MAC
- @@ -467,7 +468,7 @@
- default: icon = ":/icons/connect_4"; break;
- }
- labelConnectionsIcon->setPixmap(QIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
- - labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Bitcoin network", "", count));
- + labelConnectionsIcon->setToolTip(tr("%n active connection(s) to PPCoin network", "", count));
- }
- void BitcoinGUI::setNumBlocks(int count)
- @@ -777,7 +778,7 @@
- case WalletModel::Unlocked:
- labelEncryptionIcon->show();
- labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
- - labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
- + labelEncryptionIcon->setToolTip(fWalletUnlockMintOnly? tr("Wallet is <b>encrypted</b> and currently <b>unlocked for block minting only</b>") : tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
- encryptWalletAction->setChecked(true);
- changePassphraseAction->setEnabled(true);
- encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/qt/bitcoin.qrc ppcoin-0.3.0-linux/src/src/qt/bitcoin.qrc
- --- ppcoin-0.2.2ppc-linux/src/src/qt/bitcoin.qrc 2012-11-12 13:41:39.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/qt/bitcoin.qrc 2013-02-16 21:33:50.000000000 -0800
- @@ -1,6 +1,7 @@
- <RCC>
- <qresource prefix="/icons">
- <file alias="bitcoin">res/icons/bitcoin.png</file>
- + <file alias="ppcoin">res/icons/ppcoin.png</file>
- <file alias="address-book">res/icons/address-book.png</file>
- <file alias="quit">res/icons/quit.png</file>
- <file alias="send">res/icons/send.png</file>
- @@ -23,6 +24,7 @@
- <file alias="editcopy">res/icons/editcopy.png</file>
- <file alias="add">res/icons/add.png</file>
- <file alias="bitcoin_testnet">res/icons/bitcoin_testnet.png</file>
- + <file alias="ppcoin_testnet">res/icons/ppcoin_testnet.png</file>
- <file alias="toolbar_testnet">res/icons/toolbar_testnet.png</file>
- <file alias="edit">res/icons/edit.png</file>
- <file alias="history">res/icons/history.png</file>
- @@ -41,7 +43,7 @@
- </qresource>
- <qresource prefix="/images">
- <file alias="about">res/images/about.png</file>
- - <file alias="splash">res/images/splash2.jpg</file>
- + <file alias="splash">res/images/ppcoin_splash.png</file>
- <file alias="qrcode">res/images/qrcode.png</file>
- </qresource>
- <qresource prefix="/movies">
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/qt/forms/aboutdialog.ui ppcoin-0.3.0-linux/src/src/qt/forms/aboutdialog.ui
- --- ppcoin-0.2.2ppc-linux/src/src/qt/forms/aboutdialog.ui 2012-11-12 13:41:40.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/qt/forms/aboutdialog.ui 2013-02-16 21:33:48.000000000 -0800
- @@ -11,7 +11,7 @@
- </rect>
- </property>
- <property name="windowTitle">
- - <string>About Bitcoin</string>
- + <string>About PPCoin</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- @@ -50,7 +50,7 @@
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- - <string><b>Bitcoin</b> version</string>
- + <string><b>PPCoin</b> version</string>
- </property>
- <property name="textInteractionFlags">
- <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
- @@ -86,6 +86,19 @@
- </layout>
- </item>
- <item>
- + <widget class="QLabel" name="label_ppcoin_copyright">
- + <property name="text">
- + <string>Copyright © 2011-2013 PPCoin Developers</string>
- + </property>
- + <property name="wordWrap">
- + <bool>true</bool>
- + </property>
- + <property name="textInteractionFlags">
- + <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
- + </property>
- + </widget>
- + </item>
- + <item>
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Copyright © 2009-2012 Bitcoin Developers
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/qt/forms/qrcodedialog.ui ppcoin-0.3.0-linux/src/src/qt/forms/qrcodedialog.ui
- --- ppcoin-0.2.2ppc-linux/src/src/qt/forms/qrcodedialog.ui 2012-11-12 13:41:40.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/qt/forms/qrcodedialog.ui 2013-02-16 21:33:48.000000000 -0800
- @@ -102,7 +102,7 @@
- </sizepolicy>
- </property>
- <property name="text">
- - <string>BTC</string>
- + <string>PPC</string>
- </property>
- <property name="buddy">
- <cstring>lnReqAmount</cstring>
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/qt/forms/sendcoinsentry.ui ppcoin-0.3.0-linux/src/src/qt/forms/sendcoinsentry.ui
- --- ppcoin-0.2.2ppc-linux/src/src/qt/forms/sendcoinsentry.ui 2012-11-12 13:41:40.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/qt/forms/sendcoinsentry.ui 2013-02-16 21:33:48.000000000 -0800
- @@ -90,7 +90,7 @@
- <item>
- <widget class="QValidatedLineEdit" name="payTo">
- <property name="toolTip">
- - <string>The address to send the payment to (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)</string>
- + <string>The address to send the payment to</string>
- </property>
- <property name="maxLength">
- <number>34</number>
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/qt/res/bitcoin-qt.rc ppcoin-0.3.0-linux/src/src/qt/res/bitcoin-qt.rc
- --- ppcoin-0.2.2ppc-linux/src/src/qt/res/bitcoin-qt.rc 2012-11-12 13:41:39.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/qt/res/bitcoin-qt.rc 2013-02-16 21:33:50.000000000 -0800
- @@ -1 +1 @@
- -IDI_ICON1 ICON DISCARDABLE "icons/bitcoin.ico"
- +IDI_ICON1 ICON DISCARDABLE "icons/ppcoin.ico"
- Binary files ppcoin-0.2.2ppc-linux/src/src/qt/res/icons/ppcoin.ico and ppcoin-0.3.0-linux/src/src/qt/res/icons/ppcoin.ico differ
- Binary files ppcoin-0.2.2ppc-linux/src/src/qt/res/icons/ppcoin.png and ppcoin-0.3.0-linux/src/src/qt/res/icons/ppcoin.png differ
- Binary files ppcoin-0.2.2ppc-linux/src/src/qt/res/icons/ppcoin_testnet.png and ppcoin-0.3.0-linux/src/src/qt/res/icons/ppcoin_testnet.png differ
- Binary files ppcoin-0.2.2ppc-linux/src/src/qt/res/icons/toolbar.png and ppcoin-0.3.0-linux/src/src/qt/res/icons/toolbar.png differ
- Binary files ppcoin-0.2.2ppc-linux/src/src/qt/res/icons/toolbar_testnet.png and ppcoin-0.3.0-linux/src/src/qt/res/icons/toolbar_testnet.png differ
- Binary files ppcoin-0.2.2ppc-linux/src/src/qt/res/images/ppcoin_splash.png and ppcoin-0.3.0-linux/src/src/qt/res/images/ppcoin_splash.png differ
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/qt/sendcoinsdialog.cpp ppcoin-0.3.0-linux/src/src/qt/sendcoinsdialog.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/qt/sendcoinsdialog.cpp 2012-11-12 13:41:44.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/qt/sendcoinsdialog.cpp 2013-02-16 21:33:45.000000000 -0800
- @@ -125,7 +125,7 @@
- break;
- case WalletModel::InvalidAmount:
- QMessageBox::warning(this, tr("Send Coins"),
- - tr("The amount to pay must be larger than 0."),
- + tr("The amount to pay must be at least one cent (0.01)."),
- QMessageBox::Ok, QMessageBox::Ok);
- break;
- case WalletModel::AmountExceedsBalance:
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/qt/sendcoinsentry.cpp ppcoin-0.3.0-linux/src/src/qt/sendcoinsentry.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/qt/sendcoinsentry.cpp 2012-11-12 13:41:40.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/qt/sendcoinsentry.cpp 2013-02-16 21:33:48.000000000 -0800
- @@ -22,7 +22,7 @@
- #endif
- #if QT_VERSION >= 0x040700
- - ui->payTo->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)"));
- + ui->payTo->setPlaceholderText(tr("Enter a PPCoin address"));
- ui->addAsLabel->setPlaceholderText(tr("Enter a label for this address to add it to your address book"));
- #endif
- setFocusPolicy(Qt::TabFocus);
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/qt/transactionview.cpp ppcoin-0.3.0-linux/src/src/qt/transactionview.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/qt/transactionview.cpp 2012-11-12 13:41:44.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/qt/transactionview.cpp 2013-02-16 21:33:50.000000000 -0800
- @@ -167,7 +167,7 @@
- transactionView->setSelectionBehavior(QAbstractItemView::SelectRows);
- transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
- transactionView->setSortingEnabled(true);
- - transactionView->sortByColumn(TransactionTableModel::Status, Qt::DescendingOrder);
- + transactionView->sortByColumn(TransactionTableModel::Date, Qt::DescendingOrder);
- transactionView->verticalHeader()->hide();
- transactionView->horizontalHeader()->resizeSection(
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/qt/walletmodel.cpp ppcoin-0.3.0-linux/src/src/qt/walletmodel.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/qt/walletmodel.cpp 2012-11-12 13:41:39.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/qt/walletmodel.cpp 2013-02-16 21:33:48.000000000 -0800
- @@ -97,7 +97,7 @@
- }
- setAddress.insert(rcp.address);
- - if(rcp.amount <= 0)
- + if(rcp.amount < MIN_TXOUT_AMOUNT)
- {
- return InvalidAmount;
- }
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/rpcdump.cpp ppcoin-0.3.0-linux/src/src/rpcdump.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/rpcdump.cpp 2012-11-12 13:41:36.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/rpcdump.cpp 2013-02-16 21:33:44.000000000 -0800
- @@ -1,5 +1,5 @@
- // Copyright (c) 2009-2012 Bitcoin Developers
- -// Copyright (c) 2012 The PPCoin developers
- +// Copyright (c) 2012-2013 The PPCoin developers
- // Distributed under the MIT/X11 software license, see the accompanying
- // file COPYING or http://www.opensource.org/licenses/mit-license.php.
- @@ -54,6 +54,8 @@
- bool fGood = vchSecret.SetString(strSecret);
- if (!fGood) throw JSONRPCError(-5,"Invalid private key");
- + if (fWalletUnlockMintOnly) // ppcoin: no importprivkey in mint-only mode
- + throw JSONRPCError(-102, "Wallet is unlocked for minting only.");
- CKey key;
- bool fCompressed;
- @@ -90,6 +92,8 @@
- CBitcoinAddress address;
- if (!address.SetString(strAddress))
- throw JSONRPCError(-5, "Invalid ppcoin address");
- + if (fWalletUnlockMintOnly) // ppcoin: no dumpprivkey in mint-only mode
- + throw JSONRPCError(-102, "Wallet is unlocked for minting only.");
- CSecret vchSecret;
- bool fCompressed;
- if (!pwalletMain->GetSecret(address, vchSecret, fCompressed))
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/version.cpp ppcoin-0.3.0-linux/src/src/version.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/version.cpp 2012-11-12 13:41:36.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/version.cpp 2013-02-16 21:33:45.000000000 -0800
- @@ -36,7 +36,7 @@
- // git will put "#define GIT_ARCHIVE 1" on the next line inside archives.
- #define GIT_ARCHIVE 1
- #ifdef GIT_ARCHIVE
- -# define GIT_COMMIT_ID "290825c"
- +# define GIT_COMMIT_ID "be62545"
- # define GIT_COMMIT_DATE "$Format:%cD"
- #endif
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/version.h ppcoin-0.3.0-linux/src/src/version.h
- --- ppcoin-0.2.2ppc-linux/src/src/version.h 2012-11-12 13:41:44.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/version.h 2013-02-16 21:33:51.000000000 -0800
- @@ -1,4 +1,5 @@
- // Copyright (c) 2012 The Bitcoin developers
- +// Copyright (c) 2012-2013 The PPCoin developers
- // Distributed under the MIT/X11 software license, see the accompanying
- // file COPYING or http://www.opensource.org/licenses/mit-license.php.
- #ifndef BITCOIN_VERSION_H
- @@ -28,15 +29,15 @@
- // ppcoin version - intended for display purpose ONLY
- #define PPCOIN_VERSION_MAJOR 0
- -#define PPCOIN_VERSION_MINOR 2
- -#define PPCOIN_VERSION_REVISION 2
- +#define PPCOIN_VERSION_MINOR 3
- +#define PPCOIN_VERSION_REVISION 0
- #define PPCOIN_VERSION_BUILD 0
- //
- // network protocol versioning
- //
- -static const int PROTOCOL_VERSION = 60002;
- +static const int PROTOCOL_VERSION = 60003;
- // earlier versions not supported as of Feb 2012, and are disconnected
- // NOTE: as of bitcoin v0.6 message serialization (vSend, vRecv) still
- diff -N -r -u ppcoin-0.2.2ppc-linux/src/src/wallet.cpp ppcoin-0.3.0-linux/src/src/wallet.cpp
- --- ppcoin-0.2.2ppc-linux/src/src/wallet.cpp 2012-11-12 13:41:35.000000000 -0800
- +++ ppcoin-0.3.0-linux/src/src/wallet.cpp 2013-02-16 21:33:43.000000000 -0800
- @@ -1,14 +1,14 @@
- // Copyright (c) 2009-2010 Satoshi Nakamoto
- // Copyright (c) 2009-2012 The Bitcoin developers
- -// Copyright (c) 2011-2012 The PPCoin developers
- +// Copyright (c) 2011-2013 The PPCoin developers
- // Distributed under the MIT/X11 software license, see the accompanying
- // file COPYING or http://www.opensource.org/licenses/mit-license.php.
- #include "wallet.h"
- #include "walletdb.h"
- #include "crypter.h"
- -#include "checkpoints.h"
- #include "ui_interface.h"
- +#include "kernel.h"
- using namespace std;
- @@ -71,7 +71,7 @@
- return CWalletDB(strWalletFile).WriteCScript(Hash160(redeemScript), redeemScript);
- }
- -// ppcoin: optional setting to create coinstake only when unlocked;
- +// ppcoin: optional setting to unlock wallet for block minting only;
- // serves to disable the trivial sendmoney when OS account compromised
- bool fWalletUnlockMintOnly = false;
- @@ -834,7 +834,10 @@
- BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)
- {
- CWalletTx& wtx = *item.second;
- - wtx.RelayWalletTransaction(txdb);
- + if (wtx.CheckTransaction())
- + wtx.RelayWalletTransaction(txdb);
- + else
- + printf("ResendWalletTransactions() : CheckTransaction failed for transaction %s\n", wtx.GetHash().ToString().c_str());
- }
- }
- }
- @@ -1247,21 +1250,18 @@
- CBlock block;
- if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false))
- continue;
- - if (block.GetBlockTime() + nStakeMinAge > txNew.nTime - nMaxClockDrift)
- + static int nMaxStakeSearchInterval = 60;
- + if (block.GetBlockTime() + nStakeMinAge > txNew.nTime - nMaxStakeSearchInterval)
- continue; // only count coins meeting min age requirement
- - int64 nValueIn = pcoin.first->vout[pcoin.second].nValue;
- - CBigNum bnCoinDay = CBigNum(nValueIn) * min(txNew.nTime-pcoin.first->nTime, (unsigned int)STAKE_MAX_AGE) / COIN / (24 * 60 * 60);
- -
- bool fKernelFound = false;
- - for (int n=0; n<min(nSearchInterval,(int64)5) && !fKernelFound && !fShutdown; n++)
- + for (unsigned int n=0; n<min(nSearchInterval,(int64)nMaxStakeSearchInterval) && !fKernelFound && !fShutdown; n++)
- {
- - // Randomly pick a timestamp from protocol allowed range
- - txNew.nTime = GetAdjustedTime() - GetRandInt(nMaxClockDrift - 60);
- - // Calculate hash
- - CDataStream ss(SER_GETHASH, 0);
- - ss << nBits << block.nTime << (txindex.pos.nTxPos - txindex.pos.nBlockPos) << pcoin.first->nTime << pcoin.second << txNew.nTime;
- - if (CBigNum(Hash(ss.begin(), ss.end())) <= bnCoinDay * bnTargetPerCoinDay)
- + // Search backward in time from the given txNew timestamp
- + // Search nSearchInterval seconds back up to nMaxStakeSearchInterval
- + uint256 hashProofOfStake = 0;
- + COutPoint prevoutStake = COutPoint(pcoin.first->GetHash(), pcoin.second);
- + if (CheckStakeKernelHash(nBits, block, txindex.pos.nTxPos - txindex.pos.nBlockPos, *pcoin.first, prevoutStake, txNew.nTime - n, hashProofOfStake))
- {
- // Found a kernel
- if (fDebug && GetBoolArg("-printcoinstake"))
- @@ -1298,7 +1298,8 @@
- }
- else
- scriptPubKeyOut = scriptPubKeyKernel;
- -
- +
- + txNew.nTime -= n;
- txNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second));
- nCredit += pcoin.first->vout[pcoin.second].nValue;
- vwtxPrev.push_back(pcoin.first);
- @@ -1308,6 +1309,7 @@
- if (fDebug && GetBoolArg("-printcoinstake"))
- printf("CreateCoinStake : added kernel type=%d\n", whichType);
- fKernelFound = true;
- + break;
- }
- }
- if (fKernelFound || fShutdown)
- @@ -1334,6 +1336,9 @@
- // Do not add additional significant input
- if (pcoin.first->vout[pcoin.second].nValue > nCombineThreshold)
- continue;
- + // Do not add input that is still too young
- + if (pcoin.first->nTime + STAKE_MAX_AGE > txNew.nTime)
- + continue;
- txNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second));
- nCredit += pcoin.first->vout[pcoin.second].nValue;
- vwtxPrev.push_back(pcoin.first);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement