diff --git a/GlobalBoost-Y.pro b/GlobalBoost-Y.pro index 05a6eda..aeb4d3c 100755 --- a/GlobalBoost-Y.pro +++ b/GlobalBoost-Y.pro @@ -1,7 +1,7 @@ EMPLATE = app -TARGET = globalboost-qt +TARGET = GlobalBoost-Y-qt macx:TARGET = "GlobalBoost-Y" -VERSION = 0.9.0.3 +VERSION = 0.9.0.4 INCLUDEPATH += src src/json src/qt src/qt/plugins/mrichtexteditor QT += core gui network printsupport script widgets DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE BOOST_SPIRIT_THREADSAFE BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN __NO_SYSTEM_INCLUDES @@ -58,9 +58,9 @@ UI_DIR = build # use: qmake "RELEASE=1" contains(RELEASE, 1) { # Mac: compile for maximum compatibility (10.5, 32-bit) - macx:QMAKE_CXXFLAGS += -mmacosx-version-min=10.5 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk - macx:QMAKE_CFLAGS += -mmacosx-version-min=10.5 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk - macx:QMAKE_OBJECTIVE_CFLAGS += -mmacosx-version-min=10.5 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk + macx:QMAKE_CXXFLAGS += -mmacosx-version-min=10.6 -arch i386 -isysroot /Developer/SDKs/MacOSX10.6.sdk + macx:QMAKE_CFLAGS += -mmacosx-version-min=10.6 -arch i386 -isysroot /Developer/SDKs/MacOSX10.6.sdk + macx:QMAKE_OBJECTIVE_CFLAGS += -mmacosx-version-min=10.6 -arch i386 -isysroot /Developer/SDKs/MacOSX10.6.sdk !win32:!macx { # Linux: static link and extra security (see: https://wiki.debian.org/Hardening) diff --git a/src/base58.h b/src/base58.h index c01349f..972122a 100755 --- a/src/base58.h +++ b/src/base58.h @@ -250,7 +250,7 @@ class CBase58Data }; /** base58-encoded GlobalBoost-Y Addresses. - * Public-key-hash-addresses have version 0 (or 111 testnet). + * Public-key-hash-addresses have version 77 (or 111 testnet). * The data vector contains RIPEMD160(SHA256(pubkey)), where pubkey is the serialized public key. * Script-hash-addresses have version 5 (or 196 testnet). * The data vector contains RIPEMD160(SHA256(cscript)), where cscript is the serialized redemption script. diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 2cc4186..9e24230 100755 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -93,7 +93,7 @@ void RPCTypeCheck(const Object& o, int64 AmountFromValue(const Value& value) { double dAmount = value.get_real(); - if (dAmount <= 0.0 || dAmount > 84000000.0) + if (dAmount <= 0.0 || dAmount > 24000000.0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount"); int64 nAmount = roundint64(dAmount * COIN); if (!MoneyRange(nAmount)) diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 1853611..0164774 100755 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -37,12 +37,13 @@ namespace Checkpoints boost::assign::map_list_of ( 0, uint256("0x2e28050194ad73f2405394d2f081361a23c2df8904ec7f026a018bbe148d5adf")) ( 2672, uint256("0xe31f98339ec0c628bcc5bd20aef177bdef83deb7a606528c8977ad3a1f511906")) + ( 29000, uint256("0x63a67152f31a4596fc6ca5073ffe4cf68264922e740285f0ae7b3bb8cbc66b39")) ; static const CCheckpointData data = { &mapCheckpoints, - 1411808495, // * UNIX timestamp of last checkpoint block - 10059, // * total number of transactions between genesis and last checkpoint + 1428497654, // * UNIX timestamp of last checkpoint block + 108399, // * total number of transactions between genesis and last checkpoint // (the tx=... number in the SetBestChain debug.log lines) 12000.0 // * estimated number of transactions per day after checkpoint }; @@ -59,14 +60,12 @@ namespace Checkpoints }; const CCheckpointData &Checkpoints() { - if (fTestNet) - return dataTestnet; - else return data; } bool CheckBlock(int nHeight, const uint256& hash) { + if (fTestNet) return true; // Testnet has no checkpoints if (!GetBoolArg("-checkpoints", true)) return true; @@ -110,6 +109,7 @@ namespace Checkpoints int GetTotalBlocksEstimate() { + if (fTestNet) return 0; // Testnet has no checkpoints if (!GetBoolArg("-checkpoints", true)) return 0; @@ -120,6 +120,7 @@ namespace Checkpoints CBlockIndex* GetLastCheckpoint(const std::map& mapBlockIndex) { + if (fTestNet) return NULL; // Testnet has no checkpoints if (!GetBoolArg("-checkpoints", true)) return NULL; @@ -134,6 +135,7 @@ namespace Checkpoints } return NULL; } + uint256 GetLatestHardenedCheckpoint() { const MapCheckpoints& checkpoints = *Checkpoints().mapCheckpoints; diff --git a/src/checkpointsync.cpp b/src/checkpointsync.cpp index c1da9a8..191a140 100755 --- a/src/checkpointsync.cpp +++ b/src/checkpointsync.cpp @@ -77,8 +77,8 @@ using namespace std; // ppcoin: sync-checkpoint master key -const std::string CSyncCheckpoint::strMainPubKey = "04c91144cc667fefb3364f5c276e5aa5f8ae169eef186d81bce49f09335fe6614a6a748699d5b0ce2d7b868029313a4c56e8183e9ef2074d3e745977b48966d538"; -const std::string CSyncCheckpoint::strTestPubKey = "04ec068f9cee3d5c02eb648f2264dd5cf69e17dd1024e7b54e3a477b3f9e76c5712a5a56131de55ad96f798158c9135b6777be5128163560273d55518a42bda3ba"; +const std::string CSyncCheckpoint::strMainPubKey = "046c2a735d6d61e9bc2ccca972c2676070108b2aa5b55272ac9c56c1d74796392555ece455fd201dae6bf5834d18eb00de268b0aefbf573247dfdba9481828ecba"; +const std::string CSyncCheckpoint::strTestPubKey = "048211e9d56bc6b434e9446e65f2ee1488434ea1ede9eae6fdfad371db95e42dd179ddacddbc48f1691a609b7788fb19cb7cf00f957c3145b3a394e8e8e86bffa2"; std::string CSyncCheckpoint::strMasterPrivKey = ""; @@ -367,7 +367,7 @@ bool IsMatureSyncCheckpoint() // sync-checkpoint should always be accepted block assert(mapBlockIndex.count(hashSyncCheckpoint)); const CBlockIndex* pindexSync = mapBlockIndex[hashSyncCheckpoint]; - return (nBestHeight >= pindexSync->nHeight + COINBASE_MATURITY); + return (nBestHeight >= pindexSync->nHeight + nBaseMaturity); } // Is the sync-checkpoint too old? diff --git a/src/clientversion.h b/src/clientversion.h index 2330113..71b6dd2 100755 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -7,9 +7,9 @@ // These need to be macros, as version.cpp's and globalboost-y-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 1 -#define CLIENT_VERSION_MINOR 1 +#define CLIENT_VERSION_MINOR 2 #define CLIENT_VERSION_REVISION 0 -#define CLIENT_VERSION_BUILD 1 +#define CLIENT_VERSION_BUILD 0 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true diff --git a/src/init.cpp b/src/init.cpp index 19ecc32..19ec4cd 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -316,6 +316,7 @@ std::string HelpMessage() " -externalip= " + _("Specify your own public address") + "\n" + " -onlynet= " + _("Only connect to nodes in network (IPv4, IPv6 or Tor)") + "\n" + " -discover " + _("Discover own IP address (default: 1 when listening and no -externalip)") + "\n" + + " -checkpointenforce " + _("Only accept block chain matching checkpoints issued by the Auto-Checkpoint systems Master Node (default: 1)") + "\n" + " -checkpoints " + _("Only accept block chain matching built-in checkpoints (default: 1)") + "\n" + " -listen " + _("Accept connections from outside (default: 1 if no -proxy or -connect)") + "\n" + " -bind= " + _("Bind to given address and always listen on it. Use [host]:port notation for IPv6") + "\n" + @@ -351,7 +352,7 @@ std::string HelpMessage() #endif " -rpcuser= " + _("Username for JSON-RPC connections") + "\n" + " -rpcpassword= " + _("Password for JSON-RPC connections") + "\n" + - " -rpcport= " + _("Listen for JSON-RPC connections on (default: 8223 or testnet: 18223)") + "\n" + + " -rpcport= " + _("Listen for JSON-RPC connections on (default: 8225 or testnet: 18225)") + "\n" + " -rpcallowip= " + _("Allow JSON-RPC connections from specified IP address") + "\n" + #ifndef QT_GUI " -rpcconnect= " + _("Send commands to node running on (default: 127.0.0.1)") + "\n" + @@ -504,7 +505,7 @@ bool AppInit2(boost::thread_group& threadGroup) // ********************************************************* Step 2: parameter interactions - fTestNet = GetBoolArg("-testnet"); + fTestNet = GetBoolArg("-testnet", false); fBloomFilters = GetBoolArg("-bloomfilters", true); if (fBloomFilters) nLocalServices |= NODE_BLOOM; diff --git a/src/main.cpp b/src/main.cpp index 080cdf7..7997ce5 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,6 +10,7 @@ #include "txdb.h" #include "net.h" #include "init.h" +#include "util.h" #include "ui_interface.h" #include "checkqueue.h" #include @@ -35,6 +36,8 @@ CCriticalSection cs_main; CTxMemPool mempool; unsigned int nTransactionsUpdated = 0; +int nBaseMaturity = BASE_MATURITY; + map mapBlockIndex; uint256 hashGenesisBlock("0x2e28050194ad73f2405394d2f081361a23c2df8904ec7f026a018bbe148d5adf"); static CBigNum bnProofOfWorkLimit(~uint256(0) >> 10); // Globalboost: starting difficulty is 1 / 2^12 @@ -944,7 +947,7 @@ int CMerkleTx::GetBlocksToMaturity() const { if (!IsCoinBase()) return 0; - return max(0, (COINBASE_MATURITY+20) - GetDepthInMainChain()); + return max(0, (nBaseMaturity+20) - GetDepthInMainChain()); } @@ -1524,7 +1527,7 @@ bool CTransaction::CheckInputs(CValidationState &state, CCoinsViewCache &inputs, // If prev is coinbase, check that it's matured if (coins.IsCoinBase()) { - if (nSpendHeight - coins.nHeight < COINBASE_MATURITY) + if (nSpendHeight - coins.nHeight < nBaseMaturity) return state.Invalid(error("CheckInputs() : tried to spend coinbase at depth %d", nSpendHeight - coins.nHeight)); } @@ -2026,6 +2029,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew) else strCheckpointWarning = ""; } + std::string strCmd = GetArg("-blocknotify", ""); if (!fIsInitialDownload && !strCmd.empty()) @@ -2352,6 +2356,7 @@ bool CBlock::AcceptBlock(CValidationState &state, CDiskBlockPos *dbp) if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : nBlockEstimate)) pnode->PushInventory(CInv(MSG_BLOCK, hash)); } + // ppcoin: check pending sync-checkpoint AcceptPendingSyncCheckpoint(); @@ -2403,9 +2408,10 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl return state.DoS(100, error("ProcessBlock() : block with too little proof-of-work")); } } + // ppcoin: ask for pending sync-checkpoint if any if (!IsInitialBlockDownload()) - AskForPendingSyncCheckpoint(pfrom); + AskForPendingSyncCheckpoint(pfrom); // If we don't already have its previous block, shunt it off to holding area until we get it if (pblock->hashPrevBlock != 0 && !mapBlockIndex.count(pblock->hashPrevBlock)) @@ -2459,6 +2465,7 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl return true; } + CMerkleBlock::CMerkleBlock(const CBlock& block, CBloomFilter& filter) { header = block.GetBlockHeader(); @@ -2717,6 +2724,12 @@ bool static LoadBlockIndexDB() if (pblocktree->ReadBlockFileInfo(nLastBlockFile, infoLastBlockFile)) printf("LoadBlockIndexDB(): last block file info: %s\n", infoLastBlockFile.ToString().c_str()); + // ppcoin: load hashSyncCheckpoint + if (!pblocktree->ReadSyncCheckpoint(hashSyncCheckpoint)) + printf("LoadBlockIndexDB(): synchronized checkpoint not read\n"); + else + printf("LoadBlockIndexDB(): synchronized checkpoint %s\n", hashSyncCheckpoint.ToString().c_str()); + // Load nBestInvalidWork, OK if it doesn't exist CBigNum bnBestInvalidWork; pblocktree->ReadBestInvalidWork(bnBestInvalidWork); @@ -2922,6 +2935,7 @@ bool InitBlockIndex() { return error("LoadBlockIndex() : writing genesis block to disk failed"); if (!block.AddToBlockIndex(state, blockPos)) return error("LoadBlockIndex() : genesis block not accepted"); + // ppcoin: initialize synchronized checkpoint if (!WriteSyncCheckpoint(hashGenesisBlock)) return error("LoadBlockIndex() : failed to init sync checkpoint"); @@ -2930,6 +2944,10 @@ bool InitBlockIndex() { } } + // ppcoin: if checkpoint master key changed must reset sync-checkpoint + if (!CheckCheckpointPubKey()) + return error("LoadBlockIndex() : failed to reset checkpoint master pubkey"); + return true; } @@ -3451,15 +3469,16 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) checkpointMessage.RelayTo(pfrom); } + pfrom->fSuccessfullyConnected = true; printf("receive version message: %s: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", pfrom->cleanSubVer.c_str(), pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString().c_str(), addrFrom.ToString().c_str(), pfrom->addr.ToString().c_str()); cPeerBlockCounts.input(pfrom->nStartingHeight); + // ppcoin: ask for pending sync-checkpoint if any if (!IsInitialBlockDownload()) AskForPendingSyncCheckpoint(pfrom); - } @@ -3878,6 +3897,21 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) pfrom->addr.ToString().c_str()); } + else if (strCommand == "checkpoint") // ppcoin synchronized checkpoint + { + CSyncCheckpoint checkpoint; + vRecv >> checkpoint; + + if (checkpoint.ProcessSyncCheckpoint(pfrom)) + { + // Relay + pfrom->hashCheckpointKnown = checkpoint.hashCheckpoint; + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + checkpoint.RelayTo(pnode); + } + } + else if (strCommand == "filterload") { CBloomFilter filter; @@ -4747,7 +4781,7 @@ void static GlobalboostMiner(CWallet *pwallet) while (true) { - yescrypt_hash_sp(BEGIN(pblock->nVersion), BEGIN(thash)); + yescrypt_hash(BEGIN(pblock->nVersion), BEGIN(thash)); if (thash <= hashTarget) { diff --git a/src/main.h b/src/main.h index ca2a082..7f53200 100755 --- a/src/main.h +++ b/src/main.h @@ -23,6 +23,15 @@ class CAddress; class CInv; class CNode; +/* Maturity threshold for PoW base transactions, in blocks (confirmations) */ +extern int nBaseMaturity; +static const int BASE_MATURITY = 120; +static const int BASE_MATURITY_TESTNET = 120; +/* Offset for the above to allow safe network propagation, in blocks (confirmations) */ +static const int BASE_MATURITY_OFFSET = 1; +/* Maturity threshold for regular transactions, in blocks (confirmations) */ +static const int TX_MATURITY = 6; + struct CBlockIndexWorkComparator; /** The maximum allowed size for a serialized block, in bytes (network rule) */ diff --git a/src/net.cpp b/src/net.cpp index 8c999a2..1207d48 100755 --- a/src/net.cpp +++ b/src/net.cpp @@ -1,5 +1,4 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/version.h b/src/version.h index 5d4a8aa..8386b8f 100755 --- a/src/version.h +++ b/src/version.h @@ -25,7 +25,7 @@ extern const std::string CLIENT_DATE; // network protocol versioning // -static const int PROTOCOL_VERSION = 70002; +static const int PROTOCOL_VERSION = 70003; // intial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -38,8 +38,8 @@ static const int MIN_PEER_PROTO_VERSION = 70002; static const int CADDR_TIME_VERSION = 31402; // only request blocks from nodes outside this range of versions -static const int NOBLKS_VERSION_START = 32000; -static const int NOBLKS_VERSION_END = 32400; +static const int NOBLKS_VERSION_START = 0; +static const int NOBLKS_VERSION_END = 70001; // BIP 0031, pong message, is enabled for all versions AFTER this one static const int BIP0031_VERSION = 60000; diff --git a/src/yescryptcommon.c b/src/yescryptcommon.c index c0d0918..a91b0cd 100755 --- a/src/yescryptcommon.c +++ b/src/yescryptcommon.c @@ -116,75 +116,70 @@ yescrypt_r(const yescrypt_shared_t * shared, yescrypt_local_t * local, uint64_t N; uint32_t r, p; yescrypt_flags_t flags = YESCRYPT_WORM; - printf("pass1 ..."); fflush(stdout); if (setting[0] != '$' || setting[1] != '7') - {printf("died$7 ..."); + { fflush(stdout); return NULL; - } - printf("died80 ..."); + } fflush(stdout); src = setting + 2; - printf("hello '%p'\n", (char *)src); fflush(stdout); switch ((version = *src)) { case '$': - printf("died2 ..."); fflush(stdout); break; case 'X': src++; flags = YESCRYPT_RW; - printf("died3 ..."); fflush(stdout); break; default: - {printf("died4 ..."); + { fflush(stdout); return NULL; - } + } } - printf("pass2 ..."); + fflush(stdout); if (*src != '$') { uint32_t decoded_flags; if (decode64_one(&decoded_flags, *src)) - {printf("died5 ..."); - fflush(stdout); + { + fflush(stdout); return NULL; - } + } flags = decoded_flags; if (*++src != '$') - {printf("died6 ..."); - fflush(stdout); - return NULL; - } + { + fflush(stdout); + return NULL; + } } src++; { uint32_t N_log2; if (decode64_one(&N_log2, *src)) - {printf("died7 ..."); + { return NULL; - } + } src++; N = (uint64_t)1 << N_log2; } src = decode64_uint32(&r, 30, src); if (!src) - {printf("died6 ..."); + { return NULL; } src = decode64_uint32(&p, 30, src); if (!src) - {printf("died7 ..."); + { return NULL; - } + } prefixlen = src - setting; @@ -198,19 +193,18 @@ yescrypt_r(const yescrypt_shared_t * shared, yescrypt_local_t * local, need = prefixlen + saltlen + 1 + HASH_LEN + 1; if (need > buflen || need < saltlen) - {printf("'%d %d %d'",need,buflen, saltlen);fflush(stdout); - printf("died8killbuf ..."); - fflush(stdout); + { + fflush(stdout); return NULL; - } -printf("pass3 ..."); + } + fflush(stdout); if (yescrypt_kdf(shared, local, passwd, passwdlen, salt, saltlen, N, r, p, 0, flags, hash, sizeof(hash))) - {printf("died10 ..."); - fflush(stdout); + { + fflush(stdout); return NULL; - } + } dst = buf; memcpy(dst, setting, prefixlen + saltlen); @@ -221,12 +215,11 @@ fflush(stdout); /* Could zeroize hash[] here, but yescrypt_kdf() doesn't zeroize its * memory allocations yet anyway. */ if (!dst || dst >= buf + buflen) /* Can't happen */ - {printf("died11 ..."); + { return NULL; - } + } *dst = 0; /* NUL termination */ - printf("died12 ..."); fflush(stdout); return buf; } @@ -363,12 +356,7 @@ yescrypt_bsty(const uint8_t * passwd, size_t passwdlen, return retval; } -void yescrypt_hash_sp(const char *input, char *output) +void yescrypt_hash(const char *input, char *output) { yescrypt_bsty((const uint8_t *)input, 80, (const uint8_t *) input, 80, 2048, 8, 1, (uint8_t *)output, 32); } - -void yescrypt_hash(const char *input, char *output) -{ - yescrypt_hash_sp(input, output); -}