Commit Graph

5346 Commits

Author SHA1 Message Date
Tobin C. Harding c92290278e
base58: Close all errors
Currently we have a bunch of public errors in the `base58` crate. Only
two are returned by public functions `decode()` and
`decode_check()` (`Error` and `InvalidCharacterError` respectively).

- Close the two public errors by adding private inner errors.
- Add getters on the public errors to get the error data.
- Make all other errors private.
- Call `impl_from_infallible` for _all_ error types.

Done as part of #3261
2024-10-31 13:59:57 +11:00
Tobin C. Harding bafe11d7e4
Correctly feature gate impl_to_hex_from_lower_hex
Currently we feature gate code within the `impl_to_hex_from_lower_hex`
 macro on "alloc" but `bitcoin` does not have the "alloc" feature so
 this code is never built in. This can be seen by the lack of a
 `to_hex` function on `LeafVersion`.

Remove the feature gate from the macro and put it on the individual
call sites as needed.
2024-10-31 13:43:47 +11:00
Tobin C. Harding 57769f5f28
Fix ugly rustfmt
Fix some ugly formatting introduced by the fmt bot recently.

Whitespace only, no logic changes.
2024-10-31 13:38:27 +11:00
Tobin C. Harding dfb76c1e15
Use doc(notable_trait)
There is an unstable feature that puts up a little 'i' in a circle
next to any function that returns a type that implements an notable
trait. For us this means we can make the extension traits more
discoverable.

ref: https://doc.rust-lang.org/unstable-book/language-features/doc-notable-trait.html

Close: #3232
2024-10-31 13:33:28 +11:00
merge-script 3c16ed05c9
Merge rust-bitcoin/rust-bitcoin#3540: Automated daily update to rustc (to nightly-2024-10-30)
c80d0bfcc8 Automated update to Github CI to rustc nightly-2024-10-30 (Update Nightly Rustc Bot)

Pull request description:

  Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  tcharding:
    ACK c80d0bfcc8

Tree-SHA512: 26ee5fd03019452f0f1be637faf0f5c9129e87d375aea046de82bb3b0a56ea6e8690a08b9d3cb0b9a81c59acb89c163d15825406794d8cfa062f22939f029b11
2024-10-31 13:28:07 +11:00
Tobin C. Harding 10ff979fbd
amount: Move arbitrary impl
In an effort to make the `unsigned` and `signed` files be diff'able move
the `arbitrary` code to be in the same place.

Code move only.
2024-10-31 12:57:08 +11:00
Tobin C. Harding d4d9311603
amount: Move SignedAmount to private signed module
In an effort to make the `amount` module more readable move the
`SignedAmount` type to a private submodule.

Re-export everything so this is not a breaking change.

Code move and re-exports only.
2024-10-31 12:57:08 +11:00
Tobin C. Harding 0fc0e8760b
docs: Remove link from self
When we move `SignedAmount` to a submodule linking to `self` introduces
a clippy warning, I'm not exactly sure why but lets remove the link in
preparation for the move.
2024-10-31 12:57:03 +11:00
Tobin C. Harding 13f9fd1b77
amount: Move Amount to private unsigned module
In an effort to make the `amount` module more readable move the `Amount`
type to a private submodule.

Re-export everything so this is not a breaking change.

Code move and re-exports only.
2024-10-31 12:56:40 +11:00
Update Nightly Rustc Bot c80d0bfcc8 Automated update to Github CI to rustc nightly-2024-10-30 2024-10-31 01:50:06 +00:00
Tobin C. Harding 2d4c0fa6c1
amount: Format serde file
Done as a separate patch so that the diff of the verification code move
was less noisy.
2024-10-31 12:29:21 +11:00
Tobin C. Harding df96267342
amount: Move serde code to submodule
No changes other than moving the module code.
2024-10-31 12:29:21 +11:00
Tobin C. Harding 87c9a3fd11
amount: Format tests file
Done as a separate patch so that the diff of the verification code move
was less noisy.
2024-10-31 12:29:21 +11:00
Tobin C. Harding e0bc68042d
amount: Move test code to submodule
In preparation for splitting the two amounts into separate files; move
the `amount` module code to a submodule.

