Repository: vinteumorg/Floresta
Pull request #484: Added missing docs to Floresta Common
Author: login: luca0x46
Labels: name: documentation
description: Improvements or additions to documentation
name: enhancement
description: New feature or request
name: code quality
description: Generally improves code readability and maintainability
Created: 2025-05-14T01:28:48Z | Merged: 2025-05-19T16:05:47Z

### What is the purpose of this pull request?

- [ ] Bug fix
- [X] Documentation update
- [ ] New feature
- [ ] Test
- [ ] Other: <!-- Please describe it -->

### Which crates are being modified?

- [ ] floresta-chain
- [ ] floresta-cli
- [X] floresta-common
- [ ] floresta-compact-filters
- [ ] floresta-electrum
- [ ] floresta-watch-only
- [ ] floresta-wire
- [ ] floresta
- [ ] florestad
- [ ] Other: <!-- Please describe it -->

### Description
This PR adds missing docs from Floresta Common. It addresses #376 .

<!-- Describe the purpose of this PR, what's being added and/or fixed. If there's an open issue for it, link it here -->

### Notes to the reviewers
I added the reference to the electrum protocol to make it easier to search for. 
<!-- In this section you can include notes directed to the reviewers, like explaining why some parts of the PR were done in a specific way -->

### Author Checklist

<!-- Feel free to remove this section once you've confirmed all items -->

- [X] I've followed the [contribution guidelines](https://github.com/vinteumorg/Floresta/blob/master/CONTRIBUTING.md)
- [x] I've verified one of the following:
  - Ran `just pcc` (recommended but slower)
  - Ran `just lint-features '-- -D warnings' && cargo test --release`
  - Confirmed CI passed on my fork
- [X] I've linked any related issue(s) in the sections above

