diff --git a/bitcoin/examples/sign-tx-segwit-v0.rs b/bitcoin/examples/sign-tx-segwit-v0.rs index 60ab1e551..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") } -/// Creates 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 3b55edded..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") } -/// Creates 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 622eacea6..7cf13dc32 100644 --- a/bitcoin/src/address/mod.rs +++ b/bitcoin/src/address/mod.rs @@ -202,7 +202,7 @@ pub enum KnownHrp { } impl KnownHrp { - /// Creates a `KnownHrp` from `network`. + /// Constructs a new `KnownHrp` from `network`. fn from_network(network: Network) -> Self { use Network::*; @@ -213,7 +213,7 @@ impl KnownHrp { } } - /// Creates 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 { - /// Creates 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) } - /// Creates 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)) } - /// Creates 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) } - /// Creates 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) } - /// Creates 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) } - /// Creates 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)) } - /// Creates 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) } - /// Creates 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)) } - /// Creates 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) } - /// Creates 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) } - /// Creates 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 { } } - /// Creates 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 3cad34e46..98ecce7de 100644 --- a/bitcoin/src/bip152.rs +++ b/bitcoin/src/bip152.rs @@ -192,7 +192,7 @@ impl Encodable for HeaderAndShortIds { } impl HeaderAndShortIds { - /// Creates a new [`HeaderAndShortIds`] from a full block. + /// Constructs a new [`HeaderAndShortIds`] from a full block. /// /// The version number must be either 1 or 2. /// @@ -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/bip158.rs b/bitcoin/src/bip158.rs index 6ea426174..8c5499ad5 100644 --- a/bitcoin/src/bip158.rs +++ b/bitcoin/src/bip158.rs @@ -122,7 +122,7 @@ impl FilterHash { } impl BlockFilter { - /// Creates a new filter from pre-computed data. + /// Constructs a new filter from pre-computed data. pub fn new(content: &[u8]) -> BlockFilter { BlockFilter { content: content.to_vec() } } /// Computes a SCRIPT_FILTER that contains spent and output scripts. @@ -182,7 +182,7 @@ pub struct BlockFilterWriter<'a, W> { } impl<'a, W: Write> BlockFilterWriter<'a, W> { - /// Creates a new [`BlockFilterWriter`] from `block`. + /// Constructs a new [`BlockFilterWriter`] from `block`. pub fn new(writer: &'a mut W, block: &'a Block) -> BlockFilterWriter<'a, W> { let block_hash_as_int = block.block_hash().to_byte_array(); let k0 = u64::from_le_bytes(block_hash_as_int[0..8].try_into().expect("8 byte slice")); @@ -237,7 +237,7 @@ pub struct BlockFilterReader { } impl BlockFilterReader { - /// Creates a new [`BlockFilterReader`] from `block_hash`. + /// Constructs a new [`BlockFilterReader`] from `block_hash`. pub fn new(block_hash: BlockHash) -> BlockFilterReader { let block_hash_as_int = block_hash.to_byte_array(); let k0 = u64::from_le_bytes(block_hash_as_int[0..8].try_into().expect("8 byte slice")); @@ -273,7 +273,7 @@ pub struct GcsFilterReader { } impl GcsFilterReader { - /// Creates a new [`GcsFilterReader`] with specific seed to siphash. + /// Constructs a new [`GcsFilterReader`] with specific seed to siphash. pub fn new(k0: u64, k1: u64, m: u64, p: u8) -> GcsFilterReader { GcsFilterReader { filter: GcsFilter::new(k0, k1, p), m } } @@ -378,7 +378,7 @@ pub struct GcsFilterWriter<'a, W> { } impl<'a, W: Write> GcsFilterWriter<'a, W> { - /// Creates a new [`GcsFilterWriter`] wrapping a generic writer, with specific seed to siphash. + /// Constructs a new [`GcsFilterWriter`] wrapping a generic writer, with specific seed to siphash. pub fn new(writer: &'a mut W, k0: u64, k1: u64, m: u64, p: u8) -> GcsFilterWriter<'a, W> { GcsFilterWriter { filter: GcsFilter::new(k0, k1, p), writer, elements: BTreeSet::new(), m } } @@ -425,7 +425,7 @@ struct GcsFilter { } impl GcsFilter { - /// Creates a new [`GcsFilter`]. + /// Constructs a new [`GcsFilter`]. fn new(k0: u64, k1: u64, p: u8) -> GcsFilter { GcsFilter { k0, k1, p } } /// Golomb-Rice encodes a number `n` to a bit stream (parameter 2^k). @@ -476,7 +476,7 @@ pub struct BitStreamReader<'a, R: ?Sized> { } impl<'a, R: BufRead + ?Sized> BitStreamReader<'a, R> { - /// Creates a new [`BitStreamReader`] that reads bitwise from a given `reader`. + /// Constructs a new [`BitStreamReader`] that reads bitwise from a given `reader`. pub fn new(reader: &'a mut R) -> BitStreamReader<'a, R> { BitStreamReader { buffer: [0u8], reader, offset: 8 } } @@ -524,7 +524,7 @@ pub struct BitStreamWriter<'a, W> { } impl<'a, W: Write> BitStreamWriter<'a, W> { - /// Creates a new [`BitStreamWriter`] that writes bitwise to a given `writer`. + /// Constructs a new [`BitStreamWriter`] that writes bitwise to a given `writer`. pub fn new(writer: &'a mut W) -> BitStreamWriter<'a, W> { BitStreamWriter { buffer: [0u8], writer, offset: 0 } } diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs index ca6f957fc..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 }; - /// Create 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 { } } - /// Create 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() } - /// Create 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() } - /// Creates 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 } } - /// Creates 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 { - /// Creates 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) } - /// Creates 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/borrowed.rs b/bitcoin/src/blockdata/script/borrowed.rs index cf2e62513..e1fe91b78 100644 --- a/bitcoin/src/blockdata/script/borrowed.rs +++ b/bitcoin/src/blockdata/script/borrowed.rs @@ -28,7 +28,7 @@ crate::internal_macros::define_extension_trait! { #[inline] fn bytes(&self) -> Bytes<'_> { Bytes(self.as_bytes().iter().copied()) } - /// Creates a new script builder + /// Constructs a new script builder fn builder() -> Builder { Builder::new() } /// Returns 160-bit hash of the script for P2SH outputs. diff --git a/bitcoin/src/blockdata/script/builder.rs b/bitcoin/src/blockdata/script/builder.rs index 4c71c4aa5..6e0c7875c 100644 --- a/bitcoin/src/blockdata/script/builder.rs +++ b/bitcoin/src/blockdata/script/builder.rs @@ -15,7 +15,7 @@ use crate::Sequence; pub struct Builder(ScriptBuf, Option); impl Builder { - /// Creates a new empty script. + /// Constructs a new empty script. #[inline] pub const fn new() -> Self { Builder(ScriptBuf::new(), None) } @@ -137,7 +137,7 @@ impl Default for Builder { fn default() -> Builder { Builder::new() } } -/// Creates a new builder from an existing vector. +/// Constructs a new builder from an existing vector. impl From> for Builder { fn from(v: Vec) -> Builder { let script = ScriptBuf::from(v); diff --git a/bitcoin/src/blockdata/script/instruction.rs b/bitcoin/src/blockdata/script/instruction.rs index f971f8ced..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() } - /// Creates `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 d0e269975..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 { - /// Creates 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()))) } - /// Creates 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 { - /// Creates 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()))) } - /// Creates 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 { } } -/// Creates 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 ba7fdaae7..ccc82ca89 100644 --- a/bitcoin/src/blockdata/script/owned.rs +++ b/bitcoin/src/blockdata/script/owned.rs @@ -18,7 +18,7 @@ pub use primitives::script::ScriptBuf; crate::internal_macros::define_extension_trait! { /// Extension functionality for the [`ScriptBuf`] type. pub trait ScriptBufExt impl for ScriptBuf { - /// Creates a new script builder + /// Constructs a new script builder fn builder() -> Builder { Builder::new() } /// Generates OP_RETURN-type of scriptPubkey for the given data. @@ -26,7 +26,7 @@ crate::internal_macros::define_extension_trait! { Builder::new().push_opcode(OP_RETURN).push_slice(data).into_script() } - /// Creates 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 68a7bbe99..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 { - /// Creates `&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) } } - /// Creates `&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 { @@ -63,7 +63,7 @@ mod primitive { unsafe { &mut *(bytes as *mut [u8] as *mut PushBytes) } } - /// Creates an empty `&PushBytes`. + /// Constructs an empty `&PushBytes`. pub fn empty() -> &'static Self { Self::from_slice_unchecked(&[]) } @@ -200,11 +200,11 @@ mod primitive { pub struct PushBytesBuf(Vec); impl PushBytesBuf { - /// Creates a new empty `PushBytesBuf`. + /// Constructs an empty `PushBytesBuf`. #[inline] pub const fn new() -> Self { PushBytesBuf(Vec::new()) } - /// Creates 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 73f4a3e3a..3b0cd4cad 100644 --- a/bitcoin/src/blockdata/script/witness_program.rs +++ b/bitcoin/src/blockdata/script/witness_program.rs @@ -38,7 +38,7 @@ pub struct WitnessProgram { } impl WitnessProgram { - /// Creates a new witness program, copying the content from the given byte slice. + /// Constructs a new witness program, copying the content from the given byte slice. pub fn new(version: WitnessVersion, bytes: &[u8]) -> Result { use Error::*; @@ -56,38 +56,38 @@ impl WitnessProgram { Ok(WitnessProgram { version, program }) } - /// Creates 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) } } - /// Creates 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) } } - /// Creates 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) } } - /// Creates 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()) } - /// Creates 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) } - /// Creates 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()) } - /// Creates 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) } - /// Creates 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 6512d7e83..eefa9c058 100644 --- a/bitcoin/src/blockdata/transaction.rs +++ b/bitcoin/src/blockdata/transaction.rs @@ -68,7 +68,7 @@ const SEGWIT_FLAG: u8 = 0x01; crate::internal_macros::define_extension_trait! { /// Extension functionality for the [`OutPoint`] type. pub trait OutPointExt impl for OutPoint { - /// Creates a new [`OutPoint`]. + /// Constructs a new [`OutPoint`]. #[inline] #[deprecated(since = "TBD", note = "use struct initialization syntax instead")] #[allow(clippy::new-ret-no-self)] @@ -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) } - /// Creates 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 } } - /// Creates 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 { - /// Creates 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 1792d5325..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 { - /// Creates 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 } - /// Creates 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/encode.rs b/bitcoin/src/consensus/encode.rs index 5218250d5..476313162 100644 --- a/bitcoin/src/consensus/encode.rs +++ b/bitcoin/src/consensus/encode.rs @@ -332,7 +332,7 @@ pub struct CheckedData { } impl CheckedData { - /// Creates a new `CheckedData` computing the checksum of given data. + /// Constructs a new `CheckedData` computing the checksum of given data. pub fn new(data: Vec) -> Self { let checksum = sha2_checksum(&data); Self { data, checksum } 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 247065d0b..a0627ba0d 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 } } - /// Creates 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, @@ -845,7 +845,7 @@ impl TweakedPublicKey { TweakedPublicKey(xonly) } - /// Creates a new [`TweakedPublicKey`] from a [`XOnlyPublicKey`]. No tweak is applied, consider + /// Constructs a new [`TweakedPublicKey`] from a [`XOnlyPublicKey`]. No tweak is applied, consider /// calling `tap_tweak` on an [`UntweakedPublicKey`] instead of using this constructor. /// /// This method is dangerous and can lead to loss of funds if used incorrectly. @@ -866,7 +866,7 @@ impl TweakedPublicKey { } impl TweakedKeypair { - /// Creates a new [`TweakedKeypair`] from a [`Keypair`]. No tweak is applied, consider + /// Constructs a new [`TweakedKeypair`] from a [`Keypair`]. No tweak is applied, consider /// calling `tap_tweak` on an [`UntweakedKeypair`] instead of using this constructor. /// /// This method is dangerous and can lead to loss of funds if used incorrectly. diff --git a/bitcoin/src/crypto/sighash.rs b/bitcoin/src/crypto/sighash.rs index dda55cdf3..e6530921a 100644 --- a/bitcoin/src/crypto/sighash.rs +++ b/bitcoin/src/crypto/sighash.rs @@ -319,11 +319,11 @@ impl std::error::Error for PrevoutsIndexError { } impl<'s> ScriptPath<'s> { - /// Creates a new `ScriptPath` structure. + /// Constructs a new `ScriptPath` structure. pub fn new(script: &'s Script, leaf_version: LeafVersion) -> Self { ScriptPath { script, leaf_version } } - /// Creates a new `ScriptPath` structure using default leaf version value. + /// Constructs a new `ScriptPath` structure using default leaf version value. pub fn with_defaults(script: &'s Script) -> Self { Self::new(script, LeafVersion::TapScript) } /// Computes the leaf hash for this `ScriptPath`. pub fn leaf_hash(&self) -> TapLeafHash { @@ -418,7 +418,7 @@ impl EcdsaSighashType { } } - /// Creates 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 { } } - /// Creates 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::*; @@ -1156,7 +1156,7 @@ impl> SighashCache { pub struct Annex<'a>(&'a [u8]); impl<'a> Annex<'a> { - /// Creates a new `Annex` struct checking the first byte is `0x50`. + /// Constructs a new `Annex` struct checking the first byte is `0x50`. pub fn new(annex_bytes: &'a [u8]) -> Result { use AnnexError::*; diff --git a/bitcoin/src/internal_macros.rs b/bitcoin/src/internal_macros.rs index 70387b254..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 { - /// Creates `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 { - /// Creates `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 ef363d643..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 { - /// Create 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(); /// - /// // Create 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) } - /// Create 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()); } - /// Create 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); } - /// Create 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 7f691f74c..553efc4d6 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 { - /// Creates 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) } - /// Creates 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/network/params.rs b/bitcoin/src/network/params.rs index 3c1768927..eecc42cb8 100644 --- a/bitcoin/src/network/params.rs +++ b/bitcoin/src/network/params.rs @@ -24,7 +24,7 @@ //! } //! //! impl CustomParams { -//! /// Creates a new custom params. +//! /// Constructs a new custom params. //! pub fn new() -> Self { //! let mut params = Params::new(Network::Signet); //! params.pow_target_spacing = POW_TARGET_SPACING; diff --git a/bitcoin/src/p2p/address.rs b/bitcoin/src/p2p/address.rs index d90992001..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 { - /// Create 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 b1466248e..ff14b6ac3 100644 --- a/bitcoin/src/p2p/message.rs +++ b/bitcoin/src/p2p/message.rs @@ -301,7 +301,7 @@ impl NetworkMessage { } impl RawNetworkMessage { - /// Creates 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 bbfb92d11..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]); - /// Create 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 21019e1de..30f4de2cd 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 { - /// Creates 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)) } - /// Creates 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); - /// Creates 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)?) } - /// Creates 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)) } - /// Creates `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) } - /// Creates 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 { - /// Creates 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 52c3af918..cfe9cfb46 100644 --- a/bitcoin/src/psbt/map/input.rs +++ b/bitcoin/src/psbt/map/input.rs @@ -229,7 +229,7 @@ impl PsbtSighashType { } } - /// Creates 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 bb4782c8c..c9eac7165 100644 --- a/bitcoin/src/psbt/mod.rs +++ b/bitcoin/src/psbt/mod.rs @@ -103,7 +103,7 @@ impl Psbt { Ok(()) } - /// Creates 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 0b3030de5..bbc2b44de 100644 --- a/bitcoin/src/sign_message.rs +++ b/bitcoin/src/sign_message.rs @@ -92,7 +92,7 @@ mod message_signing { } impl MessageSignature { - /// Create 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 } - /// Creates 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 { }) } - /// Create 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 1af04212b..c629eacb6 100644 --- a/bitcoin/src/taproot/merkle_branch.rs +++ b/bitcoin/src/taproot/merkle_branch.rs @@ -63,7 +63,7 @@ impl TaprootMerkleBranch { } } - /// Creates 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; - /// Creates 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 99f1dbc70..b8bd00342 100644 --- a/bitcoin/src/taproot/mod.rs +++ b/bitcoin/src/taproot/mod.rs @@ -34,7 +34,7 @@ pub use primitives::taproot::{ crate::internal_macros::define_extension_trait! { /// Extension functionality for the [`TapTweakHash`] type. pub trait TapTweakHashExt impl for TapTweakHash { - /// Creates a new BIP341 [`TapTweakHash`] from key and tweak. Produces `H_taptweak(P||R)` where + /// Constructs a new BIP341 [`TapTweakHash`] from key and tweak. Produces `H_taptweak(P||R)` where /// `P` is the internal key and `R` is the Merkle root. fn from_key_and_tweak( internal_key: UntweakedPublicKey, @@ -181,7 +181,7 @@ pub struct TaprootSpendInfo { } impl TaprootSpendInfo { - /// Creates a new [`TaprootSpendInfo`] from a list of scripts (with default script version) and + /// Constructs a new [`TaprootSpendInfo`] from a list of scripts (with default script version) and /// weights of satisfaction for that script. /// /// See [`TaprootBuilder::with_huffman_tree`] for more detailed documentation. @@ -198,7 +198,7 @@ impl TaprootSpendInfo { Ok(builder.finalize(secp, internal_key).expect("Huffman tree is always complete")) } - /// Creates a new key spend with `internal_key` and `merkle_root`. Provide [`None`] for + /// Constructs a new key spend with `internal_key` and `merkle_root`. Provide [`None`] for /// the `merkle_root` if there is no script path. /// /// *Note*: As per BIP341 @@ -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 /// @@ -355,17 +355,17 @@ pub struct TaprootBuilder { } impl TaprootBuilder { - /// Creates a new instance of [`TaprootBuilder`]. + /// Constructs a new instance of [`TaprootBuilder`]. pub fn new() -> Self { TaprootBuilder { branch: vec![] } } - /// Creates a new instance of [`TaprootBuilder`] with a capacity hint for `size` elements. + /// Constructs a new instance of [`TaprootBuilder`] with a capacity hint for `size` elements. /// /// The size here should be maximum depth of the tree. pub fn with_capacity(size: usize) -> Self { TaprootBuilder { branch: Vec::with_capacity(size) } } - /// Creates a new [`TaprootSpendInfo`] from a list of scripts (with default script version) and + /// Constructs a new [`TaprootSpendInfo`] from a list of scripts (with default script version) and /// weights of satisfaction for that script. /// /// The weights represent the probability of each branch being taken. If probabilities/weights @@ -501,7 +501,7 @@ impl TaprootBuilder { self.branch.iter().flatten().any(|node| node.has_hidden_nodes) } - /// Creates 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 /// @@ -810,12 +810,12 @@ impl core::hash::Hash for NodeInfo { impl Eq for NodeInfo {} impl NodeInfo { - /// Creates a new [`NodeInfo`] with omitted/hidden info. + /// Constructs a new [`NodeInfo`] with omitted/hidden info. pub fn new_hidden_node(hash: TapNodeHash) -> Self { Self { hash, leaves: vec![], has_hidden_nodes: true } } - /// Creates a new leaf [`NodeInfo`] with given [`ScriptBuf`] and [`LeafVersion`]. + /// Constructs a new leaf [`NodeInfo`] with given [`ScriptBuf`] and [`LeafVersion`]. pub fn new_leaf_with_ver(script: ScriptBuf, ver: LeafVersion) -> Self { Self { hash: TapNodeHash::from_script(&script, ver), @@ -971,12 +971,12 @@ pub struct LeafNode { } impl LeafNode { - /// Creates 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() } } - /// Creates 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 { - /// Creates 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 4fd66fae2..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 { - /// Creates `SerializedSignature` from data and length. + /// Constructs new `SerializedSignature` from data and length. /// /// # Panics /// @@ -159,7 +159,7 @@ impl SerializedSignature { Signature::from_slice(self) } - /// Create 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 fa7798ce8..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 { - /// Create 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 { - /// Create a new nonce. + /// Constructs a new nonce. pub const fn new(nonce: [u8; 12]) -> Self { Nonce(nonce) } } diff --git a/hashes/src/hash160.rs b/hashes/src/hash160.rs index 49410bc70..2e90ca391 100644 --- a/hashes/src/hash160.rs +++ b/hashes/src/hash160.rs @@ -20,7 +20,7 @@ crate::internal_macros::general_hash_type! { pub struct HashEngine(sha256::HashEngine); impl HashEngine { - /// Creates a new HASH160 hash engine. + /// Constructs a new HASH160 hash engine. pub const fn new() -> Self { Self(sha256::HashEngine::new()) } } diff --git a/hashes/src/internal_macros.rs b/hashes/src/internal_macros.rs index 46480863c..a707d2222 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 0979a77a3..11acde41d 100644 --- a/hashes/src/lib.rs +++ b/hashes/src/lib.rs @@ -284,7 +284,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/ripemd160.rs b/hashes/src/ripemd160.rs index a0791904a..fa0893d7a 100644 --- a/hashes/src/ripemd160.rs +++ b/hashes/src/ripemd160.rs @@ -50,7 +50,7 @@ pub struct HashEngine { } impl HashEngine { - /// Creates a new SHA256 hash engine. + /// Constructs a new SHA256 hash engine. pub const fn new() -> Self { Self { h: [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0], diff --git a/hashes/src/sha1.rs b/hashes/src/sha1.rs index 63d7293be..152a8f348 100644 --- a/hashes/src/sha1.rs +++ b/hashes/src/sha1.rs @@ -42,7 +42,7 @@ pub struct HashEngine { } impl HashEngine { - /// Creates a new SHA1 hash engine. + /// Constructs a new SHA1 hash engine. pub const fn new() -> Self { Self { h: [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0], diff --git a/hashes/src/sha256.rs b/hashes/src/sha256.rs index 42fe5cf24..a040338f4 100644 --- a/hashes/src/sha256.rs +++ b/hashes/src/sha256.rs @@ -62,7 +62,7 @@ pub struct HashEngine { } impl HashEngine { - /// Creates a new SHA256 hash engine. + /// Constructs a new SHA256 hash engine. pub const fn new() -> Self { Self { h: [ @@ -74,7 +74,7 @@ impl HashEngine { } } - /// Creates a new [`HashEngine`] from a [`Midstate`]. + /// Constructs a new [`HashEngine`] from a [`Midstate`]. /// /// Please see docs on [`Midstate`] before using this function. pub fn from_midstate(midstate: Midstate) -> HashEngine { @@ -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) } - /// Creates 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/sha256d.rs b/hashes/src/sha256d.rs index 380a6bf24..332d6bc11 100644 --- a/hashes/src/sha256d.rs +++ b/hashes/src/sha256d.rs @@ -15,7 +15,7 @@ crate::internal_macros::general_hash_type! { pub struct HashEngine(sha256::HashEngine); impl HashEngine { - /// Creates a new SHA256d hash engine. + /// Constructs a new SHA256d hash engine. pub const fn new() -> Self { Self(sha256::HashEngine::new()) } } diff --git a/hashes/src/sha256t.rs b/hashes/src/sha256t.rs index 99ba729c6..1b4188d2c 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/sha384.rs b/hashes/src/sha384.rs index e6e1aec3a..18f23b40a 100644 --- a/hashes/src/sha384.rs +++ b/hashes/src/sha384.rs @@ -21,7 +21,7 @@ fn from_engine(e: HashEngine) -> Hash { pub struct HashEngine(sha512::HashEngine); impl HashEngine { - /// Creates a new SHA384 hash engine. + /// Constructs a new SHA384 hash engine. pub const fn new() -> Self { Self(sha512::HashEngine::sha384()) } } diff --git a/hashes/src/sha512.rs b/hashes/src/sha512.rs index 0b2e42d28..1ecd563df 100644 --- a/hashes/src/sha512.rs +++ b/hashes/src/sha512.rs @@ -51,7 +51,7 @@ pub struct HashEngine { } impl HashEngine { - /// Creates a new SHA512 hash engine. + /// Constructs a new SHA512 hash engine. #[rustfmt::skip] pub const fn new() -> Self { Self { @@ -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/sha512_256.rs b/hashes/src/sha512_256.rs index 53d08e3de..cb1d5d372 100644 --- a/hashes/src/sha512_256.rs +++ b/hashes/src/sha512_256.rs @@ -31,7 +31,7 @@ fn from_engine(e: HashEngine) -> Hash { pub struct HashEngine(sha512::HashEngine); impl HashEngine { - /// Creates a new SHA512/256 hash engine. + /// Constructs a new SHA512/256 hash engine. pub const fn new() -> Self { Self(sha512::HashEngine::sha512_256()) } } diff --git a/hashes/src/siphash24.rs b/hashes/src/siphash24.rs index 973b9089d..b751604b6 100644 --- a/hashes/src/siphash24.rs +++ b/hashes/src/siphash24.rs @@ -84,7 +84,7 @@ pub struct HashEngine { } impl HashEngine { - /// Creates a new SipHash24 engine with keys. + /// Constructs a new SipHash24 engine with keys. #[inline] pub const fn with_keys(k0: u64, k1: u64) -> HashEngine { HashEngine { @@ -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) } - /// Creates 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 b728503e8..49fca83d8 100644 --- a/internals/src/array_vec.rs +++ b/internals/src/array_vec.rs @@ -22,10 +22,10 @@ mod safety_boundary { } impl ArrayVec { - /// Creates an empty `ArrayVec`. + /// Constructs an empty `ArrayVec`. pub const fn new() -> Self { Self { len: 0, data: [MaybeUninit::uninit(); CAP] } } - /// Creates 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 1c7e78256..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 { - /// Creates `Self`. + /// Constructs a new `Self`. fn new>(input: T, source: $source) -> Self { $name { input: input.into(), diff --git a/io/src/error.rs b/io/src/error.rs index b78243887..172dd3d6a 100644 --- a/io/src/error.rs +++ b/io/src/error.rs @@ -18,7 +18,7 @@ pub struct Error { } impl Error { - /// Creates a new I/O error. + /// Constructs a new I/O error. #[cfg(feature = "std")] pub fn new(kind: ErrorKind, error: E) -> Error where @@ -27,7 +27,7 @@ impl Error { Self { kind, _not_unwind_safe: core::marker::PhantomData, error: Some(error.into()) } } - /// Creates a new I/O error. + /// Constructs a new I/O error. #[cfg(all(feature = "alloc", not(feature = "std")))] pub fn new(kind: ErrorKind, error: E) -> Error { Self { kind, _not_unwind_safe: core::marker::PhantomData, error: Some(error.into()) } diff --git a/io/src/lib.rs b/io/src/lib.rs index b764ab34a..b867be191 100644 --- a/io/src/lib.rs +++ b/io/src/lib.rs @@ -58,7 +58,7 @@ pub trait Read { Ok(()) } - /// Creates 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 { - /// Creates 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 5a87f2039..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; - /// Creates 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 09a32ea54..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. - /// Creates 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)) } - /// Creates 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 67adea787..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)) } - /// Create 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 { } } - /// Create 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 a6fbc046f..498713fe2 100644 --- a/primitives/src/opcodes.rs +++ b/primitives/src/opcodes.rs @@ -495,7 +495,7 @@ macro_rules! ordinary_opcode { } } - /// Try to create 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 6a30d7a0b..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 { - /// Creates 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/script/borrowed.rs b/primitives/src/script/borrowed.rs index 86857deb8..a7ea5e2f0 100644 --- a/primitives/src/script/borrowed.rs +++ b/primitives/src/script/borrowed.rs @@ -63,7 +63,7 @@ impl ToOwned for Script { } impl Script { - /// Creates a new empty script. + /// Constructs a new empty script. #[inline] pub fn new() -> &'static Script { Script::from_bytes(&[]) } diff --git a/primitives/src/script/owned.rs b/primitives/src/script/owned.rs index 963416731..2e980afa1 100644 --- a/primitives/src/script/owned.rs +++ b/primitives/src/script/owned.rs @@ -22,7 +22,7 @@ use crate::prelude::{Box, Vec}; pub struct ScriptBuf(pub(in crate::script) Vec); impl ScriptBuf { - /// Creates a new empty script. + /// Constructs a new empty script. #[inline] pub const fn new() -> Self { ScriptBuf(Vec::new()) } @@ -56,7 +56,7 @@ impl ScriptBuf { unsafe { Box::from_raw(rw) } } - /// Creates a new empty script with pre-allocated capacity. + /// Constructs a new empty script with pre-allocated capacity. pub fn with_capacity(capacity: usize) -> Self { ScriptBuf(Vec::with_capacity(capacity)) } /// Pre-allocates at least `additional_len` bytes if needed. diff --git a/primitives/src/sequence.rs b/primitives/src/sequence.rs index 5e2a7f32a..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) } - /// Creates 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)) } - /// Creates 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)) } - /// Creates 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)) } - /// Creates 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) } - /// Creates 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 { } } - /// Creates 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 { } } - /// Creates 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 } - /// Creates 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 83475de30..95737c7ca 100644 --- a/primitives/src/witness.rs +++ b/primitives/src/witness.rs @@ -49,13 +49,13 @@ pub struct Witness { } impl Witness { - /// Creates a new empty [`Witness`]. + /// Constructs a new empty [`Witness`]. #[inline] pub const fn new() -> Self { Witness { content: Vec::new(), witness_elements: 0, indices_start: 0 } } - /// Creates a new [`Witness`] from inner parts. + /// Constructs a new [`Witness`] from inner parts. /// /// This function leaks implementation details of the `Witness`, as such it is unstable and /// should not be relied upon (it is primarily provided for use in `rust-bitcoin`). @@ -72,7 +72,7 @@ impl Witness { Witness { content, witness_elements, indices_start } } - /// Creates 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 78219c73e..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); - /// Creates 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) } - /// Creates 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 { } } - /// Creates 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 c38257c83..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. - /// Creates 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) } - /// Creates 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 { } } - /// Creates 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 659458010..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); - /// Creates 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); - /// Creates 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 f5a82c213..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); - /// Creates 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); - /// Creates 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 0fef5b7e5..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); - /// Create 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); - /// Creates 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) } - /// Creates 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 { } } - /// Creates 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 @@ -133,7 +133,7 @@ pub struct TimeOverflowError { } impl TimeOverflowError { - /// Creates a new `TimeOverflowError` using `seconds`. + /// Constructs a new `TimeOverflowError` using `seconds`. /// /// # Panics /// diff --git a/units/src/parse.rs b/units/src/parse.rs index 7eb3f19c6..84917406d 100644 --- a/units/src/parse.rs +++ b/units/src/parse.rs @@ -378,7 +378,7 @@ pub struct MissingPrefixError { } impl MissingPrefixError { - /// Creates 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 { - /// Creates 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) }