Internal change only.
2024-10-31 12:29:20 +11:00
Tobin C. Harding 7e1269704d
tests: Use from_sat
Stop using private constructor in unit tests, use `from_sat` instead.
2024-10-31 12:29:20 +11:00
Tobin C. Harding cd5d1aba2f
amount: Format verification file
Done as a separate patch so that the diff of the verification code move
was less noisy.
2024-10-31 12:29:20 +11:00
Tobin C. Harding 01f907b7a6
amount: Move verification code to submodule
Code move only, no other changes.
2024-10-31 12:29:20 +11:00
Tobin C. Harding 5ce827c5e0
amount: Move error code to submodule
There is _a lot_ of error types in the `amount` module. Move them to a
separate `error` module.

Add a bunch of `pub(super)` to keep things private to the `amount`
module.

Eventually we will want to close all these errors.
2024-10-31 12:29:16 +11:00
merge-script 05d9ccb261
Merge rust-bitcoin/rust-bitcoin#3525: Release tracking PR: `chacha20-poly1305` v0.1.0
7d6ed16dfc Add changelog to chacha20-poly1305 crate (Nick Johnson)

Pull request description:

  The initial release for the `chacha20-poly1305` crate. No other preparation needed for release since the version, `v0.1.0`, is already set in Cargo.toml.

ACKs for top commit:
  tcharding:
    ACK 7d6ed16dfc
  storopoli:
    ACK 7d6ed16dfc
  apoelstra:
    ACK 7d6ed16dfc9e8549bcf3d73af9aae7cd13904643; successfully ran local tests

Tree-SHA512: b9b42f59f7515e1cce63601ecaf33ba11eb594ec359e436babb1e7bed299f2244cae5e4760af9534f47023d5491d718f2cbd4808a6a15deab2aaf671305b817f
2024-10-30 23:00:03 +00:00
Tobin C. Harding abc54d0343
Make amount module a directory
In preparation for splitting the error types out of `amount.rs` into
their own file move the `amount.rs` file to `amount/mod.rs`.

File move only, no other changes.
2024-10-31 09:52:32 +11:00
Tobin C. Harding 851e4111ec
Run the formatter 2024-10-31 09:52:32 +11:00
merge-script c2adc52ee1
Merge rust-bitcoin/rust-bitcoin#3510: Move `Transaction` to `primitives`
f8f846bb9e Move Transaction type to primitives (Tobin C. Harding)
7b5af2ad5b Use `Transaction::compute_txid` in rustdoc (Tobin C. Harding)
98383a0fbe Introduce Transaction extension traits (Tobin C. Harding)
3f6bc74ae4 Introduce an iterator type for script_pubkey_lens (Tobin C. Harding)
7196992d58 Split Transaction impl block (Tobin C. Harding)
693000d09c Use super::* in bench module (Tobin C. Harding)
29d23b4b3a Move import statement (Tobin C. Harding)
e84346644e Run the formatter (Tobin C. Harding)

Pull request description:

  First introduce the `Transaction` extension traits manually (without using the `define_extension_trait` macro) then move the `Transaction` to `primitives`.

  Note please patch 5, ugly due to language requirements.

ACKs for top commit:
  apoelstra:
    ACK f8f846bb9ea3cfde460ec058eb04e5aba010cdbb; successfully ran local tests

Tree-SHA512: f830ad4f763bf78c5fedf750dbcb4354b6c8f38cbe2c0b6ba9e9d6b836356c5e041fe3db04e0b354c939f4205dd1ae29ba15b8e53da6b495450852f955d2f40d
2024-10-30 21:46:46 +00:00
Tobin C. Harding f8f846bb9e
Move Transaction type to primitives
Needs no explanation - lets go!
2024-10-30 12:28:53 +11:00
Tobin C. Harding 7b5af2ad5b
Use `Transaction::compute_txid` in rustdoc
The `txid` function was re-named to `compute_txid` but we missed one
call link in rustdocs - update it.
2024-10-30 12:28:52 +11:00
Tobin C. Harding 98383a0fbe
Introduce Transaction extension traits
WARNING: This is not like all the other extension traits.

Because of the use of generics on various `Transaction` methods it is
not easily possible to use the `define_extension_trait` macro.

Manually create the extension traits (public and private) for the
`Transaction` type. This is quite ugly but c'est la vie

(Includes two in the `transaction` module and one in the
`consensus_validation` module.)
2024-10-30 12:28:52 +11:00
Tobin C. Harding 3f6bc74ae4
Introduce an iterator type for script_pubkey_lens
Currently `script_pubkey_lens` returns a generic `Iterator` using `impl`
syntax. This syntax is not supported in traits and we want to move the
function to the soon-to-be-added `TransactionExt` trait.

