What changed, and why it matters
This commit is a routine code-quality change. It replaces the word `static` with `const` for a handful of Bitcoin script opcode aliases (like OP_TRUE and OP_FALSE). In Rust, `const` values are inlined at compile time and do not need a fixed memory address, which is perfectly safe here. There is no security-relevant change.
No security action needed. Treat as a normal maintenance/refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch changes five public opcode aliases from pub static to pub const in two opcode definition files. The underlying Opcode type remains unchanged, and the aliases still point to the same opcode constants. This is a non-functional refactor that may affect downstream code taking references to these aliases, but it does not alter semantics or introduce a vulnerability.
Changed components
bitcoin/src/blockdata/opcodes.rsprimitives/src/opcodes.rsInspect captured patch +10 / −10
diff --git a/bitcoin/src/blockdata/opcodes.rs b/bitcoin/src/blockdata/opcodes.rs
index 3f3ffc97..8cd6e417 100644
--- a/bitcoin/src/blockdata/opcodes.rs
+++ b/bitcoin/src/blockdata/opcodes.rs
@@ -50,15 +50,15 @@ macro_rules! all_opcodes {
}
/// Push an empty array onto the stack.
- pub static OP_0: Opcode = OP_PUSHBYTES_0;
+ pub const OP_0: Opcode = OP_PUSHBYTES_0;
/// Empty stack is also FALSE.
- pub static OP_FALSE: Opcode = OP_PUSHBYTES_0;
+ pub const OP_FALSE: Opcode = OP_PUSHBYTES_0;
/// Number 1 is also TRUE.
- pub static OP_TRUE: Opcode = OP_PUSHNUM_1;
+ pub const OP_TRUE: Opcode = OP_PUSHNUM_1;
/// Previously called OP_NOP2.
- pub static OP_NOP2: Opcode = OP_CLTV;
+ pub const OP_NOP2: Opcode = OP_CLTV;
/// Previously called OP_NOP3.
- pub static OP_NOP3: Opcode = OP_CSV;
+ pub const OP_NOP3: Opcode = OP_CSV;
impl fmt::Display for Opcode {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
diff --git a/primitives/src/opcodes.rs b/primitives/src/opcodes.rs
index e48db743..d1b77c0d 100644
--- a/primitives/src/opcodes.rs
+++ b/primitives/src/opcodes.rs
@@ -52,15 +52,15 @@ macro_rules! all_opcodes {
}
/// Push an empty array onto the stack.
- pub static OP_0: Opcode = OP_PUSHBYTES_0;
+ pub const OP_0: Opcode = OP_PUSHBYTES_0;
/// Empty stack is also `FALSE`.
- pub static OP_FALSE: Opcode = OP_PUSHBYTES_0;
+ pub const OP_FALSE: Opcode = OP_PUSHBYTES_0;
/// Number 1 is also TRUE.
- pub static OP_TRUE: Opcode = OP_PUSHNUM_1;
+ pub const OP_TRUE: Opcode = OP_PUSHNUM_1;
/// Previously called `OP_NOP2`.
- pub static OP_NOP2: Opcode = OP_CLTV;
+ pub const OP_NOP2: Opcode = OP_CLTV;
/// Previously called `OP_NOP3`.
- pub static OP_NOP3: Opcode = OP_CSV;
+ pub const OP_NOP3: Opcode = OP_CSV;
impl fmt::Display for Opcode {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.