Update to 0.3.0 (New upstream + new RPC calls)
This commit is contained in:
1
COPYING
1
COPYING
@@ -1,3 +1,4 @@
|
||||
Copyright (c) 2013 NovaCoin Developers
|
||||
Copyright (c) 2011-2012 PPCoin Developers
|
||||
Copyright (c) 2009-2012 Bitcoin Developers
|
||||
|
||||
|
||||
0
contrib/debian/bin/bitcoin-qt
Normal file → Executable file
0
contrib/debian/bin/bitcoin-qt
Normal file → Executable file
0
contrib/debian/bin/bitcoind
Normal file → Executable file
0
contrib/debian/bin/bitcoind
Normal file → Executable file
0
contrib/debian/rules
Normal file → Executable file
0
contrib/debian/rules
Normal file → Executable file
@@ -15,16 +15,16 @@ remotes:
|
||||
- "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 @@ script: |
|
||||
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 @@ script: |
|
||||
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/
|
||||
|
||||
@@ -49,8 +49,8 @@ script: |
|
||||
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
|
||||
|
||||
0
contrib/macdeploy/macdeployqtplus
Normal file → Executable file
0
contrib/macdeploy/macdeployqtplus
Normal file → Executable file
0
contrib/pyminer/pyminer.py
Normal file → Executable file
0
contrib/pyminer/pyminer.py
Normal file → Executable file
0
contrib/qt_translations.py
Normal file → Executable file
0
contrib/qt_translations.py
Normal file → Executable file
@@ -1,6 +1,7 @@
|
||||
PPCoin 0.2.2 BETA
|
||||
NovaCoin 0.3.0 BETA
|
||||
|
||||
Copyright (c) 2011-2012 PPCoin Developers
|
||||
Copyright (c) 2013 NovaCoin 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
|
||||
@@ -10,9 +11,9 @@ cryptographic software written by Eric Young (eay@cryptsoft.com).
|
||||
|
||||
Intro
|
||||
-----
|
||||
PPCoin is a free open source project derived from Bitcoin, with
|
||||
the goal of providing a long-term energy-efficient crypto-currency.
|
||||
Built on the foundation of Bitcoin, innovations such as proof-of-stake
|
||||
NovaCoin is a free open source project derived from PPCoin, with
|
||||
the goal of providing a long-term energy-efficient scrypt-based crypto-currency.
|
||||
Built on the foundation of Bitcoin, innovations such as proof-of-stake and scrypt
|
||||
help further advance the field of crypto-currency.
|
||||
|
||||
|
||||
@@ -20,9 +21,9 @@ Setup
|
||||
-----
|
||||
After completing windows setup then run windows command line (cmd)
|
||||
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
|
||||
novacoind
|
||||
You would need to create a configuration file novacoin.conf in the default
|
||||
wallet directory. Grant access to novacoind.exe in anti-virus and firewall
|
||||
applications if necessary.
|
||||
|
||||
The software automatically finds other nodes to connect to. You can
|
||||
@@ -35,16 +36,11 @@ but allowing incoming connections helps the PPCoin network.
|
||||
Upgrade
|
||||
-------
|
||||
All you existing coins/transactions should be intact with the upgrade.
|
||||
To upgrade from 0.2, first backup wallet
|
||||
ppcoind backupwallet <destination_backup_file>
|
||||
To upgrade from 0.2.x, first backup wallet
|
||||
novacoind backupwallet <destination_backup_file>
|
||||
Then shutdown ppcoind by
|
||||
ppcoind stop
|
||||
Start up the new ppcoind (0.2.2).
|
||||
|
||||
|
||||
See the documentation/wiki at the ppcoin website:
|
||||
http://www.ppcoin.org/
|
||||
for help and more information.
|
||||
novacoind stop
|
||||
Start up the new novacoind (0.3.0).
|
||||
|
||||
|
||||
------------------
|
||||
|
||||
0
share/genbuild.sh
Normal file → Executable file
0
share/genbuild.sh
Normal file → Executable file
0
share/qt/extract_strings_qt.py
Normal file → Executable file
0
share/qt/extract_strings_qt.py
Normal file → Executable file
0
share/qt/make_spinner.py
Normal file → Executable file
0
share/qt/make_spinner.py
Normal file → Executable file
8
share/qt/make_windows_icon.sh
Normal file → Executable file
8
share/qt/make_windows_icon.sh
Normal file → Executable file
@@ -1,13 +1,5 @@
|
||||
#!/bin/bash
|
||||
# create multiresolution windows icon
|
||||
|
||||
#ICON_SRC=../../src/qt/res/icons/novacoin.png
|
||||
|
||||
ICON_DST=../../src/qt/res/icons/novacoin.ico
|
||||
|
||||
#convert ${ICON_SRC} -resize 16x16 novacoin-16.png
|
||||
#convert ${ICON_SRC} -resize 32x32 novacoin-32.png
|
||||
#convert ${ICON_SRC} -resize 48x48 novacoin-48.png
|
||||
|
||||
convert ../../src/qt/res/icons/novacoin-16.png ../../src/qt/res/icons/novacoin-32.png ../../src/qt/res/icons/novacoin-48.png ${ICON_DST}
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
Name NovaCoin
|
||||
Name PPCoin
|
||||
|
||||
RequestExecutionLevel highest
|
||||
SetCompressor /SOLID lzma
|
||||
|
||||
# General Symbol Definitions
|
||||
!define REGKEY "SOFTWARE\$(^Name)"
|
||||
!define VERSION 0.2.2
|
||||
!define COMPANY "NovaCoin project"
|
||||
!define URL http://www.novacoin.ru/
|
||||
!define VERSION 0.3.0
|
||||
!define COMPANY "PPCoin project"
|
||||
!define URL http://www.ppcoin.org/
|
||||
|
||||
# MUI Symbol Definitions
|
||||
!define MUI_ICON "../share/pixmaps/novacoin.ico"
|
||||
!define MUI_ICON "../share/pixmaps/bitcoin.ico"
|
||||
!define MUI_WELCOMEFINISHPAGE_BITMAP "../share/pixmaps/nsis-wizard.bmp"
|
||||
!define MUI_HEADERIMAGE
|
||||
!define MUI_HEADERIMAGE_RIGHT
|
||||
@@ -19,8 +19,8 @@ SetCompressor /SOLID lzma
|
||||
!define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
|
||||
!define MUI_STARTMENUPAGE_REGISTRY_KEY ${REGKEY}
|
||||
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuGroup
|
||||
!define MUI_STARTMENUPAGE_DEFAULTFOLDER NovaCoin
|
||||
#!define MUI_FINISHPAGE_RUN $INSTDIR\novacoin-qt.exe
|
||||
!define MUI_STARTMENUPAGE_DEFAULTFOLDER PPCoin
|
||||
!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,14 +45,14 @@ Var StartMenuGroup
|
||||
!insertmacro MUI_LANGUAGE English
|
||||
|
||||
# Installer attributes
|
||||
OutFile novacoin-0.2.2-win32-setup.exe
|
||||
InstallDir $PROGRAMFILES\NovaCoin
|
||||
OutFile ppcoin-0.3.0-win32-setup.exe
|
||||
InstallDir $PROGRAMFILES\PPCoin
|
||||
CRCCheck on
|
||||
XPStyle on
|
||||
BrandingText " "
|
||||
ShowInstDetails show
|
||||
VIProductVersion 0.2.2.0
|
||||
VIAddVersionKey ProductName NovaCoin
|
||||
VIProductVersion 0.3.0.0
|
||||
VIAddVersionKey ProductName PPCoin
|
||||
VIAddVersionKey ProductVersion "${VERSION}"
|
||||
VIAddVersionKey CompanyName "${COMPANY}"
|
||||
VIAddVersionKey CompanyWebsite "${URL}"
|
||||
@@ -66,18 +66,18 @@ ShowUninstDetails show
|
||||
Section -Main SEC0000
|
||||
SetOutPath $INSTDIR
|
||||
SetOverwrite on
|
||||
#File ../release/novacoin-qt.exe
|
||||
File ../release/ppcoin-qt.exe
|
||||
File /oname=license.txt ../COPYING
|
||||
File /oname=readme.txt ../doc/README_windows.txt
|
||||
SetOutPath $INSTDIR\daemon
|
||||
File ../src/novacoind.exe
|
||||
File ../src/ppcoind.exe
|
||||
SetOutPath $INSTDIR\src
|
||||
File /r /x *.exe /x *.o ../src\*.*
|
||||
SetOutPath $INSTDIR
|
||||
WriteRegStr HKCU "${REGKEY}\Components" Main 1
|
||||
|
||||
# Remove old wxwidgets-based-bitcoin executable and locales:
|
||||
#Delete /REBOOTOK $INSTDIR\novacoin.exe
|
||||
#Delete /REBOOTOK $INSTDIR\bitcoin.exe
|
||||
#RMDir /r /REBOOTOK $INSTDIR\locale
|
||||
SectionEnd
|
||||
|
||||
@@ -87,7 +87,8 @@ Section -post SEC0001
|
||||
WriteUninstaller $INSTDIR\uninstall.exe
|
||||
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
||||
CreateDirectory $SMPROGRAMS\$StartMenuGroup
|
||||
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall NovaCoin.lnk" $INSTDIR\uninstall.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)"
|
||||
WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
|
||||
@@ -120,7 +121,7 @@ done${UNSECTION_ID}:
|
||||
|
||||
# Uninstaller sections
|
||||
Section /o -un.Main UNSEC0000
|
||||
#Delete /REBOOTOK $INSTDIR\novacoin-qt.exe
|
||||
Delete /REBOOTOK $INSTDIR\ppcoin-qt.exe
|
||||
Delete /REBOOTOK $INSTDIR\license.txt
|
||||
Delete /REBOOTOK $INSTDIR\readme.txt
|
||||
RMDir /r /REBOOTOK $INSTDIR\daemon
|
||||
@@ -130,9 +131,9 @@ SectionEnd
|
||||
|
||||
Section -un.post UNSEC0001
|
||||
DeleteRegKey HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
|
||||
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall NovaCoin.lnk"
|
||||
#Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Bitcoin.lnk"
|
||||
#Delete /REBOOTOK "$SMSTARTUP\Bitcoin.lnk"
|
||||
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall PPCoin.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
|
||||
@@ -140,7 +141,7 @@ Section -un.post UNSEC0001
|
||||
DeleteRegValue HKCU "${REGKEY}" Path
|
||||
DeleteRegKey /IfEmpty HKCU "${REGKEY}\Components"
|
||||
DeleteRegKey /IfEmpty HKCU "${REGKEY}"
|
||||
DeleteRegKey HKCR "novacoin"
|
||||
DeleteRegKey HKCR "ppcoin"
|
||||
RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup
|
||||
RmDir /REBOOTOK $INSTDIR
|
||||
Push $R0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
bitcoin ICON "pixmaps/novacoin.ico"
|
||||
bitcoin ICON "pixmaps/bitcoin.ico"
|
||||
|
||||
#include "wx/msw/wx.rc"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin Developers
|
||||
// Copyright (c) 2011-2012 The PPCoin developers
|
||||
// Copyright (c) 2012-2013 The NovaCoin developers
|
||||
// Copyright (c) 2013 NovaCoin Developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -366,7 +366,7 @@ public:
|
||||
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);
|
||||
}
|
||||
@@ -385,10 +385,10 @@ public:
|
||||
bool fExpectTestNet = false;
|
||||
switch(nVersion)
|
||||
{
|
||||
case 128:
|
||||
case (128 + CBitcoinAddress::PUBKEY_ADDRESS):
|
||||
break;
|
||||
|
||||
case 239:
|
||||
case (128 + CBitcoinAddress::PUBKEY_ADDRESS_TEST):
|
||||
fExpectTestNet = true;
|
||||
break;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Copyright (c) 2011-2012 The PPCoin developers
|
||||
// Copyright (c) 2012-2013 The NovaCoin developers
|
||||
// Copyright (c) 2011-2013 The PPCoin developers
|
||||
// Copyright (c) 2013 NovaCoin Developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -47,8 +47,6 @@ static CCriticalSection cs_nWalletUnlockTime;
|
||||
extern Value dumpprivkey(const Array& params, bool fHelp);
|
||||
extern Value importprivkey(const Array& params, bool fHelp);
|
||||
|
||||
extern CBigNum bnProofOfWorkLimit;
|
||||
|
||||
Object JSONRPCError(int code, const string& message)
|
||||
{
|
||||
Object error;
|
||||
@@ -156,6 +154,11 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPri
|
||||
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)
|
||||
{
|
||||
@@ -1019,7 +1022,7 @@ Value addmultisigaddress(const Array& params, bool fHelp)
|
||||
{
|
||||
string msg = "addmultisigaddress <nrequired> <'[\"key\",\"key\"]'> [account]\n"
|
||||
"Add a nrequired-to-sign multisignature address to the wallet\"\n"
|
||||
"each key is a novacoin address or hex-encoded public key\n"
|
||||
"each key is a bitcoin address or hex-encoded public key\n"
|
||||
"If [account] is specified, assign address to [account].";
|
||||
throw runtime_error(msg);
|
||||
}
|
||||
@@ -1909,98 +1912,6 @@ Value getwork(const Array& params, bool fHelp)
|
||||
}
|
||||
}
|
||||
|
||||
Value getmemorypool(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() > 1)
|
||||
throw runtime_error(
|
||||
"getmemorypool [data]\n"
|
||||
"If [data] is not specified, returns data needed to construct a block to work on:\n"
|
||||
" \"version\" : block version\n"
|
||||
" \"previousblockhash\" : hash of current highest block\n"
|
||||
" \"transactions\" : contents of non-coinbase transactions that should be included in the next block\n"
|
||||
" \"coinbasevalue\" : maximum allowable input to coinbase transaction, including the generation award and transaction fees\n"
|
||||
" \"coinbaseflags\" : data that should be included in coinbase so support for new features can be judged\n"
|
||||
" \"time\" : timestamp appropriate for next block\n"
|
||||
" \"mintime\" : minimum timestamp appropriate for next block\n"
|
||||
" \"curtime\" : current timestamp\n"
|
||||
" \"bits\" : compressed target of next block\n"
|
||||
"If [data] is specified, tries to solve the block and returns true if it was successful.");
|
||||
|
||||
if (params.size() == 0)
|
||||
{
|
||||
if (vNodes.empty())
|
||||
throw JSONRPCError(-9, "NovaCoin is not connected!");
|
||||
|
||||
if (IsInitialBlockDownload())
|
||||
throw JSONRPCError(-10, "NovaCoin is downloading blocks...");
|
||||
|
||||
static CReserveKey reservekey(pwalletMain);
|
||||
|
||||
// Update block
|
||||
static unsigned int nTransactionsUpdatedLast;
|
||||
static CBlockIndex* pindexPrev;
|
||||
static int64 nStart;
|
||||
static CBlock* pblock;
|
||||
if (pindexPrev != pindexBest ||
|
||||
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 5))
|
||||
{
|
||||
nTransactionsUpdatedLast = nTransactionsUpdated;
|
||||
pindexPrev = pindexBest;
|
||||
nStart = GetTime();
|
||||
|
||||
// Create new block
|
||||
if(pblock)
|
||||
delete pblock;
|
||||
pblock = CreateNewBlock(pwalletMain);
|
||||
if (!pblock)
|
||||
throw JSONRPCError(-7, "Out of memory");
|
||||
}
|
||||
|
||||
// Update nTime
|
||||
pblock->UpdateTime(pindexPrev);
|
||||
pblock->nNonce = 0;
|
||||
|
||||
Array transactions;
|
||||
BOOST_FOREACH(CTransaction tx, pblock->vtx) {
|
||||
if(tx.IsCoinBase() || tx.IsCoinStake())
|
||||
continue;
|
||||
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ssTx << tx;
|
||||
|
||||
transactions.push_back(HexStr(ssTx.begin(), ssTx.end()));
|
||||
}
|
||||
|
||||
Object result;
|
||||
result.push_back(Pair("version", pblock->nVersion));
|
||||
result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex()));
|
||||
result.push_back(Pair("transactions", transactions));
|
||||
result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue));
|
||||
result.push_back(Pair("coinbaseflags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end())));
|
||||
result.push_back(Pair("time", (int64_t)pblock->nTime));
|
||||
result.push_back(Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1));
|
||||
result.push_back(Pair("curtime", (int64_t)GetAdjustedTime()));
|
||||
result.push_back(Pair("bits", HexBits(pblock->nBits)));
|
||||
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parse parameters
|
||||
CDataStream ssBlock(ParseHex(params[0].get_str()), SER_NETWORK, PROTOCOL_VERSION);
|
||||
CBlock pblock;
|
||||
ssBlock >> pblock;
|
||||
|
||||
static CReserveKey reservekey(pwalletMain);
|
||||
|
||||
if(!pblock.SignBlock(*pwalletMain))
|
||||
throw JSONRPCError(-100, "Unable to sign block, wallet locked?");
|
||||
|
||||
return CheckWork(&pblock, *pwalletMain, reservekey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Value getblocktemplate(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() > 1)
|
||||
@@ -2185,6 +2096,98 @@ Value submitblock(const Array& params, bool fHelp)
|
||||
return Value::null;
|
||||
}
|
||||
|
||||
|
||||
Value getmemorypool(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() > 1)
|
||||
throw runtime_error(
|
||||
"getmemorypool [data]\n"
|
||||
"If [data] is not specified, returns data needed to construct a block to work on:\n"
|
||||
" \"version\" : block version\n"
|
||||
" \"previousblockhash\" : hash of current highest block\n"
|
||||
" \"transactions\" : contents of non-coinbase transactions that should be included in the next block\n"
|
||||
" \"coinbasevalue\" : maximum allowable input to coinbase transaction, including the generation award and transaction fees\n"
|
||||
" \"coinbaseflags\" : data that should be included in coinbase so support for new features can be judged\n"
|
||||
" \"time\" : timestamp appropriate for next block\n"
|
||||
" \"mintime\" : minimum timestamp appropriate for next block\n"
|
||||
" \"curtime\" : current timestamp\n"
|
||||
" \"bits\" : compressed target of next block\n"
|
||||
"If [data] is specified, tries to solve the block and returns true if it was successful.");
|
||||
|
||||
if (params.size() == 0)
|
||||
{
|
||||
if (vNodes.empty())
|
||||
throw JSONRPCError(-9, "NovaCoin is not connected!");
|
||||
|
||||
if (IsInitialBlockDownload())
|
||||
throw JSONRPCError(-10, "NovaCoin is downloading blocks...");
|
||||
|
||||
static CReserveKey reservekey(pwalletMain);
|
||||
|
||||
// Update block
|
||||
static unsigned int nTransactionsUpdatedLast;
|
||||
static CBlockIndex* pindexPrev;
|
||||
static int64 nStart;
|
||||
static CBlock* pblock;
|
||||
if (pindexPrev != pindexBest ||
|
||||
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 5))
|
||||
{
|
||||
nTransactionsUpdatedLast = nTransactionsUpdated;
|
||||
pindexPrev = pindexBest;
|
||||
nStart = GetTime();
|
||||
|
||||
// Create new block
|
||||
if(pblock)
|
||||
delete pblock;
|
||||
pblock = CreateNewBlock(pwalletMain);
|
||||
if (!pblock)
|
||||
throw JSONRPCError(-7, "Out of memory");
|
||||
}
|
||||
|
||||
// Update nTime
|
||||
pblock->UpdateTime(pindexPrev);
|
||||
pblock->nNonce = 0;
|
||||
|
||||
Array transactions;
|
||||
BOOST_FOREACH(CTransaction tx, pblock->vtx) {
|
||||
if(tx.IsCoinBase() || tx.IsCoinStake())
|
||||
continue;
|
||||
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ssTx << tx;
|
||||
|
||||
transactions.push_back(HexStr(ssTx.begin(), ssTx.end()));
|
||||
}
|
||||
|
||||
Object result;
|
||||
result.push_back(Pair("version", pblock->nVersion));
|
||||
result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex()));
|
||||
result.push_back(Pair("transactions", transactions));
|
||||
result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue));
|
||||
result.push_back(Pair("coinbaseflags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end())));
|
||||
result.push_back(Pair("time", (int64_t)pblock->nTime));
|
||||
result.push_back(Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1));
|
||||
result.push_back(Pair("curtime", (int64_t)GetAdjustedTime()));
|
||||
result.push_back(Pair("bits", HexBits(pblock->nBits)));
|
||||
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parse parameters
|
||||
CDataStream ssBlock(ParseHex(params[0].get_str()), SER_NETWORK, PROTOCOL_VERSION);
|
||||
CBlock pblock;
|
||||
ssBlock >> pblock;
|
||||
|
||||
static CReserveKey reservekey(pwalletMain);
|
||||
|
||||
if(!pblock.SignBlock(*pwalletMain))
|
||||
throw JSONRPCError(-100, "Unable to sign block, wallet locked?");
|
||||
|
||||
return CheckWork(&pblock, *pwalletMain, reservekey);
|
||||
}
|
||||
}
|
||||
|
||||
Value getnewpubkey(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() > 1)
|
||||
@@ -2212,7 +2215,6 @@ Value getnewpubkey(const Array& params, bool fHelp)
|
||||
return HexStr(newKey.begin(), newKey.end());
|
||||
}
|
||||
|
||||
|
||||
Value getblockhash(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 1)
|
||||
@@ -2252,6 +2254,30 @@ Value getblock(const Array& params, bool fHelp)
|
||||
return blockToJSON(block, pblockindex, params.size() > 1 ? params[1].get_bool() : false);
|
||||
}
|
||||
|
||||
Value getblockbynumber(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||
throw runtime_error(
|
||||
"getblock <number> [txinfo]\n"
|
||||
"txinfo optional to print more detailed tx info\n"
|
||||
"Returns details of a block with given block-number.");
|
||||
|
||||
int nHeight = params[0].get_int();
|
||||
if (nHeight < 0 || nHeight > nBestHeight)
|
||||
throw runtime_error("Block number out of range.");
|
||||
|
||||
CBlock block;
|
||||
CBlockIndex* pblockindex = mapBlockIndex[hashBestChain];
|
||||
while (pblockindex->nHeight > nHeight)
|
||||
pblockindex = pblockindex->pprev;
|
||||
|
||||
uint256 hash = *pblockindex->phashBlock;
|
||||
|
||||
pblockindex = mapBlockIndex[hash];
|
||||
block.ReadFromDisk(pblockindex, true);
|
||||
|
||||
return blockToJSON(block, pblockindex, params.size() > 1 ? params[1].get_bool() : false);
|
||||
}
|
||||
|
||||
// ppcoin: get information of sync-checkpoint
|
||||
Value getcheckpoint(const Array& params, bool fHelp)
|
||||
@@ -2505,6 +2531,7 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "addmultisigaddress", &addmultisigaddress, false },
|
||||
{ "getblock", &getblock, false },
|
||||
{ "getblockhash", &getblockhash, false },
|
||||
{ "getblockbynumber", &getblockbynumber, false },
|
||||
{ "gettransaction", &gettransaction, false },
|
||||
{ "listtransactions", &listtransactions, false },
|
||||
{ "signmessage", &signmessage, false },
|
||||
@@ -2837,7 +2864,7 @@ void ThreadRPCServer2(void* parg)
|
||||
ThreadSafeMessageBox(strprintf(
|
||||
_("%s, you must set a rpcpassword in the configuration file:\n %s\n"
|
||||
"It is recommended you use the following random password:\n"
|
||||
"rpcuser=bitcoinrpc\n"
|
||||
"rpcuser=novarpc\n"
|
||||
"rpcpassword=%s\n"
|
||||
"(you do not need to remember this password)\n"
|
||||
"If the file does not exist, create it with owner-readable-only file permissions.\n"),
|
||||
@@ -3127,6 +3154,8 @@ int CommandLineRPC(int argc, char *argv[])
|
||||
if (strMethod == "listreceivedbyaccount" && n > 1) ConvertTo<bool>(params[1]);
|
||||
if (strMethod == "getbalance" && n > 1) ConvertTo<boost::int64_t>(params[1]);
|
||||
if (strMethod == "getblockhash" && n > 0) ConvertTo<boost::int64_t>(params[0]);
|
||||
if (strMethod == "getblockbynumber" && n > 0) ConvertTo<boost::int64_t>(params[0]);
|
||||
if (strMethod == "getblockbynumber" && n > 1) ConvertTo<bool>(params[1]);
|
||||
if (strMethod == "getblock" && n > 1) ConvertTo<bool>(params[1]);
|
||||
if (strMethod == "move" && n > 2) ConvertTo<double>(params[2]);
|
||||
if (strMethod == "move" && n > 3) ConvertTo<boost::int64_t>(params[3]);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Copyright (c) 2011-2012 The PPCoin developers
|
||||
// Copyright (c) 2011-2013 The PPCoin developers
|
||||
// Copyright (c) 2013 NovaCoin Developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -26,7 +27,7 @@ namespace Checkpoints
|
||||
static MapCheckpoints mapCheckpoints =
|
||||
boost::assign::map_list_of
|
||||
( 0, hashGenesisBlockOfficial )
|
||||
; // ppcoin: no checkpoint yet; to be created in future releases
|
||||
;
|
||||
|
||||
bool CheckHardened(int nHeight, const uint256& hash)
|
||||
{
|
||||
@@ -351,6 +352,16 @@ namespace Checkpoints
|
||||
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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Copyright (c) 2011-2012 The PPCoin developers
|
||||
// Copyright (c) 2012-2013 The NovaCoin 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
|
||||
@@ -10,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;
|
||||
@@ -48,6 +45,7 @@ namespace Checkpoints
|
||||
bool SetCheckpointPrivKey(std::string strPrivKey);
|
||||
bool SendSyncCheckpoint(uint256 hashCheckpoint);
|
||||
bool IsMatureSyncCheckpoint();
|
||||
bool IsSyncCheckpointTooOld(unsigned int nSeconds);
|
||||
}
|
||||
|
||||
// ppcoin: synchronized checkpoint
|
||||
|
||||
14
src/db.cpp
14
src/db.cpp
@@ -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 @@ bool CTxDB::LoadBlockIndex()
|
||||
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 @@ bool CTxDB::LoadBlockIndex()
|
||||
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 @@ bool CTxDB::LoadBlockIndex()
|
||||
{
|
||||
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
|
||||
|
||||
1
src/db.h
1
src/db.h
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Copyright (c) 2011-2012 The PPCoin developers
|
||||
// Copyright (c) 2012-2013 The NovaCoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#ifndef BITCOIN_DB_H
|
||||
|
||||
10
src/init.cpp
10
src/init.cpp
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Copyright (c) 2011-2012 The PPCoin developers
|
||||
// Copyright (c) 2012-2013 The NovaCoin developers
|
||||
// Copyright (c) 2011-2013 The PPCoin developers
|
||||
// Copyright (c) 2013 NovaCoin 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"
|
||||
@@ -205,7 +205,7 @@ bool AppInit2(int argc, char* argv[])
|
||||
#ifdef QT_GUI
|
||||
" -lang=<lang> \t\t " + _("Set language, for example \"de_DE\" (default: system locale)") + "\n" +
|
||||
#endif
|
||||
" -dnsseed \t " + _("Find peers using DNS lookup (default: 0)") + "\n" +
|
||||
" -dnsseed \t " + _("Find peers using DNS lookup (default: 1)") + "\n" +
|
||||
" -banscore=<n> \t " + _("Threshold for disconnecting misbehaving peers (default: 100)") + "\n" +
|
||||
" -bantime=<n> \t " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n" +
|
||||
" -maxreceivebuffer=<n>\t " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 10000)") + "\n" +
|
||||
@@ -234,7 +234,7 @@ bool AppInit2(int argc, char* argv[])
|
||||
#endif
|
||||
" -rpcuser=<user> \t " + _("Username for JSON-RPC connections") + "\n" +
|
||||
" -rpcpassword=<pw>\t " + _("Password for JSON-RPC connections") + "\n" +
|
||||
" -rpcport=<port> \t\t " + _("Listen for JSON-RPC connections on <port> (default: 9902)") + "\n" +
|
||||
" -rpcport=<port> \t\t " + _("Listen for JSON-RPC connections on <port> (default: 8344)") + "\n" +
|
||||
" -rpcallowip=<ip> \t\t " + _("Allow JSON-RPC connections from specified IP address") + "\n" +
|
||||
" -rpcconnect=<ip> \t " + _("Send commands to node running on <ip> (default: 127.0.0.1)") + "\n" +
|
||||
" -blocknotify=<cmd> " + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n" +
|
||||
@@ -450,7 +450,7 @@ bool AppInit2(int argc, char* argv[])
|
||||
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);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Copyright (c) 2013 NovaCoin Developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
193
src/main.cpp
193
src/main.cpp
@@ -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,8 @@
|
||||
#include "net.h"
|
||||
#include "init.h"
|
||||
#include "ui_interface.h"
|
||||
#include "kernel.h"
|
||||
#include "scrypt_mine.h"
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
@@ -31,8 +33,8 @@ unsigned int nTransactionsUpdated = 0;
|
||||
map<uint256, CBlockIndex*> mapBlockIndex;
|
||||
set<pair<COutPoint, unsigned int> > setStakeSeen;
|
||||
uint256 hashGenesisBlock = hashGenesisBlockOfficial;
|
||||
CBigNum bnProofOfWorkLimit(~uint256(0) >> 20);
|
||||
CBigNum bnInitialHashTarget(~uint256(0) >> 20);
|
||||
static CBigNum bnProofOfWorkLimit(~uint256(0) >> 20);
|
||||
static CBigNum bnInitialHashTarget(~uint256(0) >> 20);
|
||||
unsigned int nStakeMinAge = STAKE_MIN_AGE;
|
||||
int nCoinbaseMaturity = COINBASE_MATURITY_PPC;
|
||||
CBlockIndex* pindexGenesisBlock = NULL;
|
||||
@@ -48,6 +50,7 @@ CMedianFilter<int> cPeerBlockCounts(5, 0); // Amount of blocks that other nodes
|
||||
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;
|
||||
@@ -871,8 +874,7 @@ int64 GetProofOfStakeReward(int64 nCoinAge)
|
||||
}
|
||||
|
||||
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
|
||||
@@ -920,7 +922,7 @@ unsigned int static GetNextTargetRequired(const CBlockIndex* pindexLast, bool fP
|
||||
// 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);
|
||||
@@ -1351,15 +1353,17 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex)
|
||||
// already refuses previously-known transaction id's entirely.
|
||||
// This rule applies to all blocks whose timestamp is after March 15, 2012, 0:00 UTC.
|
||||
// On testnet it is enabled as of februari 20, 2012, 0:00 UTC.
|
||||
|
||||
BOOST_FOREACH(CTransaction& tx, vtx)
|
||||
if (pindex->nTime > 1331769600 || (fTestNet && pindex->nTime > 1329696000))
|
||||
{
|
||||
CTxIndex txindexOld;
|
||||
if (txdb.ReadTxIndex(tx.GetHash(), txindexOld))
|
||||
BOOST_FOREACH(CTransaction& tx, vtx)
|
||||
{
|
||||
BOOST_FOREACH(CDiskTxPos &pos, txindexOld.vSpent)
|
||||
if (pos.IsNull())
|
||||
return false;
|
||||
CTxIndex txindexOld;
|
||||
if (txdb.ReadTxIndex(tx.GetHash(), txindexOld))
|
||||
{
|
||||
BOOST_FOREACH(CDiskTxPos &pos, txindexOld.vSpent)
|
||||
if (pos.IsNull())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1677,69 +1681,6 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
@@ -1820,11 +1761,8 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos)
|
||||
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())
|
||||
{
|
||||
@@ -1835,6 +1773,35 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos)
|
||||
// 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;
|
||||
@@ -1902,8 +1869,8 @@ bool CBlock::CheckBlock() const
|
||||
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))
|
||||
@@ -2039,10 +2006,16 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock)
|
||||
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();
|
||||
@@ -2245,6 +2218,10 @@ bool CBlock::CheckBlockSignature() const
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool CheckDiskSpace(uint64 nAdditionalBytes)
|
||||
{
|
||||
uint64 nFreeBytesAvailable = filesystem::space(GetDataDir()).available;
|
||||
@@ -2313,8 +2290,8 @@ bool LoadBlockIndex(bool fAllowNew)
|
||||
nCoinbaseMaturity = 60;
|
||||
}
|
||||
|
||||
printf("%s Network: genesis=0x%s nBitsLimit=0x%08x nBitsInitial=0x%08x nStakeMinAge=%d nCoinbaseMaturity=%d\n",
|
||||
fTestNet? "Test" : "NovaCoin", 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" : "NovaCoin", hashGenesisBlock.ToString().substr(0, 20).c_str(), bnProofOfWorkLimit.GetCompact(), bnInitialHashTarget.GetCompact(), nStakeMinAge, nCoinbaseMaturity, nModifierInterval);
|
||||
|
||||
//
|
||||
// Load block index
|
||||
@@ -2332,13 +2309,6 @@ bool LoadBlockIndex(bool fAllowNew)
|
||||
if (!fAllowNew)
|
||||
return false;
|
||||
|
||||
// Genesis Block:
|
||||
// CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
|
||||
// CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
|
||||
// CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
|
||||
// CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
|
||||
// vMerkleTree: 4a5e1e
|
||||
|
||||
// Genesis block
|
||||
const char* pszTimestamp = "https://bitcointalk.org/index.php?topic=134179.msg1502196#msg1502196";
|
||||
CTransaction txNew;
|
||||
@@ -2357,9 +2327,6 @@ bool LoadBlockIndex(bool fAllowNew)
|
||||
block.nNonce = 1575379;
|
||||
|
||||
//// debug print
|
||||
printf("%s\n", block.GetHash().ToString().c_str());
|
||||
printf("%s\n", hashGenesisBlock.ToString().c_str());
|
||||
printf("%s\n", block.hashMerkleRoot.ToString().c_str());
|
||||
assert(block.hashMerkleRoot == uint256("0x4cb33b3b6a861dcbc685d3e614a9cafb945738d6833f182855679f2fad02057b"));
|
||||
block.print();
|
||||
assert(block.GetHash() == hashGenesisBlock);
|
||||
@@ -2518,11 +2485,11 @@ string GetWarnings(string strFor)
|
||||
}
|
||||
|
||||
// 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 download, or notify developers.";
|
||||
nPriority = 100;
|
||||
strStatusBar = "WARNING: Checkpoint is too old. Wait for block chain to download, or notify developers.";
|
||||
}
|
||||
|
||||
// ppcoin: if detected invalid checkpoint enter safe mode
|
||||
@@ -3654,13 +3621,18 @@ CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake)
|
||||
{
|
||||
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;
|
||||
@@ -3755,7 +3727,7 @@ CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake)
|
||||
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
|
||||
@@ -3817,9 +3789,12 @@ CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake)
|
||||
// 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();
|
||||
@@ -3932,9 +3907,9 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
|
||||
|
||||
void static ThreadBitcoinMiner(void* parg);
|
||||
|
||||
bool fGenerateBitcoins = false;
|
||||
bool fLimitProcessors = false;
|
||||
int nLimitProcessors = -1;
|
||||
static bool fGenerateBitcoins = false;
|
||||
static bool fLimitProcessors = false;
|
||||
static int nLimitProcessors = -1;
|
||||
|
||||
void BitcoinMiner(CWallet *pwallet, bool fProofOfStake)
|
||||
{
|
||||
|
||||
116
src/main.h
116
src/main.h
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Copyright (c) 2011-2012 The PPCoin developers
|
||||
// Copyright (c) 2012-2013 The NovaCoin 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
|
||||
@@ -43,6 +42,10 @@ inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONE
|
||||
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
|
||||
@@ -56,6 +59,11 @@ static const int64 nMaxClockDrift = 2 * 60 * 60; // two hours
|
||||
|
||||
extern CScript COINBASE_FLAGS;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern CCriticalSection cs_main;
|
||||
extern std::map<uint256, CBlockIndex*> mapBlockIndex;
|
||||
extern std::set<std::pair<COutPoint, unsigned int> > setStakeSeen;
|
||||
@@ -83,9 +91,9 @@ extern std::map<uint256, CBlock*> mapOrphanBlocks;
|
||||
// Settings
|
||||
extern int64 nTransactionFee;
|
||||
|
||||
extern bool fGenerateBitcoins;
|
||||
extern bool fLimitProcessors;
|
||||
extern int nLimitProcessors;
|
||||
|
||||
|
||||
|
||||
|
||||
class CReserveKey;
|
||||
class CTxDB;
|
||||
@@ -740,7 +748,6 @@ public:
|
||||
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;
|
||||
@@ -884,7 +891,7 @@ public:
|
||||
// network and disk
|
||||
std::vector<CTransaction> vtx;
|
||||
|
||||
// ppcoin: block signature - signed by coin base txout[0]'s owner
|
||||
// ppcoin: block signature - signed by one of the coin base txout[N]'s owner
|
||||
std::vector<unsigned char> vchBlockSig;
|
||||
|
||||
// memory only
|
||||
@@ -953,6 +960,7 @@ public:
|
||||
return thash;
|
||||
}
|
||||
|
||||
|
||||
int64 GetBlockTime() const
|
||||
{
|
||||
return (int64)nTime;
|
||||
@@ -960,6 +968,18 @@ public:
|
||||
|
||||
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
|
||||
{
|
||||
@@ -1159,9 +1179,22 @@ public:
|
||||
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;
|
||||
@@ -1182,7 +1215,10 @@ public:
|
||||
bnChainTrust = 0;
|
||||
nMint = 0;
|
||||
nMoneySupply = 0;
|
||||
fProofOfStake = true;
|
||||
nFlags = 0;
|
||||
nStakeModifier = 0;
|
||||
nStakeModifierChecksum = 0;
|
||||
hashProofOfStake = 0;
|
||||
prevoutStake.SetNull();
|
||||
nStakeTime = 0;
|
||||
|
||||
@@ -1204,9 +1240,13 @@ public:
|
||||
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;
|
||||
}
|
||||
@@ -1252,7 +1292,7 @@ public:
|
||||
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
|
||||
@@ -1262,7 +1302,7 @@ public:
|
||||
|
||||
bool CheckIndex() const
|
||||
{
|
||||
return IsProofOfWork() ? CheckProofOfWork(GetBlockHash(), nBits) : true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EraseBlockFromDisk()
|
||||
@@ -1310,20 +1350,53 @@ public:
|
||||
|
||||
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());
|
||||
}
|
||||
@@ -1366,16 +1439,19 @@ public:
|
||||
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
|
||||
@@ -1745,7 +1821,7 @@ public:
|
||||
bool CheckSignature()
|
||||
{
|
||||
CKey key;
|
||||
if (!key.SetPubKey(ParseHex("04a0a849dd49b113d3179a332dd77715c43be4d0076e2f19e66de23dd707e56630f792f298dfd209bf042bb3561f4af6983f3d81e439737ab0bf7f898fecd21aab")))
|
||||
if (!key.SetPubKey(ParseHex("043fa441fd4203d03f5df2b75ea14e36f20d39f43e7a61aa7552ab9bcd7ecb0e77a3be4585b13fcdaa22ef6e51f1ff6f2929bec2494385b086fb86610e33193195")))
|
||||
return error("CAlert::CheckSignature() : SetPubKey failed");
|
||||
if (!key.Verify(Hash(vchMsg.begin(), vchMsg.end()), vchSig))
|
||||
return error("CAlert::CheckSignature() : verify signature failed");
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
DEPSDIR:=/usr/i586-mingw32msvc
|
||||
|
||||
USE_UPNP:=-
|
||||
USE_UPNP:=0
|
||||
|
||||
INCLUDEPATHS= \
|
||||
-I"$(DEPSDIR)/boost_1_47_0" \
|
||||
@@ -29,7 +29,7 @@ LIBS= \
|
||||
|
||||
DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
|
||||
DEBUGFLAGS=-g
|
||||
CFLAGS=-O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
|
||||
CFLAGS=-O2 -msse2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
|
||||
|
||||
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
|
||||
|
||||
@@ -56,8 +56,6 @@ OBJS= \
|
||||
obj/irc.o \
|
||||
obj/keystore.o \
|
||||
obj/main.o \
|
||||
obj/scrypt_mine.o \
|
||||
obj/scrypt-x86.o \
|
||||
obj/net.o \
|
||||
obj/protocol.o \
|
||||
obj/bitcoinrpc.o \
|
||||
@@ -67,8 +65,11 @@ OBJS= \
|
||||
obj/wallet.o \
|
||||
obj/walletdb.o \
|
||||
obj/noui.o \
|
||||
obj/pbkdf2.o
|
||||
|
||||
obj/kernel.o \
|
||||
obj/pbkdf2.o \
|
||||
obj/scrypt_mine.o \
|
||||
obj/scrypt-x86.o \
|
||||
obj/scrypt-x86_64.o
|
||||
|
||||
all: novacoind.exe
|
||||
|
||||
@@ -81,11 +82,10 @@ obj/%.o: %.cpp $(HEADERS)
|
||||
i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/scrypt-x86.o: scrypt-x86.S
|
||||
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
|
||||
i586-mingw32msvc-g++ -c $(CFLAGS) -MMD -o $@ $<
|
||||
|
||||
obj/scrypt-x86_64.o: scrypt-x86_64.S
|
||||
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
|
||||
|
||||
i586-mingw32msvc-g++ -c $(CFLAGS) -MMD -o $@ $<
|
||||
|
||||
novacoind.exe: $(OBJS:obj/%=obj/%)
|
||||
i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
|
||||
@@ -95,7 +95,7 @@ TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
|
||||
obj-test/%.o: test/%.cpp $(HEADERS)
|
||||
i586-mingw32msvc-g++ -c $(TESTDEFS) $(CFLAGS) -o $@ $<
|
||||
|
||||
test_bitcoin.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
|
||||
test_novacoin.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
|
||||
i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework $(LIBS)
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ clean:
|
||||
-rm -f obj/*.o
|
||||
-rm -f novacoind.exe
|
||||
-rm -f obj-test/*.o
|
||||
-rm -f test_bitcoin.exe
|
||||
-rm -f test_novacoin.exe
|
||||
-rm -f src/build.h
|
||||
|
||||
FORCE:
|
||||
|
||||
@@ -52,14 +52,14 @@
|
||||
# mkdir miniupnpc
|
||||
# cp *.h miniupnpc/
|
||||
#
|
||||
# - Build ppcoind.exe
|
||||
# - Build novacoind.exe
|
||||
# in MinGW MSYS
|
||||
# cd ppcoin/src
|
||||
# make ppcoind.exe -f makefile.mingw USE_UPNP=1
|
||||
# cd novacoin/src
|
||||
# make novacoind.exe -f makefile.mingw USE_UPNP=1
|
||||
#
|
||||
#
|
||||
|
||||
USE_UPNP:=-
|
||||
USE_UPNP:=0
|
||||
|
||||
INCLUDEPATHS= \
|
||||
-I"C:\boost-1.47.0-mgw" \
|
||||
@@ -82,7 +82,7 @@ LIBS= \
|
||||
|
||||
DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
|
||||
DEBUGFLAGS=-g
|
||||
CFLAGS=-mthreads -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
|
||||
CFLAGS=-mthreads -msse2 -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
|
||||
|
||||
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
|
||||
|
||||
@@ -109,8 +109,6 @@ OBJS= \
|
||||
obj/init.o \
|
||||
obj/irc.o \
|
||||
obj/keystore.o \
|
||||
obj/scrypt_mine.o \
|
||||
obj/scrypt-x86.o \
|
||||
obj/main.o \
|
||||
obj/net.o \
|
||||
obj/protocol.o \
|
||||
@@ -121,7 +119,12 @@ OBJS= \
|
||||
obj/wallet.o \
|
||||
obj/walletdb.o \
|
||||
obj/noui.o \
|
||||
obj/pbkdf2.o
|
||||
obj/kernel.o \
|
||||
obj/pbkdf2.o \
|
||||
obj/scrypt_mine.o \
|
||||
obj/scrypt-x86.o \
|
||||
obj/scrypt-x86_64.o
|
||||
|
||||
|
||||
all: novacoind.exe
|
||||
|
||||
@@ -134,7 +137,6 @@ obj/scrypt-x86.o: scrypt-x86.S
|
||||
obj/scrypt-x86_64.o: scrypt-x86_64.S
|
||||
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
|
||||
|
||||
|
||||
novacoind.exe: $(OBJS:obj/%=obj/%)
|
||||
g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
|
||||
|
||||
@@ -143,11 +145,11 @@ TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
|
||||
obj-test/%.o: test/%.cpp $(HEADERS)
|
||||
g++ -c $(TESTDEFS) $(CFLAGS) -o $@ $<
|
||||
|
||||
test_bitcoin.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
|
||||
test_novacoin.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
|
||||
g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework $(LIBS)
|
||||
|
||||
clean:
|
||||
-del /Q novacoind test_bitcoin
|
||||
-del /Q novacoind test_novacoin
|
||||
-del /Q obj\*
|
||||
-del /Q obj-test\*
|
||||
-del /Q build.h
|
||||
|
||||
@@ -19,7 +19,7 @@ LIBPATHS= \
|
||||
-L"$(DEPSDIR)/lib" \
|
||||
-L"$(DEPSDIR)/lib/db48"
|
||||
|
||||
USE_UPNP:=-
|
||||
USE_UPNP:=1
|
||||
|
||||
LIBS= -dead_strip
|
||||
|
||||
@@ -59,9 +59,9 @@ ifdef RELEASE
|
||||
# Compile for maximum compatibility and smallest size.
|
||||
# This requires that dependencies are compiled
|
||||
# the same way.
|
||||
CFLAGS = -mmacosx-version-min=10.5 -arch i386 -O3
|
||||
CFLAGS = -mmacosx-version-min=10.5 -arch i386 -O3 -msse2
|
||||
else
|
||||
CFLAGS = -g
|
||||
CFLAGS = -g -msse2
|
||||
endif
|
||||
|
||||
# ppc doesn't work because we don't support big-endian
|
||||
@@ -80,8 +80,6 @@ OBJS= \
|
||||
obj/irc.o \
|
||||
obj/keystore.o \
|
||||
obj/main.o \
|
||||
obj/scrypt_mine.o \
|
||||
obj/scrypt-$(HOSTTYPE).o \
|
||||
obj/net.o \
|
||||
obj/protocol.o \
|
||||
obj/bitcoinrpc.o \
|
||||
@@ -91,8 +89,10 @@ OBJS= \
|
||||
obj/wallet.o \
|
||||
obj/walletdb.o \
|
||||
obj/noui.o \
|
||||
obj/pbkdf2.o
|
||||
|
||||
obj/pbkdf2.o \
|
||||
obj/scrypt_mine.o \
|
||||
obj/scrypt-x86.o \
|
||||
obj/scrypt-x86_64.o
|
||||
|
||||
ifdef USE_UPNP
|
||||
DEFS += -DUSE_UPNP=$(USE_UPNP)
|
||||
@@ -103,7 +103,7 @@ else
|
||||
endif
|
||||
endif
|
||||
|
||||
all: bitcoind
|
||||
all: novacoind
|
||||
|
||||
# auto-generated dependencies:
|
||||
-include obj/*.P
|
||||
@@ -121,7 +121,13 @@ obj/%.o: %.cpp
|
||||
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
|
||||
rm -f $(@:%.o=%.d)
|
||||
|
||||
bitcoind: $(OBJS:obj/%=obj/%)
|
||||
obj/scrypt-x86.o: scrypt-x86.S
|
||||
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
|
||||
|
||||
obj/scrypt-x86_64.o: scrypt-x86_64.S
|
||||
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
|
||||
|
||||
novacoind: $(OBJS:obj/%=obj/%)
|
||||
$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
|
||||
|
||||
TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
|
||||
@@ -133,11 +139,11 @@ obj-test/%.o: test/%.cpp
|
||||
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
|
||||
rm -f $(@:%.o=%.d)
|
||||
|
||||
test_bitcoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
|
||||
test_novacoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
|
||||
$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(TESTLIBS)
|
||||
|
||||
clean:
|
||||
-rm -f bitcoind test_bitcoin
|
||||
-rm -f novacoind test_novacoin
|
||||
-rm -f obj/*.o
|
||||
-rm -f obj-test/*.o
|
||||
-rm -f obj/*.P
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
# 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.
|
||||
|
||||
USE_UPNP:=-
|
||||
USE_UPNP:=0
|
||||
|
||||
DEFS=-DBOOST_SPIRIT_THREADSAFE
|
||||
|
||||
DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
|
||||
LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
|
||||
|
||||
HOSTTYPE = $(shell arch)
|
||||
|
||||
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
|
||||
|
||||
LMODE = dynamic
|
||||
@@ -101,8 +99,6 @@ OBJS= \
|
||||
obj/irc.o \
|
||||
obj/keystore.o \
|
||||
obj/main.o \
|
||||
obj/scrypt_mine.o \
|
||||
obj/scrypt-${HOSTTYPE}.o \
|
||||
obj/net.o \
|
||||
obj/protocol.o \
|
||||
obj/bitcoinrpc.o \
|
||||
@@ -112,9 +108,11 @@ OBJS= \
|
||||
obj/wallet.o \
|
||||
obj/walletdb.o \
|
||||
obj/noui.o \
|
||||
obj/pbkdf2.o
|
||||
|
||||
|
||||
obj/kernel.o \
|
||||
obj/pbkdf2.o \
|
||||
obj/scrypt_mine.o \
|
||||
obj/scrypt-x86.o \
|
||||
obj/scrypt-x86_64.o
|
||||
|
||||
all: novacoind
|
||||
|
||||
|
||||
16
src/net.cpp
16
src/net.cpp
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Copyright (c) 2011-2012 The PPCoin developers
|
||||
// Copyright (c) 2012-2013 The NovaCoin 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.
|
||||
|
||||
@@ -982,7 +981,8 @@ void MapPort(bool /* unused fMapPort */)
|
||||
// The second name should resolve to a list of seed addresses.
|
||||
// testnet dns seed begins with 't', all else are ppcoin dns seeds.
|
||||
static const char *strDNSSeed[][2] = {
|
||||
{"seed", "xxx"}
|
||||
{"seed", "seed.ppcoin.net"},
|
||||
{"tnseed", "tnseed.ppcoin.net"},
|
||||
};
|
||||
|
||||
void ThreadDNSAddressSeed(void* parg)
|
||||
@@ -1009,7 +1009,7 @@ void ThreadDNSAddressSeed2(void* parg)
|
||||
printf("ThreadDNSAddressSeed started\n");
|
||||
int found = 0;
|
||||
|
||||
if (true && !fTestNet)
|
||||
if (true /*!fTestNet*/) // ppcoin enables dns seeding with testnet too
|
||||
{
|
||||
printf("Loading addresses from DNS seeds (could take a while)\n");
|
||||
|
||||
@@ -1050,7 +1050,7 @@ void ThreadDNSAddressSeed2(void* parg)
|
||||
|
||||
unsigned int pnSeed[] =
|
||||
{
|
||||
0x90EF78BC,
|
||||
0x90EF78BC, 0x33F1C851, 0x36F1C851, 0xC6F5C851,
|
||||
};
|
||||
|
||||
void DumpAddresses()
|
||||
@@ -1616,6 +1616,8 @@ void StartNode(void* parg)
|
||||
printf("Error: CreateThread(ThreadDNSAddressSeed) failed\n");
|
||||
*/
|
||||
|
||||
if (!GetBoolArg("-dnsseed", false))
|
||||
printf("DNS seeding disabled\n");
|
||||
if (GetBoolArg("-dnsseed", false))
|
||||
printf("DNS seeding NYI\n");
|
||||
|
||||
@@ -1624,8 +1626,8 @@ void StartNode(void* parg)
|
||||
MapPort(fUseUPnP);
|
||||
|
||||
// Get addresses from IRC and advertise ours
|
||||
if (!CreateThread(ThreadIRCSeed, NULL))
|
||||
printf("Error: CreateThread(ThreadIRCSeed) failed\n");
|
||||
if (!CreateThread(ThreadIRCSeed, NULL))
|
||||
printf("Error: CreateThread(ThreadIRCSeed) failed\n");
|
||||
|
||||
// Send and receive from sockets, accept connections
|
||||
if (!CreateThread(ThreadSocketHandler, NULL))
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Copyright (c) 2012 The PPCoin developers
|
||||
// Copyright (c) 2012-2013 The NovaCoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#ifndef BITCOIN_NET_H
|
||||
|
||||
294
src/pbkdf2.cpp
294
src/pbkdf2.cpp
@@ -1,146 +1,148 @@
|
||||
#include <string.h>
|
||||
#include "pbkdf2.h"
|
||||
|
||||
static inline uint32_t
|
||||
be32dec(const void *pp)
|
||||
{
|
||||
const uint8_t *p = (uint8_t const *)pp;
|
||||
|
||||
return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) +
|
||||
((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24));
|
||||
}
|
||||
|
||||
static inline void
|
||||
be32enc(void *pp, uint32_t x)
|
||||
{
|
||||
uint8_t * p = (uint8_t *)pp;
|
||||
|
||||
p[3] = x & 0xff;
|
||||
p[2] = (x >> 8) & 0xff;
|
||||
p[1] = (x >> 16) & 0xff;
|
||||
p[0] = (x >> 24) & 0xff;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Initialize an HMAC-SHA256 operation with the given key. */
|
||||
void
|
||||
HMAC_SHA256_Init(HMAC_SHA256_CTX * ctx, const void * _K, size_t Klen)
|
||||
{
|
||||
unsigned char pad[64];
|
||||
unsigned char khash[32];
|
||||
const unsigned char * K = (const unsigned char *)_K;
|
||||
size_t i;
|
||||
|
||||
/* If Klen > 64, the key is really SHA256(K). */
|
||||
if (Klen > 64) {
|
||||
SHA256_Init(&ctx->ictx);
|
||||
SHA256_Update(&ctx->ictx, K, Klen);
|
||||
SHA256_Final(khash, &ctx->ictx);
|
||||
K = khash;
|
||||
Klen = 32;
|
||||
}
|
||||
|
||||
/* Inner SHA256 operation is SHA256(K xor [block of 0x36] || data). */
|
||||
SHA256_Init(&ctx->ictx);
|
||||
memset(pad, 0x36, 64);
|
||||
for (i = 0; i < Klen; i++)
|
||||
pad[i] ^= K[i];
|
||||
SHA256_Update(&ctx->ictx, pad, 64);
|
||||
|
||||
/* Outer SHA256 operation is SHA256(K xor [block of 0x5c] || hash). */
|
||||
SHA256_Init(&ctx->octx);
|
||||
memset(pad, 0x5c, 64);
|
||||
for (i = 0; i < Klen; i++)
|
||||
pad[i] ^= K[i];
|
||||
SHA256_Update(&ctx->octx, pad, 64);
|
||||
|
||||
/* Clean the stack. */
|
||||
memset(khash, 0, 32);
|
||||
}
|
||||
|
||||
/* Add bytes to the HMAC-SHA256 operation. */
|
||||
void
|
||||
HMAC_SHA256_Update(HMAC_SHA256_CTX * ctx, const void *in, size_t len)
|
||||
{
|
||||
|
||||
/* Feed data to the inner SHA256 operation. */
|
||||
SHA256_Update(&ctx->ictx, in, len);
|
||||
}
|
||||
|
||||
/* Finish an HMAC-SHA256 operation. */
|
||||
void
|
||||
HMAC_SHA256_Final(unsigned char digest[32], HMAC_SHA256_CTX * ctx)
|
||||
{
|
||||
unsigned char ihash[32];
|
||||
|
||||
/* Finish the inner SHA256 operation. */
|
||||
SHA256_Final(ihash, &ctx->ictx);
|
||||
|
||||
/* Feed the inner hash to the outer SHA256 operation. */
|
||||
SHA256_Update(&ctx->octx, ihash, 32);
|
||||
|
||||
/* Finish the outer SHA256 operation. */
|
||||
SHA256_Final(digest, &ctx->octx);
|
||||
|
||||
/* Clean the stack. */
|
||||
memset(ihash, 0, 32);
|
||||
}
|
||||
|
||||
/**
|
||||
* PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen):
|
||||
* Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and
|
||||
* write the output to buf. The value dkLen must be at most 32 * (2^32 - 1).
|
||||
*/
|
||||
void
|
||||
PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt,
|
||||
size_t saltlen, uint64_t c, uint8_t * buf, size_t dkLen)
|
||||
{
|
||||
HMAC_SHA256_CTX PShctx, hctx;
|
||||
size_t i;
|
||||
uint8_t ivec[4];
|
||||
uint8_t U[32];
|
||||
uint8_t T[32];
|
||||
uint64_t j;
|
||||
int k;
|
||||
size_t clen;
|
||||
|
||||
/* Compute HMAC state after processing P and S. */
|
||||
HMAC_SHA256_Init(&PShctx, passwd, passwdlen);
|
||||
HMAC_SHA256_Update(&PShctx, salt, saltlen);
|
||||
|
||||
/* Iterate through the blocks. */
|
||||
for (i = 0; i * 32 < dkLen; i++) {
|
||||
/* Generate INT(i + 1). */
|
||||
be32enc(ivec, (uint32_t)(i + 1));
|
||||
|
||||
/* Compute U_1 = PRF(P, S || INT(i)). */
|
||||
memcpy(&hctx, &PShctx, sizeof(HMAC_SHA256_CTX));
|
||||
HMAC_SHA256_Update(&hctx, ivec, 4);
|
||||
HMAC_SHA256_Final(U, &hctx);
|
||||
|
||||
/* T_i = U_1 ... */
|
||||
memcpy(T, U, 32);
|
||||
|
||||
for (j = 2; j <= c; j++) {
|
||||
/* Compute U_j. */
|
||||
HMAC_SHA256_Init(&hctx, passwd, passwdlen);
|
||||
HMAC_SHA256_Update(&hctx, U, 32);
|
||||
HMAC_SHA256_Final(U, &hctx);
|
||||
|
||||
/* ... xor U_j ... */
|
||||
for (k = 0; k < 32; k++)
|
||||
T[k] ^= U[k];
|
||||
}
|
||||
|
||||
/* Copy as many bytes as necessary into buf. */
|
||||
clen = dkLen - i * 32;
|
||||
if (clen > 32)
|
||||
clen = 32;
|
||||
memcpy(&buf[i * 32], T, clen);
|
||||
}
|
||||
|
||||
/* Clean PShctx, since we never called _Final on it. */
|
||||
memset(&PShctx, 0, sizeof(HMAC_SHA256_CTX));
|
||||
}
|
||||
|
||||
// Copyright (c) 2013 NovaCoin Developers
|
||||
|
||||
#include <string.h>
|
||||
#include "pbkdf2.h"
|
||||
|
||||
static inline uint32_t
|
||||
be32dec(const void *pp)
|
||||
{
|
||||
const uint8_t *p = (uint8_t const *)pp;
|
||||
|
||||
return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) +
|
||||
((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24));
|
||||
}
|
||||
|
||||
static inline void
|
||||
be32enc(void *pp, uint32_t x)
|
||||
{
|
||||
uint8_t * p = (uint8_t *)pp;
|
||||
|
||||
p[3] = x & 0xff;
|
||||
p[2] = (x >> 8) & 0xff;
|
||||
p[1] = (x >> 16) & 0xff;
|
||||
p[0] = (x >> 24) & 0xff;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Initialize an HMAC-SHA256 operation with the given key. */
|
||||
void
|
||||
HMAC_SHA256_Init(HMAC_SHA256_CTX * ctx, const void * _K, size_t Klen)
|
||||
{
|
||||
unsigned char pad[64];
|
||||
unsigned char khash[32];
|
||||
const unsigned char * K = (const unsigned char *)_K;
|
||||
size_t i;
|
||||
|
||||
/* If Klen > 64, the key is really SHA256(K). */
|
||||
if (Klen > 64) {
|
||||
SHA256_Init(&ctx->ictx);
|
||||
SHA256_Update(&ctx->ictx, K, Klen);
|
||||
SHA256_Final(khash, &ctx->ictx);
|
||||
K = khash;
|
||||
Klen = 32;
|
||||
}
|
||||
|
||||
/* Inner SHA256 operation is SHA256(K xor [block of 0x36] || data). */
|
||||
SHA256_Init(&ctx->ictx);
|
||||
memset(pad, 0x36, 64);
|
||||
for (i = 0; i < Klen; i++)
|
||||
pad[i] ^= K[i];
|
||||
SHA256_Update(&ctx->ictx, pad, 64);
|
||||
|
||||
/* Outer SHA256 operation is SHA256(K xor [block of 0x5c] || hash). */
|
||||
SHA256_Init(&ctx->octx);
|
||||
memset(pad, 0x5c, 64);
|
||||
for (i = 0; i < Klen; i++)
|
||||
pad[i] ^= K[i];
|
||||
SHA256_Update(&ctx->octx, pad, 64);
|
||||
|
||||
/* Clean the stack. */
|
||||
memset(khash, 0, 32);
|
||||
}
|
||||
|
||||
/* Add bytes to the HMAC-SHA256 operation. */
|
||||
void
|
||||
HMAC_SHA256_Update(HMAC_SHA256_CTX * ctx, const void *in, size_t len)
|
||||
{
|
||||
|
||||
/* Feed data to the inner SHA256 operation. */
|
||||
SHA256_Update(&ctx->ictx, in, len);
|
||||
}
|
||||
|
||||
/* Finish an HMAC-SHA256 operation. */
|
||||
void
|
||||
HMAC_SHA256_Final(unsigned char digest[32], HMAC_SHA256_CTX * ctx)
|
||||
{
|
||||
unsigned char ihash[32];
|
||||
|
||||
/* Finish the inner SHA256 operation. */
|
||||
SHA256_Final(ihash, &ctx->ictx);
|
||||
|
||||
/* Feed the inner hash to the outer SHA256 operation. */
|
||||
SHA256_Update(&ctx->octx, ihash, 32);
|
||||
|
||||
/* Finish the outer SHA256 operation. */
|
||||
SHA256_Final(digest, &ctx->octx);
|
||||
|
||||
/* Clean the stack. */
|
||||
memset(ihash, 0, 32);
|
||||
}
|
||||
|
||||
/**
|
||||
* PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen):
|
||||
* Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and
|
||||
* write the output to buf. The value dkLen must be at most 32 * (2^32 - 1).
|
||||
*/
|
||||
void
|
||||
PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt,
|
||||
size_t saltlen, uint64_t c, uint8_t * buf, size_t dkLen)
|
||||
{
|
||||
HMAC_SHA256_CTX PShctx, hctx;
|
||||
size_t i;
|
||||
uint8_t ivec[4];
|
||||
uint8_t U[32];
|
||||
uint8_t T[32];
|
||||
uint64_t j;
|
||||
int k;
|
||||
size_t clen;
|
||||
|
||||
/* Compute HMAC state after processing P and S. */
|
||||
HMAC_SHA256_Init(&PShctx, passwd, passwdlen);
|
||||
HMAC_SHA256_Update(&PShctx, salt, saltlen);
|
||||
|
||||
/* Iterate through the blocks. */
|
||||
for (i = 0; i * 32 < dkLen; i++) {
|
||||
/* Generate INT(i + 1). */
|
||||
be32enc(ivec, (uint32_t)(i + 1));
|
||||
|
||||
/* Compute U_1 = PRF(P, S || INT(i)). */
|
||||
memcpy(&hctx, &PShctx, sizeof(HMAC_SHA256_CTX));
|
||||
HMAC_SHA256_Update(&hctx, ivec, 4);
|
||||
HMAC_SHA256_Final(U, &hctx);
|
||||
|
||||
/* T_i = U_1 ... */
|
||||
memcpy(T, U, 32);
|
||||
|
||||
for (j = 2; j <= c; j++) {
|
||||
/* Compute U_j. */
|
||||
HMAC_SHA256_Init(&hctx, passwd, passwdlen);
|
||||
HMAC_SHA256_Update(&hctx, U, 32);
|
||||
HMAC_SHA256_Final(U, &hctx);
|
||||
|
||||
/* ... xor U_j ... */
|
||||
for (k = 0; k < 32; k++)
|
||||
T[k] ^= U[k];
|
||||
}
|
||||
|
||||
/* Copy as many bytes as necessary into buf. */
|
||||
clen = dkLen - i * 32;
|
||||
if (clen > 32)
|
||||
clen = 32;
|
||||
memcpy(&buf[i * 32], T, clen);
|
||||
}
|
||||
|
||||
/* Clean PShctx, since we never called _Final on it. */
|
||||
memset(&PShctx, 0, sizeof(HMAC_SHA256_CTX));
|
||||
}
|
||||
|
||||
|
||||
52
src/pbkdf2.h
52
src/pbkdf2.h
@@ -1,25 +1,27 @@
|
||||
#ifndef PBKDF2_H
|
||||
#define PBKDF2_H
|
||||
|
||||
#include <openssl/sha.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct HMAC_SHA256Context {
|
||||
SHA256_CTX ictx;
|
||||
SHA256_CTX octx;
|
||||
} HMAC_SHA256_CTX;
|
||||
|
||||
void
|
||||
HMAC_SHA256_Init(HMAC_SHA256_CTX * ctx, const void * _K, size_t Klen);
|
||||
|
||||
void
|
||||
HMAC_SHA256_Update(HMAC_SHA256_CTX * ctx, const void *in, size_t len);
|
||||
|
||||
void
|
||||
HMAC_SHA256_Final(unsigned char digest[32], HMAC_SHA256_CTX * ctx);
|
||||
|
||||
void
|
||||
PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt,
|
||||
size_t saltlen, uint64_t c, uint8_t * buf, size_t dkLen);
|
||||
|
||||
#endif // PBKDF2_H
|
||||
// Copyright (c) 2013 NovaCoin Developers
|
||||
|
||||
#ifndef PBKDF2_H
|
||||
#define PBKDF2_H
|
||||
|
||||
#include <openssl/sha.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct HMAC_SHA256Context {
|
||||
SHA256_CTX ictx;
|
||||
SHA256_CTX octx;
|
||||
} HMAC_SHA256_CTX;
|
||||
|
||||
void
|
||||
HMAC_SHA256_Init(HMAC_SHA256_CTX * ctx, const void * _K, size_t Klen);
|
||||
|
||||
void
|
||||
HMAC_SHA256_Update(HMAC_SHA256_CTX * ctx, const void *in, size_t len);
|
||||
|
||||
void
|
||||
HMAC_SHA256_Final(unsigned char digest[32], HMAC_SHA256_CTX * ctx);
|
||||
|
||||
void
|
||||
PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt,
|
||||
size_t saltlen, uint64_t c, uint8_t * buf, size_t dkLen);
|
||||
|
||||
#endif // PBKDF2_H
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Copyright (c) 2013 NovaCoin Developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -508,6 +508,11 @@ Are you sure you wish to encrypt your wallet?</source>
|
||||
<source>Downloaded %1 of %2 blocks of transaction history.</source>
|
||||
<translation>Загружено %1 из %2 блоков истории транзакций.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../bitcoingui.cpp" line="475"/>
|
||||
<source>Downloaded %1 of %2 blocks of transaction history (%3% done).</source>
|
||||
<translation>Загружено %1 из %2 блоков истории транзакций (%3% завершено).</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../bitcoingui.cpp" line="487"/>
|
||||
<source>Downloaded %1 blocks of transaction history.</source>
|
||||
@@ -796,7 +801,7 @@ Address: %4
|
||||
<message>
|
||||
<location filename="../forms/messagepage.ui" line="20"/>
|
||||
<source>You can sign messages with your addresses to prove you own them. Be careful not to sign anything vague, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to.</source>
|
||||
<translation>Вы можете подписать сообщение ключом от своего адреса, чтобы доказать владенгие им. Будьте осторожны и не подписывайте текст, не относящийся лично к вам. ПОдписывайте только текст, с которым вы полностью согласны и который можете однозначно интерпретировать.</translation>
|
||||
<translation>Вы можете подписать сообщение ключом от своего адреса, чтобы доказать владенгие им. Будьте осторожны и не подписывайте текст, не относящийся лично к вам. Подписывайте только текст, с которым вы полностью согласны и который можете однозначно интерпретировать.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../forms/messagepage.ui" line="38"/>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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 @@ Value importprivkey(const Array& params, bool fHelp)
|
||||
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 @@ Value dumpprivkey(const Array& params, bool fHelp)
|
||||
CBitcoinAddress address;
|
||||
if (!address.SetString(strAddress))
|
||||
throw JSONRPCError(-5, "Invalid novacoin 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))
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Copyright (c) 2012 The PPCoin developers
|
||||
// Copyright (c) 2012-2013 The NovaCoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
1830
src/scrypt-x86.S
1830
src/scrypt-x86.S
File diff suppressed because it is too large
Load Diff
3756
src/scrypt-x86_64.S
3756
src/scrypt-x86_64.S
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright 2009 Colin Percival, 2011 ArtForz, 2011 pooler, 2012 Balthazar
|
||||
* Copyright 2009 Colin Percival, 2011 ArtForz, 2011 pooler, 2013 Balthazar
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Copyright (c) 2012 The PPCoin developers
|
||||
// Copyright (c) 2012-2013 The NovaCoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#ifndef BITCOIN_SERIALIZE_H
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Copyright (c) 2011-2012 The PPCoin developers
|
||||
// Copyright (c) 2012-2013 The NovaCoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -855,7 +854,7 @@ boost::filesystem::path GetDefaultDataDir()
|
||||
|
||||
// Windows: C:\Documents and Settings\username\Application Data\NovaCoin
|
||||
// Mac: ~/Library/Application Support/NovaCoin
|
||||
// Unix: ~/.novacoin
|
||||
// Unix: ~/.ppcoin
|
||||
#ifdef WIN32
|
||||
// Windows
|
||||
return MyGetSpecialFolderPath(CSIDL_APPDATA, true) / "NovaCoin";
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Copyright (c) 2012 The PPCoin developers
|
||||
// Copyright (c) 2012-2013 The NovaCoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#ifndef BITCOIN_UTIL_H
|
||||
@@ -47,14 +46,13 @@ static const int64 CENT = 10000;
|
||||
#define UBEGIN(a) ((unsigned char*)&(a))
|
||||
#define UEND(a) ((unsigned char*)&((&(a))[1]))
|
||||
#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))
|
||||
#define printf OutputDebugStringF
|
||||
|
||||
#define UVOIDBEGIN(a) ((void*)&(a))
|
||||
#define CVOIDBEGIN(a) ((const void*)&(a))
|
||||
#define UINTBEGIN(a) ((uint32_t*)&(a))
|
||||
#define CUINTBEGIN(a) ((const uint32_t*)&(a))
|
||||
|
||||
#define printf OutputDebugStringF
|
||||
|
||||
#ifdef snprintf
|
||||
#undef snprintf
|
||||
#endif
|
||||
|
||||
@@ -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 @@ extern const std::string CLIENT_DATE;
|
||||
|
||||
// ppcoin version - intended for display purpose ONLY
|
||||
#define PPCOIN_VERSION_MAJOR 0
|
||||
#define PPCOIN_VERSION_MINOR 2
|
||||
#define PPCOIN_VERSION_REVISION 4
|
||||
#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
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// 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
|
||||
// Copyright (c) 2013 NovaCoin 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 +72,7 @@ bool CWallet::AddCScript(const CScript& redeemScript)
|
||||
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 +835,10 @@ void CWallet::ResendWalletTransactions()
|
||||
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 +1251,18 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
|
||||
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 +1299,8 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
|
||||
}
|
||||
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 +1310,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
|
||||
if (fDebug && GetBoolArg("-printcoinstake"))
|
||||
printf("CreateCoinStake : added kernel type=%d\n", whichType);
|
||||
fKernelFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fKernelFound || fShutdown)
|
||||
@@ -1334,6 +1337,9 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
|
||||
// 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);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Copyright (c) 2011-2012 The PPCoin developers
|
||||
// Copyright (c) 2012-2013 The NovaCoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#ifndef BITCOIN_WALLET_H
|
||||
|
||||
Reference in New Issue
Block a user