From: Vihiga Tyonum Date: Wed, 28 Oct 2026 12:18:10 +0000 (+0100) Subject: chore: rename ScriptType enum to CompileScriptType X-Git-Url: http://internal-gitweb-vhost/-script/src/example_cli/scripts/struct.EncoderStringWriter.html?a=commitdiff_plain;h=3b514f4bb64b7329f9532c5359031bce3b774b4b;p=bdk-cli chore: rename ScriptType enum to CompileScriptType - Rename the enum to make it clear to understand and distinguish from other Script type enums. --- diff --git a/src/handlers/descriptor.rs b/src/handlers/descriptor.rs index d6e69ae..598617a 100644 --- a/src/handlers/descriptor.rs +++ b/src/handlers/descriptor.rs @@ -14,7 +14,7 @@ use crate::{ use clap::Parser; #[cfg(feature = "compiler")] use { - crate::utils::descriptors::{ScriptType, compile_policy}, + crate::utils::descriptors::{CompileScriptType, compile_policy}, bdk_wallet::miniscript::descriptor::DescriptorPublicKey, }; @@ -64,9 +64,9 @@ pub struct CompileCommand { short = 't', long = "type", value_enum, - default_value_t = ScriptType::Wsh + default_value_t = CompileScriptType::Wsh )] - script_type: ScriptType, + script_type: CompileScriptType, /// Skip key and hash validation, accepting placeholders (e.g. pk(A)). Useful for /// inspecting a policy's shape without real keys. Descriptors compiled with this /// flag are not usable for spending. diff --git a/src/utils/descriptors.rs b/src/utils/descriptors.rs index c14b120..15e8bca 100644 --- a/src/utils/descriptors.rs +++ b/src/utils/descriptors.rs @@ -263,7 +263,7 @@ const NUMS_UNSPENDABLE_KEY_HEX: &str = /// Script types the compiled policy can be embedded in. #[cfg(feature = "compiler")] #[derive(Clone, Copy, ValueEnum, Debug, Eq, PartialEq)] -pub enum ScriptType { +pub enum CompileScriptType { Sh, Wsh, ShWsh, @@ -299,7 +299,7 @@ fn check_policy_keys( #[cfg(feature = "compiler")] pub fn compile_policy( policy_str: &str, - script_type: ScriptType, + script_type: CompileScriptType, ) -> Result<(String, Option), Error> { let policy: Concrete = Concrete::from_str(policy_str) .map_err(|e| Error::Generic(format!("Invalid policy: {e}")))?; @@ -309,19 +309,19 @@ pub fn compile_policy( // Compile per branch, not once up front: the contexts have different script // limits, and the narrowest one would reject policies valid for the requested type. let descriptor = match script_type { - ScriptType::Sh => { + CompileScriptType::Sh => { check_policy_keys::(&policy)?; Descriptor::new_sh(policy.compile()?) } - ScriptType::Wsh => { + CompileScriptType::Wsh => { check_policy_keys::(&policy)?; Descriptor::new_wsh(policy.compile()?) } - ScriptType::ShWsh => { + CompileScriptType::ShWsh => { check_policy_keys::(&policy)?; Descriptor::new_sh_wsh(policy.compile()?) } - ScriptType::Tr => { + CompileScriptType::Tr => { check_policy_keys::(&policy)?; // Use a randomized unspendable internal key (H + rG) instead of a fixed NUMS // point. This improves privacy by preventing observers from determining whether