From c8e6c13608da553d492dc055d8059d96c060cdc4 Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Tue, 25 Jun 2024 10:16:32 +0100 Subject: [PATCH] Capitalize Taproot Taproot is a proper noun and should be capitalized in docs and strings. Make all occurrences of Taproot in comments or strings capitalized. --- bitcoin/examples/taproot-psbt.rs | 12 ++--- bitcoin/src/address/mod.rs | 6 +-- bitcoin/src/blockdata/script/borrowed.rs | 8 ++-- .../src/blockdata/script/witness_program.rs | 6 +-- bitcoin/src/blockdata/transaction.rs | 10 ++-- bitcoin/src/crypto/sighash.rs | 16 +++---- bitcoin/src/crypto/taproot.rs | 10 ++-- bitcoin/src/psbt/error.rs | 10 ++-- bitcoin/src/psbt/map/input.rs | 8 ++-- bitcoin/src/psbt/mod.rs | 20 ++++---- bitcoin/src/psbt/serialize.rs | 2 +- bitcoin/src/taproot/mod.rs | 48 +++++++++---------- 12 files changed, 78 insertions(+), 78 deletions(-) diff --git a/bitcoin/examples/taproot-psbt.rs b/bitcoin/examples/taproot-psbt.rs index 1c5b4d411..84f8427ed 100644 --- a/bitcoin/examples/taproot-psbt.rs +++ b/bitcoin/examples/taproot-psbt.rs @@ -1,4 +1,4 @@ -//! Example of taproot PSBT workflow +//! Example of Taproot PSBT workflow // We use the alias `alias bt='bitcoin-cli -regtest'` for brevity. @@ -192,7 +192,7 @@ fn main() -> Result<(), Box> { // At some point we may want to extend the locktime further into the future for the beneficiary. // We can do this by "refreshing" the inheritance transaction as the benefactor. This effectively - // spends the inheritance transaction via the key path of the taproot output, and is not encumbered + // spends the inheritance transaction via the key path of the Taproot output, and is not encumbered // by the timelock so we can spend it immediately. We set up a new output similar to the first with // a locktime that is 'locktime_delta' blocks greater. let (tx, _) = benefactor.refresh_tx(1000)?; @@ -294,7 +294,7 @@ fn generate_bip86_key_spend_tx( let (_, (_, derivation_path)) = input .tap_key_origins .get(&input.tap_internal_key.ok_or("Internal key missing in PSBT")?) - .ok_or("Missing taproot key origin")?; + .ok_or("Missing Taproot key origin")?; let secret_key = master_xpriv.derive_priv(secp, &derivation_path).to_priv().inner; sign_psbt_taproot( @@ -395,7 +395,7 @@ impl BenefactorWallet { let beneficiary_key = self.beneficiary_xpub.derive_pub(&self.secp, &derivation_path)?.to_x_only_pub(); - // Build up the leaf script and combine with internal key into a taproot commitment + // Build up the leaf script and combine with internal key into a Taproot commitment let script = Self::time_lock_script(lock_time, beneficiary_key); let leaf_hash = script.tapscript_leaf_hash(); @@ -486,7 +486,7 @@ impl BenefactorWallet { let beneficiary_key = self.beneficiary_xpub.derive_pub(&self.secp, &new_derivation_path)?.to_x_only_pub(); - // Build up the leaf script and combine with internal key into a taproot commitment + // Build up the leaf script and combine with internal key into a Taproot commitment let lock_time = absolute::LockTime::from_height( psbt.unsigned_tx.lock_time.to_consensus_u32() + lock_time_delta, ) @@ -528,7 +528,7 @@ impl BenefactorWallet { let (_, (_, derivation_path)) = input .tap_key_origins .get(&input.tap_internal_key.ok_or("Internal key missing in PSBT")?) - .ok_or("Missing taproot key origin")?; + .ok_or("Missing Taproot key origin")?; let secret_key = self.master_xpriv.derive_priv(&self.secp, &derivation_path).to_priv().inner; sign_psbt_taproot( diff --git a/bitcoin/src/address/mod.rs b/bitcoin/src/address/mod.rs index 9edcd6473..7813c7030 100644 --- a/bitcoin/src/address/mod.rs +++ b/bitcoin/src/address/mod.rs @@ -465,7 +465,7 @@ impl Address { Ok(Address::p2sh_from_hash(script_hash, network)) } - /// Creates a pay to taproot address from an untweaked key. + /// Creates a pay to Taproot address from an untweaked key. pub fn p2tr( secp: &Secp256k1, internal_key: UntweakedPublicKey, @@ -476,7 +476,7 @@ impl Address { Address::from_witness_program(program, hrp) } - /// Creates a pay to taproot address from a pre-tweaked output key. + /// Creates a pay to Taproot address from a pre-tweaked output key. pub fn p2tr_tweaked(output_key: TweakedPublicKey, hrp: impl Into) -> Address { let program = WitnessProgram::p2tr_tweaked(output_key); Address::from_witness_program(program, hrp) @@ -642,7 +642,7 @@ impl Address { /// /// This is determined by directly comparing the address payload with either the /// hash of the given public key or the segwit redeem hash generated from the - /// given key. For taproot addresses, the supplied key is assumed to be tweaked + /// given key. For Taproot addresses, the supplied key is assumed to be tweaked pub fn is_related_to_pubkey(&self, pubkey: PublicKey) -> bool { let pubkey_hash = pubkey.pubkey_hash(); let payload = self.payload_as_bytes(); diff --git a/bitcoin/src/blockdata/script/borrowed.rs b/bitcoin/src/blockdata/script/borrowed.rs index dc8d57f3d..0b930c598 100644 --- a/bitcoin/src/blockdata/script/borrowed.rs +++ b/bitcoin/src/blockdata/script/borrowed.rs @@ -468,9 +468,9 @@ impl Script { /// Bitcoin Core uses accurate counting for sigops contained within redeemScripts (P2SH) /// and witnessScripts (P2WSH) only. It uses legacy for sigops in scriptSigs and scriptPubkeys. /// - /// (Note: taproot scripts don't count toward the sigop count of the block, + /// (Note: Taproot scripts don't count toward the sigop count of the block, /// nor do they have CHECKMULTISIG operations. This function does not count OP_CHECKSIGADD, - /// so do not use this to try and estimate if a taproot script goes over the sigop budget.) + /// so do not use this to try and estimate if a Taproot script goes over the sigop budget.) pub fn count_sigops(&self) -> usize { self.count_sigops_internal(true) } /// Counts the sigops for this Script using legacy counting. @@ -482,9 +482,9 @@ impl Script { /// Bitcoin Core uses legacy counting for sigops contained within scriptSigs and /// scriptPubkeys. It uses accurate for redeemScripts (P2SH) and witnessScripts (P2WSH). /// - /// (Note: taproot scripts don't count toward the sigop count of the block, + /// (Note: Taproot scripts don't count toward the sigop count of the block, /// nor do they have CHECKMULTISIG operations. This function does not count OP_CHECKSIGADD, - /// so do not use this to try and estimate if a taproot script goes over the sigop budget.) + /// so do not use this to try and estimate if a Taproot script goes over the sigop budget.) pub fn count_sigops_legacy(&self) -> usize { self.count_sigops_internal(false) } fn count_sigops_internal(&self, accurate: bool) -> usize { diff --git a/bitcoin/src/blockdata/script/witness_program.rs b/bitcoin/src/blockdata/script/witness_program.rs index 573454b38..d409b21c7 100644 --- a/bitcoin/src/blockdata/script/witness_program.rs +++ b/bitcoin/src/blockdata/script/witness_program.rs @@ -65,7 +65,7 @@ impl WitnessProgram { WitnessProgram { version: WitnessVersion::V0, program: ArrayVec::from_slice(&program) } } - /// Creates a [`WitnessProgram`] from a 32 byte serialize taproot xonly pubkey. + /// Creates a [`WitnessProgram`] from a 32 byte serialize Taproot xonly pubkey. fn new_p2tr(program: [u8; 32]) -> Self { WitnessProgram { version: WitnessVersion::V1, program: ArrayVec::from_slice(&program) } } @@ -86,7 +86,7 @@ impl WitnessProgram { WitnessProgram::new_p2wsh(hash.to_byte_array()) } - /// Creates a pay to taproot address from an untweaked key. + /// Creates a pay to Taproot address from an untweaked key. pub fn p2tr( secp: &Secp256k1, internal_key: UntweakedPublicKey, @@ -97,7 +97,7 @@ impl WitnessProgram { WitnessProgram::new_p2tr(pubkey) } - /// Creates a pay to taproot address from a pre-tweaked output key. + /// Creates a pay to Taproot address from a pre-tweaked output key. pub fn p2tr_tweaked(output_key: TweakedPublicKey) -> Self { let pubkey = output_key.to_inner().serialize(); WitnessProgram::new_p2tr(pubkey) diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs index d927c1bf5..0b4c93fae 100644 --- a/bitcoin/src/blockdata/transaction.rs +++ b/bitcoin/src/blockdata/transaction.rs @@ -920,9 +920,9 @@ impl Transaction { /// Counts the total number of sigops. /// - /// This value is for pre-taproot transactions only. + /// This value is for pre-Taproot transactions only. /// - /// > In taproot, a different mechanism is used. Instead of having a global per-block limit, + /// > In Taproot, a different mechanism is used. Instead of having a global per-block limit, /// > there is a per-transaction-input limit, proportional to the size of that input. /// > ref: /// @@ -983,7 +983,7 @@ impl Transaction { count } - /// Includes wrapped segwit (returns 0 for taproot spends). + /// Includes wrapped segwit (returns 0 for Taproot spends). fn count_witness_sigops(&self, spent: &mut S) -> usize where S: FnMut(&OutPoint) -> Option, @@ -1523,14 +1523,14 @@ impl InputWeightPrediction { /// [`InputWeightPrediction::new`]. pub const P2PKH_UNCOMPRESSED_MAX: Self = InputWeightPrediction::from_slice(139, &[]); - /// Input weight prediction corresponding to spending of taproot output using the key and + /// Input weight prediction corresponding to spending of Taproot output using the key and /// default sighash. /// /// If the input in your transaction uses Taproot key spend you can use this instead of /// [`InputWeightPrediction::new`]. pub const P2TR_KEY_DEFAULT_SIGHASH: Self = InputWeightPrediction::from_slice(0, &[64]); - /// Input weight prediction corresponding to spending of taproot output using the key and + /// Input weight prediction corresponding to spending of Taproot output using the key and /// **non**-default sighash. /// /// If the input in your transaction uses Taproot key spend you can use this instead of diff --git a/bitcoin/src/crypto/sighash.rs b/bitcoin/src/crypto/sighash.rs index b5388adef..cf302e5ca 100644 --- a/bitcoin/src/crypto/sighash.rs +++ b/bitcoin/src/crypto/sighash.rs @@ -72,13 +72,13 @@ sha256t_hash_newtype! { /// Taproot-tagged hash with tag \"TapSighash\". /// - /// This hash type is used for computing taproot signature hash." + /// This hash type is used for computing Taproot signature hash." pub struct TapSighash(_); } impl_message_from_hash!(TapSighash); -/// Efficiently calculates signature hash message for legacy, segwit and taproot inputs. +/// Efficiently calculates signature hash message for legacy, segwit and Taproot inputs. #[derive(Debug)] pub struct SighashCache> { /// Access to transaction required for transaction introspection. Moreover, type @@ -86,17 +86,17 @@ pub struct SighashCache> { /// the latter in particular is necessary for [`SighashCache::witness_mut`]. tx: T, - /// Common cache for taproot and segwit inputs, `None` for legacy inputs. + /// Common cache for Taproot and segwit inputs, `None` for legacy inputs. common_cache: Option, /// Cache for segwit v0 inputs (the result of another round of sha256 on `common_cache`). segwit_cache: Option, - /// Cache for taproot v1 inputs. + /// Cache for Taproot v1 inputs. taproot_cache: Option, } -/// Common values cached between segwit and taproot inputs. +/// Common values cached between segwit and Taproot inputs. #[derive(Debug)] struct CommonCache { prevouts: sha256::Hash, @@ -115,7 +115,7 @@ struct SegwitCache { outputs: sha256d::Hash, } -/// Values cached for taproot inputs. +/// Values cached for Taproot inputs. #[derive(Debug)] struct TaprootCache { amounts: sha256::Hash, @@ -1166,7 +1166,7 @@ impl<'a> Encodable for Annex<'a> { } } -/// Error computing a taproot sighash. +/// Error computing a Taproot sighash. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum TaprootError { @@ -1196,7 +1196,7 @@ impl fmt::Display for TaprootError { PrevoutsSize(ref e) => write_err!(f, "prevouts size"; e), PrevoutsIndex(ref e) => write_err!(f, "prevouts index"; e), PrevoutsKind(ref e) => write_err!(f, "prevouts kind"; e), - InvalidSighashType(hash_ty) => write!(f, "invalid taproot sighash type : {} ", hash_ty), + InvalidSighashType(hash_ty) => write!(f, "invalid Taproot sighash type : {} ", hash_ty), } } } diff --git a/bitcoin/src/crypto/taproot.rs b/bitcoin/src/crypto/taproot.rs index a6950af2e..49050aa3c 100644 --- a/bitcoin/src/crypto/taproot.rs +++ b/bitcoin/src/crypto/taproot.rs @@ -1,8 +1,8 @@ // SPDX-License-Identifier: CC0-1.0 -//! Bitcoin taproot keys. +//! Bitcoin Taproot keys. //! -//! This module provides taproot keys used in Bitcoin (including reexporting secp256k1 keys). +//! This module provides Taproot keys used in Bitcoin (including reexporting secp256k1 keys). use core::fmt; @@ -13,7 +13,7 @@ use crate::prelude::Vec; use crate::sighash::{InvalidSighashTypeError, TapSighashType}; use crate::taproot::serialized_signature::{self, SerializedSignature}; -/// A BIP340-341 serialized taproot signature with the corresponding hash type. +/// A BIP340-341 serialized Taproot signature with the corresponding hash type. #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(crate = "actual_serde"))] @@ -96,7 +96,7 @@ pub enum SigFromSliceError { SighashType(InvalidSighashTypeError), /// A secp256k1 error. Secp256k1(secp256k1::Error), - /// Invalid taproot signature size + /// Invalid Taproot signature size InvalidSignatureSize(usize), } @@ -109,7 +109,7 @@ impl fmt::Display for SigFromSliceError { match *self { SighashType(ref e) => write_err!(f, "sighash"; e), Secp256k1(ref e) => write_err!(f, "secp256k1"; e), - InvalidSignatureSize(sz) => write!(f, "invalid taproot signature size: {}", sz), + InvalidSignatureSize(sz) => write!(f, "invalid Taproot signature size: {}", sz), } } } diff --git a/bitcoin/src/psbt/error.rs b/bitcoin/src/psbt/error.rs index 0bbcdf97e..142b2396e 100644 --- a/bitcoin/src/psbt/error.rs +++ b/bitcoin/src/psbt/error.rs @@ -83,13 +83,13 @@ pub enum Error { InvalidXOnlyPublicKey, /// Parsing error indicating invalid ECDSA signatures InvalidEcdsaSignature(crate::crypto::ecdsa::Error), - /// Parsing error indicating invalid taproot signatures + /// Parsing error indicating invalid Taproot signatures InvalidTaprootSignature(crate::crypto::taproot::SigFromSliceError), /// Parsing error indicating invalid control block InvalidControlBlock, /// Parsing error indicating invalid leaf version InvalidLeafVersion, - /// Parsing error indicating a taproot error + /// Parsing error indicating a Taproot error Taproot(&'static str), /// Taproot tree deserilaization error TapTree(crate::taproot::IncompleteBuilderError), @@ -147,11 +147,11 @@ impl fmt::Display for Error { InvalidSecp256k1PublicKey(ref e) => write_err!(f, "invalid secp256k1 public key"; e), InvalidXOnlyPublicKey => f.write_str("invalid xonly public key"), InvalidEcdsaSignature(ref e) => write_err!(f, "invalid ECDSA signature"; e), - InvalidTaprootSignature(ref e) => write_err!(f, "invalid taproot signature"; e), + InvalidTaprootSignature(ref e) => write_err!(f, "invalid Taproot signature"; e), InvalidControlBlock => f.write_str("invalid control block"), InvalidLeafVersion => f.write_str("invalid leaf version"), - Taproot(s) => write!(f, "taproot error - {}", s), - TapTree(ref e) => write_err!(f, "taproot tree error"; e), + Taproot(s) => write!(f, "Taproot error - {}", s), + TapTree(ref e) => write_err!(f, "Taproot tree error"; e), XPubKey(s) => write!(f, "xpub key error - {}", s), Version(s) => write!(f, "version error {}", s), PartialDataConsumption => diff --git a/bitcoin/src/psbt/map/input.rs b/bitcoin/src/psbt/map/input.rs index 0d6396d7e..f5a7e2f69 100644 --- a/bitcoin/src/psbt/map/input.rs +++ b/bitcoin/src/psbt/map/input.rs @@ -78,7 +78,7 @@ pub struct Input { /// including P2SH embedded ones. pub witness_utxo: Option, /// A map from public keys to their corresponding signature as would be - /// pushed to the stack from a scriptSig or witness for a non-taproot inputs. + /// pushed to the stack from a scriptSig or witness for a non-Taproot inputs. pub partial_sigs: BTreeMap, /// The sighash type to be used for this input. Signatures for this input /// must use the sighash type. @@ -109,7 +109,7 @@ pub struct Input { /// HAS256 hash to preimage map. #[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::btreemap_byte_values"))] pub hash256_preimages: BTreeMap>, - /// Serialized taproot signature with sighash type for key spend. + /// Serialized Taproot signature with sighash type for key spend. pub tap_key_sig: Option, /// Map of `|` with signature. #[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::btreemap_as_seq"))] @@ -132,7 +132,7 @@ pub struct Input { pub unknown: BTreeMap>, } -/// A Signature hash type for the corresponding input. As of taproot upgrade, the signature hash +/// A Signature hash type for the corresponding input. As of Taproot upgrade, the signature hash /// type can be either [`EcdsaSighashType`] or [`TapSighashType`] but it is not possible to know /// directly which signature hash type the user is dealing with. Therefore, the user is responsible /// for converting to/from [`PsbtSighashType`] from/to the desired signature hash type they need. @@ -169,7 +169,7 @@ impl FromStr for PsbtSighashType { fn from_str(s: &str) -> Result { // We accept strings of form: "SIGHASH_ALL" etc. // - // NB: some of Taproot sighash types are non-standard for pre-taproot + // NB: some of Taproot sighash types are non-standard for pre-Taproot // inputs. We also do not support SIGHASH_RESERVED in verbatim form // ("0xFF" string should be used instead). if let Ok(ty) = TapSighashType::from_str(s) { diff --git a/bitcoin/src/psbt/mod.rs b/bitcoin/src/psbt/mod.rs index 8d6ad58f7..1ae87642a 100644 --- a/bitcoin/src/psbt/mod.rs +++ b/bitcoin/src/psbt/mod.rs @@ -545,7 +545,7 @@ impl Psbt { Ok((Message::from(sighash), hash_ty)) } Tr => { - // This PSBT signing API is WIP, taproot to come shortly. + // This PSBT signing API is WIP, Taproot to come shortly. Err(SignError::Unsupported) } } @@ -899,7 +899,7 @@ pub enum OutputType { ShWsh, /// A pay-to-script-hash output excluding wrapped segwit (P2SH). Sh, - /// A taproot output (P2TR). + /// A Taproot output (P2TR). Tr, } @@ -954,7 +954,7 @@ pub enum SignError { SegwitV0Sighash(transaction::InputsIndexError), /// Sighash computation error (p2wpkh input). P2wpkhSighash(sighash::P2wpkhError), - /// Sighash computation error (taproot input). + /// Sighash computation error (Taproot input). TaprootError(sighash::TaprootError), /// Unable to determine the output type. UnknownOutputType, @@ -984,7 +984,7 @@ impl fmt::Display for SignError { NotWpkh => write!(f, "the scriptPubkey is not a P2WPKH script"), SegwitV0Sighash(ref e) => write_err!(f, "segwit v0 sighash"; e), P2wpkhSighash(ref e) => write_err!(f, "p2wpkh sighash"; e), - TaprootError(ref e) => write_err!(f, "taproot sighash"; e), + TaprootError(ref e) => write_err!(f, "Taproot sighash"; e), UnknownOutputType => write!(f, "unable to determine the output type"), KeyNotFound => write!(f, "unable to find key"), WrongSigningAlgorithm => @@ -1867,11 +1867,11 @@ mod tests { assert_eq!(err.to_string(), "invalid xonly public key"); let err = hex_psbt("70736274ff010071020000000127744ababf3027fe0d6cf23a96eee2efb188ef52301954585883e69b6624b2420000000000ffffffff02787c01000000000016001483a7e34bd99ff03a4962ef8a1a101bb295461ece606b042a010000001600147ac369df1b20e033d6116623957b0ac49f3c52e8000000000001012b00f2052a010000002251205a2c2cf5b52cf31f83ad2e8da63ff03183ecd8f609c7510ae8a48e03910a0757011342173bb3d36c074afb716fec6307a069a2e450b995f3c82785945ab8df0e24260dcd703b0cbf34de399184a9481ac2b3586db6601f026a77f7e4938481bc34751701aa000000").unwrap_err(); #[cfg(feature = "std")] - assert_eq!(err.to_string(), "invalid taproot signature"); + assert_eq!(err.to_string(), "invalid Taproot signature"); #[cfg(not(feature = "std"))] assert_eq!( err.to_string(), - "invalid taproot signature: invalid taproot signature size: 66" + "invalid Taproot signature: invalid Taproot signature size: 66" ); let err = hex_psbt("70736274ff010071020000000127744ababf3027fe0d6cf23a96eee2efb188ef52301954585883e69b6624b2420000000000ffffffff02787c01000000000016001483a7e34bd99ff03a4962ef8a1a101bb295461ece606b042a010000001600147ac369df1b20e033d6116623957b0ac49f3c52e8000000000001012b00f2052a010000002251205a2c2cf5b52cf31f83ad2e8da63ff03183ecd8f609c7510ae8a48e03910a0757221602fe349064c98d6e2a853fa3c9b12bd8b304a19c195c60efa7ee2393046d3fa2321900772b2da75600008001000080000000800100000000000000000000").unwrap_err(); assert_eq!(err.to_string(), "invalid xonly public key"); @@ -1889,19 +1889,19 @@ mod tests { ); let err = hex_psbt("70736274ff01005e02000000019bd48765230bf9a72e662001f972556e54f0c6f97feb56bcb5600d817f6995260100000000ffffffff0148e6052a01000000225120030da4fce4f7db28c2cb2951631e003713856597fe963882cb500e68112cca63000000000001012b00f2052a01000000225120c2247efbfd92ac47f6f40b8d42d169175a19fa9fa10e4a25d7f35eb4dd85b69241142cb13ac68248de806aa6a3659cf3c03eb6821d09c8114a4e868febde865bb6d2cd970e15f53fc0c82f950fd560ffa919b76172be017368a89913af074f400b094289756aa3739ccc689ec0fcf3a360be32cc0b59b16e93a1e8bb4605726b2ca7a3ff706c4176649632b2cc68e1f912b8a578e3719ce7710885c7a966f49bcd43cb01010000").unwrap_err(); #[cfg(feature = "std")] - assert_eq!(err.to_string(), "invalid taproot signature"); + assert_eq!(err.to_string(), "invalid Taproot signature"); #[cfg(not(feature = "std"))] assert_eq!( err.to_string(), - "invalid taproot signature: invalid taproot signature size: 66" + "invalid Taproot signature: invalid Taproot signature size: 66" ); let err = hex_psbt("70736274ff01005e02000000019bd48765230bf9a72e662001f972556e54f0c6f97feb56bcb5600d817f6995260100000000ffffffff0148e6052a01000000225120030da4fce4f7db28c2cb2951631e003713856597fe963882cb500e68112cca63000000000001012b00f2052a01000000225120c2247efbfd92ac47f6f40b8d42d169175a19fa9fa10e4a25d7f35eb4dd85b69241142cb13ac68248de806aa6a3659cf3c03eb6821d09c8114a4e868febde865bb6d2cd970e15f53fc0c82f950fd560ffa919b76172be017368a89913af074f400b093989756aa3739ccc689ec0fcf3a360be32cc0b59b16e93a1e8bb4605726b2ca7a3ff706c4176649632b2cc68e1f912b8a578e3719ce7710885c7a966f49bcd43cb0000").unwrap_err(); #[cfg(feature = "std")] - assert_eq!(err.to_string(), "invalid taproot signature"); + assert_eq!(err.to_string(), "invalid Taproot signature"); #[cfg(not(feature = "std"))] assert_eq!( err.to_string(), - "invalid taproot signature: invalid taproot signature size: 57" + "invalid Taproot signature: invalid Taproot signature size: 57" ); let err = hex_psbt("70736274ff01005e02000000019bd48765230bf9a72e662001f972556e54f0c6f97feb56bcb5600d817f6995260100000000ffffffff0148e6052a01000000225120030da4fce4f7db28c2cb2951631e003713856597fe963882cb500e68112cca63000000000001012b00f2052a01000000225120c2247efbfd92ac47f6f40b8d42d169175a19fa9fa10e4a25d7f35eb4dd85b6926315c150929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac06f7d62059e9497a1a4a267569d9876da60101aff38e3529b9b939ce7f91ae970115f2e490af7cc45c4f78511f36057ce5c5a5c56325a29fb44dfc203f356e1f80023202cb13ac68248de806aa6a3659cf3c03eb6821d09c8114a4e868febde865bb6d2acc00000").unwrap_err(); assert_eq!(err.to_string(), "invalid control block"); diff --git a/bitcoin/src/psbt/serialize.rs b/bitcoin/src/psbt/serialize.rs index 148fb61bc..e80ac6221 100644 --- a/bitcoin/src/psbt/serialize.rs +++ b/bitcoin/src/psbt/serialize.rs @@ -117,7 +117,7 @@ impl_psbt_hash_de_serialize!(TapNodeHash); impl_psbt_hash_de_serialize!(hash160::Hash); impl_psbt_hash_de_serialize!(sha256d::Hash); -// taproot +// Taproot impl_psbt_de_serialize!(Vec); impl Serialize for ScriptBuf { diff --git a/bitcoin/src/taproot/mod.rs b/bitcoin/src/taproot/mod.rs index 7c3276294..2101a81fe 100644 --- a/bitcoin/src/taproot/mod.rs +++ b/bitcoin/src/taproot/mod.rs @@ -2,7 +2,7 @@ //! Bitcoin Taproot. //! -//! This module provides support for taproot tagged hashes. +//! This module provides support for Taproot tagged hashes. pub mod merkle_branch; pub mod serialized_signature; @@ -41,7 +41,7 @@ sha256t_hash_newtype! { sha256t_hash_newtype! { pub struct TapBranchTag = hash_str("TapBranch"); - /// Tagged hash used in taproot trees. + /// Tagged hash used in Taproot trees. /// /// See BIP-340 for tagging rules. pub struct TapNodeHash(_); @@ -136,10 +136,10 @@ impl From for TapNodeHash { fn from(leaf: TapLeafHash) -> TapNodeHash { TapNodeHash::from_byte_array(leaf.to_byte_array()) } } -/// Maximum depth of a taproot tree script spend path. +/// Maximum depth of a Taproot tree script spend path. // https://github.com/bitcoin/bitcoin/blob/e826b22da252e0599c61d21c98ff89f366b3120f/src/script/interpreter.h#L229 pub const TAPROOT_CONTROL_MAX_NODE_COUNT: usize = 128; -/// Size of a taproot control node. +/// Size of a Taproot control node. // https://github.com/bitcoin/bitcoin/blob/e826b22da252e0599c61d21c98ff89f366b3120f/src/script/interpreter.h#L228 pub const TAPROOT_CONTROL_NODE_SIZE: usize = 32; /// Tapleaf mask for getting the leaf version from first byte of control block. @@ -161,7 +161,7 @@ pub const TAPROOT_CONTROL_MAX_SIZE: usize = // type alias for versioned tap script corresponding merkle proof type ScriptMerkleProofMap = BTreeMap<(ScriptBuf, LeafVersion), BTreeSet>; -/// Represents taproot spending information. +/// Represents Taproot spending information. /// /// Taproot output corresponds to a combination of a single public key condition (known as the /// internal key), and zero or more general conditions encoded in scripts organized in the form of a @@ -176,7 +176,7 @@ type ScriptMerkleProofMap = BTreeMap<(ScriptBuf, LeafVersion), BTreeSet( secp: &Secp256k1, @@ -264,7 +264,7 @@ impl TaprootSpendInfo { /// Computes the [`TaprootSpendInfo`] from `internal_key` and `node`. /// - /// This is useful when you want to manually build a taproot tree without using + /// This is useful when you want to manually build a Taproot tree without using /// [`TaprootBuilder`]. pub fn from_node_info( secp: &Secp256k1, @@ -329,7 +329,7 @@ impl From<&TaprootSpendInfo> for TapTweakHash { fn from(spend_info: &TaprootSpendInfo) -> TapTweakHash { spend_info.tap_tweak() } } -/// Builder for building taproot iteratively. Users can specify tap leaf or omitted/hidden branches +/// Builder for building Taproot iteratively. Users can specify tap leaf or omitted/hidden branches /// in a depth-first search (DFS) walk order to construct this tree. /// /// See Wikipedia for more details on [DFS](https://en.wikipedia.org/wiki/Depth-first_search). @@ -709,7 +709,7 @@ impl TapTree { /// Gets the inner [`NodeInfo`] of this tree root. pub fn into_node_info(self) -> NodeInfo { self.0 } - /// Returns [`TapTreeIter<'_>`] iterator for a taproot script tree, operating in DFS order over + /// Returns [`TapTreeIter<'_>`] iterator for a Taproot script tree, operating in DFS order over /// tree [`ScriptLeaf`]s. pub fn script_leaves(&self) -> ScriptLeaves { ScriptLeaves { leaf_iter: self.0.leaf_nodes() } } @@ -747,7 +747,7 @@ impl TryFrom for TapTree { } } -/// Iterator for a taproot script tree, operating in DFS order yielding [`ScriptLeaf`]. +/// Iterator for a Taproot script tree, operating in DFS order yielding [`ScriptLeaf`]. /// /// Returned by [`TapTree::script_leaves`]. [`TapTree`] does not allow hidden nodes, /// so this iterator is guaranteed to yield all known leaves. @@ -774,7 +774,7 @@ impl<'tree> DoubleEndedIterator for ScriptLeaves<'tree> { ScriptLeaf::from_leaf_node(self.leaf_iter.next_back()?) } } -/// Iterator for a taproot script tree, operating in DFS order yielding [`LeafNode`]. +/// Iterator for a Taproot script tree, operating in DFS order yielding [`LeafNode`]. /// /// Returned by [`NodeInfo::leaf_nodes`]. This can potentially yield hidden nodes. pub struct LeafNodes<'a> { @@ -798,7 +798,7 @@ impl<'tree> DoubleEndedIterator for LeafNodes<'tree> { #[inline] fn next_back(&mut self) -> Option { self.leaf_iter.next_back() } } -/// Represents the node information in taproot tree. In contrast to [`TapTree`], this +/// Represents the node information in Taproot tree. In contrast to [`TapTree`], this /// is allowed to have hidden leaves as children. /// /// Helper type used in merkle tree construction allowing one to build sparse merkle trees. The node @@ -940,7 +940,7 @@ impl<'de> serde::Deserialize<'de> for NodeInfo { } } NodeInfo::try_from(builder).map_err(|e| { - serde::de::Error::custom(format!("Incomplete taproot tree: {}", e)) + serde::de::Error::custom(format!("Incomplete Taproot tree: {}", e)) }) } } @@ -949,7 +949,7 @@ impl<'de> serde::Deserialize<'de> for NodeInfo { } } -/// Leaf node in a taproot tree. Can be either hidden or known. +/// Leaf node in a Taproot tree. Can be either hidden or known. #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(crate = "actual_serde"))] @@ -980,7 +980,7 @@ impl TapLeaf { } } -/// Store information about taproot leaf node. +/// Store information about Taproot leaf node. #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct LeafNode { /// The [`TapLeaf`] @@ -1009,7 +1009,7 @@ impl LeafNode { /// Computes a leaf hash for this [`ScriptLeaf`] if the leaf is known. /// - /// This [`TapLeafHash`] is useful while signing taproot script spends. + /// This [`TapLeafHash`] is useful while signing Taproot script spends. /// /// See [`LeafNode::node_hash`] for computing the [`TapNodeHash`] which returns the hidden node /// hash if the node is hidden. @@ -1049,7 +1049,7 @@ impl LeafNode { pub fn leaf(&self) -> &TapLeaf { &self.leaf } } -/// Script leaf node in a taproot tree along with the merkle proof to get this node. +/// Script leaf node in a Taproot tree along with the merkle proof to get this node. /// Returned by [`TapTree::script_leaves`] #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct ScriptLeaf<'leaf> { @@ -1096,8 +1096,8 @@ pub struct ControlBlock { impl ControlBlock { /// Decodes bytes representing a `ControlBlock`. /// - /// This is an extra witness element that provides the proof that taproot script pubkey is - /// correctly computed with some specified leaf hash. This is the last element in taproot + /// This is an extra witness element that provides the proof that Taproot script pubkey is + /// correctly computed with some specified leaf hash. This is the last element in Taproot /// witness when spending a output via script path. /// /// # Errors @@ -1301,7 +1301,7 @@ impl<'de> serde::Deserialize<'de> for LeafVersion { type Value = LeafVersion; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("a valid consensus-encoded taproot leaf version") + formatter.write_str("a valid consensus-encoded Taproot leaf version") } fn visit_u64(self, value: u64) -> Result @@ -1327,7 +1327,7 @@ impl<'de> serde::Deserialize<'de> for LeafVersion { } } -/// Detailed error type for taproot builder. +/// Detailed error type for Taproot builder. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum TaprootBuilderError { @@ -1380,7 +1380,7 @@ impl From for TaprootBuilderError { fn from(e: InvalidMerkleTreeDepthError) -> Self { Self::InvalidMerkleTreeDepth(e) } } -/// Detailed error type for taproot utilities. +/// Detailed error type for Taproot utilities. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum TaprootError { @@ -1392,7 +1392,7 @@ pub enum TaprootError { InvalidTaprootLeafVersion(InvalidTaprootLeafVersionError), /// Invalid control block size. InvalidControlBlockSize(InvalidControlBlockSizeError), - /// Invalid taproot internal key. + /// Invalid Taproot internal key. InvalidInternalKey(secp256k1::Error), /// Empty tap tree. EmptyTree,