diff --git a/BitcoinTX.pro b/BitcoinTX.pro index 95087d9..3b2aabf 100644 --- a/BitcoinTX.pro +++ b/BitcoinTX.pro @@ -460,7 +460,8 @@ QMAKE_EXTRA_COMPILERS += TSQM # "Other files" to show in Qt Creator OTHER_FILES += \ - doc/*.rst doc/*.txt doc/README README.md res/bitcoin-qt.rc + doc/*.rst doc/*.txt doc/README README.md res/bitcoin-qt.rc \ + README.md # platform specific defaults, if not overridden on command line isEmpty(BOOST_LIB_SUFFIX) { diff --git a/README.md b/README.md new file mode 100644 index 0000000..a7e0ed6 --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +#BitcoinTX development tree for version 2.1.5. +**BitcoinTX is a PoS-based cryptocurrency.** + +##Specifications: + +* Block Spacing: 60 Seconds +* Diff Retarget: 2 Blocks +* Maturity: 40 Blocks +* Stake Minimum Age: 1 Hour +* Stake Maximun Age: 14 Days +* Masternode Deposit: 250,000 +* Port: 28280 +* RPC Port: 28282 + +BitcoinTX is dependent upon libsecp256k1. BitcoinTX includes an Address Index feature, based on the address index API (searchrawtransactions RPC command) implemented in Bitcoin Core but modified implementation to work with the BitcoinTX codebase (PoS coins maintain a txindex by default for instance). + +Initialize the Address Index By Running with -reindexaddr Command Line Argument. It may take 10-15 minutes to build the initial index. + +### Release Notes for *v2.1.5 (11/02/2015)*: +1. Updated src/chainparams.cpp. Added five DNS seeders. Turned ON by default. Use -dnsseed to turn off. + * btxseed1.bitcointx.info (New York) + * btxseed2.bitcointx.io (San Francisco) + * btxseed3.btxcoin.org (Amsterdam) + * btxseed4.btxcoin.net (London) + * btxseed5.bitcointx.co (Sigapore) +2. Updated src/net.cpp. IRC seeding. Turned OFF by default. Use -ircseed to turn on. +3. Updated src/checkpoints.cpp. Added new checkpoints. +4. Updated src/clientversion.h. Bump version to 2.1.5.0. +5. Updated src/version.h. Bump protocol version to 61339 for v2.1.5. +6. Updated src/main.cpp. + * Ignore "gettaddr" requests on Outbound connections. + * Don't check duplicate stake while importing. + * Ignore blocks received while importing. +7. Updated src/compat.h. Max number of fds in fd_set and prevent redefinition compiler warning. +8. Updated src/spork.h. Masternode enforce payments. +9. Updated src/timedata.cpp. Do not store more than 200 timedata samples. +10. Updated src/wallet.cpp. Fix priority calculation in CreateTransaction. +11. Updated src/rpcprotocol.cpp. prevent easy memory exhaustion attack in rpc. + +##### **Special thanks to SCDeveloper (https://github.com/SCDeveloper/) for item #6-11.** +###### This version has NOT been fully tested. Please use at your own risk. +###### DNS seeder nodes maintained and deployed by MCDev. +###### All coding changes performed and reviewed by CrytoVote. Email: CrytoVote@yandex.com. + +####Contact: +* Wallet Code: CrytoVote@yandex.com. +* Network/MN Support: +* DNS Seeds: + +####Discussions: +* BitcoinTalk.org: https://bitcointalk.org/index.php?topic=1051266.0 +* Slack: https://btxcoin.slack.com + +####Exchanges: +* C-CEX: https://c-cex.com/index.html?p=btx-btc + +####Build Instructions: +* *Linux*: +* *Windows*: +* *MacOS*: + +## License + +### Code +MIT License: http://bitcointx.mit-license.org/ + +### Logo +# ![BitcoinTX logo](https://github.com/CryptoDJ/BitcoinTX/blob/master/src/qt/res/images/about.png) +Copyright 2015, MIT License: http://bitcointx.mit-license.org/ diff --git a/src/chainparams.cpp b/src/chainparams.cpp index f5f95fd..4b4df43 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -78,15 +78,19 @@ class CMainParams : public CChainParams { assert(hashGenesisBlock == uint256("0x00000449ae58462bbad8d26c7eb0270d332948872cfe97b7d5c42c154bfa5523")); assert(genesis.hashMerkleRoot == uint256("0x543528ec7c8617e4816916806d3536b6a22f18907deae54c13c30d725b7d908f")); - - - - - base58Prefixes[PUBKEY_ADDRESS] = list_of(35); - base58Prefixes[SCRIPT_ADDRESS] = list_of(85); - base58Prefixes[SECRET_KEY] = list_of(153); - base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x88)(0xB2)(0x1E); - base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x88)(0xAD)(0xE4); + vSeeds.push_back(CDNSSeedData("bitcointx.info", "btxseed1.bitcointx.info")); + vSeeds.push_back(CDNSSeedData("bitcointx.io", "btxseed2.bitcointx.io")); + vSeeds.push_back(CDNSSeedData("btxcoin.org", "btxseed3.btxcoin.org")); + vSeeds.push_back(CDNSSeedData("btxcoin.net", "btxseed4.btxcoin.net")); + vSeeds.push_back(CDNSSeedData("bitcointx.co", "btxseed5.bitcointx.co")); + vSeeds.push_back(CDNSSeedData("bitcointx.io", "btxseed6.bitcointx.io")); + vSeeds.push_back(CDNSSeedData("bitcointx.io", "btxseed7.bitcointx.io")); + + base58Prefixes[PUBKEY_ADDRESS] = boost::assign::list_of(35); + base58Prefixes[SCRIPT_ADDRESS] = boost::assign::list_of(85); + base58Prefixes[SECRET_KEY] = boost::assign::list_of(153); + base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x88)(0xB2)(0x1E).convert_to_container >(); + base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container >(); convertSeed6(vFixedSeeds, pnSeed6_main, ARRAYLEN(pnSeed6_main)); @@ -135,11 +139,11 @@ class CTestNetParams : public CMainParams { vFixedSeeds.clear(); vSeeds.clear(); - base58Prefixes[PUBKEY_ADDRESS] = list_of(125); - base58Prefixes[SCRIPT_ADDRESS] = list_of(196); - base58Prefixes[SECRET_KEY] = list_of(239); - base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF); - base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94); + base58Prefixes[PUBKEY_ADDRESS] = boost::assign::list_of(125); + base58Prefixes[SCRIPT_ADDRESS] = boost::assign::list_of(196); + base58Prefixes[SECRET_KEY] = boost::assign::list_of(239); + base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container >(); + base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container >(); convertSeed6(vFixedSeeds, pnSeed6_test, ARRAYLEN(pnSeed6_test)); diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 02077e1..0f1ac6c 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -27,8 +27,16 @@ namespace Checkpoints // static MapCheckpoints mapCheckpoints = boost::assign::map_list_of - ( 0, uint256("0x1fc69e54b798486c469bbda82aca1f4550a6c35d60e6becc13f82f0687573a09") ) - //( 15, uint256("0x0000009db19214c5e655f4d8509d7b62f6dd34e3fae17f7c5d6c6cce0588c8c5") ) + ( 0, uint256("0x00000449ae58462bbad8d26c7eb0270d332948872cfe97b7d5c42c154bfa5523") ) + ( 9950, uint256("0x2bc193c75c0f967825ea78f1e92e57880040f011fa9343d321b34742563039d4") ) + ( 25000, uint256("0x2c3628b858553f96771ef8771bfc85e6738442e8e995927abe1287f4f45a53f8") ) + ( 56000, uint256("0x317c2f300b998e885a914e551270ec199aef14ade90d94c454685225b50d50d5") ) + ( 76000, uint256("0x5ae7590572ff76223dffaa04ef87c24e824bb3ea614a9f23b1f89c9acf259c08") ) + ( 90001, uint256("0x5c89cf3a408121b7850bfbbe01bd0b3cacf2927b3803b2e502bec0329f43af57") ) + ( 100014, uint256("0x70050e7917796b8fe4974b226b8e5fbdb386174bb4904daf3465a94de5876443") ) + ( 120010, uint256("0x74f3a0917a0ca006445df6753f1a80de6c05659b6e1ae51105659ce3b446f7ac") ) + ( 130542, uint256("0x902fe4e1e0a51ccbf806bb79b582b90b415a7c3bca272b763488633fb04187d4") ) + //( 0, uint256("0x") ) ; // TestNet has no checkpoints diff --git a/src/clientversion.h b/src/clientversion.h index 40bc4c3..b142a26 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -8,7 +8,7 @@ // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 2 #define CLIENT_VERSION_MINOR 1 -#define CLIENT_VERSION_REVISION 2 +#define CLIENT_VERSION_REVISION 6 #define CLIENT_VERSION_BUILD 0 // Set to true for release, false for prerelease or test build diff --git a/src/compat.h b/src/compat.h index 1049c93..498f0d3 100644 --- a/src/compat.h +++ b/src/compat.h @@ -11,6 +11,10 @@ #ifndef NOMINMAX #define NOMINMAX #endif +#ifdef FD_SETSIZE +#undef FD_SETSIZE // prevent redefinition compiler warning +#endif +#define FD_SETSIZE 1024 // max number of fds in fd_set #include #include #include diff --git a/src/main.cpp b/src/main.cpp index 1d8f1e4..d122328 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2664,7 +2664,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) // ppcoin: check proof-of-stake // Limited duplicity on stake: prevents block flood attack // Duplicate stake allowed only when there is orphan child block - if (pblock->IsProofOfStake() && setStakeSeen.count(pblock->GetProofOfStake()) && !mapOrphanBlocksByPrev.count(hash) && !Checkpoints::WantedByPendingSyncCheckpoint(hash)) + if (!fReindex && !fImporting && pblock->IsProofOfStake() && setStakeSeen.count(pblock->GetProofOfStake()) && !mapOrphanBlocksByPrev.count(hash) && !Checkpoints::WantedByPendingSyncCheckpoint(hash)) return error("ProcessBlock() : duplicate proof-of-stake (%s, %d) for block %s", pblock->GetProofOfStake().first.ToString(), pblock->GetProofOfStake().second, hash.ToString()); CBlockIndex* pcheckpoint = Checkpoints::GetLastSyncCheckpoint(); @@ -3833,7 +3833,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } - else if (strCommand == "block") + else if (strCommand == "block" && !fImporting && !fReindex) { CBlock block; vRecv >> block; @@ -3855,7 +3855,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } - else if (strCommand == "getaddr") + //This asymmetric behavior for inbound and outbound connections was introduced + //to prevent a fingerprinting attack: an attacker can send specific fake addresses + //to users' AddrMan and later request them by sending getaddr messages. + //Making users (which are behind NAT and can only make outgoing connections) ignore + //getaddr message mitigates the attack. + else if ((strCommand == "getaddr") && (pfrom->fInbound)) { // Don't return addresses older than nCutOff timestamp int64_t nCutOff = GetTime() - (nNodeLifespan * 24 * 60 * 60); diff --git a/src/net.cpp b/src/net.cpp index a2fe759..5500a20 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1674,8 +1674,9 @@ void StartNode(boost::thread_group& threadGroup) MapPort(GetBoolArg("-upnp", USE_UPNP)); #endif - // Get addresses from IRC and advertise ours - threadGroup.create_thread(boost::bind(&TraceThread, "irc", &ThreadIRCSeed)); + //Enable IRC only with -ircseed command. + if (!GetBoolArg("-ircseed", true)) + threadGroup.create_thread(boost::bind(&TraceThread, "irc", &ThreadIRCSeed)); // Send and receive from sockets, accept connections threadGroup.create_thread(boost::bind(&TraceThread, "net", &ThreadSocketHandler)); diff --git a/src/rpcprotocol.cpp b/src/rpcprotocol.cpp index 5b700b2..0f333ca 100644 --- a/src/rpcprotocol.cpp +++ b/src/rpcprotocol.cpp @@ -26,6 +26,8 @@ using namespace boost; using namespace boost::asio; using namespace json_spirit; +const size_t POST_READ_SIZE = 256 * 1024; + // // HTTP protocol // @@ -190,8 +192,26 @@ int ReadHTTPMessage(std::basic_istream& stream, map 0) { - vector vch(nLen); - stream.read(&vch[0], nLen); + //RPC Bug Fix: + //Prevent easy memory exhaustion attack + //Allocate memory for POST message data only as bytes come in, instead of + + //all at once at the beginning. + vector vch; + size_t ptr = 0; + + while (ptr < (size_t)nLen) + { + size_t bytes_to_read = std::min((size_t)nLen - ptr, POST_READ_SIZE); + vch.resize(ptr + bytes_to_read); + + stream.read(&vch[ptr], bytes_to_read); + + if (!stream) // Connection lost while reading + return HTTP_INTERNAL_SERVER_ERROR; + + ptr += bytes_to_read; + } strMessageRet = string(vch.begin(), vch.end()); } diff --git a/src/spork.h b/src/spork.h index e3726af..9e0a7c2 100644 --- a/src/spork.h +++ b/src/spork.h @@ -25,10 +25,10 @@ using namespace boost; #define SPORK_4_NOTUSED 10004 -#define SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT 2428537599 //2015-4-8 23:59:59 GMT +#define SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT 1442707200 //2015-09-20 00:00:00 GMT #define SPORK_2_MAX_VALUE_DEFAULT 500 //500 BTX #define SPORK_3_REPLAY_BLOCKS_DEFAULT 0 -#define SPORK_4_RECONVERGE_DEFAULT 1420070400 //2047-1-1 +#define SPORK_4_RECONVERGE_DEFAULT 1420070400 //2015-01-01 00:00:00 GMT class CSporkMessage; class CSporkManager; diff --git a/src/timedata.cpp b/src/timedata.cpp index d6a2f0f..2d401fc 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -15,6 +15,7 @@ using namespace std; static CCriticalSection cs_nTimeOffset; static int64_t nTimeOffset = 0; +#define BTX_TIMEDATA_MAX_SAMPLES 200 // // "Never go to sea with two chronometers; take one or three." @@ -42,11 +43,15 @@ void AddTimeData(const CNetAddr& ip, int64_t nTime) LOCK(cs_nTimeOffset); // Ignore duplicates static set setKnown; + + if (setKnown.size() == BTX_TIMEDATA_MAX_SAMPLES) + return; + if (!setKnown.insert(ip).second) return; // Add data - static CMedianFilter vTimeOffsets(200,0); + static CMedianFilter vTimeOffsets(BTX_TIMEDATA_MAX_SAMPLES,0); vTimeOffsets.input(nOffsetSample); LogPrintf("Added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60); diff --git a/src/version.h b/src/version.h index e5ab07d..e63421d 100644 --- a/src/version.h +++ b/src/version.h @@ -30,7 +30,7 @@ static const int DATABASE_VERSION = 70509; // network protocol versioning // -static const int PROTOCOL_VERSION = 61338; +static const int PROTOCOL_VERSION = 61339; // intial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; diff --git a/src/wallet.cpp b/src/wallet.cpp index 324d7df..7944905 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -2468,7 +2468,16 @@ bool CWallet::CreateTransaction(const vector >& vecSend, BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) { int64_t nCredit = pcoin.first->vout[pcoin.second].nValue; - dPriority += (double)nCredit * pcoin.first->GetDepthInMainChain(); + //Fix priority calculation in CreateTransaction + //Make this projection of priority in 1 block match the + //calculation in the low priority reject code. + //But mempool inputs might still be in the mempool, so their age stays 0 + int age = pcoin.first->GetDepthInMainChain(); + + if (age != 0) + age += 1; + + dPriority += (double)nCredit * age; } int64_t nChange = nValueIn - nValue - nFeeRet;