diff --git a/bitcoin/examples/sign-tx-segwit-v0.rs b/bitcoin/examples/sign-tx-segwit-v0.rs index c98383e72..d3ab61030 100644 --- a/bitcoin/examples/sign-tx-segwit-v0.rs +++ b/bitcoin/examples/sign-tx-segwit-v0.rs @@ -108,7 +108,7 @@ fn receivers_address() -> Address { .expect("valid address for mainnet") } -/// Constructs a p2wpkh output locked to the key associated with `wpkh`. +/// Constructs a new p2wpkh output locked to the key associated with `wpkh`. /// /// An utxo is described by the `OutPoint` (txid and index within the transaction that it was /// created). Using the out point one can get the transaction by `txid` and using the `vout` get the diff --git a/bitcoin/examples/sign-tx-taproot.rs b/bitcoin/examples/sign-tx-taproot.rs index e19a0a2e0..b7e22aa4d 100644 --- a/bitcoin/examples/sign-tx-taproot.rs +++ b/bitcoin/examples/sign-tx-taproot.rs @@ -105,7 +105,7 @@ fn receivers_address() -> Address { .expect("valid address for mainnet") } -/// Constructs a p2wpkh output locked to the key associated with `wpkh`. +/// Constructs a new p2wpkh output locked to the key associated with `wpkh`. /// /// An utxo is described by the `OutPoint` (txid and index within the transaction that it was /// created). Using the out point one can get the transaction by `txid` and using the `vout` get the diff --git a/bitcoin/src/address/mod.rs b/bitcoin/src/address/mod.rs index 0615f9a98..7cf13dc32 100644 --- a/bitcoin/src/address/mod.rs +++ b/bitcoin/src/address/mod.rs @@ -202,7 +202,7 @@ pub enum KnownHrp { } impl KnownHrp { - /// Constructs a `KnownHrp` from `network`. + /// Constructs a new `KnownHrp` from `network`. fn from_network(network: Network) -> Self { use Network::*; @@ -213,7 +213,7 @@ impl KnownHrp { } } - /// Constructs a `KnownHrp` from a [`bech32::Hrp`]. + /// Constructs a new `KnownHrp` from a [`bech32::Hrp`]. fn from_hrp(hrp: Hrp) -> Result { if hrp == bech32::hrp::BC { Ok(Self::Mainnet) @@ -387,7 +387,7 @@ impl Address { /// Methods and functions that can be called only on `Address`. impl Address { - /// Constructs a pay to (compressed) public key hash address from a public key. + /// Constructs a new pay to (compressed) public key hash address from a public key. /// /// This is the preferred non-witness type address. #[inline] @@ -396,7 +396,7 @@ impl Address { Self(AddressInner::P2pkh { hash, network: network.into() }, PhantomData) } - /// Constructs a pay to script hash P2SH address from a script. + /// Constructs a new pay to script hash P2SH address from a script. /// /// This address type was introduced with BIP16 and is the popular type to implement multi-sig /// these days. @@ -409,7 +409,7 @@ impl Address { Ok(Address::p2sh_from_hash(hash, network)) } - /// Constructs a pay to script hash P2SH address from a script hash. + /// Constructs a new pay to script hash P2SH address from a script hash. /// /// # Warning /// @@ -419,7 +419,7 @@ impl Address { Self(AddressInner::P2sh { hash, network: network.into() }, PhantomData) } - /// Constructs a witness pay to public key address from a public key. + /// Constructs a new witness pay to public key address from a public key. /// /// This is the native segwit address type for an output redeemable with a single signature. pub fn p2wpkh(pk: CompressedPublicKey, hrp: impl Into) -> Self { @@ -427,7 +427,7 @@ impl Address { Address::from_witness_program(program, hrp) } - /// Constructs a pay to script address that embeds a witness pay to public key. + /// Constructs a new pay to script address that embeds a witness pay to public key. /// /// This is a segwit address type that looks familiar (as p2sh) to legacy clients. pub fn p2shwpkh(pk: CompressedPublicKey, network: impl Into) -> Address { @@ -436,7 +436,7 @@ impl Address { Address::p2sh_from_hash(script_hash, network) } - /// Constructs a witness pay to script hash address. + /// Constructs a new witness pay to script hash address. pub fn p2wsh( witness_script: &Script, hrp: impl Into, @@ -445,13 +445,13 @@ impl Address { Ok(Address::from_witness_program(program, hrp)) } - /// Constructs a witness pay to script hash address. + /// Constructs a new witness pay to script hash address. pub fn p2wsh_from_hash(hash: WScriptHash, hrp: impl Into) -> Address { let program = WitnessProgram::p2wsh_from_hash(hash); Address::from_witness_program(program, hrp) } - /// Constructs a pay to script address that embeds a witness pay to script hash address. + /// Constructs a new 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. pub fn p2shwsh( @@ -464,7 +464,7 @@ impl Address { Ok(Address::p2sh_from_hash(script_hash, network)) } - /// Constructs a pay to Taproot address from an untweaked key. + /// Constructs a new pay to Taproot address from an untweaked key. pub fn p2tr( secp: &Secp256k1, internal_key: UntweakedPublicKey, @@ -475,13 +475,13 @@ impl Address { Address::from_witness_program(program, hrp) } - /// Constructs a pay to Taproot address from a pre-tweaked output key. + /// Constructs a new 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) } - /// Constructs an address from an arbitrary witness program. + /// Constructs a new address from an arbitrary witness program. /// /// This only exists to support future witness versions. If you are doing normal mainnet things /// then you likely do not need this constructor. @@ -569,7 +569,7 @@ impl Address { /// pub fn is_spend_standard(&self) -> bool { self.address_type().is_some() } - /// Constructs an [`Address`] from an output script (`scriptPubkey`). + /// Constructs a new [`Address`] from an output script (`scriptPubkey`). pub fn from_script( script: &Script, params: impl AsRef, @@ -608,7 +608,7 @@ impl Address { } } - /// Constructs a URI string *bitcoin:address* optimized to be encoded in QR codes. + /// Constructs a new URI string *bitcoin:address* optimized to be encoded in QR codes. /// /// If the address is bech32, the address becomes uppercase. /// If the address is base58, the address is left mixed case. diff --git a/bitcoin/src/bip152.rs b/bitcoin/src/bip152.rs index 78b0efb54..98ecce7de 100644 --- a/bitcoin/src/bip152.rs +++ b/bitcoin/src/bip152.rs @@ -378,7 +378,7 @@ pub struct BlockTransactions { impl_consensus_encoding!(BlockTransactions, block_hash, transactions); impl BlockTransactions { - /// Constructs a [`BlockTransactions`] from a [`BlockTransactionsRequest`] and + /// Constructs a new [`BlockTransactions`] from a [`BlockTransactionsRequest`] and /// the corresponding full [`Block`] by providing all requested transactions. pub fn from_request( request: &BlockTransactionsRequest, diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs index a427541b3..6f609b59a 100644 --- a/bitcoin/src/bip32.rs +++ b/bitcoin/src/bip32.rs @@ -138,7 +138,7 @@ impl ChildNumber { /// Hardened child number with index 1. pub const ONE_HARDENED: Self = ChildNumber::Hardened { index: 1 }; - /// Construct a [`Normal`] from an index, returns an error if the index is not within + /// Constructs a new [`Normal`] from an index, returns an error if the index is not within /// [0, 2^31 - 1]. /// /// [`Normal`]: #variant.Normal @@ -150,7 +150,7 @@ impl ChildNumber { } } - /// Construct a [`Hardened`] from an index, returns an error if the index is not within + /// Constructs a new [`Hardened`] from an index, returns an error if the index is not within /// [0, 2^31 - 1]. /// /// [`Hardened`]: #variant.Hardened @@ -387,7 +387,7 @@ impl DerivationPath { /// is empty). True for `m` path. pub fn is_master(&self) -> bool { self.0.is_empty() } - /// Construct a new [DerivationPath] that is a child of this one. + /// Constructs a new [DerivationPath] that is a child of this one. pub fn child(&self, cn: ChildNumber) -> DerivationPath { let mut path = self.0.clone(); path.push(cn); @@ -451,7 +451,7 @@ impl DerivationPath { /// ``` pub fn to_u32_vec(&self) -> Vec { self.into_iter().map(|&el| el.into()).collect() } - /// Constructs a derivation path from a slice of u32s. + /// Constructs a new derivation path from a slice of u32s. /// ``` /// use bitcoin::bip32::DerivationPath; /// @@ -575,7 +575,7 @@ impl From for Error { } impl Xpriv { - /// Construct a new master key from a seed value + /// Constructs a new master key from a seed value pub fn new_master(network: impl Into, seed: &[u8]) -> Result { let mut hmac_engine: HmacEngine = HmacEngine::new(b"Bitcoin seed"); hmac_engine.input(seed); @@ -591,21 +591,21 @@ impl Xpriv { }) } - /// Constructs ECDSA compressed private key matching internal secret key representation. + /// Constructs a new ECDSA compressed private key matching internal secret key representation. #[deprecated(since = "TBD", note = "use `to_private_key()` instead")] pub fn to_priv(self) -> PrivateKey { self.to_private_key() } - /// Constructs ECDSA compressed private key matching internal secret key representation. + /// Constructs a new ECDSA compressed private key matching internal secret key representation. pub fn to_private_key(self) -> PrivateKey { PrivateKey { compressed: true, network: self.network, inner: self.private_key } } - /// Constructs new extended public key from this extended private key. + /// Constructs a new extended public key from this extended private key. pub fn to_xpub(&self, secp: &Secp256k1) -> Xpub { Xpub::from_xpriv(secp, self) } - /// Constructs BIP340 keypair for Schnorr signatures and Taproot use matching the internal + /// Constructs a new BIP340 keypair for Schnorr signatures and Taproot use matching the internal /// secret key representation. pub fn to_keypair(self, secp: &Secp256k1) -> Keypair { Keypair::from_seckey_slice(secp, &self.private_key[..]) @@ -730,13 +730,13 @@ impl Xpriv { } impl Xpub { - /// Constructs extended public key from an extended private key. + /// Constructs a new extended public key from an extended private key. #[deprecated(since = "TBD", note = "use `from_xpriv()` instead")] pub fn from_priv(secp: &Secp256k1, sk: &Xpriv) -> Xpub { Self::from_xpriv(secp, sk) } - /// Constructs extended public key from an extended private key. + /// Constructs a new extended public key from an extended private key. pub fn from_xpriv(secp: &Secp256k1, xpriv: &Xpriv) -> Xpub { Xpub { network: xpriv.network, @@ -748,19 +748,19 @@ impl Xpub { } } - /// Constructs ECDSA compressed public key matching internal public key representation. + /// Constructs a new ECDSA compressed public key matching internal public key representation. #[deprecated(since = "TBD", note = "use `to_public_key()` instead")] pub fn to_pub(self) -> CompressedPublicKey { self.to_public_key() } - /// Constructs ECDSA compressed public key matching internal public key representation. + /// Constructs a new ECDSA compressed public key matching internal public key representation. pub fn to_public_key(self) -> CompressedPublicKey { CompressedPublicKey(self.public_key) } - /// Constructs BIP340 x-only public key for BIP-340 signatures and Taproot use matching + /// Constructs a new BIP340 x-only public key for BIP-340 signatures and Taproot use matching /// the internal public key representation. #[deprecated(since = "TBD", note = "use `to_x_only_public_key()` instead")] pub fn to_x_only_pub(self) -> XOnlyPublicKey { self.to_x_only_public_key() } - /// Constructs BIP340 x-only public key for BIP-340 signatures and Taproot use matching + /// Constructs a new BIP340 x-only public key for BIP-340 signatures and Taproot use matching /// the internal public key representation. pub fn to_x_only_public_key(self) -> XOnlyPublicKey { XOnlyPublicKey::from(self.public_key) } diff --git a/bitcoin/src/blockdata/script/instruction.rs b/bitcoin/src/blockdata/script/instruction.rs index 32ef59945..8bf30cdd7 100644 --- a/bitcoin/src/blockdata/script/instruction.rs +++ b/bitcoin/src/blockdata/script/instruction.rs @@ -220,7 +220,7 @@ impl<'a> InstructionIndices<'a> { #[inline] pub fn as_script(&self) -> &'a Script { self.instructions.as_script() } - /// Constructs `Self` setting `pos` to 0. + /// Constructs a new `Self` setting `pos` to 0. pub(super) fn from_instructions(instructions: Instructions<'a>) -> Self { InstructionIndices { instructions, pos: 0 } } diff --git a/bitcoin/src/blockdata/script/mod.rs b/bitcoin/src/blockdata/script/mod.rs index 063dfcaa5..774e95c3b 100644 --- a/bitcoin/src/blockdata/script/mod.rs +++ b/bitcoin/src/blockdata/script/mod.rs @@ -95,7 +95,7 @@ hashes::hash_newtype! { impl_asref_push_bytes!(ScriptHash, WScriptHash); impl ScriptHash { - /// Constructs a `ScriptHash` after first checking the script size. + /// Constructs a new `ScriptHash` after first checking the script size. /// /// # 520-byte limitation on serialized script size /// @@ -113,7 +113,7 @@ impl ScriptHash { Ok(ScriptHash(hash160::Hash::hash(redeem_script.as_bytes()))) } - /// Constructs a `ScriptHash` from any script irrespective of script size. + /// Constructs a new `ScriptHash` from any script irrespective of script size. /// /// If you hash a script that exceeds 520 bytes in size and use it to create a P2SH output /// then the output will be unspendable (see [BIP-16]). @@ -125,7 +125,7 @@ impl ScriptHash { } impl WScriptHash { - /// Constructs a `WScriptHash` after first checking the script size. + /// Constructs a new `WScriptHash` after first checking the script size. /// /// # 10,000-byte limit on the witness script /// @@ -141,7 +141,7 @@ impl WScriptHash { Ok(WScriptHash(sha256::Hash::hash(witness_script.as_bytes()))) } - /// Constructs a `WScriptHash` from any script irrespective of script size. + /// Constructs a new `WScriptHash` from any script irrespective of script size. /// /// If you hash a script that exceeds 10,000 bytes in size and use it to create a Segwit /// output then the output will be unspendable (see [BIP-141]). @@ -200,7 +200,7 @@ impl TryFrom<&Script> for WScriptHash { } } -/// Constructs the script code used for spending a P2WPKH output. +/// Constructs a new [`ScriptBuf`] containing the script code used for spending a P2WPKH output. /// /// The `scriptCode` is described in [BIP143]. /// diff --git a/bitcoin/src/blockdata/script/owned.rs b/bitcoin/src/blockdata/script/owned.rs index ee7a1e83e..ccc82ca89 100644 --- a/bitcoin/src/blockdata/script/owned.rs +++ b/bitcoin/src/blockdata/script/owned.rs @@ -26,7 +26,7 @@ crate::internal_macros::define_extension_trait! { Builder::new().push_opcode(OP_RETURN).push_slice(data).into_script() } - /// Constructs a [`ScriptBuf`] from a hex string. + /// Constructs a new [`ScriptBuf`] from a hex string. fn from_hex(s: &str) -> Result { let v = Vec::from_hex(s)?; Ok(ScriptBuf::from_bytes(v)) diff --git a/bitcoin/src/blockdata/script/push_bytes.rs b/bitcoin/src/blockdata/script/push_bytes.rs index c0e20f382..d597cb79d 100644 --- a/bitcoin/src/blockdata/script/push_bytes.rs +++ b/bitcoin/src/blockdata/script/push_bytes.rs @@ -45,7 +45,7 @@ mod primitive { pub struct PushBytes([u8]); impl PushBytes { - /// Constructs `&PushBytes` without checking the length. + /// Constructs a new `&PushBytes` without checking the length. /// /// The caller is responsible for checking that the length is less than the 2^32. fn from_slice_unchecked(bytes: &[u8]) -> &Self { @@ -54,7 +54,7 @@ mod primitive { unsafe { &*(bytes as *const [u8] as *const PushBytes) } } - /// Constructs `&mut PushBytes` without checking the length. + /// Constructs a new `&mut PushBytes` without checking the length. /// /// The caller is responsible for checking that the length is less than the 2^32. fn from_mut_slice_unchecked(bytes: &mut [u8]) -> &mut Self { @@ -200,11 +200,11 @@ mod primitive { pub struct PushBytesBuf(Vec); impl PushBytesBuf { - /// Constructs a new empty `PushBytesBuf`. + /// Constructs an empty `PushBytesBuf`. #[inline] pub const fn new() -> Self { PushBytesBuf(Vec::new()) } - /// Constructs a new empty `PushBytesBuf` with reserved capacity. + /// Constructs an empty `PushBytesBuf` with reserved capacity. pub fn with_capacity(capacity: usize) -> Self { PushBytesBuf(Vec::with_capacity(capacity)) } /// Reserve capacity for `additional_capacity` bytes. diff --git a/bitcoin/src/blockdata/script/witness_program.rs b/bitcoin/src/blockdata/script/witness_program.rs index 98d18701b..3b0cd4cad 100644 --- a/bitcoin/src/blockdata/script/witness_program.rs +++ b/bitcoin/src/blockdata/script/witness_program.rs @@ -56,38 +56,38 @@ impl WitnessProgram { Ok(WitnessProgram { version, program }) } - /// Constructs a [`WitnessProgram`] from a 20 byte pubkey hash. + /// Constructs a new [`WitnessProgram`] from a 20 byte pubkey hash. fn new_p2wpkh(program: [u8; 20]) -> Self { WitnessProgram { version: WitnessVersion::V0, program: ArrayVec::from_slice(&program) } } - /// Constructs a [`WitnessProgram`] from a 32 byte script hash. + /// Constructs a new [`WitnessProgram`] from a 32 byte script hash. fn new_p2wsh(program: [u8; 32]) -> Self { WitnessProgram { version: WitnessVersion::V0, program: ArrayVec::from_slice(&program) } } - /// Constructs a [`WitnessProgram`] from a 32 byte serialize Taproot xonly pubkey. + /// Constructs a new [`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) } } - /// Constructs a [`WitnessProgram`] from `pk` for a P2WPKH output. + /// Constructs a new [`WitnessProgram`] from `pk` for a P2WPKH output. pub fn p2wpkh(pk: CompressedPublicKey) -> Self { let hash = pk.wpubkey_hash(); WitnessProgram::new_p2wpkh(hash.to_byte_array()) } - /// Constructs a [`WitnessProgram`] from `script` for a P2WSH output. + /// Constructs a new [`WitnessProgram`] from `script` for a P2WSH output. pub fn p2wsh(script: &Script) -> Result { script.wscript_hash().map(Self::p2wsh_from_hash) } - /// Constructs a [`WitnessProgram`] from `script` for a P2WSH output. + /// Constructs a new [`WitnessProgram`] from `script` for a P2WSH output. pub fn p2wsh_from_hash(hash: WScriptHash) -> Self { WitnessProgram::new_p2wsh(hash.to_byte_array()) } - /// Constructs a pay to Taproot address from an untweaked key. + /// Constructs a new pay to Taproot address from an untweaked key. pub fn p2tr( secp: &Secp256k1, internal_key: UntweakedPublicKey, @@ -98,7 +98,7 @@ impl WitnessProgram { WitnessProgram::new_p2tr(pubkey) } - /// Constructs a pay to Taproot address from a pre-tweaked output key. + /// Constructs a new 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 5015a165f..52004d7ff 100644 --- a/bitcoin/src/blockdata/transaction.rs +++ b/bitcoin/src/blockdata/transaction.rs @@ -174,7 +174,7 @@ crate::internal_macros::define_extension_trait! { /// There is no difference between base size vs total size for outputs. fn size(&self) -> usize { size_from_script_pubkey(&self.script_pubkey) } - /// Constructs a `TxOut` with given script and the smallest possible `value` that is **not** dust + /// Constructs a new `TxOut` with given script and the smallest possible `value` that is **not** dust /// per current Core policy. /// /// Dust depends on the -dustrelayfee value of the Bitcoin Core node you are broadcasting to. @@ -187,7 +187,7 @@ crate::internal_macros::define_extension_trait! { TxOut { value: script_pubkey.minimal_non_dust(), script_pubkey } } - /// Constructs a `TxOut` with given script and the smallest possible `value` that is **not** dust + /// Constructs a new `TxOut` with given script and the smallest possible `value` that is **not** dust /// per current Core policy. /// /// Dust depends on the -dustrelayfee value of the Bitcoin Core node you are broadcasting to. @@ -639,7 +639,7 @@ impl std::error::Error for IndexOutOfBoundsError { crate::internal_macros::define_extension_trait! { /// Extension functionality for the [`Version`] type. pub trait VersionExt impl for Version { - /// Constructs a non-standard transaction version. + /// Constructs a new non-standard transaction version. fn non_standard(version: i32) -> Version { Self(version) } /// Returns true if this transaction version number is considered standard. diff --git a/bitcoin/src/blockdata/witness.rs b/bitcoin/src/blockdata/witness.rs index d5a2a2af5..0844161cd 100644 --- a/bitcoin/src/blockdata/witness.rs +++ b/bitcoin/src/blockdata/witness.rs @@ -112,7 +112,7 @@ impl Encodable for Witness { crate::internal_macros::define_extension_trait! { /// Extension functionality for the [`Witness`] type. pub trait WitnessExt impl for Witness { - /// Constructs a witness required to spend a P2WPKH output. + /// Constructs a new witness required to spend a P2WPKH output. /// /// The witness will be made up of the DER encoded signature + sighash_type followed by the /// serialized public key. Also useful for spending a P2SH-P2WPKH output. @@ -125,7 +125,7 @@ crate::internal_macros::define_extension_trait! { witness } - /// Constructs a witness required to do a key path spend of a P2TR output. + /// Constructs a new witness required to do a key path spend of a P2TR output. fn p2tr_key_spend(signature: &taproot::Signature) -> Witness { let mut witness = Witness::new(); witness.push(signature.serialize()); diff --git a/bitcoin/src/consensus/error.rs b/bitcoin/src/consensus/error.rs index 72d6c222b..21fd89bbe 100644 --- a/bitcoin/src/consensus/error.rs +++ b/bitcoin/src/consensus/error.rs @@ -243,7 +243,7 @@ impl From for FromHexError { fn from(e: OddLengthStringError) -> Self { Self::OddLengthString(e) } } -/// Constructs a `Error::ParseFailed` error. +/// Constructs a new `Error::ParseFailed` error. // This whole variant should go away because of the inner string. pub(crate) fn parse_failed_error(msg: &'static str) -> Error { Error::Parse(ParseError::ParseFailed(msg)) diff --git a/bitcoin/src/consensus/serde.rs b/bitcoin/src/consensus/serde.rs index 66d06033d..8db3989b2 100644 --- a/bitcoin/src/consensus/serde.rs +++ b/bitcoin/src/consensus/serde.rs @@ -319,7 +319,7 @@ pub trait ByteDecoder<'a> { /// The decoder state. type Decoder: Iterator>; - /// Constructs the decoder from string. + /// Constructs a new decoder from string. fn from_str(s: &'a str) -> Result; } diff --git a/bitcoin/src/crypto/ecdsa.rs b/bitcoin/src/crypto/ecdsa.rs index 19fbb0f80..2755f0b51 100644 --- a/bitcoin/src/crypto/ecdsa.rs +++ b/bitcoin/src/crypto/ecdsa.rs @@ -32,7 +32,7 @@ pub struct Signature { } impl Signature { - /// Constructs an ECDSA Bitcoin signature for [`EcdsaSighashType::All`]. + /// Constructs a new ECDSA Bitcoin signature for [`EcdsaSighashType::All`]. pub fn sighash_all(signature: secp256k1::ecdsa::Signature) -> Signature { Signature { signature, sighash_type: EcdsaSighashType::All } } diff --git a/bitcoin/src/crypto/key.rs b/bitcoin/src/crypto/key.rs index feda9678f..6df019f5c 100644 --- a/bitcoin/src/crypto/key.rs +++ b/bitcoin/src/crypto/key.rs @@ -38,12 +38,12 @@ pub struct PublicKey { } impl PublicKey { - /// Constructs compressed ECDSA public key from the provided generic Secp256k1 public key. + /// Constructs a new compressed ECDSA public key from the provided generic Secp256k1 public key. pub fn new(key: impl Into) -> PublicKey { PublicKey { compressed: true, inner: key.into() } } - /// Constructs uncompressed (legacy) ECDSA public key from the provided generic Secp256k1 + /// Constructs a new uncompressed (legacy) ECDSA public key from the provided generic Secp256k1 /// public key. pub fn new_uncompressed(key: impl Into) -> PublicKey { PublicKey { compressed: false, inner: key.into() } @@ -416,20 +416,20 @@ pub struct PrivateKey { } impl PrivateKey { - /// Constructs new compressed ECDSA private key using the secp256k1 algorithm and + /// Constructs a new compressed ECDSA private key using the secp256k1 algorithm and /// a secure random number generator. #[cfg(feature = "rand-std")] pub fn generate(network: impl Into) -> PrivateKey { let secret_key = secp256k1::SecretKey::new(&mut rand::thread_rng()); PrivateKey::new(secret_key, network.into()) } - /// Constructs compressed ECDSA private key from the provided generic Secp256k1 private key + /// Constructs a new compressed ECDSA private key from the provided generic Secp256k1 private key /// and the specified network. pub fn new(key: secp256k1::SecretKey, network: impl Into) -> PrivateKey { PrivateKey { compressed: true, network: network.into(), inner: key } } - /// Constructs uncompressed (legacy) ECDSA private key from the provided generic Secp256k1 + /// Constructs a new uncompressed (legacy) ECDSA private key from the provided generic Secp256k1 /// private key and the specified network. pub fn new_uncompressed( key: secp256k1::SecretKey, @@ -438,7 +438,7 @@ impl PrivateKey { PrivateKey { compressed: false, network: network.into(), inner: key } } - /// Constructs a public key from this private key. + /// Constructs a new public key from this private key. pub fn public_key(&self, secp: &Secp256k1) -> PublicKey { PublicKey { compressed: self.compressed, diff --git a/bitcoin/src/crypto/sighash.rs b/bitcoin/src/crypto/sighash.rs index 7126010da..e6530921a 100644 --- a/bitcoin/src/crypto/sighash.rs +++ b/bitcoin/src/crypto/sighash.rs @@ -418,7 +418,7 @@ impl EcdsaSighashType { } } - /// Constructs a [`EcdsaSighashType`] from a raw `u32`. + /// Constructs a new [`EcdsaSighashType`] from a raw `u32`. /// /// **Note**: this replicates consensus behaviour, for current standardness rules correctness /// you probably want [`Self::from_standard`]. @@ -449,7 +449,7 @@ impl EcdsaSighashType { } } - /// Constructs a [`EcdsaSighashType`] from a raw `u32`. + /// Constructs a new [`EcdsaSighashType`] from a raw `u32`. /// /// # Errors /// @@ -506,7 +506,7 @@ impl TapSighashType { } } - /// Constructs a [`TapSighashType`] from a raw `u8`. + /// Constructs a new [`TapSighashType`] from a raw `u8`. pub fn from_consensus_u8(sighash_type: u8) -> Result { use TapSighashType::*; diff --git a/bitcoin/src/internal_macros.rs b/bitcoin/src/internal_macros.rs index 23185bb08..5292b716b 100644 --- a/bitcoin/src/internal_macros.rs +++ b/bitcoin/src/internal_macros.rs @@ -54,7 +54,7 @@ pub(crate) use impl_consensus_encoding; macro_rules! impl_array_newtype_stringify { ($t:ident, $len:literal) => { impl $t { - /// Constructs `Self` from a hex string. + /// Constructs a new `Self` from a hex string. pub fn from_hex(s: &str) -> Result { Ok($t($crate::hex::FromHex::from_hex(s)?)) } @@ -282,7 +282,7 @@ pub(crate) use define_extension_trait; macro_rules! impl_array_newtype { ($thing:ident, $ty:ty, $len:literal) => { impl $thing { - /// Constructs `Self` by wrapping `bytes`. + /// Constructs a new `Self` by wrapping `bytes`. #[inline] pub fn from_byte_array(bytes: [u8; $len]) -> Self { Self(bytes) } diff --git a/bitcoin/src/merkle_tree/block.rs b/bitcoin/src/merkle_tree/block.rs index c95ca96ff..e6c2c1578 100644 --- a/bitcoin/src/merkle_tree/block.rs +++ b/bitcoin/src/merkle_tree/block.rs @@ -35,7 +35,7 @@ pub struct MerkleBlock { } impl MerkleBlock { - /// Construct a MerkleBlock from a block, that contains proofs for specific txids. + /// Constructs a new MerkleBlock from a block, that contains proofs for specific txids. /// /// The `block` is a full block containing the header and transactions and `match_txids` is a /// function that returns true for the ids that should be included in the partial Merkle tree. @@ -60,7 +60,7 @@ impl MerkleBlock { /// 5d35549d88ac00000000").unwrap(); /// let block: Block = bitcoin::consensus::deserialize(&block_bytes).unwrap(); /// - /// // Construct a Merkle block containing a single transaction + /// // Constructs a new Merkle block containing a single transaction /// let txid = "5a4ebf66822b0b2d56bd9dc64ece0bc38ee7844a23ff1d7320a88c5fdb2ad3e2".parse::().unwrap(); /// let match_txids: Vec = vec![txid].into_iter().collect(); /// let mb = MerkleBlock::from_block_with_predicate(&block, |t| match_txids.contains(t)); @@ -79,7 +79,7 @@ impl MerkleBlock { Self::from_header_txids_with_predicate(&block.header, &block_txids, match_txids) } - /// Construct a MerkleBlock from the block's header and txids, that contain proofs for specific txids. + /// Constructs a new MerkleBlock from the block's header and txids, that contain proofs for specific txids. /// /// The `header` is the block header, `block_txids` is the full list of txids included in the block and /// `match_txids` is a function that returns true for the ids that should be included in the partial Merkle tree. @@ -185,7 +185,7 @@ impl PartialMerkleTree { /// Returns the transaction ids and internal hashes of the partial Merkle tree. pub fn hashes(&self) -> &Vec { &self.hashes } - /// Construct a partial Merkle tree + /// Constructs a new partial Merkle tree /// The `txids` are the transaction hashes of the block and the `matches` is the contains flags /// wherever a tx hash should be included in the proof. /// @@ -653,7 +653,7 @@ mod tests { assert_eq!(mb_hex, encode::serialize(&mb).to_lower_hex_string().as_str()); } - /// Construct a CMerkleBlock using a list of txids which will be found in the + /// Constructs a new CMerkleBlock using a list of txids which will be found in the /// given block. #[test] fn merkleblock_construct_from_txids_found() { @@ -692,7 +692,7 @@ mod tests { assert_eq!(index[1], 8); } - /// Construct a CMerkleBlock using a list of txids which will not be found in the given block + /// Constructs a new CMerkleBlock using a list of txids which will not be found in the given block #[test] fn merkleblock_construct_from_txids_not_found() { let block = get_block_13b8a(); diff --git a/bitcoin/src/network/mod.rs b/bitcoin/src/network/mod.rs index 19edd3920..12e6ab6a2 100644 --- a/bitcoin/src/network/mod.rs +++ b/bitcoin/src/network/mod.rs @@ -124,7 +124,7 @@ impl<'de> Deserialize<'de> for Network { } impl Network { - /// Constructs a `Network` from the magic bytes. + /// Constructs a new `Network` from the magic bytes. /// /// # Examples /// @@ -207,7 +207,7 @@ impl Network { /// ``` pub fn chain_hash(self) -> ChainHash { ChainHash::using_genesis_block_const(self) } - /// Constructs a `Network` from the chain hash (genesis block hash). + /// Constructs a new `Network` from the chain hash (genesis block hash). /// /// # Examples /// diff --git a/bitcoin/src/p2p/address.rs b/bitcoin/src/p2p/address.rs index 1430977dc..d30541d58 100644 --- a/bitcoin/src/p2p/address.rs +++ b/bitcoin/src/p2p/address.rs @@ -28,7 +28,7 @@ pub struct Address { const ONION: [u16; 3] = [0xFD87, 0xD87E, 0xEB43]; impl Address { - /// Construct an address message for a socket + /// Construct a new address message for a socket pub fn new(socket: &SocketAddr, services: ServiceFlags) -> Address { let (address, port) = match *socket { SocketAddr::V4(addr) => (addr.ip().to_ipv6_mapped().segments(), addr.port()), diff --git a/bitcoin/src/p2p/message.rs b/bitcoin/src/p2p/message.rs index 7ef76ef86..ff14b6ac3 100644 --- a/bitcoin/src/p2p/message.rs +++ b/bitcoin/src/p2p/message.rs @@ -301,7 +301,7 @@ impl NetworkMessage { } impl RawNetworkMessage { - /// Constructs a [RawNetworkMessage] + /// Constructs a new [RawNetworkMessage] pub fn new(magic: Magic, payload: NetworkMessage) -> Self { let mut engine = sha256d::Hash::engine(); let payload_len = payload.consensus_encode(&mut engine).expect("engine doesn't error"); diff --git a/bitcoin/src/p2p/mod.rs b/bitcoin/src/p2p/mod.rs index 8685a0390..074a225c2 100644 --- a/bitcoin/src/p2p/mod.rs +++ b/bitcoin/src/p2p/mod.rs @@ -228,7 +228,7 @@ impl Magic { /// Bitcoin regtest network magic bytes. pub const REGTEST: Self = Self([0xFA, 0xBF, 0xB5, 0xDA]); - /// Construct network magic from bytes. + /// Construct a new network magic from bytes. pub const fn from_bytes(bytes: [u8; 4]) -> Magic { Magic(bytes) } /// Get network magic bytes. diff --git a/bitcoin/src/pow.rs b/bitcoin/src/pow.rs index 24976f8b0..c43d9f8b8 100644 --- a/bitcoin/src/pow.rs +++ b/bitcoin/src/pow.rs @@ -340,13 +340,13 @@ impl_to_hex_from_lower_hex!(Target, |_| 64); define_extension_trait! { /// Extension functionality for the [`CompactTarget`] type. pub trait CompactTargetExt impl for CompactTarget { - /// Constructs a `CompactTarget` from a prefixed hex string. + /// Constructs a new `CompactTarget` from a prefixed hex string. fn from_hex(s: &str) -> Result { let target = parse::hex_u32_prefixed(s)?; Ok(Self::from_consensus(target)) } - /// Constructs a `CompactTarget` from an unprefixed hex string. + /// Constructs a new `CompactTarget` from an unprefixed hex string. fn from_unprefixed_hex(s: &str) -> Result { let target = parse::hex_u32_unprefixed(s)?; Ok(Self::from_consensus(target)) @@ -466,13 +466,13 @@ impl U256 { const ONE: U256 = U256(0, 1); - /// Constructs a `U256` from a prefixed hex string. + /// Constructs a new `U256` from a prefixed hex string. fn from_hex(s: &str) -> Result { let checked = parse::hex_remove_prefix(s)?; Ok(U256::from_hex_internal(checked)?) } - /// Constructs a `U256` from an unprefixed hex string. + /// Constructs a new `U256` from an unprefixed hex string. fn from_unprefixed_hex(s: &str) -> Result { let checked = parse::hex_check_unprefixed(s)?; Ok(U256::from_hex_internal(checked)?) @@ -496,7 +496,7 @@ impl U256 { Ok(U256(high, low)) } - /// Constructs `U256` from a big-endian array of `u8`s. + /// Constructs a new `U256` from a big-endian array of `u8`s. #[cfg_attr(all(test, mutate), mutate)] fn from_be_bytes(a: [u8; 32]) -> U256 { let (high, low) = split_in_half(a); @@ -505,7 +505,7 @@ impl U256 { U256(big, little) } - /// Constructs a `U256` from a little-endian array of `u8`s. + /// Constructs a new `U256` from a little-endian array of `u8`s. #[cfg_attr(all(test, mutate), mutate)] fn from_le_bytes(a: [u8; 32]) -> U256 { let (high, low) = split_in_half(a); @@ -1105,7 +1105,7 @@ mod tests { } impl U256 { - /// Constructs a U256 from a big-endian array of u64's + /// Constructs a new U256 from a big-endian array of u64's fn from_array(a: [u64; 4]) -> Self { let mut ret = U256::ZERO; ret.0 = (a[0] as u128) << 64 ^ (a[1] as u128); diff --git a/bitcoin/src/psbt/map/input.rs b/bitcoin/src/psbt/map/input.rs index 4e7e95260..cfe9cfb46 100644 --- a/bitcoin/src/psbt/map/input.rs +++ b/bitcoin/src/psbt/map/input.rs @@ -229,7 +229,7 @@ impl PsbtSighashType { } } - /// Constructs a [`PsbtSighashType`] from a raw `u32`. + /// Constructs a new [`PsbtSighashType`] from a raw `u32`. /// /// Allows construction of a non-standard or non-valid sighash flag /// ([`EcdsaSighashType`], [`TapSighashType`] respectively). diff --git a/bitcoin/src/psbt/mod.rs b/bitcoin/src/psbt/mod.rs index 5ec15053c..c9eac7165 100644 --- a/bitcoin/src/psbt/mod.rs +++ b/bitcoin/src/psbt/mod.rs @@ -103,7 +103,7 @@ impl Psbt { Ok(()) } - /// Constructs a PSBT from an unsigned transaction. + /// Constructs a new PSBT from an unsigned transaction. /// /// # Errors /// diff --git a/bitcoin/src/psbt/raw.rs b/bitcoin/src/psbt/raw.rs index fb49001d9..4502bde61 100644 --- a/bitcoin/src/psbt/raw.rs +++ b/bitcoin/src/psbt/raw.rs @@ -172,7 +172,7 @@ impl ProprietaryKey where Subtype: Copy + From + Into, { - /// Constructs full [Key] corresponding to this proprietary key type + /// Constructs a new full [Key] corresponding to this proprietary key type pub fn to_key(&self) -> Key { Key { type_value: 0xFC, key_data: serialize(self) } } } @@ -182,7 +182,7 @@ where { type Error = Error; - /// Constructs a [`ProprietaryKey`] from a [`Key`]. + /// Constructs a new [`ProprietaryKey`] from a [`Key`]. /// /// # Errors /// diff --git a/bitcoin/src/sign_message.rs b/bitcoin/src/sign_message.rs index 6965c3b5a..bbc2b44de 100644 --- a/bitcoin/src/sign_message.rs +++ b/bitcoin/src/sign_message.rs @@ -92,7 +92,7 @@ mod message_signing { } impl MessageSignature { - /// Construct a new [MessageSignature]. + /// Constructs a new [MessageSignature]. pub fn new(signature: RecoverableSignature, compressed: bool) -> MessageSignature { MessageSignature { signature, compressed } } @@ -106,7 +106,7 @@ mod message_signing { serialized } - /// Constructs a `MessageSignature` from a fixed-length array. + /// Constructs a new `MessageSignature` from a fixed-length array. pub fn from_byte_array(bytes: &[u8; 65]) -> Result { // We just check this here so we can safely subtract further. if bytes[0] < 27 { @@ -119,7 +119,7 @@ mod message_signing { }) } - /// Construct a `MessageSignature` from a byte slice. + /// Constructs a new `MessageSignature` from a byte slice. #[deprecated(since = "TBD", note = "use `from_byte_array` instead")] pub fn from_slice(bytes: &[u8]) -> Result { let byte_array: [u8; 65] = diff --git a/bitcoin/src/taproot/merkle_branch.rs b/bitcoin/src/taproot/merkle_branch.rs index fab67a22e..c629eacb6 100644 --- a/bitcoin/src/taproot/merkle_branch.rs +++ b/bitcoin/src/taproot/merkle_branch.rs @@ -63,7 +63,7 @@ impl TaprootMerkleBranch { } } - /// Constructs a Merkle proof from list of hashes. + /// Constructs a new Merkle proof from list of hashes. /// /// # Errors /// @@ -121,7 +121,7 @@ macro_rules! impl_try_from { impl TryFrom<$from> for TaprootMerkleBranch { type Error = InvalidMerkleTreeDepthError; - /// Constructs a Merkle proof from list of hashes. + /// Constructs a new Merkle proof from list of hashes. /// /// # Errors /// diff --git a/bitcoin/src/taproot/mod.rs b/bitcoin/src/taproot/mod.rs index a16a40bbf..b8bd00342 100644 --- a/bitcoin/src/taproot/mod.rs +++ b/bitcoin/src/taproot/mod.rs @@ -282,7 +282,7 @@ impl TaprootSpendInfo { info } - /// Constructs a [`ControlBlock`] for particular script with the given version. + /// Constructs a new [`ControlBlock`] for particular script with the given version. /// /// # Returns /// @@ -501,7 +501,7 @@ impl TaprootBuilder { self.branch.iter().flatten().any(|node| node.has_hidden_nodes) } - /// Constructs a [`TaprootSpendInfo`] with the given internal key. + /// Constructs a new [`TaprootSpendInfo`] with the given internal key. /// /// Returns the unmodified builder as Err if the builder is not finalizable. /// See also [`TaprootBuilder::is_finalizable`] @@ -702,7 +702,7 @@ impl TapTree { impl TryFrom for TapTree { type Error = IncompleteBuilderError; - /// Constructs [`TapTree`] from a [`TaprootBuilder`] if it is complete binary tree. + /// Constructs a new [`TapTree`] from a [`TaprootBuilder`] if it is complete binary tree. /// /// # Returns /// @@ -714,7 +714,7 @@ impl TryFrom for TapTree { impl TryFrom for TapTree { type Error = HiddenNodesError; - /// Constructs [`TapTree`] from a [`NodeInfo`] if it is complete binary tree. + /// Constructs a new [`TapTree`] from a [`NodeInfo`] if it is complete binary tree. /// /// # Returns /// @@ -971,12 +971,12 @@ pub struct LeafNode { } impl LeafNode { - /// Constructs an new [`ScriptLeaf`] from `script` and `ver` and no Merkle branch. + /// Constructs a new [`ScriptLeaf`] from `script` and `ver` and no Merkle branch. pub fn new_script(script: ScriptBuf, ver: LeafVersion) -> Self { Self { leaf: TapLeaf::Script(script, ver), merkle_branch: Default::default() } } - /// Constructs an new [`ScriptLeaf`] from `hash` and no Merkle branch. + /// Constructs a new [`ScriptLeaf`] from `hash` and no Merkle branch. pub fn new_hidden(hash: TapNodeHash) -> Self { Self { leaf: TapLeaf::Hidden(hash), merkle_branch: Default::default() } } @@ -1213,7 +1213,7 @@ pub enum LeafVersion { } impl LeafVersion { - /// Constructs a [`LeafVersion`] from consensus byte representation. + /// Constructs a new [`LeafVersion`] from consensus byte representation. /// /// # Errors /// diff --git a/bitcoin/src/taproot/serialized_signature.rs b/bitcoin/src/taproot/serialized_signature.rs index 73087a6c4..14cfa22be 100644 --- a/bitcoin/src/taproot/serialized_signature.rs +++ b/bitcoin/src/taproot/serialized_signature.rs @@ -131,7 +131,7 @@ impl<'a> TryFrom<&'a SerializedSignature> for Signature { } impl SerializedSignature { - /// Constructs `SerializedSignature` from data and length. + /// Constructs new `SerializedSignature` from data and length. /// /// # Panics /// @@ -159,7 +159,7 @@ impl SerializedSignature { Signature::from_slice(self) } - /// Construct a SerializedSignature from a Signature. + /// Constructs a new SerializedSignature from a Signature. /// (this serializes it) #[inline] pub fn from_signature(sig: Signature) -> SerializedSignature { sig.serialize() } diff --git a/chacha20_poly1305/src/chacha20.rs b/chacha20_poly1305/src/chacha20.rs index b647498cc..51d0e4b88 100644 --- a/chacha20_poly1305/src/chacha20.rs +++ b/chacha20_poly1305/src/chacha20.rs @@ -18,7 +18,7 @@ const CHACHA_BLOCKSIZE: usize = 64; pub struct Key([u8; 32]); impl Key { - /// Construct a new key. + /// Constructs a new key. pub const fn new(key: [u8; 32]) -> Self { Key(key) } } @@ -27,7 +27,7 @@ impl Key { pub struct Nonce([u8; 12]); impl Nonce { - /// Construct a new nonce. + /// Constructs a new nonce. pub const fn new(nonce: [u8; 12]) -> Self { Nonce(nonce) } } diff --git a/hashes/src/internal_macros.rs b/hashes/src/internal_macros.rs index 2e4701b38..c73246491 100644 --- a/hashes/src/internal_macros.rs +++ b/hashes/src/internal_macros.rs @@ -105,7 +105,7 @@ macro_rules! hash_type_no_default { impl Hash { const fn internal_new(arr: [u8; $bits / 8]) -> Self { Hash(arr) } - /// Constructs a hash from the underlying byte array. + /// Constructs a new hash from the underlying byte array. pub const fn from_byte_array(bytes: [u8; $bits / 8]) -> Self { Self::internal_new(bytes) } diff --git a/hashes/src/lib.rs b/hashes/src/lib.rs index 00ca7fd70..bc4061e72 100644 --- a/hashes/src/lib.rs +++ b/hashes/src/lib.rs @@ -279,7 +279,7 @@ pub trait Hash: /// For some reason Satoshi decided this should be true for `Sha256dHash`, so here we are. const DISPLAY_BACKWARD: bool = false; - /// Constructs a hash from the underlying byte array. + /// Constructs a new hash from the underlying byte array. fn from_byte_array(bytes: Self::Bytes) -> Self; /// Copies a byte slice into a hash object. diff --git a/hashes/src/macros.rs b/hashes/src/macros.rs index 2d37645c9..5520ffe90 100644 --- a/hashes/src/macros.rs +++ b/hashes/src/macros.rs @@ -137,7 +137,7 @@ macro_rules! hash_newtype { #[allow(unused)] // Private wrapper types may not need all functions. impl $newtype { - /// Constructs a hash from the underlying byte array. + /// Constructs a new hash from the underlying byte array. pub const fn from_byte_array(bytes: <$hash as $crate::Hash>::Bytes) -> Self { $newtype(<$hash>::from_byte_array(bytes)) } diff --git a/hashes/src/sha256.rs b/hashes/src/sha256.rs index deeae7d95..a7a7def71 100644 --- a/hashes/src/sha256.rs +++ b/hashes/src/sha256.rs @@ -198,7 +198,7 @@ impl Midstate { /// Deconstructs the [`Midstate`], returning the underlying byte array and number of bytes hashed. pub const fn to_parts(self) -> ([u8; 32], u64) { (self.bytes, self.bytes_hashed) } - /// Constructs midstate for tagged hashes. + /// Constructs a new midstate for tagged hashes. /// /// Warning: this function is inefficient. It should be only used in `const` context. /// diff --git a/hashes/src/sha256t.rs b/hashes/src/sha256t.rs index 8e6faab73..99d23f83f 100644 --- a/hashes/src/sha256t.rs +++ b/hashes/src/sha256t.rs @@ -25,7 +25,7 @@ where { const fn internal_new(arr: [u8; 32]) -> Self { Hash(arr, PhantomData) } - /// Constructs a hash from the underlying byte array. + /// Constructs a new hash from the underlying byte array. pub const fn from_byte_array(bytes: [u8; 32]) -> Self { Self::internal_new(bytes) } /// Zero cost conversion between a fixed length byte array shared reference and diff --git a/hashes/src/sha512.rs b/hashes/src/sha512.rs index 21640d243..401b31eaf 100644 --- a/hashes/src/sha512.rs +++ b/hashes/src/sha512.rs @@ -86,7 +86,7 @@ impl HashEngine { ret } - /// Constructs a hash engine suitable for use constructing a `sha512_256::HashEngine`. + /// Constructs a new hash engine suitable for use constructing a `sha512_256::HashEngine`. #[rustfmt::skip] pub(crate) const fn sha512_256() -> Self { HashEngine { @@ -99,7 +99,7 @@ impl HashEngine { } } - /// Constructs a hash engine suitable for constructing `sha384::HashEngine`. + /// Constructs a new hash engine suitable for constructing a `sha384::HashEngine`. #[rustfmt::skip] pub(crate) const fn sha384() -> Self { HashEngine { diff --git a/hashes/src/siphash24.rs b/hashes/src/siphash24.rs index c46e65aa8..b751604b6 100644 --- a/hashes/src/siphash24.rs +++ b/hashes/src/siphash24.rs @@ -209,7 +209,7 @@ impl Hash { /// Returns the (little endian) 64-bit integer representation of the hash value. pub fn to_u64(self) -> u64 { u64::from_le_bytes(self.0) } - /// Constructs a hash from its (little endian) 64-bit integer representation. + /// Constructs a new hash from its (little endian) 64-bit integer representation. pub fn from_u64(hash: u64) -> Hash { Hash(hash.to_le_bytes()) } } diff --git a/internals/src/array_vec.rs b/internals/src/array_vec.rs index 077ba8389..49fca83d8 100644 --- a/internals/src/array_vec.rs +++ b/internals/src/array_vec.rs @@ -25,7 +25,7 @@ mod safety_boundary { /// Constructs an empty `ArrayVec`. pub const fn new() -> Self { Self { len: 0, data: [MaybeUninit::uninit(); CAP] } } - /// Constructs an `ArrayVec` initialized with the contets of `slice`. + /// Constructs a new `ArrayVec` initialized with the contets of `slice`. /// /// # Panics /// diff --git a/internals/src/error/parse_error.rs b/internals/src/error/parse_error.rs index e54c7a1bd..4a2642706 100644 --- a/internals/src/error/parse_error.rs +++ b/internals/src/error/parse_error.rs @@ -25,7 +25,7 @@ macro_rules! parse_error_type { } impl $name { - /// Constructs `Self`. + /// Constructs a new `Self`. fn new>(input: T, source: $source) -> Self { $name { input: input.into(), diff --git a/io/src/lib.rs b/io/src/lib.rs index 708720fe1..b867be191 100644 --- a/io/src/lib.rs +++ b/io/src/lib.rs @@ -58,7 +58,7 @@ pub trait Read { Ok(()) } - /// Constructs an adapter which will read at most `limit` bytes. + /// Constructs a new adapter which will read at most `limit` bytes. #[inline] fn take(&mut self, limit: u64) -> Take { Take { reader: self, remaining: limit } } @@ -195,7 +195,7 @@ pub struct Cursor { } impl> Cursor { - /// Constructs a `Cursor` by wrapping `inner`. + /// Constructs a new `Cursor` by wrapping `inner`. #[inline] pub fn new(inner: T) -> Self { Cursor { inner, pos: 0 } } diff --git a/primitives/src/block.rs b/primitives/src/block.rs index 5950f3dcf..20475c942 100644 --- a/primitives/src/block.rs +++ b/primitives/src/block.rs @@ -120,7 +120,7 @@ impl Version { /// The value has the top three bits `001` which enables the use of version bits to signal for soft forks. const USE_VERSION_BITS: u32 = 0x2000_0000; - /// Constructs a [`Version`] from a signed 32 bit integer value. + /// Constructs a new [`Version`] from a signed 32 bit integer value. /// /// This is the data type used in consensus code in Bitcoin Core. #[inline] diff --git a/primitives/src/locktime/absolute.rs b/primitives/src/locktime/absolute.rs index 7fa12d768..e54dae56d 100644 --- a/primitives/src/locktime/absolute.rs +++ b/primitives/src/locktime/absolute.rs @@ -92,19 +92,19 @@ impl LockTime { /// The number of bytes that the locktime contributes to the size of a transaction. pub const SIZE: usize = 4; // Serialized length of a u32. - /// Constructs a `LockTime` from a prefixed hex string. + /// Constructs a new `LockTime` from a prefixed hex string. pub fn from_hex(s: &str) -> Result { let lock_time = parse::hex_u32_prefixed(s)?; Ok(Self::from_consensus(lock_time)) } - /// Constructs a `LockTime` from an unprefixed hex string. + /// Constructs a new `LockTime` from an unprefixed hex string. pub fn from_unprefixed_hex(s: &str) -> Result { let lock_time = parse::hex_u32_unprefixed(s)?; Ok(Self::from_consensus(lock_time)) } - /// Constructs a `LockTime` from an nLockTime value or the argument to OP_CHEKCLOCKTIMEVERIFY. + /// Constructs a new `LockTime` from an nLockTime value or the argument to OP_CHEKCLOCKTIMEVERIFY. /// /// # Examples /// @@ -124,7 +124,7 @@ impl LockTime { } } - /// Constructs a `LockTime` from `n`, expecting `n` to be a valid block height. + /// Constructs a new `LockTime` from `n`, expecting `n` to be a valid block height. /// /// # Note /// @@ -147,7 +147,7 @@ impl LockTime { Ok(LockTime::Blocks(height)) } - /// Constructs a `LockTime` from `n`, expecting `n` to be a valid block time. + /// Constructs a new `LockTime` from `n`, expecting `n` to be a valid block time. /// /// # Note /// diff --git a/primitives/src/locktime/relative.rs b/primitives/src/locktime/relative.rs index 16d32c4c5..aa5d61118 100644 --- a/primitives/src/locktime/relative.rs +++ b/primitives/src/locktime/relative.rs @@ -52,7 +52,7 @@ impl LockTime { /// The number of bytes that the locktime contributes to the size of a transaction. pub const SIZE: usize = 4; // Serialized length of a u32. - /// Constructs a `LockTime` from an nSequence value or the argument to OP_CHECKSEQUENCEVERIFY. + /// Constructs a new `LockTime` from an nSequence value or the argument to OP_CHECKSEQUENCEVERIFY. /// /// This method will **not** round-trip with [`Self::to_consensus_u32`], because relative /// locktimes only use some bits of the underlying `u32` value and discard the rest. If @@ -88,7 +88,7 @@ impl LockTime { } } - /// Constructs a `LockTime` from the sequence number of a Bitcoin input. + /// Constructs a new `LockTime` from the sequence number of a Bitcoin input. /// /// This method will **not** round-trip with [`Self::to_sequence`]. See the /// docs for [`Self::from_consensus`] for more information. @@ -101,11 +101,11 @@ impl LockTime { #[inline] pub fn to_sequence(&self) -> Sequence { Sequence::from_consensus(self.to_consensus_u32()) } - /// Constructs a `LockTime` from `n`, expecting `n` to be a 16-bit count of blocks. + /// Constructs a new `LockTime` from `n`, expecting `n` to be a 16-bit count of blocks. #[inline] pub const fn from_height(n: u16) -> Self { LockTime::Blocks(Height::from_height(n)) } - /// Constructs a `LockTime` from `n`, expecting `n` to be a count of 512-second intervals. + /// Constructs a new `LockTime` from `n`, expecting `n` to be a count of 512-second intervals. /// /// This function is a little awkward to use, and users may wish to instead use /// [`Self::from_seconds_floor`] or [`Self::from_seconds_ceil`]. @@ -114,7 +114,7 @@ impl LockTime { LockTime::Time(Time::from_512_second_intervals(intervals)) } - /// Construct a [`LockTime`] from seconds, converting the seconds into 512 second interval + /// Construct a new [`LockTime`] from seconds, converting the seconds into 512 second interval /// with truncating division. /// /// # Errors @@ -128,7 +128,7 @@ impl LockTime { } } - /// Construct a [`LockTime`] from seconds, converting the seconds into 512 second interval + /// Construct a new [`LockTime`] from seconds, converting the seconds into 512 second interval /// with ceiling division. /// /// # Errors diff --git a/primitives/src/opcodes.rs b/primitives/src/opcodes.rs index c69f7375d..498713fe2 100644 --- a/primitives/src/opcodes.rs +++ b/primitives/src/opcodes.rs @@ -495,7 +495,7 @@ macro_rules! ordinary_opcode { } } - /// Try to construct a [`Ordinary`] from an [`Opcode`]. + /// Constructs a new [`Ordinary`] from an [`Opcode`]. pub fn from_opcode(b: Opcode) -> Option { match b { $( $op => { Some(Ordinary::$op) } ),* diff --git a/primitives/src/pow.rs b/primitives/src/pow.rs index f39e7a360..b4a25f340 100644 --- a/primitives/src/pow.rs +++ b/primitives/src/pow.rs @@ -23,7 +23,7 @@ use core::fmt; pub struct CompactTarget(u32); impl CompactTarget { - /// Constructs a [`CompactTarget`] from a consensus encoded `u32`. + /// Constructs a new [`CompactTarget`] from a consensus encoded `u32`. pub fn from_consensus(bits: u32) -> Self { Self(bits) } /// Returns the consensus encoded `u32` representation of this [`CompactTarget`]. diff --git a/primitives/src/sequence.rs b/primitives/src/sequence.rs index 0654b59dc..5f0233c9c 100644 --- a/primitives/src/sequence.rs +++ b/primitives/src/sequence.rs @@ -126,25 +126,25 @@ impl Sequence { self.is_relative_lock_time() & (self.0 & Sequence::LOCK_TYPE_MASK > 0) } - /// Constructs a `Sequence` from a prefixed hex string. + /// Constructs a new `Sequence` from a prefixed hex string. #[cfg(feature = "alloc")] pub fn from_hex(s: &str) -> Result { let lock_time = parse::hex_u32_prefixed(s)?; Ok(Self::from_consensus(lock_time)) } - /// Constructs a `Sequence` from an unprefixed hex string. + /// Constructs a new `Sequence` from an unprefixed hex string. #[cfg(feature = "alloc")] pub fn from_unprefixed_hex(s: &str) -> Result { let lock_time = parse::hex_u32_unprefixed(s)?; Ok(Self::from_consensus(lock_time)) } - /// Constructs a relative lock-time using block height. + /// Constructs a new relative lock-time using block height. #[inline] pub fn from_height(height: u16) -> Self { Sequence(u32::from(height)) } - /// Constructs a relative lock-time using time intervals where each interval is equivalent + /// Constructs a new relative lock-time using time intervals where each interval is equivalent /// to 512 seconds. /// /// Encoding finer granularity of time for relative lock-times is not supported in Bitcoin @@ -153,7 +153,7 @@ impl Sequence { Sequence(u32::from(intervals) | Sequence::LOCK_TYPE_MASK) } - /// Constructs a relative lock-time from seconds, converting the seconds into 512 second + /// Constructs a new relative lock-time from seconds, converting the seconds into 512 second /// interval with floor division. /// /// Will return an error if the input cannot be encoded in 16 bits. @@ -167,7 +167,7 @@ impl Sequence { } } - /// Constructs a relative lock-time from seconds, converting the seconds into 512 second + /// Constructs a new relative lock-time from seconds, converting the seconds into 512 second /// interval with ceiling division. /// /// Will return an error if the input cannot be encoded in 16 bits. @@ -181,7 +181,7 @@ impl Sequence { } } - /// Constructs a sequence from a u32 value. + /// Constructs a new sequence from a u32 value. #[inline] pub fn from_consensus(n: u32) -> Self { Sequence(n) } @@ -189,7 +189,7 @@ impl Sequence { #[inline] pub fn to_consensus_u32(self) -> u32 { self.0 } - /// Constructs a [`relative::LockTime`] from this [`Sequence`] number. + /// Constructs a new [`relative::LockTime`] from this [`Sequence`] number. #[inline] #[cfg(feature = "alloc")] pub fn to_relative_lock_time(&self) -> Option { diff --git a/primitives/src/witness.rs b/primitives/src/witness.rs index 0e0036d18..95737c7ca 100644 --- a/primitives/src/witness.rs +++ b/primitives/src/witness.rs @@ -72,7 +72,7 @@ impl Witness { Witness { content, witness_elements, indices_start } } - /// Constructs a [`Witness`] object from a slice of bytes slices where each slice is a witness item. + /// Constructs a new [`Witness`] object from a slice of bytes slices where each slice is a witness item. pub fn from_slice>(slice: &[T]) -> Self { let witness_elements = slice.len(); let index_size = witness_elements * 4; diff --git a/units/src/amount/signed.rs b/units/src/amount/signed.rs index 9c1103cdb..2d763335f 100644 --- a/units/src/amount/signed.rs +++ b/units/src/amount/signed.rs @@ -46,7 +46,7 @@ impl SignedAmount { /// The maximum value of an amount. pub const MAX: SignedAmount = SignedAmount(i64::MAX); - /// Constructs a [`SignedAmount`] with satoshi precision and the given number of satoshis. + /// Constructs a new [`SignedAmount`] with satoshi precision and the given number of satoshis. pub const fn from_sat(satoshi: i64) -> SignedAmount { SignedAmount(satoshi) } /// Gets the number of satoshis in this [`SignedAmount`]. @@ -154,7 +154,7 @@ impl SignedAmount { SignedAmount::from_str_in(&value.to_string(), denom) } - /// Constructs an object that implements [`fmt::Display`] using specified denomination. + /// Constructs a new object that implements [`fmt::Display`] using specified denomination. pub fn display_in(self, denomination: Denomination) -> Display { Display { sats_abs: self.unsigned_abs().to_sat(), @@ -163,7 +163,7 @@ impl SignedAmount { } } - /// Constructs an object that implements [`fmt::Display`] dynamically selecting denomination. + /// Constructs a new object that implements [`fmt::Display`] dynamically selecting denomination. /// /// This will use BTC for values greater than or equal to 1 BTC and satoshis otherwise. To /// avoid confusion the denomination is always shown. diff --git a/units/src/amount/unsigned.rs b/units/src/amount/unsigned.rs index 90c5945d3..74628e313 100644 --- a/units/src/amount/unsigned.rs +++ b/units/src/amount/unsigned.rs @@ -56,7 +56,7 @@ impl Amount { /// The number of bytes that an amount contributes to the size of a transaction. pub const SIZE: usize = 8; // Serialized length of a u64. - /// Constructs an [`Amount`] with satoshi precision and the given number of satoshis. + /// Constructs a new [`Amount`] with satoshi precision and the given number of satoshis. pub const fn from_sat(satoshi: u64) -> Amount { Amount(satoshi) } /// Gets the number of satoshis in this [`Amount`]. @@ -160,7 +160,7 @@ impl Amount { Amount::from_str_in(&value.to_string(), denom) } - /// Constructs an object that implements [`fmt::Display`] using specified denomination. + /// Constructs a new object that implements [`fmt::Display`] using specified denomination. pub fn display_in(self, denomination: Denomination) -> Display { Display { sats_abs: self.to_sat(), @@ -169,7 +169,7 @@ impl Amount { } } - /// Constructs an object that implements [`fmt::Display`] dynamically selecting denomination. + /// Constructs a new object that implements [`fmt::Display`] dynamically selecting denomination. /// /// This will use BTC for values greater than or equal to 1 BTC and satoshis otherwise. To /// avoid confusion the denomination is always shown. diff --git a/units/src/block.rs b/units/src/block.rs index 41303bf78..7b407e33c 100644 --- a/units/src/block.rs +++ b/units/src/block.rs @@ -41,7 +41,7 @@ impl BlockHeight { /// The maximum block height. pub const MAX: Self = BlockHeight(u32::MAX); - /// Constructs a block height from a `u32`. + /// Constructs a new block height from a `u32`. // Because From is not const. pub const fn from_u32(inner: u32) -> Self { Self(inner) } @@ -108,7 +108,7 @@ impl BlockInterval { /// The maximum block interval. pub const MAX: Self = BlockInterval(u32::MAX); - /// Constructs a block interval from a `u32`. + /// Constructs a new block interval from a `u32`. // Because From is not const. pub const fn from_u32(inner: u32) -> Self { Self(inner) } diff --git a/units/src/fee_rate.rs b/units/src/fee_rate.rs index b3974422c..3cf0269b9 100644 --- a/units/src/fee_rate.rs +++ b/units/src/fee_rate.rs @@ -44,10 +44,10 @@ impl FeeRate { /// Fee rate used to compute dust amount. pub const DUST: FeeRate = FeeRate::from_sat_per_vb_unchecked(3); - /// Constructs [`FeeRate`] from satoshis per 1000 weight units. + /// Constructs a new [`FeeRate`] from satoshis per 1000 weight units. pub const fn from_sat_per_kwu(sat_kwu: u64) -> Self { FeeRate(sat_kwu) } - /// Constructs [`FeeRate`] from satoshis per virtual bytes. + /// Constructs a new [`FeeRate`] from satoshis per virtual bytes. /// /// # Errors /// @@ -59,7 +59,7 @@ impl FeeRate { Some(FeeRate(sat_vb.checked_mul(1000 / 4)?)) } - /// Constructs [`FeeRate`] from satoshis per virtual bytes without overflow check. + /// Constructs a new [`FeeRate`] from satoshis per virtual bytes without overflow check. pub const fn from_sat_per_vb_unchecked(sat_vb: u64) -> Self { FeeRate(sat_vb * (1000 / 4)) } /// Returns raw fee rate. diff --git a/units/src/locktime/absolute.rs b/units/src/locktime/absolute.rs index 0266171ff..4ee23e3dd 100644 --- a/units/src/locktime/absolute.rs +++ b/units/src/locktime/absolute.rs @@ -35,7 +35,7 @@ impl Height { /// The maximum absolute block height. pub const MAX: Self = Height(LOCK_TIME_THRESHOLD - 1); - /// Constructs a [`Height`] from a hex string. + /// Constructs a new [`Height`] from a hex string. /// /// The input string may or may not contain a typical hex prefix e.g., `0x`. pub fn from_hex(s: &str) -> Result { @@ -133,7 +133,7 @@ impl Time { /// The maximum absolute block time (Sun Feb 07 2106 06:28:15 GMT+0000). pub const MAX: Self = Time(u32::MAX); - /// Constructs a [`Time`] from a hex string. + /// Constructs a new [`Time`] from a hex string. /// /// The input string may or may not contain a typical hex prefix e.g., `0x`. pub fn from_hex(s: &str) -> Result { parse_hex(s, Self::from_consensus) } @@ -256,10 +256,10 @@ pub struct ConversionError { } impl ConversionError { - /// Constructs a `ConversionError` from an invalid `n` when expecting a height value. + /// Constructs a new `ConversionError` from an invalid `n` when expecting a height value. const fn invalid_height(n: u32) -> Self { Self { unit: LockTimeUnit::Blocks, input: n } } - /// Constructs a `ConversionError` from an invalid `n` when expecting a time value. + /// Constructs a new `ConversionError` from an invalid `n` when expecting a time value. const fn invalid_time(n: u32) -> Self { Self { unit: LockTimeUnit::Seconds, input: n } } } diff --git a/units/src/locktime/relative.rs b/units/src/locktime/relative.rs index 5f8c7f7e3..9b98e38c4 100644 --- a/units/src/locktime/relative.rs +++ b/units/src/locktime/relative.rs @@ -22,7 +22,7 @@ impl Height { /// The maximum relative block height. pub const MAX: Self = Height(u16::MAX); - /// Construct a [`Height`] using a count of blocks. + /// Constructs a new [`Height`] using a count of blocks. #[inline] pub const fn from_height(blocks: u16) -> Self { Height(blocks) } @@ -66,13 +66,13 @@ impl Time { /// The maximum relative block time (33,554,432 seconds or approx 388 days). pub const MAX: Self = Time(u16::MAX); - /// Constructs a [`Time`] using time intervals where each interval is equivalent to 512 seconds. + /// Constructs a new [`Time`] using time intervals where each interval is equivalent to 512 seconds. /// /// Encoding finer granularity of time for relative lock-times is not supported in Bitcoin. #[inline] pub const fn from_512_second_intervals(intervals: u16) -> Self { Time(intervals) } - /// Constructs a [`Time`] from seconds, converting the seconds into 512 second interval with + /// Constructs a new [`Time`] from seconds, converting the seconds into 512 second interval with /// truncating division. /// /// # Errors @@ -89,7 +89,7 @@ impl Time { } } - /// Constructs a [`Time`] from seconds, converting the seconds into 512 second intervals with + /// Constructs a new [`Time`] from seconds, converting the seconds into 512 second intervals with /// ceiling division. /// /// # Errors diff --git a/units/src/parse.rs b/units/src/parse.rs index d7888c2c5..84917406d 100644 --- a/units/src/parse.rs +++ b/units/src/parse.rs @@ -378,7 +378,7 @@ pub struct MissingPrefixError { } impl MissingPrefixError { - /// Constructs an error from the string with the missing prefix. + /// Constructs a new error from the string with the missing prefix. pub(crate) fn new(hex: &str) -> Self { Self { hex: hex.into() } } } @@ -398,7 +398,7 @@ pub struct ContainsPrefixError { } impl ContainsPrefixError { - /// Constructs an error from the string that contains the prefix. + /// Constructs a new error from the string that contains the prefix. pub(crate) fn new(hex: &str) -> Self { Self { hex: hex.into() } } } diff --git a/units/src/weight.rs b/units/src/weight.rs index f9022ed38..b43d76341 100644 --- a/units/src/weight.rs +++ b/units/src/weight.rs @@ -45,21 +45,21 @@ impl Weight { /// The minimum transaction weight for a valid serialized transaction. pub const MIN_TRANSACTION: Weight = Weight(Self::WITNESS_SCALE_FACTOR * 60); - /// Directly constructs [`Weight`] from weight units. + /// Constructs a new [`Weight`] from weight units. pub const fn from_wu(wu: u64) -> Self { Weight(wu) } - /// Directly constructs [`Weight`] from usize weight units. + /// Constructs a new [`Weight`] from usize weight units. pub const fn from_wu_usize(wu: usize) -> Self { Weight(wu as u64) } - /// Constructs [`Weight`] from kilo weight units returning [`None`] if an overflow occurred. + /// Constructs a new [`Weight`] from kilo weight units returning [`None`] if an overflow occurred. pub fn from_kwu(wu: u64) -> Option { wu.checked_mul(1000).map(Weight) } - /// Constructs [`Weight`] from virtual bytes, returning [`None`] if an overflow occurred. + /// Constructs a new [`Weight`] from virtual bytes, returning [`None`] if an overflow occurred. pub fn from_vb(vb: u64) -> Option { vb.checked_mul(Self::WITNESS_SCALE_FACTOR).map(Weight::from_wu) } - /// Constructs [`Weight`] from virtual bytes panicking if an overflow occurred. + /// Constructs a new [`Weight`] from virtual bytes panicking if an overflow occurred. /// /// # Panics /// @@ -71,13 +71,13 @@ impl Weight { } } - /// Constructs [`Weight`] from virtual bytes without an overflow check. + /// Constructs a new [`Weight`] from virtual bytes without an overflow check. pub const fn from_vb_unchecked(vb: u64) -> Self { Weight::from_wu(vb * 4) } - /// Constructs [`Weight`] from witness size. + /// Constructs a new [`Weight`] from witness size. pub const fn from_witness_data_size(witness_size: u64) -> Self { Weight(witness_size) } - /// Constructs [`Weight`] from non-witness size. + /// Constructs a new [`Weight`] from non-witness size. pub const fn from_non_witness_data_size(non_witness_size: u64) -> Self { Weight(non_witness_size * Self::WITNESS_SCALE_FACTOR) }