mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
Merge bitcoin#13134: net: Add option -enablebip61
to configure sending of BIP61 notifications (#3414)
* Merge #13134: net: Add option `-enablebip61` to configure sending of BIP61 notifications 87fe292d897e09e176ac7e254144466c319cc9ac doc: Mention disabling BIP61 in bips.md (Wladimir J. van der Laan) fe16dd8226d924f44432c5b5014aa49ff45c82ff net: Add option `-enablebip61` to configure sending of BIP61 notifications (Wladimir J. van der Laan) Pull request description: This commit adds a boolean option `-peersendreject`, defaulting to `1`, that can be used to disable the sending of [BIP61](https://github.com/bitcoin/bips/blob/master/bip-0061.mediawiki) `reject` messages. This functionality has been requested for various reasons: - security (DoS): reject messages can reveal internal state that can be used to target certain resources such as the mempool more easily. - bandwidth: a typical node sends lots of reject messages; this counts against upstream bandwidth. Also the reject messages tend to be larger than the message that was rejected. On the other hand, reject messages can be useful while developing client software (I found them indispensable while creating bitcoin-submittx), as well as for our own test cases, so whatever the default becomes on the long run, IMO the functionality should be retained as option. But that's a discussion for later, for now it's simply a node operator decision. Also adds a RPC test that checks the functionality. Tree-SHA512: 9488cc53e13cd8e5c6f8eb472a44309572673405c1d1438c3488f627fae622c95e2198bde5ed7d29e56b948e2918bf1920239e9f865889f4c37c097c37a4d7a9 * 0.17 -> 0.16 Signed-off-by: Pasta <pasta@dashboost.org> * tx1 -> base_ tx fixing 13134 Signed-off-by: Pasta <pasta@dashboost.org> * move added bip61 message checking up Signed-off-by: Pasta <pasta@dashboost.org> * Dash specific code, only send reject messages if bip61 is enabled Signed-off-by: Pasta <pasta@dashboost.org> * Fix invalidtxrequest.py Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
This commit is contained in:
parent
d06597a421
commit
d804a753af
@ -15,7 +15,7 @@ BIPs that are implemented by Bitcoin Core (up-to-date up to **v0.13.0**):
|
||||
* [`BIP 35`](https://github.com/bitcoin/bips/blob/master/bip-0035.mediawiki): The 'mempool' protocol message (and the protocol version bump to 60002) has been implemented since **v0.7.0** ([PR #1641](https://github.com/bitcoin/bitcoin/pull/1641)).
|
||||
* [`BIP 37`](https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki): The bloom filtering for transaction relaying, partial merkle trees for blocks, and the protocol version bump to 70001 (enabling low-bandwidth SPV clients) has been implemented since **v0.8.0** ([PR #1795](https://github.com/bitcoin/bitcoin/pull/1795)).
|
||||
* [`BIP 42`](https://github.com/bitcoin/bips/blob/master/bip-0042.mediawiki): The bug that would have caused the subsidy schedule to resume after block 13440000 was fixed in **v0.9.2** ([PR #3842](https://github.com/bitcoin/bitcoin/pull/3842)).
|
||||
* [`BIP 61`](https://github.com/bitcoin/bips/blob/master/bip-0061.mediawiki): The 'reject' protocol message (and the protocol version bump to 70002) was added in **v0.9.0** ([PR #3185](https://github.com/bitcoin/bitcoin/pull/3185)).
|
||||
* [`BIP 61`](https://github.com/bitcoin/bips/blob/master/bip-0061.mediawiki): The 'reject' protocol message (and the protocol version bump to 70002) was added in **v0.9.0** ([PR #3185](https://github.com/bitcoin/bitcoin/pull/3185)). Starting *v0.16.0*, whether to send reject messages can be configured with the `-enablebip61` option.
|
||||
* [`BIP 65`](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki): The CHECKLOCKTIMEVERIFY softfork was merged in **v0.12.0** ([PR #6351](https://github.com/bitcoin/bitcoin/pull/6351)), and backported to **v0.11.2** and **v0.10.4**. Mempool-only CLTV was added in [PR #6124](https://github.com/bitcoin/bitcoin/pull/6124).
|
||||
* [`BIP 66`](https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki): The strict DER rules and associated version 3 blocks have been implemented since **v0.10.0** ([PR #5713](https://github.com/bitcoin/bitcoin/pull/5713)).
|
||||
* [`BIP 68`](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki): Sequence locks have been implemented as of **v0.12.1** ([PR #7184](https://github.com/bitcoin/bitcoin/pull/7184)), and have been activated since *block 419328*.
|
||||
|
@ -95,7 +95,11 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm
|
||||
if (strCommand == NetMsgType::MNGOVERNANCESYNC) {
|
||||
if (pfrom->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) {
|
||||
LogPrint(BCLog::GOBJECT, "MNGOVERNANCESYNC -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE, strprintf("Version must be %d or greater", MIN_GOVERNANCE_PEER_PROTO_VERSION)));
|
||||
if (g_enable_bip61) {
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
|
||||
REJECT_OBSOLETE, strprintf(
|
||||
"Version must be %d or greater", MIN_GOVERNANCE_PEER_PROTO_VERSION)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -140,7 +144,11 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm
|
||||
|
||||
if (pfrom->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) {
|
||||
LogPrint(BCLog::GOBJECT, "MNGOVERNANCEOBJECT -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE, strprintf("Version must be %d or greater", MIN_GOVERNANCE_PEER_PROTO_VERSION)));
|
||||
if (g_enable_bip61) {
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
|
||||
REJECT_OBSOLETE, strprintf(
|
||||
"Version must be %d or greater", MIN_GOVERNANCE_PEER_PROTO_VERSION)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -215,7 +223,11 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm
|
||||
|
||||
if (pfrom->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) {
|
||||
LogPrint(BCLog::GOBJECT, "MNGOVERNANCEOBJECTVOTE -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE, strprintf("Version must be %d or greater", MIN_GOVERNANCE_PEER_PROTO_VERSION)));
|
||||
if (g_enable_bip61) {
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
|
||||
REJECT_OBSOLETE, strprintf(
|
||||
"Version must be %d or greater", MIN_GOVERNANCE_PEER_PROTO_VERSION)));
|
||||
}
|
||||
}
|
||||
|
||||
// Ignore such messages until masternode list is synced
|
||||
|
@ -488,6 +488,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-discover", _("Discover own IP addresses (default: 1 when listening and no -externalip or -proxy)"));
|
||||
strUsage += HelpMessageOpt("-dns", _("Allow DNS lookups for -addnode, -seednode and -connect") + " " + strprintf(_("(default: %u)"), DEFAULT_NAME_LOOKUP));
|
||||
strUsage += HelpMessageOpt("-dnsseed", _("Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect used)"));
|
||||
strUsage += HelpMessageOpt("-enablebip61", strprintf(_("Send reject messages per BIP61 (default: %u)"), DEFAULT_ENABLE_BIP61));
|
||||
strUsage += HelpMessageOpt("-externalip=<ip>", _("Specify your own public address"));
|
||||
strUsage += HelpMessageOpt("-forcednsseed", strprintf(_("Always query for peer addresses via DNS lookup (default: %u)"), DEFAULT_FORCEDNSSEED));
|
||||
strUsage += HelpMessageOpt("-listen", _("Accept connections from outside (default: 1 if no -proxy or -connect)"));
|
||||
@ -1285,6 +1286,8 @@ bool AppInitParameterInteraction()
|
||||
if (gArgs.GetBoolArg("-peerbloomfilters", DEFAULT_PEERBLOOMFILTERS))
|
||||
nLocalServices = ServiceFlags(nLocalServices | NODE_BLOOM);
|
||||
|
||||
g_enable_bip61 = gArgs.GetBoolArg("-enablebip61", DEFAULT_ENABLE_BIP61);
|
||||
|
||||
nMaxTipAge = gArgs.GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
|
||||
|
||||
if (gArgs.IsArgSet("-vbparams")) {
|
||||
|
@ -77,6 +77,7 @@ static_assert(INBOUND_PEER_TX_DELAY >= MAX_GETDATA_RANDOM_DELAY,
|
||||
static const unsigned int MAX_GETDATA_SZ = 1000;
|
||||
|
||||
std::atomic<int64_t> nTimeBestReceived(0); // Used only to inform the wallet of when we last received a block
|
||||
bool g_enable_bip61 = DEFAULT_ENABLE_BIP61;
|
||||
|
||||
struct IteratorComparator
|
||||
{
|
||||
@ -2061,7 +2062,9 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
||||
// Each connection can only send one version message
|
||||
if (pfrom->nVersion != 0)
|
||||
{
|
||||
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_DUPLICATE, std::string("Duplicate version message")));
|
||||
if (g_enable_bip61) {
|
||||
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_DUPLICATE, std::string("Duplicate version message")));
|
||||
}
|
||||
LOCK(cs_main);
|
||||
Misbehaving(pfrom->GetId(), 1);
|
||||
return false;
|
||||
@ -2090,8 +2093,10 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
||||
if (!pfrom->fInbound && !pfrom->fFeeler && !pfrom->m_manual_connection && !HasAllDesirableServiceFlags(nServices))
|
||||
{
|
||||
LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom->GetId(), nServices, GetDesirableServiceFlags(nServices));
|
||||
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_NONSTANDARD,
|
||||
strprintf("Expected to offer services %08x", GetDesirableServiceFlags(nServices))));
|
||||
if (g_enable_bip61) {
|
||||
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_NONSTANDARD,
|
||||
strprintf("Expected to offer services %08x", GetDesirableServiceFlags(nServices))));
|
||||
}
|
||||
pfrom->fDisconnect = true;
|
||||
return false;
|
||||
}
|
||||
@ -2100,8 +2105,10 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
||||
{
|
||||
// disconnect from peers older than this proto version
|
||||
LogPrint(BCLog::NET, "peer=%d using obsolete version %i; disconnecting\n", pfrom->GetId(), nVersion);
|
||||
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
|
||||
strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)));
|
||||
if (g_enable_bip61) {
|
||||
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
|
||||
strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)));
|
||||
}
|
||||
pfrom->fDisconnect = true;
|
||||
return false;
|
||||
}
|
||||
@ -2880,9 +2887,10 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
||||
LogPrint(BCLog::MEMPOOLREJ, "%s from peer=%d was not accepted: %s\n", tx.GetHash().ToString(),
|
||||
pfrom->GetId(),
|
||||
FormatStateMessage(state));
|
||||
if (state.GetRejectCode() > 0 && state.GetRejectCode() < REJECT_INTERNAL) // Never send AcceptToMemoryPool's internal codes over P2P
|
||||
if (g_enable_bip61 && state.GetRejectCode() > 0 && state.GetRejectCode() < REJECT_INTERNAL) { // Never send AcceptToMemoryPool's internal codes over P2P
|
||||
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::REJECT, strCommand, (unsigned char)state.GetRejectCode(),
|
||||
state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), inv.hash));
|
||||
}
|
||||
if (nDoS > 0) {
|
||||
Misbehaving(pfrom->GetId(), nDoS);
|
||||
}
|
||||
@ -3503,8 +3511,10 @@ static bool SendRejectsAndCheckIfBanned(CNode* pnode, CConnman* connman)
|
||||
AssertLockHeld(cs_main);
|
||||
CNodeState &state = *State(pnode->GetId());
|
||||
|
||||
for (const CBlockReject& reject : state.rejects) {
|
||||
connman->PushMessage(pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, (std::string)NetMsgType::BLOCK, reject.chRejectCode, reject.strRejectReason, reject.hashBlock));
|
||||
if (g_enable_bip61) {
|
||||
for (const CBlockReject& reject : state.rejects) {
|
||||
connman->PushMessage(pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, (std::string)NetMsgType::BLOCK, reject.chRejectCode, reject.strRejectReason, reject.hashBlock));
|
||||
}
|
||||
}
|
||||
state.rejects.clear();
|
||||
|
||||
@ -3622,7 +3632,9 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
|
||||
}
|
||||
catch (const std::ios_base::failure& e)
|
||||
{
|
||||
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_MALFORMED, std::string("error parsing message")));
|
||||
if (g_enable_bip61) {
|
||||
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_MALFORMED, std::string("error parsing message")));
|
||||
}
|
||||
if (strstr(e.what(), "end of data"))
|
||||
{
|
||||
// Allow exceptions from under-length message on vRecv
|
||||
|
@ -37,6 +37,11 @@ static constexpr int64_t EXTRA_PEER_CHECK_INTERVAL = 45;
|
||||
/** Minimum time an outbound-peer-eviction candidate must be connected for, in order to evict, in seconds */
|
||||
static constexpr int64_t MINIMUM_CONNECT_TIME = 30;
|
||||
|
||||
/** Default for BIP61 (sending reject messages) */
|
||||
static constexpr bool DEFAULT_ENABLE_BIP61 = true;
|
||||
/** Enable BIP61 (sending reject messages) */
|
||||
extern bool g_enable_bip61;
|
||||
|
||||
class PeerLogicValidation : public CValidationInterface, public NetEventsInterface {
|
||||
private:
|
||||
CConnman* const connman;
|
||||
|
@ -39,7 +39,11 @@ void CPrivateSendClientManager::ProcessMessage(CNode* pfrom, const std::string&
|
||||
if (strCommand == NetMsgType::DSQUEUE) {
|
||||
if (pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
|
||||
LogPrint(BCLog::PRIVATESEND, "DSQUEUE -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE, strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
if (g_enable_bip61) {
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
|
||||
REJECT_OBSOLETE, strprintf(
|
||||
"Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -135,7 +139,11 @@ void CPrivateSendClientSession::ProcessMessage(CNode* pfrom, const std::string&
|
||||
if (strCommand == NetMsgType::DSSTATUSUPDATE) {
|
||||
if (pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
|
||||
LogPrint(BCLog::PRIVATESEND, "DSSTATUSUPDATE -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE, strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
if (g_enable_bip61) {
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
|
||||
REJECT_OBSOLETE, strprintf(
|
||||
"Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -172,7 +180,11 @@ void CPrivateSendClientSession::ProcessMessage(CNode* pfrom, const std::string&
|
||||
} else if (strCommand == NetMsgType::DSFINALTX) {
|
||||
if (pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
|
||||
LogPrint(BCLog::PRIVATESEND, "DSFINALTX -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE, strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
if (g_enable_bip61) {
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
|
||||
REJECT_OBSOLETE, strprintf(
|
||||
"Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -198,7 +210,11 @@ void CPrivateSendClientSession::ProcessMessage(CNode* pfrom, const std::string&
|
||||
} else if (strCommand == NetMsgType::DSCOMPLETE) {
|
||||
if (pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
|
||||
LogPrint(BCLog::PRIVATESEND, "DSCOMPLETE -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE, strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
if (g_enable_bip61) {
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
|
||||
REJECT_OBSOLETE, strprintf(
|
||||
"Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,11 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm
|
||||
if (strCommand == NetMsgType::DSACCEPT) {
|
||||
if (pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
|
||||
LogPrint(BCLog::PRIVATESEND, "DSACCEPT -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE, strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
if (g_enable_bip61) {
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
|
||||
REJECT_OBSOLETE, strprintf(
|
||||
"Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
}
|
||||
PushStatus(pfrom, STATUS_REJECTED, ERR_VERSION, connman);
|
||||
return;
|
||||
}
|
||||
@ -101,7 +105,11 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm
|
||||
} else if (strCommand == NetMsgType::DSQUEUE) {
|
||||
if (pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
|
||||
LogPrint(BCLog::PRIVATESEND, "DSQUEUE -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE, strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
if (g_enable_bip61) {
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
|
||||
REJECT_OBSOLETE, strprintf(
|
||||
"Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -161,7 +169,11 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm
|
||||
} else if (strCommand == NetMsgType::DSVIN) {
|
||||
if (pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
|
||||
LogPrint(BCLog::PRIVATESEND, "DSVIN -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE, strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
if (g_enable_bip61) {
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
|
||||
REJECT_OBSOLETE, strprintf(
|
||||
"Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
}
|
||||
PushStatus(pfrom, STATUS_REJECTED, ERR_VERSION, connman);
|
||||
return;
|
||||
}
|
||||
@ -192,7 +204,11 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm
|
||||
} else if (strCommand == NetMsgType::DSSIGNFINALTX) {
|
||||
if (pfrom->nVersion < MIN_PRIVATESEND_PEER_PROTO_VERSION) {
|
||||
LogPrint(BCLog::PRIVATESEND, "DSSIGNFINALTX -- peer=%d using obsolete version %i\n", pfrom->GetId(), pfrom->nVersion);
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE, strprintf("Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
if (g_enable_bip61) {
|
||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::REJECT, strCommand,
|
||||
REJECT_OBSOLETE, strprintf(
|
||||
"Version must be %d or greater", MIN_PRIVATESEND_PEER_PROTO_VERSION)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,9 @@ from test_framework.util import (
|
||||
wait_until,
|
||||
)
|
||||
|
||||
|
||||
REJECT_INVALID = 16
|
||||
|
||||
class InvalidTxRequestTest(BitcoinTestFramework):
|
||||
|
||||
def set_test_params(self):
|
||||
@ -81,7 +84,7 @@ class InvalidTxRequestTest(BitcoinTestFramework):
|
||||
# and we get disconnected immediately
|
||||
self.log.info('Test a transaction that is rejected')
|
||||
tx1 = create_transaction(block1.vtx[0], 0, b'\x64', 50 * COIN)
|
||||
node.p2p.send_txs_and_test([tx1], node, success=False, expect_disconnect=True)
|
||||
node.p2p.send_txs_and_test([tx1], node, success=False, expect_disconnect=True, reject_code=REJECT_INVALID, reject_reason=b'mandatory-script-verify-flag-failed (Invalid OP_IF construction)')
|
||||
|
||||
# Make two p2p connections to provide the node with orphans
|
||||
# * p2ps[0] will send valid orphan txs (one with low fee)
|
||||
@ -90,7 +93,17 @@ class InvalidTxRequestTest(BitcoinTestFramework):
|
||||
|
||||
self.log.info('Test orphan transaction handling ... ')
|
||||
self.test_orphan_tx_handling(block1.vtx[0].sha256, False)
|
||||
node.generate(1) # Clear mempool
|
||||
|
||||
# restart node with sending BIP61 messages disabled, check that it disconnects without sending the reject message
|
||||
self.log.info('Test a transaction that is rejected, with BIP61 disabled')
|
||||
self.restart_node(0, ['-enablebip61=0','-persistmempool=0'])
|
||||
self.reconnect_p2p(num_connections=1)
|
||||
node.p2p.send_txs_and_test([tx1], node, success=False, expect_disconnect=True)
|
||||
# send_txs_and_test will have waited for disconnect, so we can safely check that no reject has been received
|
||||
assert_equal(node.p2p.reject_code_received, None)
|
||||
|
||||
self.log.info('Test orphan transaction handling, resolve via block')
|
||||
self.restart_node(0, ['-persistmempool=0'])
|
||||
self.reconnect_p2p(num_connections=2)
|
||||
self.test_orphan_tx_handling(block2.vtx[0].sha256, True)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user