Skip to content

Remove the error case for match_any#325

Closed
rustaceanrob wants to merge 1 commit intomasterfrom
filter-api-4-5
Closed

Remove the error case for match_any#325
rustaceanrob wants to merge 1 commit intomasterfrom
filter-api-4-5

Conversation

@rustaceanrob
Copy link
Copy Markdown
Collaborator

@rustaceanrob rustaceanrob commented Apr 5, 2025

As of Rust lang 1.0.0 the &[u8] type does not include any error cases in the Read::read function (instead there are panics). The bip158 module of rust-bitcoin involves a lot of error propagation, but ultimately the fallible function is Read::read on a slice. Removing the error case allows for a cleaner API both internally and externally for future silent payments users.

Read trait invocation: https://docs.rs/bitcoin/latest/src/bitcoin/bip158.rs.html#455
The buffer: https://docs.rs/bitcoin/latest/src/bitcoin/bip158.rs.html#470
Read implemented for &[u8]: https://doc.rust-lang.org/src/std/io/impls.rs.html#298-403

Note this is the same message in the commit so there is a reference.

As of Rust lang `1.0.0` the `&[u8]` type does not include any error
cases in the `Read::read` function. The bip158 module of `rust-bitcoin`
involves a lot of propagation, but ultimately the fallible function
is `Read::read` on a slice. Removing the error case allows for a cleaner
API both internally and externally for future silent payments users.

Read trait invokation: https://docs.rs/bitcoin/latest/src/bitcoin/bip158.rs.html#455
The buffer: https://docs.rs/bitcoin/latest/src/bitcoin/bip158.rs.html#470
Read implemented for `&[u8]`: https://doc.rust-lang.org/src/std/io/impls.rs.html#298-403
@rustaceanrob rustaceanrob changed the title Rmove the error case for match_any Remove the error case for match_any Apr 5, 2025
@rustaceanrob
Copy link
Copy Markdown
Collaborator Author

rustaceanrob commented Apr 7, 2025

Shoot. I thought the read call here was from the Read trait but it's actually a method on the struct that is being used. Within that there is a read_exact which is technically fallible. I still think this cannot error for Vec<u8> but perhaps if a filter is malformed and sent maliciously it can. Requires a little research.

@rustaceanrob rustaceanrob deleted the filter-api-4-5 branch April 22, 2025 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant