ee113aa91f ci: add daily job to update nightly rustc (Andrew Poelstra)
f82567fda4 ci: rename a couple .yml files to indicate that they're scheduled (Andrew Poelstra)
85ead84a99 ci: pin nightly in current CI (Andrew Poelstra)
c97f2ccc69 ci: require a nightly compiler rather than using +nightly (Andrew Poelstra)
e386cbfadf ci: delete *test.sh files (Andrew Poelstra)
Pull request description:
We should be pinning our nightly compiler in CI so that
* running CI on old release branches will continue to work (not quite -- we'd want to do the same thing for Cargo.lock, but ok, one PR at a time)
* when CI breaks due to nightly updates (usually new Clippy lints), we can address that in a dedicated "update nightly" PR rather than having every other PR suddenly break on us
Co-authored with ChatGPT which found several typos and suggested most of the error-handling logic.
ACKs for top commit:
tcharding:
ACK ee113aa91f
Kixunil:
ACK ee113aa91f
Tree-SHA512: f198349291a7654f4e6f03998d02c1f7d2c7f999e0b5a89a915beb3e7c741148c2c65367b107c54c34d6669e6f0972699401ef85e76e76e5900c1fb5c844db4f
e3db95226a Tidy description (yancy)
Pull request description:
I noticed `uncheced_add` looked really bad with two spaces (my mistake). Fixed some others as well.
ACKs for top commit:
apoelstra:
ACK e3db95226a oops, we should have caught this. Thanks for the fix!
tcharding:
ACK e3db95226a
Tree-SHA512: 8a2e7f85262f17063bea6ac22855ae45d99a1559a2d30f2627ffba1108f0fd8ebd0b541b50fe746b5af2ebb013cb3e9ea432987b90f37c046120388a808c5443
This can be checked against the 0.29.x branch, and against the commit
prior to #1659 (40c246743b^) and you will see that it is consistent
EXCEPT:
* In rust-bitcoin 0.29.x we did not have multiple sighash types, only
`Sighash`; we now have `LegacySighash`, `SegwitV0Sighash`, and
`TapSighash`.
* In #1565 we deliberately changed the display direction of the
sighashes, to match BIP 143.
Fixes#2495.
08f83898a3 Report the position of an invalid char in amount (Martin Habovstiak)
73b325aec5 Report position of the first "too precise" digit (Martin Habovstiak)
28d83551eb Improve `ParseAmountError::InputTooLarge` (Martin Habovstiak)
b7689a7d60 Split up `ParseAmountError::InvalidFormat` (Martin Habovstiak)
Pull request description:
This contains several improvements to `PareAmountError`& co - see the individual commit messages. The changes should be pretty easy to follow.
Note that my planned amount error work is not complete by this, so if this happens to get ACK by tomorrow, I'll wait for this to merge, if not I'll add more commits (without changing the existing ones).
I want to get this stuff into the first `units` release.
ACKs for top commit:
tcharding:
ACK 08f83898a3
apoelstra:
ACK 08f83898a3
Tree-SHA512: aee476c4b306b940978b61f8e7ea89ce401a5736971fb3d4bd6fbfc54916695631022199cd0247a3ecb678653facbe486c89e667de26dc9e67902037cb00b23a
We can't link to `std::error::Error` in rustdoc because it breaks
non-std builds. Just use backticks - this is not an optimal solution but
I know no other.
I have no clue why this is showing up now.
The `address` module is currently publicly re-exporting all error types
that appear as return values for any pubic function, except for the
`P2shError` - we should be uniform.
This re-export of error thing has not been discussed/agreed upon as a
policy but I have been doing it for the last few months anytime I
introduced an `error` module - there has been no push back so I assumed
it was acceptable. Before 1.0 we should probably have a policy on this.
If we pin the version of nightly to a specific date then `cargo
+nightly` will stop working. And even locally, if you want to use a
specific version of nightly, you can't if the script is overriding your
version with "+nightly". Instead the user should set RUSTUP_TOOLCHAIN.
These are not run in CI since #2353 and are likely to go out of date. If
we want a script that users can run locally then we should create a new
script that wraps our current CI.
86f8043e80 Remove Error suffix from variant (Tobin C. Harding)
482c8cb7f8 Clean up error type from impls (Tobin C. Harding)
Pull request description:
Done while working on other error code; two trivial cleanups.
This PR gives us a place to debate the current error `From` impl format. The canonical form is, as far as I understand:
```rust
impl From<FooError> for Error {
#[inline]
fn from(e: FooError) -> Self { Self::Foo(e) }
}
```
ACKs for top commit:
apoelstra:
utACK 86f8043e80
Kixunil:
ACK 86f8043e80
Tree-SHA512: 82169baf5ec58f5fd08c7615e6f639721870a264dd93e253d3128ebee5bfe3646354fa10d38b496792bf979e03a1c7a54fb47c7a4dce9822ea7f04b84a0fbac1
a55e78a28d internals: Implement Default for ArrayVec (Tobin C. Harding)
Pull request description:
In an unrelated PR CI run we got the following error:
```
error: you should consider adding a `Default` implementation for `ArrayVec<T, CAP>`
```
I did not bother to dig any deeper since this seems like a reasonable suggestion by the compiler since we provide a `new` function that takes zero arguments.
Add a `Default` implementation to `ArrayVec`.
ACKs for top commit:
apoelstra:
ACK a55e78a28d
Kixunil:
ACK a55e78a28d
Tree-SHA512: 85b8248ca3b6d098eeb65042d89f69fc359ef1d167c52abf321b5a6597c0a8d44cd7383668b959c2082156214a47a61478d725431718c41f23f3ca48fb274342
In an unrelated PR CI run we got the following error:
```
error: you should consider adding a `Default` implementation for `ArrayVec<T, CAP>`
```
I did not bother to dig any deeper since this seems like a reasonable
suggestion by the compiler since we provide a `new` function that takes
zero arguments.
Add a `Default` implementation to `ArrayVec`.
7e2a81d03b Remove unused address::Error type (Tobin C. Harding)
a92dc9c35c Add NetworkValidationError (Tobin C. Harding)
Pull request description:
Replaces #2502 because there is going to be way too much arguing on this to bother a newer contributor with.
This PR takes into consideration #2507 but does not improve the issue, it also does not make it worse. I propose to do this and then consider #2507 since this is a step forwards IMO.
Remove the `address::Error` because its not good. Add a `NetworkValidationError` and return it from `require_network` - leaving the door open for resolving Kix's issue in 2507.
ACKs for top commit:
Kixunil:
ACK 7e2a81d03b
apoelstra:
ACK 7e2a81d03b
Tree-SHA512: 0a220dbec1457f35e3d95f32399f258e65c0477e8b4d14dbe2dfad0a44966ab0339d4c2d9828da318bf131db45cecb2447c0e32d5669a5f4c4739b90c83d3c0d
9d688396c9 base58: Use pub extern crate instead of module (Tobin C. Harding)
Pull request description:
We don't add any implementations to the `base58` types so we can just `pub extern` the crate instead of using a module and re-exporting.
ACKs for top commit:
Kixunil:
ACK 9d688396c9
apoelstra:
ACK 9d688396c9
Tree-SHA512: 521af0fd1ae365a6d060dd3c38fc18c1fb3a6c46adb7cba64e53128c7a898c766bcc603078b4cb8a3672df96559633495b23203a33147b5b4959b0c690ab7451
We have three integer wrapping types that can be created from hex
strings where the conversion from an integer is infallible:
- `absolute::LockTime`
- `Sequence`
- `CompactTarget`
We would like to improve our handling of the two prefix characters (eg
0x) by making it explicit.
- Modify the inherent `from_hex` method on each type to error if the
input string does not contain a prefix.
- Add an additional inherent method on each type `from_unprefixed_hex`
that errors if the input string does contain a prefix.
This patch does not touch the wrapper types that cannot be infallibly
constructed from an integer (i.e. absolute `Height` and `Time`).
The `FromHexStr` trait is used to parse integer-like types, however we
can achieve the same using inherent methods.
Move the hex parsing functionality to inherent methods, keeping the same
behaviour in regard to the `0x` prefix.
4e557fa4e6 Update bech32 dependency (Tobin C. Harding)
Pull request description:
Update `bech32` to the newly released version `0.11.0`.
ACKs for top commit:
apoelstra:
ACK 4e557fa4e6
Kixunil:
ACK 4e557fa4e6
Tree-SHA512: bbf19876553b7b27191610a68da60a7d1c5246646c0109dd9bc4909259244ca79f624e0c8a6fc205d93fcdacfd3a82201cda6cf09e0c233cceb10e25b3133871
c2d658ac05 Add `P2shError` for handling errors related to P2sh (harshit933)
5182a8d7a8 Remove unused variants from `Address::Error` (harshit933)
05b24946eb Add the `FromScriptError` for handling errors in `address` (harshit933)
Pull request description:
This commit adds the `FromScriptError` struct to handle the errors while generating address from any script. It includes :
- Unrecognized script error.
- Witness Program error.
- Witness Version error.
ACKs for top commit:
tcharding:
ACK c2d658ac05
apoelstra:
ACK c2d658ac05
Tree-SHA512: 891eed787129aaf1b664cc16d325178d5d2f77cc41a0543a3d9d1a5af1b58188daece1f6a653bdc6b76b82db0490a39e9bba7fc090e3727d15ee9b8977733698
ac88bc03fd Make constructors const (Tobin C. Harding)
Pull request description:
Audit the codebase for any function that starts with `/// Creates` and see if we can make it const. Inline them at the same time.
ACKs for top commit:
Kixunil:
ACK ac88bc03fd
apoelstra:
ACK ac88bc03fd
Tree-SHA512: 0c71e38018e74b3ce1aae871fc6208b87655a0970ae6cca7a538b9f896c95542c6905eb4d7e02539847e88d8a22a873039a5734130c2a46efb4d1b2b9ffd9f4a
aa8ba118ae Add a new base58 crate (Tobin C. Harding)
Pull request description:
Add a new `base58check` 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.
ACKs for top commit:
Kixunil:
ACK aa8ba118ae
apoelstra:
ACK aa8ba118ae though is this `pub mod` thing equivalent to `pub extern crate`?
Tree-SHA512: a8db975655029b46df3b40ceca064ba708ce2f5fff0cfd6776d691441356c8a58fe6bdae6a1bf495da5112962e73c2b46df740a4041bed56f2559cb3c47ff34a
Sometimes people don't remember the exact number of decimal places
supported by denomination or don't want to count (e.g. when converting
fiat to BTC the calculator may yield too precise value). It's helpful to
say in error message at which digit the precision is too high.
This adds `TooPreciseError` struct containing the information and
improves the error message to display it.
This variant lacked pretty important information: what is the limit. We
could just write it in the error message but it's even better to move it
to a separate struct which also says how many characters exceed the
limit - this helps users know how many need to be deleted.
The `InvalidFormat` variant was pretty bad: it didn't make it clear what
exactly is wrong with the input string, especially since it was used
when the denomination was missing. Not only was this unhelpful to the
users who don't know they have to write the denomination when the amount
was otherwise correct but it was also attributed to a problem with the
amount rather than a problem with denomination.
To fix this the variant is replaced by `MissingDigitsError`,
`MissingError` and `InvalidCharError` - all the cases `InvalidFormat`
was originally used in.
`InvalidCharError` is effectively the same as the existing variant but
it was made into a separate error to enable special casing `.` and make
extensions possible. Further this opportunity was used to add a special
case for `-` as well.
`MissingDigitsError` currently contains special casing for empty string
and a string only containing minus sign. It's currently unclear if it's
useful so this change makes this distinction private and only makes it
affect error messages.
As opposed to the previous two variants, `MissingDenominationError` was
added to `ParseError`. The struct is currenly empty and may be extended
in the future with e.g. span information.
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.
1ee887a2fc Make from_hex inherent for byte-like types (Tobin C. Harding)
Pull request description:
Byte like types naturally display in hex, therefore they should havean inherent method `from_hex` and not implement `FromHex`.
ACKs for top commit:
Kixunil:
ACK 1ee887a2fc
apoelstra:
ACK 1ee887a2fc
Tree-SHA512: fc69168f6111e402ffca6e861a9fdd50742d8faf361929c620d94c8f5598fb7d6920cab4529d69a7cce2a5ff112849aa77517d230fa580ad11b62e6eb7f4a8d3
This commit adds the `FromScriptError` struct to handle the errors
while generating address from any script. It includes :
- Unrecognized script error.
- Witness Program error.
- Witness Version error.