Skip to content

Commit cf90378

Browse files
committed
Merge rust-bitcoin#5095: chore: clarify last_pushdata comment
894a255 docs: clarify last pushdata comment (Galoretka) Pull request description: The inline comment in last_pushdata was misleading and outdated. It claimed to “handle op codes up to (but excluding) OP_PUSHNUM_NEG”, implying special treatment for numeric push opcodes and referencing a deprecated name. In reality, last_pushdata only returns true data pushes (Instruction::PushBytes) and excludes numeric push opcodes (OP_0, OP_1NEGATE, OP_1..OP_16) since they are emitted as Instruction::Op. Updated the comment to explicitly state this behavior. No logic changes. ACKs for top commit: apoelstra: ACK 894a255; successfully ran local tests tcharding: ACK 894a255 Tree-SHA512: b295ee2ff87a55e9040ce96bf1e1681ba20c0f2946853cdb8e70c35daf7acbeb377f6d563d63e6beaab56081f265a56b2c2e9b72c82d45d9d0ff6d9185fe4b85
2 parents 3f50209 + 894a255 commit cf90378

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

bitcoin/src/blockdata/script/borrowed.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,10 @@ internal_macros::define_extension_trait! {
529529
/// Returns `None` if the instruction is an opcode or if the script is empty.
530530
fn last_pushdata(&self) -> Option<&PushBytes> {
531531
match self.instructions().last() {
532-
// Handles op codes up to (but excluding) OP_PUSHNUM_NEG.
532+
// Returns only true data pushes.
533+
// Note: OP_0 (empty push) is included as PushBytes; numeric push opcodes
534+
// OP_1NEGATE and OP_1..OP_16 are opcodes (not pushdata) and thus excluded.
535+
// OP_RESERVED is also excluded.
533536
Some(Ok(Instruction::PushBytes(bytes))) => Some(bytes),
534537
// OP_16 (0x60) and lower are considered "pushes" by Bitcoin Core (excl. OP_RESERVED).
535538
// However we are only interested in the pushdata so we can ignore them.

0 commit comments

Comments
 (0)