From df83016c98bdcb069c1579d9f1fa7f74139214c0 Mon Sep 17 00:00:00 2001 From: "jamil.lambert" Date: Thu, 23 May 2024 12:15:40 +0100 Subject: [PATCH] Standardize function doc Errors Changed the function docs to have the same format of /// /// # Errors /// /// description --- bitcoin/src/blockdata/script/push_bytes.rs | 4 ++-- bitcoin/src/psbt/mod.rs | 8 +++---- bitcoin/src/psbt/raw.rs | 1 + bitcoin/src/taproot/merkle_branch.rs | 2 ++ bitcoin/src/taproot/mod.rs | 27 +++++++++++++++++----- 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/bitcoin/src/blockdata/script/push_bytes.rs b/bitcoin/src/blockdata/script/push_bytes.rs index 1b229489a..63b613bc2 100644 --- a/bitcoin/src/blockdata/script/push_bytes.rs +++ b/bitcoin/src/blockdata/script/push_bytes.rs @@ -207,7 +207,7 @@ mod primitive { /// Try pushing a single byte. /// - /// ## Errors + /// # Errors /// /// This method fails if `self` would exceed the limit. #[allow(deprecated)] @@ -220,7 +220,7 @@ mod primitive { /// Try appending a slice to `PushBytesBuf` /// - /// ## Errors + /// # Errors /// /// This method fails if `self` would exceed the limit. pub fn extend_from_slice(&mut self, bytes: &[u8]) -> Result<(), PushBytesError> { diff --git a/bitcoin/src/psbt/mod.rs b/bitcoin/src/psbt/mod.rs index 713dc2481..c7a588755 100644 --- a/bitcoin/src/psbt/mod.rs +++ b/bitcoin/src/psbt/mod.rs @@ -67,7 +67,7 @@ impl Psbt { /// For each PSBT input that contains UTXO information `Ok` is returned containing that information. /// The order of returned items is same as the order of inputs. /// - /// ## Errors + /// # Errors /// /// The function returns error when UTXO information is not present or is invalid. /// @@ -140,7 +140,7 @@ impl Psbt { /// Extracts the [`Transaction`] from a [`Psbt`] by filling in the available signature information. /// - /// ## Errors + /// # Errors /// /// [`ExtractTxError`] variants will contain either the [`Psbt`] itself or the [`Transaction`] /// that was extracted. These can be extracted from the Errors in order to recover. @@ -151,7 +151,7 @@ impl Psbt { /// Extracts the [`Transaction`] from a [`Psbt`] by filling in the available signature information. /// - /// ## Errors + /// # Errors /// /// See [`extract_tx`]. /// @@ -703,7 +703,7 @@ impl Psbt { /// 'Fee' being the amount that will be paid for mining a transaction with the current inputs /// and outputs i.e., the difference in value of the total inputs and the total outputs. /// - /// ## Errors + /// # Errors /// /// - [`Error::MissingUtxo`] when UTXO information for any input is not present or is invalid. /// - [`Error::NegativeFee`] if calculated value is negative. diff --git a/bitcoin/src/psbt/raw.rs b/bitcoin/src/psbt/raw.rs index 65b350b3c..e782ca727 100644 --- a/bitcoin/src/psbt/raw.rs +++ b/bitcoin/src/psbt/raw.rs @@ -188,6 +188,7 @@ where /// Constructs a [`ProprietaryKey`] from a [`Key`]. /// /// # Errors + /// /// Returns [`Error::InvalidProprietaryKey`] if `key` does not start with `0xFC` byte. fn try_from(key: Key) -> Result { if key.type_value != 0xFC { diff --git a/bitcoin/src/taproot/merkle_branch.rs b/bitcoin/src/taproot/merkle_branch.rs index 79d6e36b3..0e5732669 100644 --- a/bitcoin/src/taproot/merkle_branch.rs +++ b/bitcoin/src/taproot/merkle_branch.rs @@ -66,6 +66,7 @@ impl TaprootMerkleBranch { /// Creates a merkle proof from list of hashes. /// /// # Errors + /// /// If inner proof length is more than [`TAPROOT_CONTROL_MAX_NODE_COUNT`] (128). #[inline] fn from_collection + Into>>( @@ -123,6 +124,7 @@ macro_rules! impl_try_from { /// Creates a merkle proof from list of hashes. /// /// # Errors + /// /// If inner proof length is more than [`TAPROOT_CONTROL_MAX_NODE_COUNT`] (128). #[inline] fn try_from(v: $from) -> Result { diff --git a/bitcoin/src/taproot/mod.rs b/bitcoin/src/taproot/mod.rs index cfb843c9c..dc3de6e73 100644 --- a/bitcoin/src/taproot/mod.rs +++ b/bitcoin/src/taproot/mod.rs @@ -429,8 +429,13 @@ impl TaprootBuilder { Ok(TaprootBuilder { branch: vec![Some(node)] }) } - /// Adds a leaf script at `depth` to the builder with script version `ver`. Errors if the leaves - /// are not provided in DFS walk order. The depth of the root node is 0. + /// Adds a leaf script at `depth` to the builder with script version `ver`. + /// + /// The depth of the root node is 0. + /// + /// # Errors + /// + /// Errors if the leaves are not provided in DFS walk order. pub fn add_leaf_with_ver( self, depth: u8, @@ -441,16 +446,26 @@ impl TaprootBuilder { self.insert(leaf, depth) } - /// Adds a leaf script at `depth` to the builder with default script version. Errors if the - /// leaves are not provided in DFS walk order. The depth of the root node is 0. + /// Adds a leaf script at `depth` to the builder with default script version. + /// + /// The depth of the root node is 0. /// /// See [`TaprootBuilder::add_leaf_with_ver`] for adding a leaf with specific version. + /// + /// # Errors + /// + /// Errors if the leaves are not provided in DFS walk order. pub fn add_leaf(self, depth: u8, script: ScriptBuf) -> Result { self.add_leaf_with_ver(depth, script, LeafVersion::TapScript) } - /// Adds a hidden/omitted node at `depth` to the builder. Errors if the leaves are not provided - /// in DFS walk order. The depth of the root node is 0. + /// Adds a hidden/omitted node at `depth` to the builder. + /// + /// The depth of the root node is 0. + /// + /// # Errors + /// + /// Errors if the leaves are not provided in DFS walk order. pub fn add_hidden_node( self, depth: u8,