{
 "number": 35920,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/35920",
 "title": "net_processing: Ignore MSG_WITNESS_TX entries from INV messages",
 "author": "ajtowns",
 "author_association": "MEMBER",
 "created_at": "2026-08-06T20:41:43Z",
 "updated_at": "2026-09-16T16:55:22Z",
 "age_days": 41,
 "draft": false,
 "labels": [],
 "milestone": null,
 "base": "master",
 "head_sha": "0f9bffe6e1bcfdec55a03defc36e7ab282d7ef9d",
 "head_ref": "202608-inv-msg-witness",
 "head_repo": "ajtowns/bitcoin",
 "head_history": [
  {
   "t": "2026-08-12T22:05:51Z",
   "sha": "0f9bffe6e1bcfdec55a03defc36e7ab282d7ef9d"
  }
 ],
 "additions": 28,
 "deletions": 25,
 "changed_files": 3,
 "commit_count": 3,
 "size_bucket": "S",
 "mergeable_state": "clean",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {
    "concept_ack": [
     {
      "login": "fjahr",
      "url": "https://github.com/bitcoin/bitcoin/pull/35920#issuecomment-5254066033"
     },
     {
      "login": "l0rinc",
      "url": "https://github.com/bitcoin/bitcoin/pull/35920#issuecomment-5209106759"
     }
    ]
   },
   "conflicts": [
    {
     "number": 36257,
     "title": "qa: assert_equals -> assert_true/assert_false",
     "author": "hodlinator"
    }
   ]
  }
 },
 "acks_parsed": {
  "l0rinc": {
   "kind": "concept_ack",
   "hash": null,
   "t": "2026-08-06T21:02:57Z",
   "stale": false
  },
  "fjahr": {
   "kind": "concept_ack",
   "hash": null,
   "t": "2026-08-11T13:50:09Z",
   "stale": false
  }
 },
 "acks_tally": {
  "ack": 0,
  "stale_ack": 0,
  "concept_ack": 2,
  "approach_ack": 0,
  "nack": 0,
  "concept_nack": 0,
  "approach_nack": 0
 },
 "reviews": {
  "approved": 0,
  "changes_requested": 0,
  "distinct_reviewers": [
   "0xB10C",
   "darosior",
   "fjahr",
   "l0rinc"
  ]
 },
 "signals": {
  "needs_rebase": false,
  "ci_failed": false,
  "mergeable_state": "clean",
  "last_author_activity": "2026-08-12T22:09:17Z",
  "last_reviewer_activity": "2026-08-12T15:02:18Z",
  "last_reviewer": "0xB10C",
  "author_silent_days": 35,
  "waiting_on_author_days": 0,
  "days_since_update": 0
 },
 "refs": {
  "mentioned": [
   35917
  ],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [
   {
    "number": 35917,
    "type": "pull",
    "state": "closed",
    "merged": false,
    "merged_at": null,
    "title": "net_proc: use a single set to deduplicate tx INVs"
   }
  ],
  "conflicts": [
   36257
  ]
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [
  "src/net_processing.cpp"
 ],
 "body": "When introducing wtxidrelay we added checks to skip attempts to announce txs with the wrong hash (https://github.com/bitcoin/bitcoin/pull/18044#discussion_r403953004), but didn't similarly ignore `MSG_WITNESS_TX` entries in announcements, which have never been valid (see [BIP-144](https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki#relay)).\n\nThis PR corrects that oversight, skipping such announcements. It also moves the check to be after the disconnect code, so that attempting to announce txs on `fRelay=false` doesn't get treated as okay just because you're doing it wrong. As a result this allows deduping the `seen_tx_hashes` set.",
 "commits": [
  {
   "sha": "2eefc296d488368a97dfcb60ccd49533661d39b3",
   "date": "2026-08-12T22:05:14Z",
   "message": "net_processing: Ignore MSG_WITNESS_TX entries in inv messages\n\nBIP 144 specifies that MSG_WITNESS_TX is \"only for use in getdata\",\nso if we receive it anyway, ignore it, rather than treating it as a\nby-txid announcement.\n\nAlso changes the code ordering so that attempting to announce txs on a\nconnection where tx relay is disabled triggers a disconnect, even if we\nwould have ignored the announcement for being the wrong inv type."
  },
  {
   "sha": "a24f315175c87bfdee2736ec478b5b7501be4541",
   "date": "2026-08-12T22:05:14Z",
   "message": "tests: Check we disconnect on tx INVs on blocks-only conns\n\nPreviously we only checked disconnection occurs on \"correct\" announcements\n(WTX on a wtxidrelay connection); extend that to checking all possible\nannouncements (still only on a wtxidrelay connection)."
  },
  {
   "sha": "0f9bffe6e1bcfdec55a03defc36e7ab282d7ef9d",
   "date": "2026-08-12T22:05:14Z",
   "message": "net_processing: Combine seen_txids and seen_wtxids\n\nAfter the previous commit only one of these will ever be used\nfor any particular INV message, so there's no need for two.\n\nCo-Authored-By: Antoine Poinsot <mail@antoinep.com>"
  }
 ],
 "timeline": [
  {
   "t": "2026-08-06T20:56:28Z",
   "kind": "comment",
   "who": "ajtowns",
   "assoc": "MEMBER",
   "text": "See also #35917 and https://github.com/bitcoin/bitcoin/pull/35878#discussion_r3724297158"
  },
  {
   "t": "2026-08-06T21:02:57Z",
   "kind": "comment",
   "who": "l0rinc",
   "assoc": "MEMBER",
   "text": "Concept ACK, thanks for pushing a fix for https://github.com/bitcoin/bitcoin/pull/35878#discussion_r3724297158. If you touch again, please add me as coauthor."
  },
  {
   "t": "2026-08-07T21:01:31Z",
   "kind": "review_comment",
   "who": "darosior",
   "assoc": "MEMBER",
   "path": "src/net_processing.cpp",
   "commit": "eaaea13cda0f6f45df01ca5db91aa0e2950eb5c2",
   "in_reply_to": null,
   "text": "Ignoring MSG_WITNESS_TX for wtxid relay peers seems fine, because i expect wtxid relay codebases to be newer / better maintained, and because BIP 339 explicitly states:\n[quoted text omitted]\n\nHowever for txid relay peers, i'm afraid we are in a similar situation to unannounced transaction processing. We have supported it for a decade, and while it Is Incorrect, i'm afraid there may be an unmaintained codebase out there that relies on it. It's a bit more niche than unannounced transaction processing, but still, i think we should have some evidence this isn't being used in the wild before dropping support."
  },
  {
   "t": "2026-08-08T01:26:29Z",
   "kind": "review_comment",
   "who": "ajtowns",
   "assoc": "MEMBER",
   "path": "src/net_processing.cpp",
   "commit": "eaaea13cda0f6f45df01ca5db91aa0e2950eb5c2",
   "in_reply_to": 3738744242,
   "text": "Based on the [`got inv`](https://github.com/bitcoin/bitcoin/blob/1be0b46297c6b61fefb870db6b3b18c273bcaf97/src/net_processing.cpp#L4392) debug.log lines, my lots-of-peers node received no witness-tx invs in April-July, versus:\n\n| Month | block | tx | wtx |\n| ----- | ----- | -- | --- |\n| April |  3,210 | 6,935,321 | 1,174,811,061 |\n| May |  2,092 | 3,530,619 | 854,676,397 |\n| June | 1,783  | 13,683,220 | 1,793,970,323 |\n| July | 1,924 | 10,870,284  | 2,474,162,561 |\n\nNumbers from:\n\n```sh\nzstdcat debug.log-202604*.zst | grep got.inv: | cut -d\\  -f5 |\n  awk '{c[$0]++} END {for (l in c) printf \"%8d %s\\n\", c[l], l}'\n```"
  },
  {
   "t": "2026-08-11T13:50:09Z",
   "kind": "comment",
   "who": "fjahr",
   "assoc": "MEMBER",
   "text": "Concept ACK"
  },
  {
   "t": "2026-08-12T03:19:28Z",
   "kind": "review_comment",
   "who": "ajtowns",
   "assoc": "MEMBER",
   "path": "src/net_processing.cpp",
   "commit": "eaaea13cda0f6f45df01ca5db91aa0e2950eb5c2",
   "in_reply_to": 3738744242,
   "text": "For people who do find instances of this, `grep got.inv:.witness-tx .bitcoin/debug.log` should indicate the txid being sent, as well as whether your peer already had the tx in question (\"have\" vs \"new\")."
  },
  {
   "t": "2026-08-12T15:02:18Z",
   "kind": "comment",
   "who": "0xB10C",
   "assoc": "MEMBER",
   "text": "As per https://bnoc.xyz/t/any-reachable-node-receiving-tx-announcement-via-msg-witness-tx/159/5: `/btcwire:0.5.0/neutrino:0.12.0-beta/` seems to be announcing transactions with `InvTypeWitnessTx`:\n\nhttps://github.com/lightninglabs/neutrino/blob/c96685a023c6946be7d463541b49e0f37f527982/query.go#L951-L969"
  },
  {
   "t": "2026-08-12T21:47:48Z",
   "kind": "comment",
   "who": "ajtowns",
   "assoc": "MEMBER",
   "text": "[quoted text omitted]\n\nFiled as https://github.com/lightninglabs/neutrino/issues/384"
  },
  {
   "t": "2026-08-12T22:05:51Z",
   "kind": "force_push",
   "who": "ajtowns",
   "commit": "0f9bffe6e1bcfdec55a03defc36e7ab282d7ef9d"
  },
  {
   "t": "2026-08-12T22:09:17Z",
   "kind": "comment",
   "who": "ajtowns",
   "assoc": "MEMBER",
   "text": "Changed to allow witness-tx in invs for non-wtxidrelay peers. Lame.\n\n[quoted text omitted]\nI didn't copy any code from you, and I'm not even sure what this is in regards to. Nothing here is substantive enough to be worth arguing about authorship."
  }
 ],
 "labels_log": [],
 "state_log": [
  {
   "t": "2026-08-06T21:04:41Z",
   "kind": "renamed",
   "who": "ajtowns",
   "from": "net_processing: Ignore MSG_TX_WITNESS entries from INV messages",
   "to": "net_processing: Ignore MSG_WITNESS_TX entries from INV messages"
  },
  {
   "t": "2026-08-07T06:08:23Z",
   "kind": "closed",
   "who": "DrahtBot"
  },
  {
   "t": "2026-08-07T06:08:28Z",
   "kind": "reopened",
   "who": "DrahtBot"
  }
 ],
 "text_chars": 3967,
 "text_tokens_estimate": 991,
 "changed_paths": [
  "src/net_processing.cpp",
  "test/functional/p2p_blocksonly.py",
  "test/functional/p2p_tx_download.py"
 ],
 "files": [
  {
   "path": "src/net_processing.cpp",
   "add": 14,
   "del": 14
  },
  {
   "path": "test/functional/p2p_blocksonly.py",
   "add": 12,
   "del": 9
  },
  {
   "path": "test/functional/p2p_tx_download.py",
   "add": 2,
   "del": 2
  }
 ],
 "test_lines": 25,
 "git": {
  "head": "0f9bffe6e1bcfdec55a03defc36e7ab282d7ef9d",
  "head_matches_backup": true,
  "base": "c36ffd870e8b0b9933f991dc6eda661a943f3819",
  "commits": [
   {
    "sha": "2eefc296d4",
    "subject": "net_processing: Ignore MSG_WITNESS_TX entries in inv messages",
    "files": 2,
    "add": 13,
    "del": 12
   },
   {
    "sha": "a24f315175",
    "subject": "tests: Check we disconnect on tx INVs on blocks-only conns",
    "files": 1,
    "add": 12,
    "del": 9
   },
   {
    "sha": "0f9bffe6e1",
    "subject": "net_processing: Combine seen_txids and seen_wtxids",
    "files": 1,
    "add": 3,
    "del": 4
   }
  ],
  "patch_truncated": false
 },
 "input_hash": "2b3d3f0794001097",
 "extracted_at": "2026-09-17T16:15:31+00:00"
}