Skip to content

Commit 48c59f5

Browse files
matheusdjrick
authored andcommitted
[release-v2.0] p2p: Ban peer with mix inv when disablerelaytx is active
Version 2.0.1 of dcrd will now not send invs related to mixing when disablerelaytx is signalled during the peer negotiation stage. Therefore, the wallet should ban peers that incorrectly send such invs when the wallet was configured with this flag. While there may still be some peers running v2.0.0 (which would cause them to be banned from the wallet), their number should be small enough to not cause significant connection issues. Backport of a92f57a.
1 parent 3b46b15 commit 48c59f5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

p2p/peering.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,13 +2141,16 @@ func (rp *RemotePeer) GetInitState(ctx context.Context, msg *wire.MsgGetInitStat
21412141
}
21422142
}
21432143

2144-
// invVecContainsTx returns true if at least one inv vector is of type
2145-
// transaction.
2146-
func invVecContainsTx(inv []*wire.InvVect) bool {
2144+
// invVecContainsTxOrMix returns true if at least one inv vector is of type
2145+
// transaction or mix message.
2146+
func invVecContainsTxOrMix(inv []*wire.InvVect) bool {
21472147
for i := range inv {
21482148
if inv[i].Type == wire.InvTypeTx {
21492149
return true
21502150
}
2151+
if inv[i].Type == wire.InvTypeMix {
2152+
return true
2153+
}
21512154
}
21522155
return false
21532156
}
@@ -2157,7 +2160,7 @@ func (rp *RemotePeer) receivedInv(ctx context.Context, inv *wire.MsgInv) {
21572160
const opf = "remotepeer(%v).receivedInv"
21582161

21592162
// When tx relay is disabled, we don't expect transactions on invs.
2160-
if rp.lp.disableRelayTx && invVecContainsTx(inv.InvList) {
2163+
if rp.lp.disableRelayTx && invVecContainsTxOrMix(inv.InvList) {
21612164
op := errors.Opf(opf, rp.raddr)
21622165
err := errors.E(op, errors.Protocol, "received tx in msginv when tx relaying is disabled")
21632166
rp.Disconnect(err)

0 commit comments

Comments
 (0)