Commit Graph

8 Commits

Author SHA1 Message Date
Fmt Bot a565db9fdd 2024-03-31 automated rustfmt nightly 2024-03-31 01:03:18 +00:00
Tobin C. Harding af49841433
Hide base58::Error internals
As is convention here in `rust-bitcoin`, hide the `base58::Error`
internals by adding struct error types.
2024-03-21 06:22:51 +11:00
Tobin C. Harding 4f68e79da0
bitcoin: Stop using base58 errors
We are currently using the `base58::Error` type to create errors in
`bitcoin`, these are bitcoin errors not `base58` errors.

Note that we add what looks like duplicate
`InvalidBase58PayloadLengthError` types but they are different because
of the expected length. This could have been a field but I elected not
to do so for two reasons:

1. We will need to do so anyways if we crate smash more
2. The `crypto::key` one can have one of two values 33 or 34.

With this applied we can remove the now unused error variants from
`base58::Error`.
2024-03-21 06:22:51 +11:00
Tobin C. Harding 669d5e8fc6
base58: Add InvalidCharacterError for decoding
The `base58::decode` function can only return a single error type, add a
`InvalidCharacterError` struct (leaf error) to use as the return type.
2024-03-21 06:22:51 +11:00
Tobin C. Harding ec8609393b
base58: Add error module
In preparation for improving the `base58` error types crate an `error`
module and move the single current error type there. Make the module
public and reexport the type.
2024-03-21 06:22:51 +11:00
Tobin C. Harding 42fabbab03
base58: Run the formatter 2024-03-21 06:22:49 +11:00
Liam Aharon b9f7462958
Implement infallible for errors
Creates a new macro `impl_from_infallible`, and applies it to custom
error types in the codebase.

Closes #1222.
2024-03-08 16:48:34 +11:00
Tobin C. Harding aa8ba118ae
Add a new base58 crate
Add a new `base58` crate to the workspace and move the `bitcoin::base58`
module to it.

Done as part of crate smashing, specifically so that we can make `bip32`
into a separate crate.
2024-02-23 12:54:24 +11:00