Add a struct to hold the iterator returned by `Map`, this is ugly but
its the least ugly thing I could come up with.
2024-10-30 12:28:51 +11:00
Tobin C. Harding 7196992d58
Split Transaction impl block
Split the `Transaction` impl block into three parts:

- The bits going to `primitives`
- The bits staying in a public extension trait
- The bits staying in a private extension trait

Internal change only.
2024-10-30 11:30:41 +11:00
Tobin C. Harding 693000d09c
Use super::* in bench module
It is acceptable to use a wildcard import in bench code for the same
reasons it is acceptable in the `tests` module.

In preparation for introducing extension traits in the `transaction`
module use wildcard import in the module's bench code.
2024-10-30 11:30:36 +11:00
Tobin C. Harding 29d23b4b3a
Move import statement
The code using this import is a feature gated test, move the import into
the test.

Found with clippy. Internal change only.
2024-10-30 11:30:25 +11:00
Tobin C. Harding e84346644e
Run the formatter
Run `just fmt` - no other changes.
2024-10-30 11:30:24 +11:00
merge-script 77a8f076b8
Merge rust-bitcoin/rust-bitcoin#3528: hashes: Make more effort with the macros docs
abcac54078 hashes: Move public macros (Tobin C. Harding)
2868985a91 Replace TBD with next hashes release version (Tobin C. Harding)
baab5e580d hashes: Move private macro (Tobin C. Harding)
e4486d07f0 hashes: Hide macros from docs (Tobin C. Harding)
25c4c78e26 hashes: Put attribute under rustdoc (Tobin C. Harding)

Pull request description:

  A quick cleanup to try and make the docs better around our macros.

  Last patch might be churn, can drop it if wanted. Came about because the `macros` module shows empty in the docs currently.

ACKs for top commit:
  apoelstra:
    ACK abcac540782dd84992e47f342929efd407746c65; successfully ran local tests

Tree-SHA512: e2b4b4fe98e38f32902f7985f995c4bbc302b19b67010ddae38c22cac8151dd19370f3bd236836075744e7e5d9c6900e25416c221cddefa2452e4af81eb49dc2
2024-10-29 22:39:02 +00:00
Tobin C. Harding abcac54078
hashes: Move public macros
Put the two "real" public macros at the top of the `macros` file and add
a module level doc to link to them because they don't show up otherwise.
2024-10-30 07:10:37 +11:00
Tobin C. Harding 2868985a91
Replace TBD with next hashes release version
We are about to release `bitcoin_hashes 0.15.0`, replace the TBD string
with the version number.

Requires changing `allow(deprecated_in_future)` attribute to
`allow(deprecated)` (in functions that are them self deprecated).
2024-10-30 07:10:36 +11:00
merge-script c40826e008
Merge rust-bitcoin/rust-bitcoin#3480: bitcoin: Add some upgrade notes
f2e1a4b16c bitcoin: Add some upgrade notes (Tobin C. Harding)

Pull request description:

  While upgrading `miniscript` to use tip of master I made some notes to help users upgrade. Just throw them in the changelog file or now.

ACKs for top commit:
  storopoli:
    ACK f2e1a4b16c
  apoelstra:
    ACK f2e1a4b16cb8b71b50da723a20761fbe3822d6fc; successfully ran local tests

Tree-SHA512: 3e7a64445476dce8c716edf127b2594c434948bfff7c301ac74a723fa49b2784cca90cf74d231fe18a9fa8e80ffd5cb43232fb90aeae5943568623d4252fc4ef
2024-10-29 14:15:36 +00:00
merge-script 6c8d0ef95b
Merge rust-bitcoin/rust-bitcoin#3519: psbt: Fix bug in Subtype consensus_encode
c89b816437 psbt: Fix bug in Subtype consensus_encode (Tobin C. Harding)

Pull request description:

  In #2906 we switched from using a `u8` for type keys to using a `u64` and encoding as a compact int (inline with the spec). Note that a `u8` encodes to the same bytes as a `u64` when the value is < 252.

  In that patch, I introduced a bug because the length returned by `PoprietaryKey::consensus_encode` uses a hard code 1 for the length of the encoding (because of single byte) instead of the variable length for the new compact encoding.

  Bug showed up in fuzzing, and was isolated by Jamil - mad props.

  Fix: #3501

