[DEV-351] Disallow unrequested transactions (#171)

This commit is contained in:
Svarog 2019-01-23 16:34:57 +02:00 committed by Evgeny Khirin
parent 349e62fcd5
commit 9507ed0a97

View File

@ -408,15 +408,14 @@ func (sm *SyncManager) handleTxMsg(tmsg *txMsg) {
return
}
// NOTE: BitcoinJ, and possibly other wallets, don't follow the spec of
// sending an inventory message and allowing the remote peer to decide
// whether or not they want to request the transaction via a getdata
// message. Unfortunately, the reference implementation permits
// unrequested data, so it has allowed wallets that don't follow the
// spec to proliferate. While this is not ideal, there is no check here
// to disconnect peers for sending unsolicited transactions to provide
// interoperability.
// If we didn't ask for this transaction then the peer is misbehaving.
txID := tmsg.tx.ID()
if _, exists = state.requestedTxns[*txID]; !exists {
log.Warnf("Got unrequested transaction %v from %s -- "+
"disconnecting", txID, peer.Addr())
peer.Disconnect()
return
}
// Ignore transactions that we have already rejected. Do not
// send a reject message here because if the transaction was already