Remove script:: prefix from unambiguous types

There is no need to qualify `Script` and `ScriptBuf` with the `script::`
prefix, remove it.
This commit is contained in:
Tobin C. Harding 2023-01-20 12:33:56 +11:00
parent 5ab5c264d2
commit 83e1c40c4d
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 15 additions and 15 deletions

View File

@ -41,9 +41,9 @@ use crate::blockdata::constants::{
MAX_SCRIPT_ELEMENT_SIZE, PUBKEY_ADDRESS_PREFIX_MAIN, PUBKEY_ADDRESS_PREFIX_TEST, MAX_SCRIPT_ELEMENT_SIZE, PUBKEY_ADDRESS_PREFIX_MAIN, PUBKEY_ADDRESS_PREFIX_TEST,
SCRIPT_ADDRESS_PREFIX_MAIN, SCRIPT_ADDRESS_PREFIX_TEST, SCRIPT_ADDRESS_PREFIX_MAIN, SCRIPT_ADDRESS_PREFIX_TEST,
}; };
use crate::blockdata::opcodes;
use crate::blockdata::opcodes::all::*; use crate::blockdata::opcodes::all::*;
use crate::blockdata::script::Instruction; use crate::blockdata::script::{self, Instruction, Script, ScriptBuf};
use crate::blockdata::{opcodes, script};
use crate::crypto::key::PublicKey; use crate::crypto::key::PublicKey;
use crate::crypto::schnorr::{TapTweak, TweakedPublicKey, UntweakedPublicKey}; use crate::crypto::schnorr::{TapTweak, TweakedPublicKey, UntweakedPublicKey};
use crate::error::ParseIntError; use crate::error::ParseIntError;
@ -432,7 +432,7 @@ impl WitnessProgram {
impl Payload { impl Payload {
/// Constructs a [Payload] from an output script (`scriptPubkey`). /// Constructs a [Payload] from an output script (`scriptPubkey`).
pub fn from_script(script: &script::Script) -> Result<Payload, Error> { pub fn from_script(script: &Script) -> Result<Payload, Error> {
Ok(if script.is_p2pkh() { Ok(if script.is_p2pkh() {
let mut hash_inner = [0u8; 20]; let mut hash_inner = [0u8; 20];
hash_inner.copy_from_slice(&script.as_bytes()[3..23]); hash_inner.copy_from_slice(&script.as_bytes()[3..23]);
@ -455,12 +455,12 @@ impl Payload {
} }
/// Generates a script pubkey spending to this [Payload]. /// Generates a script pubkey spending to this [Payload].
pub fn script_pubkey(&self) -> script::ScriptBuf { pub fn script_pubkey(&self) -> ScriptBuf {
match *self { match *self {
Payload::PubkeyHash(ref hash) => script::ScriptBuf::new_p2pkh(hash), Payload::PubkeyHash(ref hash) => ScriptBuf::new_p2pkh(hash),
Payload::ScriptHash(ref hash) => script::ScriptBuf::new_p2sh(hash), Payload::ScriptHash(ref hash) => ScriptBuf::new_p2sh(hash),
Payload::WitnessProgram(ref prog) => Payload::WitnessProgram(ref prog) =>
script::ScriptBuf::new_witness_program(prog) ScriptBuf::new_witness_program(prog)
} }
} }
@ -470,7 +470,7 @@ impl Payload {
/// Creates a pay to script hash P2SH payload from a script /// Creates a pay to script hash P2SH payload from a script
#[inline] #[inline]
pub fn p2sh(script: &script::Script) -> Result<Payload, Error> { pub fn p2sh(script: &Script) -> Result<Payload, Error> {
if script.len() > MAX_SCRIPT_ELEMENT_SIZE { if script.len() > MAX_SCRIPT_ELEMENT_SIZE {
return Err(Error::ExcessiveScriptSize); return Err(Error::ExcessiveScriptSize);
} }
@ -496,7 +496,7 @@ impl Payload {
} }
/// Create a witness pay to script hash payload. /// Create a witness pay to script hash payload.
pub fn p2wsh(script: &script::Script) -> Payload { pub fn p2wsh(script: &Script) -> Payload {
let prog = WitnessProgram::new( let prog = WitnessProgram::new(
WitnessVersion::V0, WitnessVersion::V0,
script.wscript_hash().as_ref().to_vec() script.wscript_hash().as_ref().to_vec()
@ -505,7 +505,7 @@ impl Payload {
} }
/// Create a pay to script payload that embeds a witness pay to script hash address /// Create a pay to script payload that embeds a witness pay to script hash address
pub fn p2shwsh(script: &script::Script) -> Payload { pub fn p2shwsh(script: &Script) -> Payload {
let ws = let ws =
script::Builder::new().push_int(0).push_slice(script.wscript_hash().as_ref()).into_script(); script::Builder::new().push_int(0).push_slice(script.wscript_hash().as_ref()).into_script();
@ -820,7 +820,7 @@ impl Address {
/// This address type was introduced with BIP16 and is the popular type to implement multi-sig /// This address type was introduced with BIP16 and is the popular type to implement multi-sig
/// these days. /// these days.
#[inline] #[inline]
pub fn p2sh(script: &script::Script, network: Network) -> Result<Address, Error> { pub fn p2sh(script: &Script, network: Network) -> Result<Address, Error> {
Ok(Address::new(network, Payload::p2sh(script)?)) Ok(Address::new(network, Payload::p2sh(script)?))
} }
@ -845,14 +845,14 @@ impl Address {
} }
/// Creates a witness pay to script hash address. /// Creates a witness pay to script hash address.
pub fn p2wsh(script: &script::Script, network: Network) -> Address { pub fn p2wsh(script: &Script, network: Network) -> Address {
Address::new(network, Payload::p2wsh(script)) Address::new(network, Payload::p2wsh(script))
} }
/// Creates a pay to script address that embeds a witness pay to script hash address. /// Creates a pay to script address that embeds a witness pay to script hash address.
/// ///
/// This is a segwit address type that looks familiar (as p2sh) to legacy clients. /// This is a segwit address type that looks familiar (as p2sh) to legacy clients.
pub fn p2shwsh(script: &script::Script, network: Network) -> Address { pub fn p2shwsh(script: &Script, network: Network) -> Address {
Address::new(network, Payload::p2shwsh(script)) Address::new(network, Payload::p2shwsh(script))
} }
@ -905,12 +905,12 @@ impl Address {
pub fn is_standard(&self) -> bool { self.address_type().is_some() } pub fn is_standard(&self) -> bool { self.address_type().is_some() }
/// Constructs an [`Address`] from an output script (`scriptPubkey`). /// Constructs an [`Address`] from an output script (`scriptPubkey`).
pub fn from_script(script: &script::Script, network: Network) -> Result<Address, Error> { pub fn from_script(script: &Script, network: Network) -> Result<Address, Error> {
Ok(Address::new(network, Payload::from_script(script)?)) Ok(Address::new(network, Payload::from_script(script)?))
} }
/// Generates a script pubkey spending to this address. /// Generates a script pubkey spending to this address.
pub fn script_pubkey(&self) -> script::ScriptBuf { self.payload.script_pubkey() } pub fn script_pubkey(&self) -> ScriptBuf { self.payload.script_pubkey() }
/// Creates a URI string *bitcoin:address* optimized to be encoded in QR codes. /// Creates a URI string *bitcoin:address* optimized to be encoded in QR codes.
/// ///