ACKs for top commit:
  jamillambert:
    ACK c89b816437
  apoelstra:
    ACK c89b8164377123eb20476636f2f5271c6a687406; successfully ran local tests

Tree-SHA512: 1b61b6a9ece197d74038ceedb447fd3ca21db8e2a6a96c9281a99ac232c18c3ca55da8e3f46930401714d3575e9a406a36e4f44929ca963208a5df4be6b46cfb
2024-10-29 13:10:08 +00:00
merge-script 34bf82060c
Merge rust-bitcoin/rust-bitcoin#3520: Use fully qualified path in macro
025a8773bf Use fully qualified path in macro (Tobin C. Harding)

Pull request description:

  Using fully qualified paths in macros reduces maintenance burden. We have one macro where we use relative path to access the `psbt` module.

  Refactor only, no external change.

ACKs for top commit:
  apoelstra:
    ACK 025a8773bf63aacdaca011ef000f41a85a961567; successfully ran local tests; will one-ACK merge

Tree-SHA512: eb5923a48ae4d82499679a58375ef7d2e8ba85c91671e350f7be19f0372750a269f44dd2f05f4a70ed0c7f277b160400eb41ff1d42b90e6057f1344be7e11a89
2024-10-29 04:28:20 +00:00
Tobin C. Harding baab5e580d
hashes: Move private macro
We have two files one for public macros and one for private macros. Move
the `engine_input_impl` macro to the private macros file.

Requires change to call sites because we do not have `use_macros`
attribute on the `internal_macros` file.
2024-10-29 14:06:12 +11:00
Tobin C. Harding e4486d07f0
hashes: Hide macros from docs
These three macros are solely provided to reduce code duplication, they
are only part of the public API because they are used by the "real"
public macro `hash_newtype`.
2024-10-29 14:01:50 +11:00
Tobin C. Harding 25c4c78e26
hashes: Put attribute under rustdoc
Like we do for all the other macros ptu the `macro_export` attribute
below the macro comments.
2024-10-29 13:58:50 +11:00
merge-script 0bef101262
Merge rust-bitcoin/rust-bitcoin#3299: hashes: Remove `utils` module
5a736edaaa hashes: Move serde_macros code into macros (Tobin C. Harding)
aaa78a3a09 hashes: Rename util to macros (Tobin C. Harding)
34e638d40c hashes: Separate private and public modules (Tobin C. Harding)

Pull request description:

  We don't want dump-all module names. Remove `utils` in favour of `macros`, while we are at it roll the `serde_maros` code into it as well and remove that module.

  Fix: #2665

ACKs for top commit:
  apoelstra:
    ACK 5a736edaaac5e13166dc907c8608b84132c65096; successfully ran local tests

Tree-SHA512: 95de1ecb0ec3884824df10a4a2e48b20786fbe819adc26e2260981d53810ff6d3f2c9ce7916e7184e54d0f8bf724217b1a10497c63020f972c6f81cc9ccd590d
2024-10-29 01:05:03 +00:00
merge-script 1f578fc929
Merge rust-bitcoin/rust-bitcoin#3518: Automated nightly rustfmt (2024-10-27)
39f46a16bc 2024-10-27 automated rustfmt nightly (Fmt Bot)

Pull request description:

  Automated nightly `rustfmt` changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  tcharding:
    ACK 39f46a16bc
  apoelstra:
    ACK 39f46a16bc0da356f495166ccd5829627af3749b; successfully ran local tests

Tree-SHA512: 6c27714b18ad6957104246145a2d4243f8e43e378d63f3d946ba05ecaf859432f2fe363fe3e7a29a33c41297216fd1176c165ac55deb109f636813c637ff6c43
2024-10-28 21:34:59 +00:00
Nick Johnson 7d6ed16dfc Add changelog to chacha20-poly1305 crate
* No other preperation needed for release since the version is already
set in Cargo.toml.
2024-10-28 13:21:39 -07:00
merge-script 6c54a1d2f2
Merge rust-bitcoin/rust-bitcoin#3497: Explicitly re-export stuff from crates down the stack
66da2266e2 Explicitly re-export stuff from crates down the stack (Tobin C. Harding)

