Skip to content

Commit 6815720

Browse files
committed
spv: Disconnect peer relaying invalid txns.
A peer relaying transactions which fail script validation is misbehaving so should be dropped instead of being allowed to keep announcing them.
1 parent 43b095a commit 6815720

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

spv/sync.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,15 @@ func (s *Syncer) handleTxInvs(ctx context.Context, rp *p2p.RemotePeer, hashes []
11571157
err := s.wallet.AddTransaction(ctx, tx, nil)
11581158
if err != nil {
11591159
op := errors.Opf(opf, rp.RemoteAddr())
1160-
log.Warn(errors.E(op, err))
1160+
err := errors.E(op, err)
1161+
log.Warn(err)
1162+
1163+
// Relaying transactions which fail script validation is misbehavior
1164+
// so drop the peer instead of allowing it to keep announcing them.
1165+
if errors.Is(err, errors.ScriptFailure) {
1166+
rp.Disconnect(err)
1167+
return
1168+
}
11611169
}
11621170
}
11631171
s.mempoolTxs(relevant)

0 commit comments

Comments
 (0)