Skip to content

Commit 172f006

Browse files
only accept transactions sent by IP address if -allowreceivebyip is specified
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@156 1a98c847-1fd6-4fd8-948a-caf3550aa51b
1 parent efae3da commit 172f006

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

main.cpp

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,9 +1374,13 @@ bool CBlock::CheckBlock() const
13741374
// that can be verified before saving an orphan block.
13751375

13761376
// Size limits
1377-
if (vtx.empty() || vtx.size() > MAX_SIZE || ::GetSerializeSize(*this, SER_NETWORK) > MAX_SIZE)
1377+
if (vtx.empty() || vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE)
13781378
return error("CheckBlock() : size limits failed");
13791379

1380+
// Check proof of work matches claimed amount
1381+
if (!CheckProofOfWork(GetHash(), nBits))
1382+
return error("CheckBlock() : proof of work failed");
1383+
13801384
// Check timestamp
13811385
if (GetBlockTime() > GetAdjustedTime() + 2 * 60 * 60)
13821386
return error("CheckBlock() : block timestamp too far in the future");
@@ -1393,9 +1397,9 @@ bool CBlock::CheckBlock() const
13931397
if (!tx.CheckTransaction())
13941398
return error("CheckBlock() : CheckTransaction failed");
13951399

1396-
// Check proof of work matches claimed amount
1397-
if (!CheckProofOfWork(GetHash(), nBits))
1398-
return error("CheckBlock() : proof of work failed");
1400+
// Check that it's not full of nonstandard transactions
1401+
if (GetSigOpCount() > MAX_BLOCK_SIGOPS)
1402+
return error("CheckBlock() : too many nonstandard transactions");
13991403

14001404
// Check merkleroot
14011405
if (hashMerkleRoot != BuildMerkleTree())
@@ -1418,13 +1422,9 @@ bool CBlock::AcceptBlock()
14181422
CBlockIndex* pindexPrev = (*mi).second;
14191423
int nHeight = pindexPrev->nHeight+1;
14201424

1421-
// Check size
1422-
if (nHeight > 79400 && ::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE)
1423-
return error("AcceptBlock() : over size limit");
1424-
1425-
// Check that it's not full of nonstandard transactions
1426-
if (nHeight > 79400 && GetSigOpCount() > MAX_BLOCK_SIGOPS)
1427-
return error("AcceptBlock() : too many nonstandard transactions");
1425+
// Check proof of work
1426+
if (nBits != GetNextWorkRequired(pindexPrev))
1427+
return error("AcceptBlock() : incorrect proof of work");
14281428

14291429
// Check timestamp against prev
14301430
if (GetBlockTime() <= pindexPrev->GetMedianTimePast())
@@ -1435,10 +1435,6 @@ bool CBlock::AcceptBlock()
14351435
if (!tx.IsFinal(nHeight, GetBlockTime()))
14361436
return error("AcceptBlock() : contains a non-final transaction");
14371437

1438-
// Check proof of work
1439-
if (nBits != GetNextWorkRequired(pindexPrev))
1440-
return error("AcceptBlock() : incorrect proof of work");
1441-
14421438
// Check that the block chain matches the known block chain up to a checkpoint
14431439
if ((nHeight == 11111 && hash != uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) ||
14441440
(nHeight == 33333 && hash != uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")) ||
@@ -2415,6 +2411,12 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
24152411
CWalletTx order;
24162412
vRecv >> hashReply >> order;
24172413

2414+
if (!mapArgs.count("-allowreceivebyip") || mapArgs["-allowreceivebyip"] == "0")
2415+
{
2416+
pfrom->PushMessage("reply", hashReply, (int)2, string(""));
2417+
return true;
2418+
}
2419+
24182420
/// we have a chance to check the order here
24192421

24202422
// Keep giving the same key to the same ip until they use it
@@ -2435,6 +2437,12 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
24352437
vRecv >> hashReply >> wtxNew;
24362438
wtxNew.fFromMe = false;
24372439

2440+
if (!mapArgs.count("-allowreceivebyip") || mapArgs["-allowreceivebyip"] == "0")
2441+
{
2442+
pfrom->PushMessage("reply", hashReply, (int)2);
2443+
return true;
2444+
}
2445+
24382446
// Broadcast
24392447
if (!wtxNew.AcceptWalletTransaction())
24402448
{

serialize.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CAutoFile;
2323
static const unsigned int MAX_SIZE = 0x02000000;
2424

2525
static const int VERSION = 312;
26-
static const char* pszSubVer = ".6";
26+
static const char* pszSubVer = ".7";
2727

2828

2929

ui.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,8 +2186,12 @@ void CSendingDialog::OnReply2(CDataStream& vRecv)
21862186
if (nRet > 0)
21872187
{
21882188
string strMessage;
2189-
vRecv >> strMessage;
2190-
Error(_("Transfer was not accepted"));
2189+
if (!vRecv.empty())
2190+
vRecv >> strMessage;
2191+
if (nRet == 2)
2192+
Error(_("Recipient is not accepting transactions sent by IP address"));
2193+
else
2194+
Error(_("Transfer was not accepted"));
21912195
//// todo: enlarge the window and enable a hidden white box to put seller's message
21922196
return;
21932197
}

0 commit comments

Comments
 (0)