Skip to main content

bitcoin_primitives/script/
tag.rs

1// SPDX-License-Identifier: CC0-1.0
2
3//! Script tags.
4//!
5//! Tags are used to differentiate the different kinds of scripts that appear
6//! in Bitcoin transactions.
7
8/// Sealed trait representing a type of script.
9pub trait Tag: sealed::Sealed {}
10
11mod sealed {
12    pub trait Sealed {}
13    impl Sealed for super::RedeemScriptTag {}
14    impl Sealed for super::ScriptSigTag {}
15    impl Sealed for super::ScriptPubKeyTag {}
16    impl Sealed for super::SignetBlockScriptTag {}
17    impl Sealed for super::TapScriptTag {}
18    impl Sealed for super::WitnessScriptTag {}
19}
20
21/// A P2SH redeem script.
22#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
23pub enum RedeemScriptTag {}
24impl Tag for RedeemScriptTag {}
25
26/// A script signature (scriptSig).
27#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
28pub enum ScriptSigTag {}
29impl Tag for ScriptSigTag {}
30
31/// A script public key (scriptPubKey).
32#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
33pub enum ScriptPubKeyTag {}
34impl Tag for ScriptPubKeyTag {}
35
36/// A signet block challenge script.
37#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
38pub enum SignetBlockScriptTag {}
39impl Tag for SignetBlockScriptTag {}
40
41/// A Segwit v1 Taproot script.
42#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
43pub enum TapScriptTag {}
44impl Tag for TapScriptTag {}
45
46/// A Segwit v0 witness script.
47#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
48pub enum WitnessScriptTag {}
49impl Tag for WitnessScriptTag {}