{
 "number": 36280,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/36280",
 "title": "validation: throw when a compressed script can't be decompressed",
 "author": "furszy",
 "author_association": "MEMBER",
 "created_at": "2026-09-16T20:49:24Z",
 "updated_at": "2026-09-16T22:20:29Z",
 "age_days": 0,
 "draft": false,
 "labels": [
  "Validation"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "da94b76da6d0cb0984e70490c5173287523e44f4",
 "head_ref": "2026_compression_throw",
 "head_repo": "furszy/bitcoin-core",
 "head_history": [
  {
   "t": "2026-09-16T21:17:19Z",
   "sha": "da94b76da6d0cb0984e70490c5173287523e44f4"
  }
 ],
 "additions": 61,
 "deletions": 4,
 "changed_files": 3,
 "commit_count": 2,
 "size_bucket": "S",
 "mergeable_state": "clean",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {
    "approach_ack": [
     {
      "login": "sedited",
      "url": "https://github.com/bitcoin/bitcoin/pull/36280#issuecomment-5705072137"
     }
    ]
   },
   "conflicts": []
  }
 },
 "acks_parsed": {
  "sedited": {
   "kind": "approach_ack",
   "hash": null,
   "t": "2026-09-16T21:49:40Z",
   "stale": false
  }
 },
 "acks_tally": {
  "ack": 0,
  "stale_ack": 0,
  "concept_ack": 0,
  "approach_ack": 1,
  "nack": 0,
  "concept_nack": 0,
  "approach_nack": 0
 },
 "reviews": {
  "approved": 0,
  "changes_requested": 0,
  "distinct_reviewers": [
   "sedited"
  ]
 },
 "signals": {
  "needs_rebase": false,
  "ci_failed": false,
  "mergeable_state": "clean",
  "last_author_activity": "2026-09-16T21:17:19Z",
  "last_reviewer_activity": "2026-09-16T21:49:40Z",
  "last_reviewer": "sedited",
  "author_silent_days": 0,
  "waiting_on_author_days": 0,
  "days_since_update": 0
 },
 "refs": {
  "mentioned": [],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [],
  "conflicts": []
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [],
 "body": "`ScriptCompression::Unser` ignores the `DecompressScript` return value and\nleaves the script empty on failure, without notifying upper layers about the error.\nIn the worst-case scenario, which is currently only reachable through corruption,\nan unspendable off-curve P2PK turns into an anyone-can-spend empty script.\nGiven that, properly throwing the error to prevent any future mistakes from\nhappening seems the sanest path to follow.\n\nAside from that, added coverage for a P2PK script with an uncompressed pubkey\nthat has a valid X but a wrong Y, which makes it unspendable. Checking we store\nsuch scripts raw and never encode them as 0x04/0x05, as those encodings\nserialize X with only Y's parity (not the full Y), which would make decompression\nrecompute Y from X and turn the unspendable script into a spendable one, which\nwould not be good.",
 "commits": [
  {
   "sha": "27c6a2c75bf90ef03f8b297a00853d910170a0c6",
   "date": "2026-09-16T20:41:09Z",
   "message": "test: script compression with off-curve and wrong-Y P2PK pubkeys\n\nAdds coverage for two cases:\n\nThe existing compress_p2pk_scripts_not_on_curve test now also covers\nthe ScriptCompression ser + unser round-trip, and checks the behavior\nof a compressed record that can't be decompressed.\nThe worst-case scenario is a P2PK to an off-curve pubkey, which nobody\ncan spend, that is turned into an anyone-can-spend script during\ndecompression without throwing an error to upper layers.\nNote: this could only ever happen after corruption today, but better\nto add proper coverage for it, and add the missing error signaling\n(next commit).\n\nThen added coverage for a P2PK script with an uncompressed pubkey that\nhas a valid X but a wrong Y, which makes it unspendable. Checking we store\nsuch scripts raw and never encode them as 0x04/0x05, as those encodings\nserialize X with only Y's parity (not the full Y), so decompress would\nrecompute Y from X and turn the unspendable script into a spendable one,\nwhich would be bad."
  },
  {
   "sha": "da94b76da6d0cb0984e70490c5173287523e44f4",
   "date": "2026-09-16T21:16:54Z",
   "message": "compressor: throw when compressed script can't be decompressed\n\n`ScriptCompression::Unser` ignores the `DecompressScript` return value and\nleaves the script empty on failure, without notifying upper layers about the error.\nIn the worst-case scenario, which is currently only reachable through corruption,\nthis turns an unspendable off-curve P2PK into an anyone-can-spend script.\nGiven that, properly throwing the error to prevent any future mistakes from\nhappening seems the sanest path to follow."
  }
 ],
 "timeline": [
  {
   "t": "2026-09-16T21:17:19Z",
   "kind": "force_push",
   "who": "furszy",
   "commit": "da94b76da6d0cb0984e70490c5173287523e44f4"
  },
  {
   "t": "2026-09-16T21:49:40Z",
   "kind": "comment",
   "who": "sedited",
   "assoc": "MEMBER",
   "text": "Approach ACK"
  }
 ],
 "labels_log": [
  {
   "t": "2026-09-16T20:49:28Z",
   "action": "labeled",
   "label": "Validation",
   "who": "DrahtBot"
  },
  {
   "t": "2026-09-16T21:17:55Z",
   "action": "labeled",
   "label": "CI failed",
   "who": "DrahtBot"
  },
  {
   "t": "2026-09-16T22:20:29Z",
   "action": "unlabeled",
   "label": "CI failed",
   "who": "DrahtBot"
  }
 ],
 "state_log": [],
 "text_chars": 2434,
 "text_tokens_estimate": 608,
 "changed_paths": [
  "src/compressor.h",
  "src/test/compress_tests.cpp",
  "src/test/fuzz/script.cpp"
 ],
 "files": [
  {
   "path": "src/compressor.h",
   "add": 7,
   "del": 3
  },
  {
   "path": "src/test/compress_tests.cpp",
   "add": 46,
   "del": 0
  },
  {
   "path": "src/test/fuzz/script.cpp",
   "add": 8,
   "del": 1
  }
 ],
 "test_lines": 55,
 "git": {
  "head": "da94b76da6d0cb0984e70490c5173287523e44f4",
  "head_matches_backup": true,
  "base": "fc6923cec5b440b611700f6629d8c6a61c6f11bd",
  "commits": [
   {
    "sha": "27c6a2c75b",
    "subject": "test: script compression with off-curve and wrong-Y P2PK pubkeys",
    "files": 1,
    "add": 46,
    "del": 0
   },
   {
    "sha": "da94b76da6",
    "subject": "compressor: throw when compressed script can't be decompressed",
    "files": 3,
    "add": 17,
    "del": 6
   }
  ],
  "patch_truncated": false
 },
 "input_hash": "0cb9d8e680a22b3d",
 "extracted_at": "2026-09-17T16:15:31+00:00"
}