@@ -190,6 +190,15 @@ namespace {
190
190
* million to make it highly unlikely for users to have issues with this
191
191
* filter.
192
192
*
193
+ * We only need to add wtxids to this filter. For non-segwit
194
+ * transactions, the txid == wtxid, so this only prevents us from
195
+ * re-downloading non-segwit transactions when communicating with
196
+ * non-wtxidrelay peers -- which is important for avoiding malleation
197
+ * attacks that could otherwise interfere with transaction relay from
198
+ * non-wtxidrelay peers. For communicating with wtxidrelay peers, having
199
+ * the reject filter store wtxids is exactly what we want to avoid
200
+ * redownload of a rejected transaction.
201
+ *
193
202
* Memory used: 1.3 MB
194
203
*/
195
204
std::unique_ptr<CRollingBloomFilter> recentRejects GUARDED_BY (cs_main);
@@ -2033,6 +2042,7 @@ void static ProcessOrphanTx(CConnman& connman, CTxMemPool& mempool, std::set<uin
2033
2042
// Probably non-standard or insufficient fee
2034
2043
LogPrint (BCLog::MEMPOOL, " removed orphan tx %s\n " , orphanHash.ToString ());
2035
2044
if (orphan_state.GetResult () != TxValidationResult::TX_WITNESS_STRIPPED) {
2045
+ // We can add the wtxid of this transaction to our reject filter.
2036
2046
// Do not add txids of witness transactions or witness-stripped
2037
2047
// transactions to the filter, as they can have been malleated;
2038
2048
// adding such txids to the reject filter would potentially
@@ -3004,11 +3014,16 @@ void ProcessMessage(
3004
3014
LogPrint (BCLog::MEMPOOL, " not keeping orphan with rejected parents %s\n " ,tx.GetHash ().ToString ());
3005
3015
// We will continue to reject this tx since it has rejected
3006
3016
// parents so avoid re-requesting it from other peers.
3017
+ // Here we add both the txid and the wtxid, as we know that
3018
+ // regardless of what witness is provided, we will not accept
3019
+ // this, so we don't need to allow for redownload of this txid
3020
+ // from any of our non-wtxidrelay peers.
3007
3021
recentRejects->insert (tx.GetHash ());
3008
3022
recentRejects->insert (tx.GetWitnessHash ());
3009
3023
}
3010
3024
} else {
3011
3025
if (state.GetResult () != TxValidationResult::TX_WITNESS_STRIPPED) {
3026
+ // We can add the wtxid of this transaction to our reject filter.
3012
3027
// Do not add txids of witness transactions or witness-stripped
3013
3028
// transactions to the filter, as they can have been malleated;
3014
3029
// adding such txids to the reject filter would potentially
0 commit comments