From 3e058875797425dfec858240c109bb58a9c958e5 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Thu, 31 Mar 2022 10:56:36 +1100 Subject: [PATCH 1/3] Use 'the' to improve sentence Adding a 'the' makes this sentence a little better. --- src/util/taproot.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/taproot.rs b/src/util/taproot.rs index 69d381b7..62977a28 100644 --- a/src/util/taproot.rs +++ b/src/util/taproot.rs @@ -211,7 +211,7 @@ impl TaprootSpendInfo { } /// Creates a new key spend with `internal_key` and `merkle_root`. Provide [`None`] for - /// `merkle_root` if there is no script path. + /// the `merkle_root` if there is no script path. /// /// *Note*: As per BIP341 /// From 492ccebd996fbf988842ee8754b1e57395388b4c Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Thu, 31 Mar 2022 10:57:05 +1100 Subject: [PATCH 2/3] Use links for error types We can help the users by linking them to errors when mentioning them in the docs. --- src/util/taproot.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/taproot.rs b/src/util/taproot.rs index 62977a28..77e21f53 100644 --- a/src/util/taproot.rs +++ b/src/util/taproot.rs @@ -704,11 +704,11 @@ impl ControlBlock { /// /// # Errors /// - /// - `TaprootError::InvalidControlBlockSize` if `sl` is not of size 1 + 32 + 32N for any N >= 0. - /// - `TaprootError::InvalidParity` if first byte of `sl` is not a valid output key parity. - /// - `TaprootError::InvalidTaprootLeafVersion` if first byte of `sl` is not a valid leaf version. - /// - `TaprootError::InvalidInternalKey` if internal key is invalid (first 32 bytes after the parity byte). - /// - `TaprootError::InvalidMerkleTreeDepth` if merkle tree is too deep (more than 128 levels). + /// - [`TaprootError::InvalidControlBlockSize`] if `sl` is not of size 1 + 32 + 32N for any N >= 0. + /// - [`TaprootError::InvalidParity`] if first byte of `sl` is not a valid output key parity. + /// - [`TaprootError::InvalidTaprootLeafVersion`] if first byte of `sl` is not a valid leaf version. + /// - [`TaprootError::InvalidInternalKey`] if internal key is invalid (first 32 bytes after the parity byte). + /// - [`TaprootError::InvalidMerkleTreeDepth`] if merkle tree is too deep (more than 128 levels). pub fn from_slice(sl: &[u8]) -> Result { if sl.len() < TAPROOT_CONTROL_BASE_SIZE || (sl.len() - TAPROOT_CONTROL_BASE_SIZE) % TAPROOT_CONTROL_NODE_SIZE != 0 From da731c48252f43d7bfa171bf3b203c52bdd9285d Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Thu, 31 Mar 2022 10:57:37 +1100 Subject: [PATCH 3/3] Add further description to the NodeInfo struct Further assist devs in understanding the `NodeInfo` struct by adding docs about when/why the struct is used. --- src/util/taproot.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/util/taproot.rs b/src/util/taproot.rs index 77e21f53..500f8931 100644 --- a/src/util/taproot.rs +++ b/src/util/taproot.rs @@ -521,8 +521,12 @@ impl TaprootBuilder { /// Represents the node information in taproot tree. /// -/// You can use [`TaprootSpendInfo::from_node_info`] to a get [`TaprootSpendInfo`] -/// from the merkle root [`NodeInfo`]. +/// Helper type used in merkle tree construction allowing one to build sparse merkle trees. The node +/// represents part of the tree that has information about all of its descendants. +/// See how [`TaprootBuilder`] works for more details. +/// +/// You can use [`TaprootSpendInfo::from_node_info`] to a get a [`TaprootSpendInfo`] from the merkle +/// root [`NodeInfo`]. #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct NodeInfo {