Pull request description:

  Up until recently we were using wildcard re-exports for types moved to `units` and `primitives`. We have decided against doing so in favour of explicit re-exports.

  Audit `units` and `primitives` using `git grep 'pub enum'` (and `struct`) and explicitly re-export all types.

  Remove all wildcards except for the re-exports from `opcodes`, there are too many opcodes, explicitly re-exporting them does not aid clarity.

ACKs for top commit:
  apoelstra:
    ACK 66da2266e26dfe53947c4606e9d18620931e93cf; successfully ran local tests

Tree-SHA512: 74717f8b127e975e3d131aab884bdfe78e699d88b7ee1db7731ad117437d37684285264001cf6b2182eb1e565171167695e00c4b6aef28a3e26b69d9cebfbb74
2024-10-28 19:20:23 +00:00
merge-script 4bd820b8cc
Merge rust-bitcoin/rust-bitcoin#3045: Remove `bech32` from `address::ParseError`
9a7b1c232b Wrap the bech32 decoding error (Tobin C. Harding)

Pull request description:

  In #2381 we attempted to fully encapsulate the `bech32` crate to help with stabalizing `rust-bitcoin` however we failed to notice the `address:ParseError` has a variant that includes `bech32`. Public enums have public variant internals in Rust. Also the `From<bech32::segtiw::DecodeError` makes `bech32` public.

  Closes: #3043

ACKs for top commit:
  apoelstra:
    ACK 9a7b1c232b494dccdce091a46d916cc411a612a1; successfully ran local tests; will one-ACK merge since this is a gazillion years old and obviously right

Tree-SHA512: b5053aa43107aa47da1fe7e7db0f882cfb231b9769a7b67d8c930532c471df191f588bf98f2b00cc76d5a2e9c74e035ee96128da115363ac3952f96a766494ea
2024-10-28 18:15:38 +00:00
merge-script 20479f199f
Merge rust-bitcoin/rust-bitcoin#3522: Elide more lifetimes
3e2c43b19e Elide more lifetimes (Tobin C. Harding)

Pull request description:

  clippy found some more lifetimes to elide.

ACKs for top commit:
  jamillambert:
    ACK 3e2c43b19e
  apoelstra:
    ACK 3e2c43b19e111ee58fb280232e084ea40263040b; successfully ran local tests

Tree-SHA512: 4ad27794f67e1fa42a17830983fc124d53aff3f9c31a0b37760f6fa674cc0bf01b1f0d2861fb953a1c9e7507d45078ff6408e9ee203dab0171bfded10409a6a3
2024-10-28 16:07:37 +00:00
Tobin C. Harding 3e2c43b19e
Elide more lifetimes
clippy found some more lifetimes to elide.
2024-10-28 15:22:13 +11:00
Tobin C. Harding 025a8773bf
Use fully qualified path in macro
Using fully qualified paths in macros reduces maintenance burden. We
have one macro where we use relative path to access the `psbt` module.

Refactor only, no external change.
2024-10-28 09:08:26 +11:00
merge-script 2edfcedde1
Merge rust-bitcoin/rust-bitcoin#3485: Automated weekly update to rustc stable (to 1.82.0)
b47aff60ef Automated update to Github CI to rustc stable-1.82.0 (Update Stable Rustc Bot)

Pull request description:

  Automated update to Github CI workflow `semver-checks.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  tcharding:
    ACK b47aff60ef

Tree-SHA512: 75327c5fe8c3f3e59211e000c4d100e4eecf894fae963a7b645746059ecce4b0700fb45dece82ee174087e03e1ac326eea623496a6b8f5ab02d589c8fc005de5
2024-10-28 08:16:53 +11:00
Tobin C. Harding c89b816437
psbt: Fix bug in Subtype consensus_encode
In #2906 we switched from using a `u8` for type keys to using a `u64`
and encoding as a compact int (inline with the spec). Note that a `u8`
encodes to the same bytes as a `u64` when the value is < 252.

In that patch, I introduced a bug because the length returned by
`PoprietaryKey::consensus_encode` uses a hard code 1 for the length of
the encoding (because of single byte) instead of the variable length for
the new compact encoding.

Bug showed up in fuzzing, and was isolated by Jamil - mad props.
2024-10-28 08:09:41 +11:00
Fmt Bot 39f46a16bc 2024-10-27 automated rustfmt nightly 2024-10-27 01:21:24 +00:00