![image](https://github.com/user-attachments/assets/7f18564d-4c0e-4be7-8b5a-a582f36feda8)



Diff:
diff --git a/crates/floresta-common/src/lib.rs b/crates/floresta-common/src/lib.rs
index 573b4ba01..07d1c6f66 100644
--- a/crates/floresta-common/src/lib.rs
+++ b/crates/floresta-common/src/lib.rs
@@ -1,5 +1,9 @@
 // SPDX-License-Identifier: MIT
 
+//! # Floresta Common
+//! Provides utility functions, macros and modules to be
+//! used in other Floresta crates.
+
 #![no_std]
 
 use bitcoin::hashes::sha256;
@@ -18,19 +22,30 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Computes the SHA-256 digest of the byte slice data and returns a [Hash] from `bitcoin_hashes`.
+///
+/// [Hash]: https://docs.rs/bitcoin_hashes/latest/bitcoin_hashes/sha256/struct.Hash.html
 pub fn get_hash_from_u8(data: &[u8]) -> sha256::Hash {
     let hash = sha2::Sha256::new().chain_update(data).finalize();
-    sha256::Hash::from_slice(hash.as_slice()).expect("Engines shouldn't be Err")
+    sha256::Hash::from_byte_array(hash.into())
 }
 
+/// Computes the SHA-256 digest of a script, reverses its bytes, and returns a [Hash] from
+/// `bitcoin_hashes`.
+///
+/// The source to the specification can be found in the Electrum protocol [documentation], and it is
+/// used to identify scripts in the Electrum Protocol.
+///
+/// [documentation]: https://electrum-protocol.readthedocs.io/en/latest/protocol-basics.html#script-hashes
+/// [Hash]: https://docs.rs/bitcoin_hashes/latest/bitcoin_hashes/sha256/struct.Hash.html
 pub fn get_spk_hash(spk: &ScriptBuf) -> sha256::Hash {
-    let script_hash = spk.as_bytes();
-    let mut hash = sha2::Sha256::new().chain_update(script_hash).finalize();
+    let data = spk.as_bytes();
+    let mut hash = sha2::Sha256::new().chain_update(data).finalize();
     hash.reverse();
-    sha256::Hash::from_slice(hash.as_slice()).expect("Engines shouldn't be Err")
+    sha256::Hash::from_byte_array(hash.into())
 }
 
-/// Non-standard service flags that aren't in rust-bitcoin yet
+/// Non-standard service flags that aren't in rust-bitcoin yet.
 pub mod service_flags {
     /// This peer supports UTREEXO messages
     pub const UTREEXO: u64 = 1 << 24;
@@ -77,6 +92,8 @@ impl FractionAvg {
 }
 
 #[cfg(any(feature = "descriptors-std", feature = "descriptors-no-std"))]
+/// Takes an array of descriptors as `String`, performs sanity checks on each one
+/// and returns list of parsed descriptors.
 pub fn parse_descriptors(
     descriptors: &[String],
 ) -> Result<Vec<Descriptor<DescriptorPublicKey>>, miniscript::Error> {
@@ -126,7 +143,14 @@ pub mod prelude {
     pub use hashbrown::HashMap;
     pub use hashbrown::HashSet;
 }
+
 #[cfg(feature = "std")]
+/// Provides implementation for basic `std` types, without assuming we have a `std` library.
+///
+/// This module is used to avoid having `#[cfg(feature = "no-std")]` sprinkled
+/// around all crates that support `no-std`. It imports all types we would use
+/// from the `stdlib`, either from the lib itself, or from other sources in case
+/// `stdlib` isn't available.
 pub mod prelude {
     extern crate alloc;
     extern crate std;
diff --git a/crates/floresta-common/src/macros.rs b/crates/floresta-common/src/macros.rs
index 311f1881a..a25a0c063 100644
--- a/crates/floresta-common/src/macros.rs
+++ b/crates/floresta-common/src/macros.rs
@@ -1,4 +1,34 @@
+//! This module has useful macros for usage on other crates.
+
 #[macro_export]
+/// Implements the `From` trait for converting a specific type into an enum variant or struct field.
+///
+/// This macro is useful when building error enums or wrapper types that need to support automatic
+/// conversions from underlying error types using the `?` operator.
+///
+/// # Parameters
+///
+/// - `$thing`: The target type to implement `From` for (usually an enum or struct).
+/// - `$from_thing`: The source type that should be converted into `$thing`.
+/// - `$field`: The variant or field of `$thing` that wraps a value of type `$from_thing`.
+///
+/// # Example
+///
+/// ```rust
+/// # use floresta_common::impl_error_from;
+/// enum MyError {
+///     Io(std::io::Error),
+///     Parse(std::num::ParseIntError),
+/// }
+///
+/// impl_error_from!(MyError, std::io::Error, Io);
+/// impl_error_from!(MyError, std::num::ParseIntError, Parse);
+///
+/// fn parse_number(s: &str) -> Result<i32, MyError> {
+///     let n: i32 = s.parse()?; // Automatically converts ParseIntError into MyError
+///     Ok(n)
+/// }
+/// ```
 macro_rules! impl_error_from {
     ($thing:ty, $from_thing:ty, $field:ident) => {
         impl From<$from_thing> for $thing {


Reviews:
user: login: JoseSK999
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-14T09:55:34Z
user: login: luca0x46
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T09:59:45Z
user: login: luca0x46
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T10:00:15Z
user: login: luca0x46
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T10:22:09Z
user: login: Davidson-Souza
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-14T15:55:39Z
user: login: luca0x46
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T19:45:22Z
user: login: luca0x46
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-15T20:30:48Z
user: login: JoseSK999
state: CHANGES_REQUESTED
author_association: MEMBER
submitted_at: 2025-05-16T13:15:51Z
user: login: luca0x46
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-16T17:40:04Z
user: login: JoseSK999
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-16T18:50:24Z
user: login: luca0x46
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-16T19:47:21Z
user: login: JoseSK999
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-16T20:35:27Z
user: login: luca0x46
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-17T03:28:46Z
user: login: Davidson-Souza
body: ACK [124e810](https://github.com/vinteumorg/Floresta/commit/124e810dcdf68cf9cce1bbe5885ae75292b2ae79)
state: APPROVED
author_association: MEMBER
submitted_at: 2025-05-19T15:37:36Z
user: login: JoseSK999
body: ACK [124e810](https://github.com/vinteumorg/Floresta/commit/124e810dcdf68cf9cce1bbe5885ae75292b2ae79)
state: APPROVED
author_association: MEMBER
submitted_at: 2025-05-19T15:43:30Z

Review comments:
diff_hunk: @@ -18,11 +22,17 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a `sha256::Hash`.
path: crates/floresta-common/src/lib.rs
user: login: JoseSK999
body: You can mention here that this type is from the `bitcoin` crate
created_at: 2025-05-14T09:53:14Z
author_association: MEMBER
diff_hunk: @@ -1,4 +1,33 @@
+//! This module has usefull macros for usage on other crates.
+
 #[macro_export]
+/// Implements the `From` trait for converting a specific type into an enum variant or struct field.
+///
+/// This macro is useful when building error enums or wrapper types that need to support automatic
+/// conversions from underlying error types using the `?` operator.
+///
+/// # Parameters
+///
+/// - `$thing`: The target type to implement `From` for (usually an enum or struct).
+/// - `$from_thing`: The source type that should be converted into `$thing`.
+/// - `$field`: The variant or field of `$thing` that wraps a value of type `$from_thing`.
+///
+/// # Example
+///
+/// ```rust
+/// enum MyError {
path: crates/floresta-common/src/macros.rs
user: login: JoseSK999
body: You need this import at the top
```suggestion
/// ```rust
/// # use floresta_common::impl_error_from;
/// enum MyError {
```
created_at: 2025-05-14T09:55:12Z
author_association: MEMBER
diff_hunk: @@ -1,4 +1,33 @@
+//! This module has usefull macros for usage on other crates.
+
 #[macro_export]
+/// Implements the `From` trait for converting a specific type into an enum variant or struct field.
+///
+/// This macro is useful when building error enums or wrapper types that need to support automatic
+/// conversions from underlying error types using the `?` operator.
+///
+/// # Parameters
+///
+/// - `$thing`: The target type to implement `From` for (usually an enum or struct).
+/// - `$from_thing`: The source type that should be converted into `$thing`.
+/// - `$field`: The variant or field of `$thing` that wraps a value of type `$from_thing`.
+///
+/// # Example
+///
+/// ```rust
+/// enum MyError {
path: crates/floresta-common/src/macros.rs
user: login: luca0x46
body: I was just doing this 😅 Thanks!
created_at: 2025-05-14T09:59:45Z
author_association: CONTRIBUTOR
diff_hunk: @@ -18,11 +22,17 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a `sha256::Hash`.
path: crates/floresta-common/src/lib.rs
user: login: luca0x46
body: Okay, I will add it
created_at: 2025-05-14T10:00:14Z
author_association: CONTRIBUTOR
diff_hunk: @@ -18,11 +22,17 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a `sha256::Hash`.
path: crates/floresta-common/src/lib.rs
user: login: luca0x46
body: I wanted to be able to have both a clickable link when built with dependencies but still be "pretty" when built `--no-deps`.

Do you know a good way to achieve this?

created_at: 2025-05-14T10:22:09Z
author_association: CONTRIBUTOR
diff_hunk: @@ -18,11 +22,17 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a `sha256::Hash`.
 pub fn get_hash_from_u8(data: &[u8]) -> sha256::Hash {
     let hash = sha2::Sha256::new().chain_update(data).finalize();
     sha256::Hash::from_slice(hash.as_slice()).expect("Engines shouldn't be Err")
 }
 
+/// Takes a script and returns its hash following the Electrum protocol
+/// convention of reversing it.
+///
+/// The source to the specification can be found [here](https://electrum-protocol.readthedocs.io/en/latest/protocol-basics.html#script-hashes).
path: crates/floresta-common/src/lib.rs
user: login: Davidson-Souza
body: ```suggestion
/// Computes the sha256 of a script and reverses the bytes.
///
/// The source to the specification can be found in the Electrum protocol [documentation], and it is
/// used to identify scripts in the Electrum Protocol.
///
/// [documentation]: (https://electrum-protocol.readthedocs.io/en/latest/protocol-basics.html#script-hashes).
```

I think this way of doing links is way cleaner. I think we should add this to our coding standards.
created_at: 2025-05-14T15:50:20Z
author_association: MEMBER
diff_hunk: @@ -18,11 +22,17 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a `sha256::Hash`.
path: crates/floresta-common/src/lib.rs
user: login: Davidson-Souza
body: Can't you link to the `bitcoin` stuct?
created_at: 2025-05-14T15:51:19Z
author_association: MEMBER
diff_hunk: @@ -77,6 +87,8 @@ impl FractionAvg {
 }
 
 #[cfg(any(feature = "descriptors-std", feature = "descriptors-no-std"))]
+/// Takes an array of descriptors as `String`, performs sanity checks on each one
+/// and returns a `Vec<Descriptor<DescriptorPublicKey>>` if successful.
path: crates/floresta-common/src/lib.rs
user: login: Davidson-Souza
body: ```suggestion
/// Takes an array of descriptors as `String`, performs sanity checks on each one
/// and returns list of parsed descriptors.
```
created_at: 2025-05-14T15:52:11Z
author_association: MEMBER
diff_hunk: @@ -125,7 +137,10 @@ pub mod prelude {
     pub use hashbrown::HashMap;
     pub use hashbrown::HashSet;
 }
+
 #[cfg(feature = "std")]
+/// Provides commonly used items and traits in a centralized way,
+/// simplifying imports across the codebase.
path: crates/floresta-common/src/lib.rs
user: login: Davidson-Souza
body: ```suggestion
/// Provides implementation for basic `std` types, without assuming we have a `std` library.
///
/// This module is used to avoid having `#[cfg(feature = "no-std")]` sprinkled
/// around all crates that support `no-std`. It imports all types we would use
/// from the `stdlib`, either from the lib itself, or from other sources in case
/// `stdlib` isn't available.
```
created_at: 2025-05-14T15:55:33Z
author_association: MEMBER
diff_hunk: @@ -18,11 +22,17 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a `sha256::Hash`.
path: crates/floresta-common/src/lib.rs
user: login: luca0x46
body: If I use the ` accent, it just highlights

If I use the brackets, when built with dependencies, it is clickable and pretty, but if I build without deps, it shows as raw: [bitcoin]

created_at: 2025-05-14T19:45:22Z
author_association: CONTRIBUTOR
diff_hunk: @@ -18,11 +22,19 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a `sha256::Hash`.
 pub fn get_hash_from_u8(data: &[u8]) -> sha256::Hash {
     let hash = sha2::Sha256::new().chain_update(data).finalize();
     sha256::Hash::from_slice(hash.as_slice()).expect("Engines shouldn't be Err")
 }
 
+/// Computes the sha256 of a script and reverses the bytes.
+///
+/// The source to the specification can be found in the Electrum protocol [documentation], and it is
+/// used to identify scripts in the Electrum Protocol.
+///
+/// [documentation]: (https://electrum-protocol.readthedocs.io/en/latest/protocol-basics.html#script-hashes).
path: crates/floresta-common/src/lib.rs
user: login: luca0x46
body: @Davidson-Souza this syntax is not correct. When I click, it goes to `file:///Users/luca/Floresta/target/doc/floresta_common/(https://electrum-protocol.readthedocs.io/en/latest/protocol-basics.html#script-hashes).`  Displaying an error. It does not go to the expected URL. 

The correct format is:
`/// [documentation]: https://electrum-protocol.readthedocs.io/en/latest/protocol-basics.html#script-hashes` 

created_at: 2025-05-15T20:28:45Z
author_association: CONTRIBUTOR
diff_hunk: @@ -18,11 +22,17 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a `sha256::Hash`.
path: crates/floresta-common/src/lib.rs
user: login: luca0x46
body: The best option I have found it to link it using a hyperlink to the webpage as we build without deps, it will not show correctly if not done this way.

Wdyt?

```
/// Takes a reference to an array of bytes and returns
/// a [Hash].

/// [Hash]: https://docs.rs/bitcoin_hashes/latest/bitcoin_hashes/sha256/struct.Hash.html
```
created_at: 2025-05-15T20:30:44Z
author_association: CONTRIBUTOR
diff_hunk: @@ -18,11 +22,21 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a [Hash].
path: crates/floresta-common/src/lib.rs
user: login: JoseSK999
body: With a bit more context of what kind of hash it is (SHA-256) and where it comes from (`bitcoin_hashes`)
```suggestion
/// Computes the SHA-256 digest of the byte slice data and returns a [Hash] from `bitcoin_hashes`.
```
created_at: 2025-05-16T13:07:00Z
author_association: MEMBER
diff_hunk: @@ -18,11 +22,21 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a [Hash].
+///
+/// [Hash]: https://docs.rs/bitcoin_hashes/latest/bitcoin_hashes/sha256/struct.Hash.html
 pub fn get_hash_from_u8(data: &[u8]) -> sha256::Hash {
     let hash = sha2::Sha256::new().chain_update(data).finalize();
     sha256::Hash::from_slice(hash.as_slice()).expect("Engines shouldn't be Err")
 }
 
+/// Computes the sha256 of a script and reverses the bytes.
path: crates/floresta-common/src/lib.rs
user: login: JoseSK999
body: Similarly
```suggestion
/// Computes the SHA-256 digest of a script, reverses its bytes, and returns a [Hash] from
/// `bitcoin_hashes`.
```
created_at: 2025-05-16T13:08:10Z
author_association: MEMBER
diff_hunk: @@ -18,11 +22,21 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a [Hash].
+///
+/// [Hash]: https://docs.rs/bitcoin_hashes/latest/bitcoin_hashes/sha256/struct.Hash.html
 pub fn get_hash_from_u8(data: &[u8]) -> sha256::Hash {
     let hash = sha2::Sha256::new().chain_update(data).finalize();
     sha256::Hash::from_slice(hash.as_slice()).expect("Engines shouldn't be Err")
 }
 
+/// Computes the sha256 of a script and reverses the bytes.
+///
+/// The source to the specification can be found in the Electrum protocol [documentation], and it is
+/// used to identify scripts in the Electrum Protocol.
+///
+/// [documentation]: https://electrum-protocol.readthedocs.io/en/latest/protocol-basics.html#script-hashes
path: crates/floresta-common/src/lib.rs
user: login: JoseSK999
body: And we add the Hash link
```suggestion
/// [documentation]: https://electrum-protocol.readthedocs.io/en/latest/protocol-basics.html#script-hashes
/// [Hash]: https://docs.rs/bitcoin_hashes/latest/bitcoin_hashes/sha256/struct.Hash.html
```
created_at: 2025-05-16T13:09:05Z
author_association: MEMBER
diff_hunk: @@ -18,11 +22,21 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a [Hash].
+///
+/// [Hash]: https://docs.rs/bitcoin_hashes/latest/bitcoin_hashes/sha256/struct.Hash.html
 pub fn get_hash_from_u8(data: &[u8]) -> sha256::Hash {
     let hash = sha2::Sha256::new().chain_update(data).finalize();
     sha256::Hash::from_slice(hash.as_slice()).expect("Engines shouldn't be Err")
path: crates/floresta-common/src/lib.rs
user: login: JoseSK999
body: Not related to the PR but could you do this here:
```suggestion
    sha256::Hash::from_byte_array(hash.into())
```
created_at: 2025-05-16T13:10:43Z
author_association: MEMBER
diff_hunk: @@ -18,11 +22,21 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a [Hash].
+///
+/// [Hash]: https://docs.rs/bitcoin_hashes/latest/bitcoin_hashes/sha256/struct.Hash.html
 pub fn get_hash_from_u8(data: &[u8]) -> sha256::Hash {
     let hash = sha2::Sha256::new().chain_update(data).finalize();
     sha256::Hash::from_slice(hash.as_slice()).expect("Engines shouldn't be Err")
 }
 
+/// Computes the sha256 of a script and reverses the bytes.
+///
+/// The source to the specification can be found in the Electrum protocol [documentation], and it is
+/// used to identify scripts in the Electrum Protocol.
+///
+/// [documentation]: https://electrum-protocol.readthedocs.io/en/latest/protocol-basics.html#script-hashes
 pub fn get_spk_hash(spk: &ScriptBuf) -> sha256::Hash {
     let script_hash = spk.as_bytes();
path: crates/floresta-common/src/lib.rs
user: login: JoseSK999
body: Also unrelated but could you rename `script_hash` to `data`, and below use as well the:

```rust
    sha256::Hash::from_byte_array(hash.into())
```
created_at: 2025-05-16T13:12:25Z
author_association: MEMBER
diff_hunk: @@ -1,4 +1,35 @@
+//! This module has usefull macros for usage on other crates.
path: crates/floresta-common/src/macros.rs
user: login: JoseSK999
body: Nit: typo
```suggestion
//! This module has useful macros for usage on other crates.
```
created_at: 2025-05-16T13:13:23Z
author_association: MEMBER
diff_hunk: @@ -1,4 +1,35 @@
+//! This module has usefull macros for usage on other crates.
+
 #[macro_export]
+/// Implements the `From` trait for converting a specific type into an enum variant or struct field.
+///
+/// This macro is useful when building error enums or wrapper types that need to support automatic
+/// conversions from underlying error types using the `?` operator.
+///
+/// # Parameters
+///
+/// - `$thing`: The target type to implement `From` for (usually an enum or struct).
+/// - `$from_thing`: The source type that should be converted into `$thing`.
+/// - `$field`: The variant or field of `$thing` that wraps a value of type `$from_thing`.
+///
+/// # Example
+///
+/// ```rust
+/// use floresta_common::impl_error_from;
+///
path: crates/floresta-common/src/macros.rs
user: login: JoseSK999
body: I would hide the import like this, and remove the empty line:
```suggestion
/// # use floresta_common::impl_error_from;
```
created_at: 2025-05-16T13:15:01Z
author_association: MEMBER
diff_hunk: @@ -18,11 +22,21 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a [Hash].
+///
+/// [Hash]: https://docs.rs/bitcoin_hashes/latest/bitcoin_hashes/sha256/struct.Hash.html
 pub fn get_hash_from_u8(data: &[u8]) -> sha256::Hash {
     let hash = sha2::Sha256::new().chain_update(data).finalize();
     sha256::Hash::from_slice(hash.as_slice()).expect("Engines shouldn't be Err")
path: crates/floresta-common/src/lib.rs
user: login: luca0x46
body: I would still need an `.unwrap()` or an `expect()` 
created_at: 2025-05-16T17:40:04Z
author_association: CONTRIBUTOR
diff_hunk: @@ -18,11 +22,21 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a [Hash].
+///
+/// [Hash]: https://docs.rs/bitcoin_hashes/latest/bitcoin_hashes/sha256/struct.Hash.html
 pub fn get_hash_from_u8(data: &[u8]) -> sha256::Hash {
     let hash = sha2::Sha256::new().chain_update(data).finalize();
     sha256::Hash::from_slice(hash.as_slice()).expect("Engines shouldn't be Err")
path: crates/floresta-common/src/lib.rs
user: login: JoseSK999
body: Not in this case I think
created_at: 2025-05-16T18:50:24Z
author_association: MEMBER
diff_hunk: @@ -18,11 +22,21 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a [Hash].
+///
+/// [Hash]: https://docs.rs/bitcoin_hashes/latest/bitcoin_hashes/sha256/struct.Hash.html
 pub fn get_hash_from_u8(data: &[u8]) -> sha256::Hash {
     let hash = sha2::Sha256::new().chain_update(data).finalize();
     sha256::Hash::from_slice(hash.as_slice()).expect("Engines shouldn't be Err")
path: crates/floresta-common/src/lib.rs
user: login: luca0x46
body: Due to the return value. `sha256::Hash::something()` returns a Result, and our function/method expects a Ok value
created_at: 2025-05-16T19:47:21Z
author_association: CONTRIBUTOR
diff_hunk: @@ -18,11 +22,21 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a [Hash].
+///
+/// [Hash]: https://docs.rs/bitcoin_hashes/latest/bitcoin_hashes/sha256/struct.Hash.html
 pub fn get_hash_from_u8(data: &[u8]) -> sha256::Hash {
     let hash = sha2::Sha256::new().chain_update(data).finalize();
     sha256::Hash::from_slice(hash.as_slice()).expect("Engines shouldn't be Err")
path: crates/floresta-common/src/lib.rs
user: login: JoseSK999
body: `sha256::Hash::from_byte_array` doesn't return Result
created_at: 2025-05-16T20:35:27Z
author_association: MEMBER
diff_hunk: @@ -18,11 +22,21 @@ pub mod spsc;
 use prelude::*;
 pub use spsc::Channel;
 
+/// Takes a reference to an array of bytes and returns
+/// a [Hash].
+///
+/// [Hash]: https://docs.rs/bitcoin_hashes/latest/bitcoin_hashes/sha256/struct.Hash.html
 pub fn get_hash_from_u8(data: &[u8]) -> sha256::Hash {
     let hash = sha2::Sha256::new().chain_update(data).finalize();
     sha256::Hash::from_slice(hash.as_slice()).expect("Engines shouldn't be Err")
path: crates/floresta-common/src/lib.rs
user: login: luca0x46
body: You are right. I was using `from_slice(hash.into())` 

I believe I have checked all your suggestions. Please let me know if I overlooked something.
created_at: 2025-05-17T03:28:46Z
author_association: CONTRIBUTOR

PR comments:
user: login: JoseSK999
created_at: 2025-05-17T09:58:40Z
body: Apparently there is a new lint issue, should be easy to fix
author_association: MEMBER
user: login: luca0x46
created_at: 2025-05-17T12:45:06Z
body: > Apparently there is a new lint issue, should be easy to fix

Yeah, also, our CI is running trying to activate the `--experimental-p2p` feature on master run.

For this PR, I did not understand why it is failing in the rpc thing tho. Like, it wasnt noticed before and I havent changed anything there.
author_association: CONTRIBUTOR
user: login: JoseSK999
created_at: 2025-05-17T16:36:07Z
body: Likely it is a new lint analysis introduced
author_association: MEMBER
user: login: Davidson-Souza
created_at: 2025-05-17T16:42:48Z
body: Yeah, it's a new lint. You were the lucky one where it broke first. Just do what cargo is telling you to

```
error: this call to `clone` can be replaced with `std::slice::from_ref`
     --> florestad/src/json_rpc/server.rs:119:48
      |
  119 |         let Ok(mut parsed) = parse_descriptors(&[descriptor.clone()]) else {
      |                                                ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::slice::from_ref(&descriptor)`
      |
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cloned_ref_to_slice_refs
      = note: `-D clippy::cloned-ref-to-slice-refs` implied by `-D warnings`
      = help: to override `-D warnings` add `#[allow(clippy::cloned_ref_to_slice_refs)]`
  ```

Since it's so minor, I don't mind it being fixed in an unrelated PR (this or some other that's almost done)
author_association: MEMBER
user: login: Davidson-Souza
created_at: 2025-05-17T21:31:49Z
body: Just rebase with `master`. This got fixed by #489 
author_association: MEMBER