Merge rust-bitcoin/rust-bitcoin#3126: Remove catch all pattern

6836de9ee6 Remove catch all pattern (Tobin C. Harding)

Pull request description:

  The `PushBytes` type enforces len is less than 0x100000000 so we do not need to panic in a catch all pattern after explicitly matching against less than 0x100000000.

  Refactor only because of the invariant on `PushBytes` - no logic changes.

ACKs for top commit:
  apoelstra:
    ACK 6836de9ee6 successfully ran local tests
  Kixunil:
    ACK 6836de9ee6

Tree-SHA512: a7cdb31683a8c00eecbdd0879886bec48133f9029f899b5279f1f5294ef40320592db196bfcafdeef4507636fc785a7ab87879b25b6d1b4905ae573b545f1ff4
This commit is contained in:
merge-script 2024-08-06 13:06:20 +00:00
commit 2dac88b416
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 1 additions and 2 deletions

View File

@ -113,14 +113,13 @@ impl ScriptBuf {
self.0.push((n % 0x100) as u8);
self.0.push((n / 0x100) as u8);
}
n if n < 0x100000000 => {
n => { // `PushBytes` enforces len < 0x100000000
self.0.push(opcodes::Ordinary::OP_PUSHDATA4.to_u8());
self.0.push((n % 0x100) as u8);
self.0.push(((n / 0x100) % 0x100) as u8);
self.0.push(((n / 0x10000) % 0x100) as u8);
self.0.push((n / 0x1000000) as u8);
}
_ => panic!("tried to put a 4bn+ sized object into a script!"),
}
// Then push the raw bytes
self.0.extend_from_slice(data.as_bytes());