File tree Expand file tree Collapse file tree 4 files changed +29
-2
lines changed Expand file tree Collapse file tree 4 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -2342,6 +2342,10 @@ void ProcessMessage(
2342
2342
if (pfrom.fInbound )
2343
2343
PushNodeVersion (pfrom, connman, GetAdjustedTime ());
2344
2344
2345
+ if (nVersion >= WTXID_RELAY_VERSION) {
2346
+ connman.PushMessage (&pfrom, CNetMsgMaker (INIT_PROTO_VERSION).Make (NetMsgType::WTXIDRELAY));
2347
+ }
2348
+
2345
2349
connman.PushMessage (&pfrom, CNetMsgMaker (INIT_PROTO_VERSION).Make (NetMsgType::VERACK));
2346
2350
2347
2351
pfrom.nServices = nServices;
@@ -2478,6 +2482,18 @@ void ProcessMessage(
2478
2482
return ;
2479
2483
}
2480
2484
2485
+ // Feature negotiation of wtxidrelay should happen between VERSION and
2486
+ // VERACK, to avoid relay problems from switching after a connection is up
2487
+ if (msg_type == NetMsgType::WTXIDRELAY) {
2488
+ if (pfrom.nVersion >= WTXID_RELAY_VERSION) {
2489
+ LOCK (cs_main);
2490
+ if (!State (pfrom.GetId ())->m_wtxid_relay ) {
2491
+ State (pfrom.GetId ())->m_wtxid_relay = true ;
2492
+ }
2493
+ }
2494
+ return ;
2495
+ }
2496
+
2481
2497
if (!pfrom.fSuccessfullyConnected ) {
2482
2498
// Must have a verack message before anything else
2483
2499
LOCK (cs_main);
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ const char *GETCFHEADERS="getcfheaders";
46
46
const char *CFHEADERS=" cfheaders" ;
47
47
const char *GETCFCHECKPT=" getcfcheckpt" ;
48
48
const char *CFCHECKPT=" cfcheckpt" ;
49
+ const char *WTXIDRELAY=" wtxidrelay" ;
49
50
} // namespace NetMsgType
50
51
51
52
/* * All known message types. Keep this in the same order as the list of
@@ -83,6 +84,7 @@ const static std::string allNetMessageTypes[] = {
83
84
NetMsgType::CFHEADERS,
84
85
NetMsgType::GETCFCHECKPT,
85
86
NetMsgType::CFCHECKPT,
87
+ NetMsgType::WTXIDRELAY,
86
88
};
87
89
const static std::vector<std::string> allNetMessageTypesVec (allNetMessageTypes, allNetMessageTypes+ARRAYLEN(allNetMessageTypes));
88
90
Original file line number Diff line number Diff line change @@ -261,6 +261,12 @@ extern const char* GETCFCHECKPT;
261
261
* evenly spaced filter headers for blocks on the requested chain.
262
262
*/
263
263
extern const char * CFCHECKPT;
264
+ /* *
265
+ * Indicates that a node prefers to relay transactions via wtxid, rather than
266
+ * txid.
267
+ * @since protocol version 70016 as described by BIP 339.
268
+ */
269
+ extern const char *WTXIDRELAY;
264
270
}; // namespace NetMsgType
265
271
266
272
/* Get a vector of all valid message types (see above) */
@@ -402,7 +408,7 @@ enum GetDataMsg : uint32_t {
402
408
MSG_TX = 1 ,
403
409
MSG_BLOCK = 2 ,
404
410
MSG_WTX = 5 , // !< Defined in BIP 339
405
- // The following can only occur in getdata. Invs always use TX or BLOCK.
411
+ // The following can only occur in getdata. Invs always use TX/WTX or BLOCK.
406
412
MSG_FILTERED_BLOCK = 3 , // !< Defined in BIP37
407
413
MSG_CMPCT_BLOCK = 4 , // !< Defined in BIP152
408
414
MSG_WITNESS_BLOCK = MSG_BLOCK | MSG_WITNESS_FLAG, // !< Defined in BIP144
Original file line number Diff line number Diff line change 9
9
* network protocol versioning
10
10
*/
11
11
12
- static const int PROTOCOL_VERSION = 70015 ;
12
+ static const int PROTOCOL_VERSION = 70016 ;
13
13
14
14
//! initial proto version, to be increased after version/verack negotiation
15
15
static const int INIT_PROTO_VERSION = 209 ;
@@ -35,4 +35,7 @@ static const int SHORT_IDS_BLOCKS_VERSION = 70014;
35
35
//! not banning for invalid compact blocks starts with this version
36
36
static const int INVALID_CB_NO_BAN_VERSION = 70015 ;
37
37
38
+ //! "wtxidrelay" command for wtxid-based relay starts with this version
39
+ static const int WTXID_RELAY_VERSION = 70016 ;
40
+
38
41
#endif // BITCOIN_VERSION_H
You can’t perform that action at this time.
0 commit comments