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
This commit is contained in:
parent
efae3da41d
commit
172f006020
3 changed files with 30 additions and 18 deletions
38
main.cpp
38
main.cpp
|
@ -1374,9 +1374,13 @@ bool CBlock::CheckBlock() const
|
||||||
// that can be verified before saving an orphan block.
|
// that can be verified before saving an orphan block.
|
||||||
|
|
||||||
// Size limits
|
// Size limits
|
||||||
if (vtx.empty() || vtx.size() > MAX_SIZE || ::GetSerializeSize(*this, SER_NETWORK) > MAX_SIZE)
|
if (vtx.empty() || vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE)
|
||||||
return error("CheckBlock() : size limits failed");
|
return error("CheckBlock() : size limits failed");
|
||||||
|
|
||||||
|
// Check proof of work matches claimed amount
|
||||||
|
if (!CheckProofOfWork(GetHash(), nBits))
|
||||||
|
return error("CheckBlock() : proof of work failed");
|
||||||
|
|
||||||
// Check timestamp
|
// Check timestamp
|
||||||
if (GetBlockTime() > GetAdjustedTime() + 2 * 60 * 60)
|
if (GetBlockTime() > GetAdjustedTime() + 2 * 60 * 60)
|
||||||
return error("CheckBlock() : block timestamp too far in the future");
|
return error("CheckBlock() : block timestamp too far in the future");
|
||||||
|
@ -1393,9 +1397,9 @@ bool CBlock::CheckBlock() const
|
||||||
if (!tx.CheckTransaction())
|
if (!tx.CheckTransaction())
|
||||||
return error("CheckBlock() : CheckTransaction failed");
|
return error("CheckBlock() : CheckTransaction failed");
|
||||||
|
|
||||||
// Check proof of work matches claimed amount
|
// Check that it's not full of nonstandard transactions
|
||||||
if (!CheckProofOfWork(GetHash(), nBits))
|
if (GetSigOpCount() > MAX_BLOCK_SIGOPS)
|
||||||
return error("CheckBlock() : proof of work failed");
|
return error("CheckBlock() : too many nonstandard transactions");
|
||||||
|
|
||||||
// Check merkleroot
|
// Check merkleroot
|
||||||
if (hashMerkleRoot != BuildMerkleTree())
|
if (hashMerkleRoot != BuildMerkleTree())
|
||||||
|
@ -1418,13 +1422,9 @@ bool CBlock::AcceptBlock()
|
||||||
CBlockIndex* pindexPrev = (*mi).second;
|
CBlockIndex* pindexPrev = (*mi).second;
|
||||||
int nHeight = pindexPrev->nHeight+1;
|
int nHeight = pindexPrev->nHeight+1;
|
||||||
|
|
||||||
// Check size
|
// Check proof of work
|
||||||
if (nHeight > 79400 && ::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE)
|
if (nBits != GetNextWorkRequired(pindexPrev))
|
||||||
return error("AcceptBlock() : over size limit");
|
return error("AcceptBlock() : incorrect proof of work");
|
||||||
|
|
||||||
// Check that it's not full of nonstandard transactions
|
|
||||||
if (nHeight > 79400 && GetSigOpCount() > MAX_BLOCK_SIGOPS)
|
|
||||||
return error("AcceptBlock() : too many nonstandard transactions");
|
|
||||||
|
|
||||||
// Check timestamp against prev
|
// Check timestamp against prev
|
||||||
if (GetBlockTime() <= pindexPrev->GetMedianTimePast())
|
if (GetBlockTime() <= pindexPrev->GetMedianTimePast())
|
||||||
|
@ -1435,10 +1435,6 @@ bool CBlock::AcceptBlock()
|
||||||
if (!tx.IsFinal(nHeight, GetBlockTime()))
|
if (!tx.IsFinal(nHeight, GetBlockTime()))
|
||||||
return error("AcceptBlock() : contains a non-final transaction");
|
return error("AcceptBlock() : contains a non-final transaction");
|
||||||
|
|
||||||
// Check proof of work
|
|
||||||
if (nBits != GetNextWorkRequired(pindexPrev))
|
|
||||||
return error("AcceptBlock() : incorrect proof of work");
|
|
||||||
|
|
||||||
// Check that the block chain matches the known block chain up to a checkpoint
|
// Check that the block chain matches the known block chain up to a checkpoint
|
||||||
if ((nHeight == 11111 && hash != uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) ||
|
if ((nHeight == 11111 && hash != uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) ||
|
||||||
(nHeight == 33333 && hash != uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")) ||
|
(nHeight == 33333 && hash != uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")) ||
|
||||||
|
@ -2415,6 +2411,12 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||||
CWalletTx order;
|
CWalletTx order;
|
||||||
vRecv >> hashReply >> order;
|
vRecv >> hashReply >> order;
|
||||||
|
|
||||||
|
if (!mapArgs.count("-allowreceivebyip") || mapArgs["-allowreceivebyip"] == "0")
|
||||||
|
{
|
||||||
|
pfrom->PushMessage("reply", hashReply, (int)2, string(""));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// we have a chance to check the order here
|
/// we have a chance to check the order here
|
||||||
|
|
||||||
// Keep giving the same key to the same ip until they use it
|
// 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)
|
||||||
vRecv >> hashReply >> wtxNew;
|
vRecv >> hashReply >> wtxNew;
|
||||||
wtxNew.fFromMe = false;
|
wtxNew.fFromMe = false;
|
||||||
|
|
||||||
|
if (!mapArgs.count("-allowreceivebyip") || mapArgs["-allowreceivebyip"] == "0")
|
||||||
|
{
|
||||||
|
pfrom->PushMessage("reply", hashReply, (int)2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Broadcast
|
// Broadcast
|
||||||
if (!wtxNew.AcceptWalletTransaction())
|
if (!wtxNew.AcceptWalletTransaction())
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,7 @@ class CAutoFile;
|
||||||
static const unsigned int MAX_SIZE = 0x02000000;
|
static const unsigned int MAX_SIZE = 0x02000000;
|
||||||
|
|
||||||
static const int VERSION = 312;
|
static const int VERSION = 312;
|
||||||
static const char* pszSubVer = ".6";
|
static const char* pszSubVer = ".7";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
8
ui.cpp
8
ui.cpp
|
@ -2186,8 +2186,12 @@ void CSendingDialog::OnReply2(CDataStream& vRecv)
|
||||||
if (nRet > 0)
|
if (nRet > 0)
|
||||||
{
|
{
|
||||||
string strMessage;
|
string strMessage;
|
||||||
vRecv >> strMessage;
|
if (!vRecv.empty())
|
||||||
Error(_("Transfer was not accepted"));
|
vRecv >> strMessage;
|
||||||
|
if (nRet == 2)
|
||||||
|
Error(_("Recipient is not accepting transactions sent by IP address"));
|
||||||
|
else
|
||||||
|
Error(_("Transfer was not accepted"));
|
||||||
//// todo: enlarge the window and enable a hidden white box to put seller's message
|
//// todo: enlarge the window and enable a hidden white box to put seller's message
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue