Skip to content

Commit ed772d4

Browse files
committed
Merge rust-bitcoin#4168: Move opcodes back to bitcoin
a743933 Move opcodes back to bitcoin (Tobin C. Harding) Pull request description: Duplicate `opcodes` in `bitcoin` and hide it in `primitives` so we do not have to commit to the API. We use opcodes in `impl fmt::Display for Script`. Close: rust-bitcoin#4144 ACKs for top commit: apoelstra: ACK a743933; successfully ran local tests; sure Kixunil: ACK a743933 Tree-SHA512: 738685b9cd2288a581daa6219e3b21bd48bb4845ea627bf6b8085e0e48f5649ac5ec616a3421d10cd37543f76b66d31f94fd55bf94effc2fb8f91d1ecf5c8611
2 parents 644adb4 + a743933 commit ed772d4

File tree

7 files changed

+909
-14
lines changed

7 files changed

+909
-14
lines changed

bitcoin/src/blockdata/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
pub mod block;
99
pub mod constants;
10+
pub mod opcodes;
1011
pub mod script;
1112
pub mod transaction;
1213
pub mod witness;
@@ -70,12 +71,6 @@ pub mod locktime {
7071
}
7172
}
7273

73-
/// Bitcoin script opcodes.
74-
pub mod opcodes {
75-
/// Re-export everything from the [`primitives::opcodes`] module.
76-
pub use primitives::opcodes::*;
77-
}
78-
7974
/// Implements `Weight` and associated features.
8075
pub mod weight {
8176
/// Re-export everything from the [`units::weight`] module.

bitcoin/src/blockdata/opcodes.rs

+901
Large diffs are not rendered by default.

bitcoin/src/blockdata/script/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ use core::convert::Infallible;
6161
use core::fmt;
6262

6363
use io::{BufRead, Write};
64-
use primitives::opcodes::all::*;
65-
use primitives::opcodes::Opcode;
6664

6765
use crate::consensus::{encode, Decodable, Encodable};
6866
use crate::internal_macros::impl_asref_push_bytes;
6967
use crate::key::WPubkeyHash;
68+
use crate::opcodes::all::*;
69+
use crate::opcodes::Opcode;
7070
use crate::prelude::Vec;
7171
use crate::OutPoint;
7272

bitcoin/src/blockdata/script/tests.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
// SPDX-License-Identifier: CC0-1.0
22

33
use hex_lit::hex;
4-
use primitives::opcodes;
54

65
use super::*;
76
use crate::address::script_pubkey::{
87
BuilderExt as _, ScriptBufExt as _, ScriptExt as _, ScriptExtPrivate as _,
98
};
109
use crate::consensus::encode::{deserialize, serialize};
1110
use crate::crypto::key::{PublicKey, XOnlyPublicKey};
12-
use crate::{Amount, FeeRate};
11+
use crate::{Amount, FeeRate, opcodes};
1312

1413
#[test]
1514
#[rustfmt::skip]

bitcoin/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ pub use primitives::{
123123
Unchecked as BlockUnchecked, Validation as BlockValidation, WitnessCommitment,
124124
},
125125
merkle_tree::{TxMerkleNode, WitnessMerkleNode},
126-
opcodes::Opcode,
127126
pow::CompactTarget, // No `pow` module outside of `primitives`.
128127
script::{Script, ScriptBuf},
129128
sequence::{self, Sequence}, // No `sequence` module outside of `primitives`.
@@ -161,12 +160,13 @@ pub use crate::{
161160
pub use crate::{
162161
// Also, re-export types and modules from `blockdata` that don't come from `primitives`.
163162
blockdata::locktime::{absolute, relative},
163+
blockdata::opcodes::{self, Opcode},
164164
blockdata::script::witness_program::{self, WitnessProgram},
165165
blockdata::script::witness_version::{self, WitnessVersion},
166166
blockdata::script::{ScriptHash, WScriptHash}, // TODO: Move these down below after they are in primitives.
167167
// These modules also re-export all the respective `primitives` types.
168168
blockdata::{
169-
block, constants, fee_rate, locktime, opcodes, script, transaction, weight, witness,
169+
block, constants, fee_rate, locktime, script, transaction, weight, witness,
170170
},
171171
};
172172

primitives/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub mod _export {
4444
pub mod block;
4545
pub mod locktime;
4646
pub mod merkle_tree;
47-
pub mod opcodes;
47+
mod opcodes;
4848
pub mod pow;
4949
#[cfg(feature = "alloc")]
5050
pub mod script;
@@ -76,7 +76,6 @@ pub use self::{
7676
block::{BlockHash, Header as BlockHeader, WitnessCommitment},
7777
locktime::{absolute, relative},
7878
merkle_tree::{TxMerkleNode, WitnessMerkleNode},
79-
opcodes::Opcode,
8079
pow::CompactTarget,
8180
sequence::Sequence,
8281
transaction::{OutPoint, Txid, Wtxid},

primitives/src/opcodes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//! all of the opcodes for that language.
77
88
#![allow(non_camel_case_types)]
9+
#![allow(dead_code)] // This module is private and is duplicated in `bitcoin`.
910

1011
use core::fmt;
1112

0 commit comments

Comments
 (0)