Commit Graph

1920 Commits

Author SHA1 Message Date
Tobin C. Harding cf455d3a06
Fix typo in prifixes
Close: #3856
2025-01-05 12:36:56 +11:00
merge-script 72cc88d907
Merge rust-bitcoin/rust-bitcoin#3847: ParsePublicKeyError using hex::InvalidCharError
945fcd0920 fix ParsePublicKeyError using hex::InvalidCharError (Innocent Onyemaenu)

Pull request description:

  Replaced the InvalidChar variant u8 with hex::InvalidCharError

  Resolves #3835

  changed InvalidChar variant of the ParsePublicKeyError from `u8` to `hex::InvalidCharError`

  ```
  pub enum ParsePublicKeyError {
      ...
      /// Hex decoding error.
      InvalidChar(hex::InvalidCharError),
      ...
  }

  Also,

  modified the test cases to accommodate the new variant

  Why:
  - hex::InvalidCharError includes both the invalid character and its position.
  - This improves debugging and makes error messages more actionable.

ACKs for top commit:
  apoelstra:
    ACK 945fcd09209120ef8869a2e4165e866328cc9bd5; successfully ran local tests; I like it
  clarkmoody:
    utACK 945fcd0920

Tree-SHA512: c13446c099cb02b4f253f9cc559a860aff3288a2cc5eac96d3cf910bf63e78957741bbdff69b936b16b36e46b366841a5c94876d16cbc0c41aea2a70866a6e45
2025-01-04 01:05:04 +00:00
merge-script 3b2363b2c6
Merge rust-bitcoin/rust-bitcoin#3846: Remove `test_` prefix from unit tests
85e04315d5 Remove test_ prefix from unit tests (Tobin C. Harding)

Pull request description:

  There is a loose convention in Rust to not use `test_` prefix. The reason being that `cargo test` outputs 'test <test name>' using the prefix makes the output stutter.

  This patch smells a bit like code-churn but having the prefix in some places and not others is confusing to new contributors and is leading me to explain this many times now. Lets just fix it.

  Remove the prefix unless doing so breaks the code.

ACKs for top commit:
  shinghim:
    ACK 85e04315d5
  apoelstra:
    ACK 85e04315d5eb90075ce55bf18fab8876a4583def; successfully ran local tests

Tree-SHA512: d90ae5ef75cc5e5a8f43f60819544f1a447f13cbe660ba71e84b8f27bfcc04a11d3afde0ed56e4eea5c73ebc3925024b800a1b995f73142cab892f97a414f14a
2025-01-04 00:23:46 +00:00
Innocent Onyemaenu 945fcd0920 fix ParsePublicKeyError using hex::InvalidCharError
What:
- Replaced the InvalidChar variant u8 with hex::InvalidCharError

Why:
- hex::InvalidCharError includes both the invalid character and its position.
- This improves debugging and makes error messages more actionable.
2025-01-03 15:33:26 +01:00
Tobin C. Harding 85e04315d5
Remove test_ prefix from unit tests
There is a loose convention in Rust to not use `test_` prefix. The
reason being that `cargo test` outputs 'test <test name>' using the
prefix makes the output stutter.

This patch smells a bit like code-churn but having the prefix in some
places and not others is confusing to new contributors and is leading me
to explain this many times now. Lets just fix it.

Remove the prefix unless doing so breaks the code.
2025-01-02 10:06:50 +11:00
Tobin C. Harding fd8d563b87
Remove macro debug_from_display
Rust macros, while at times useful, are a maintenance nightmare. And
we have been bitten by calling macros from other crates multiple times
in the past.

In a push to just use less macros remove the `debug_from_display`
macro and just write the code.

This is an API breaking change to `internals` but an internal change
only to any of the _real_ crates.
2025-01-02 07:31:13 +11:00
merge-script 21d435cf84
Merge rust-bitcoin/rust-bitcoin#3836: Update to rust-ordered 0.4.0
1a8f5b19fb Update to rust-ordered 0.4.0 (Tobin C. Harding)

Pull request description:

  We just released a version of `ordered` that makes `ArbitraryOrd` object safe - use it.

  Upgrade to the latest version of `rust-ordered` - `v0.4.0`.

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

Tree-SHA512: 823962a9e6b956126c7ff7a63b780431e358a9f0713f30e3801de3febea1e1e569b8ba3f6e3c0dc3c38759ac233c3d0ddea2223588cd796db6849fae8b599e04
2025-01-01 16:52:11 +00:00
merge-script 16b522043d
Merge rust-bitcoin/rust-bitcoin#3789: Add hash data to Inventory's Error variant
72e97c637f Add a hash value to Inventory's Error variant (Nick Johnson)

Pull request description:

  I am working on adding BIP324 V2 p2p network message support to the p2p module and ran into a little snag. I can post a draft branch of that work if helpful, but the general strategy is to add a `V2NetworkMessage` which operates in parallel with the existing `RawNetworkMessage` type (which is a bit of misnomer and may be better described in the future as `V1NetworkMessage`, see #3157). This allows both p2p message types to hook into the existing `Encodable`/`Decodeable` chain.

  But the `Error` variant of the `Inventory` type message does not have symmetrical encoding and decoding paths. Encoding writes out a zero'd 32 bytes while decoding ignores it completely. And while it is not clear to me if there is [requirement written down](https://en.bitcoin.it/wiki/Protocol_documentation#Inventory_Vectors) anywhere, [bitcoin core does appear to always expect a hash](c1252b14d7/src/protocol.h (L499)) even with the `Error` variant where it is meaningless.

  I believe rust-bitcoin's handling of this was never a problem before because the top level `RawNetworkPackage` pulls all the required bytes off a reader before decoding them. But this is not as easy to do with the v2 p2p network messages since the length is decoded at the transport level, not the message itself. I believe it is preferable for the Decoders to *not* assume that all bytes have been pulled off already given their input stream interface. Maybe somewhat surprisingly, this is the only issue I have run into so far adding the v2 encoding and decoding paths. As it is now, the code panics with an `Unconsumed` because it hasn't pulled the dummy zero bytes off the reader.

  This patch adds the 32 byte array to the Error variant in order to make its Encoding and Decoding paths symmetrical. This also allows a reader to discard the 32 bytes when decoding a message while cleanly keeping things hooked up with the `Decodeable` chain. The hash is still not exposed to the caller.

  This is *a way* to solve my issue, but not sure if it will cause more confusion than its worth. I tried a few other strategies, but preferred this one due to how well it hooks into `Decodeable`.

ACKs for top commit:
  apoelstra:
    ACK 72e97c637fa0916be75aef28ea8169ffbbe2c4f5; successfully ran local tests
  tcharding:
    ACK 72e97c637f

Tree-SHA512: 20cb9fec0768e0fdf7c7f520a00e1a37f5ef0583e2ebc7d47583249c6829c47826d83694a56338efa5844a9fe264a77f6d04c0c46c85f8732c7585515723d7ce
2024-12-31 14:08:25 +00:00
Tobin C. Harding 1a8f5b19fb
Update to rust-ordered 0.4.0
We just released a version of `ordered` that makes `ArbitraryOrd` object
safe - use it.

Upgrade to the latest version of `rust-ordered` - `v0.4.0`.
2024-12-31 10:42:24 +11:00
Tobin C. Harding 20b798175c
Update to latest rust-ordered
I just went to town on the `rust-ordered` crate to get it ready for
releasing a `1.0` version. None of the changes effect our usage here in
`rust-bitcoin`.

Upgrade to the latest version of `rust-ordered` - `v0.3.0`.
2024-12-30 08:35:01 +11:00
merge-script 779768eff9
Merge rust-bitcoin/rust-bitcoin#3769: Change method return type for to_unsigned()
e13355318e Add From impl (yancy)
364e9ff775 Change method return type (yancy)
fdf3336ed5 Add unchecked variant (yancy)

Pull request description:

  Any SignedAmount can now be cast to Amount since the range is the same.  Specifically, the range for SignedAmount is (- 21 million, 21 million) while the range for Amount is (0, 21 million).  Therefore any value from Amount can be cast to a SignedAmount and it will work.  Note it's not the same and still requires checking when going from SignedAmount to Amount since Amount can't handle the negative range.

ACKs for top commit:
  tcharding:
    ACK e13355318e

Tree-SHA512: c016b51bdd87a12eb09d9c1a82699dad1e866bf96bd3235eeb131f216f02422acb992ddb3a8135af00bbc10e240178fde5e37fb7860d9e6eaf433cf917d4d16a
2024-12-29 14:58:47 +00:00
yancy 364e9ff775 Change method return type
Any SignedAmount can now be cast to Amount since the range is the same.
Specifically, the range for SignedAmount is (- 21 million, 21 million)
while the range for Amount is (0, 21 million).  Therefore any value from
Amount can be cast to a SignedAmount and it will work.  Note it's not
the same and still requires checking when going from SignedAmount to
Amount since Amount can't handle the negative range.

As a side effect of changing the return type, TryFrom is no longer valid
and does not compile.  Therefore in addition to changing the return
type, TryFrom is also removed.
2024-12-24 11:31:49 -06:00
merge-script 2de44ab2a6
Merge rust-bitcoin/rust-bitcoin#3798: refactor: use amount type
774f066879 refactor: Change from u64 to Amount (yancy)

Pull request description:

  Separate out refactor commit from https://github.com/rust-bitcoin/rust-bitcoin/pull/3794.  Can be merged independently.

ACKs for top commit:
  tcharding:
    ACK 774f066879
  apoelstra:
    ACK 774f066879c8ad1af81c7e46b404fa63682a0b4c; successfully ran local tests

Tree-SHA512: 9ec5121d823ee3ec506eee5b5187bd496221bd3576afcaa6daf647099720d87b58b69521f29ae9537f123e2958771bc867b123da3f2ba941cba403a6c98e46de
2024-12-24 14:53:03 +00:00
yancy 774f066879 refactor: Change from u64 to Amount
The Amount type provides better type safety and is more appropriate in
this context than u64.  Currently the checked arithmetic operations for
Amount and u64 are identical in behavior.  Therefore, this refactor does
not result in any behavior change and is purely cosmetic.
2024-12-23 13:03:53 -06:00
calciumbe bcf8580913
bitcoin: fix typo 2024-12-23 20:44:18 +08:00
Nick Johnson 72e97c637f Add a hash value to Inventory's Error variant
While the hash value of the Error variant is meaningless, the variant
still conforms to all other Inventory messages and requires a 32
byte hash to be sent over the wire. This is how bitcoin core operates.

This patch adds the 32 byte array to the Error variant in order to make
its Encoding and Decoding paths symmetrical. This also allows a reader
to discard the 32 bytes when decoding a message. The hash is still not
exposed to the caller.

This was never a problem before because the top level RawNetworkPackage
pulls all the required bytes off a reader before decoding. But this is
not as easy to do with the v2 p2p network messages.
2024-12-18 19:24:26 -08:00
merge-script f4069fcd61
Merge rust-bitcoin/rust-bitcoin#3780: Use uniform capitalisation of SegWit in rustdocs
e56f461916 Make capitalization of SegWit uniform in strings (Jamil Lambert, PhD)
3520e832ac Make capitalization of SegWit uniform in rustdocs (Jamil Lambert, PhD)

Pull request description:

  Fixes #3770

  - Searched and replaced all occurrences of `//` * `segwit` (case insensitive) with `//` * `SegWit`
  - Searched and replaced all occurrences of `"` * `segwit` (case insensitive) with `"` * `SegWit`

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

Tree-SHA512: c56704102d8e86f26378bb302d5fdc7ea21d41fd49f55606e589ec32ff896f1adfb1960d8fb29abccfbf298b90fc357ed609d80fd0163dcb4ff01573646b02c3
2024-12-17 18:10:44 +00:00
merge-script 1d3f42e589
Merge rust-bitcoin/rust-bitcoin#3762: Remove double spacing in rustdocs
bb29490308 Remove double spacing in rustdocs (Jamil Lambert, PhD)

Pull request description:

  Fixes #3761

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

Tree-SHA512: efc41bdfd7b46bae4ed1159c852b3a2df0a95e36e1964679640de37ae3e0cc994426e7e9d643beb5ba0f5210bb6c2a19028fc8d28a6150580bad4471d4502bb3
2024-12-17 16:38:01 +00:00
Jamil Lambert, PhD e56f461916
Make capitalization of SegWit uniform in strings 2024-12-17 14:49:01 +00:00
Jamil Lambert, PhD 3520e832ac
Make capitalization of SegWit uniform in rustdocs 2024-12-17 14:28:28 +00:00
Jamil Lambert, PhD bb29490308
Remove double spacing in rustdocs 2024-12-17 14:21:12 +00:00
Tobin C. Harding b5f553d866
hashes: Bump version to 0.16.0
We need to do a quick release because it turns out I was wrong in
thinking that making `hex` an optional dependency is not a breaking
change.

```
the package `bitcoin` depends on `bitcoin_hashes`, with features: `hex`
but `bitcoin_hashes` does not have these features. It has a required
dependency with that name, but only optional dependencies can be used as
features.
```

Add a changelog, bump the version, depend on the new version repo wide,
and update the lock files - like its our job.
2024-12-16 12:41:17 +11:00
merge-script c40e2516ae
Merge rust-bitcoin/rust-bitcoin#3737: Improve rustdocs on addresses module
f85456a726 Improve rustdocs on addresses module (Tobin C. Harding)

Pull request description:

  These docs are stale, update them.

  - Mention segwit and legacy
  - Improve example code to show feature gating
  - Fix headings to be as typical

ACKs for top commit:
  storopoli:
    ACK f85456a726
  apoelstra:
    ACK f85456a726a201b26eac58d22eb0eb6a58ad411b; successfully ran local tests

Tree-SHA512: c1cdde744fb960c4119805e6b3fb0cc971eaa94173fb85f8f7a34daab7985a0f14c9be477d7dda430c6873fed7265c598b8dcfbffe0ed6a99ca8590a2b2b724e
2024-12-15 17:32:14 +00:00
Tobin C. Harding f85456a726
Improve rustdocs on addresses module
These docs are stale, update them.

- Mention segwit and legacy
- Improve example code to show feature gating
- Fix headings to be as typical
2024-12-15 09:29:48 +11:00
merge-script 1c4d66ab39
Merge rust-bitcoin/rust-bitcoin#3749: Remove unnecessary type
3ac9b2ded2 Remove unnecessary type (Tobin C. Harding)

Pull request description:

  `hex_psbt` returns `Psbt`, no need for the explicit type.

  Internal change only.

ACKs for top commit:
  shinghim:
    ACK 3ac9b2ded2
  apoelstra:
    ACK 3ac9b2ded24d5428945538c0a674301f6094df96; successfully ran local tests

Tree-SHA512: 2be1bfa56729bf97e60d721a184d3d21bfb27115fab1dd1b9103428658b5faca012d8f01e0458be7f17dadcd8cc495b327f2b472d825d46aa5cb71d0906ecb21
2024-12-14 17:48:02 +00:00
merge-script 25236ce697
Merge rust-bitcoin/rust-bitcoin#3746: bitcoin: Improve rustdocs on extern crates
a5993426fd bitcoin: Improve rustdocs on extern crates (Tobin C. Harding)

Pull request description:

  Make slight improvement to the extern crates we re-export from `bitcoin`.

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

Tree-SHA512: bb857316fc2606aa553f15e1c9fcf8dd87374e170121fe30cf9e44ae190f873f94c113af49b096cb49a65fd68d1bf24732e3f1aba04861e2ae934414f30473c6
2024-12-14 17:03:56 +00:00
merge-script fcbe970ddb
Merge rust-bitcoin/rust-bitcoin#3734: Move script hash types to `primitives`
6e01383f16 api: Run just check-api (Tobin C. Harding)
3855d3cc83 Move script hashes to primitives (Tobin C. Harding)
d1dd63d6d4 Remove wildcard in script re-exports (Tobin C. Harding)

Pull request description:

  Woops, this should have been done before v0.101.0 was released.

  Move the `ScriptHash` and `WScriptHash` types to `primitives`.

  Requires moving constants and error types as well. We re-export the errors because they are in the `mod.rs` file so they should appear in both `primitives::script::FooError` and `bitcoin::script::FooError`.

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

Tree-SHA512: 4ef838ee9c4cb3eb308ffa855ea5d6f5ad46f81c17b9413faa493a46a262afc18b47f28a0fdd5fc675eea31b895d0eb0e2505a523e820504ec88d9334d6874b4
2024-12-14 06:14:39 +00:00
merge-script 3c25a8acbc
Merge rust-bitcoin/rust-bitcoin#3753: Update to arbitrary v1.4
463fbd16f1 Update to arbitrary v1.4 (Tobin C. Harding)

Pull request description:

  Out with the old in with the new, update to the latest minor version of arbitrary.

  No real reason to do this except that I wanted to add the minor version instead of using just `1` so that we don't accidentally pull a new minor version in during a patch release (after we 1.0).

  (I'm unsure if this is necessary and did not test it against MSRV.)

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

Tree-SHA512: 88913f993b97abba224ba94ee9d5057894bb7142fef07e557de03a423da314a9f21632932fb64c4c27c676051bbb6e90d9b90bfa944af810e834bf42707d3cff
2024-12-14 01:39:38 +00:00
merge-script 7ab569388b
Merge rust-bitcoin/rust-bitcoin#3743: Refactor predict weight
0135cddc32 Refactor non_input_size (Tobin C. Harding)
f42f13cd8d Simplify closures in call to fold (Tobin C. Harding)

Pull request description:

  Two refactorings to make the code easier to read. No logic changes.

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

Tree-SHA512: 747cfe1212283a62545cb86a5af0be46592ab3b41f94ab0a2dad8f06b094c04eb9265520ece595d2aab303fddf55a652e7ef977911439602550c264bedd4385b
2024-12-13 23:58:31 +00:00
merge-script ee8430a527
Merge rust-bitcoin/rust-bitcoin#3738: Remove Weight::from_wu_usize function
3c8c956511 Remove Weight::from_wu_usize function (Tobin C. Harding)

Pull request description:

  This constructor is an anomaly in this repo. Also it is ugly to have the type parameter hard coded in the function name.

  The problem the constructor is trying to solve is that we don't like casts that don't obviously loose data. We have a solution for that already in `internals::ToU64`. This trait cannot be used in const contexts though so we do introduce a single cast in this patch.

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

Tree-SHA512: 168196edb7c151378d425b96ea3c9cdb0a4f6a879543e89facd02ed1fdf9bc69bde8ef862ffa0959b7c5ca21d6f4fe5ae38a933c379e7e88a946ca7cb68d61ec
2024-12-13 22:16:59 +00:00
merge-script 7977231839
Merge rust-bitcoin/rust-bitcoin#3751: Remove unnecessary rustdocs
99e2a9f530 Remove unnecessary rustdocs (Tobin C. Harding)

Pull request description:

  The `deprecated` attribute already fully explains the status of a deprecated function and the replacement - no need to repeat this.

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

Tree-SHA512: 133d41573a3ba97abf85100649c1e8dfe131521a627e0b7f1ab803845caf1c183b99488cb5d9f7e858cab1b35f8907a79b320ec01901b15fdd63d08f0bc1f87e
2024-12-13 20:01:34 +00:00
merge-script 66accdee08
Merge rust-bitcoin/rust-bitcoin#3748: Remove ToU64 from rustdocs
4ef06b4f2b Remove ToU64 from rustdocs (Tobin C. Harding)

Pull request description:

  The `ToU64` trait is not meant to be used publicly, remove the mention of it from rustdocs.

ACKs for top commit:
  shinghim:
    ACK 4ef06b4f2b
  apoelstra:
    ACK 4ef06b4f2b9945b46c190abd0cb3a6dfe234c7b5; successfully ran local tests

Tree-SHA512: e9acef9194cee380aa2aa44af9285d4f6e025bdf09f76e5066916c51215db15f1f920fd8ecf3cf079f0a2dddab0332b3a7df104f5bd61d12fc337b4ed163310c
2024-12-13 18:01:29 +00:00
Tobin C. Harding d066a863bf
Use backticks on amount types 2024-12-13 09:01:16 +11:00
Tobin C. Harding a5993426fd
bitcoin: Improve rustdocs on extern crates
Make slight improvement to the extern crates we re-export from
`bitcoin`.
2024-12-13 09:01:08 +11:00
Tobin C. Harding 4ef06b4f2b
Remove ToU64 from rustdocs
The `ToU64` trait is not meant to be used publicly, remove the mention
of it from rustdocs.
2024-12-13 09:00:53 +11:00
Tobin C. Harding 3ac9b2ded2
Remove unnecessary type
`hex_psbt` returns `Psbt`, no need for the explicit type.

Internal change only.
2024-12-13 09:00:41 +11:00
Tobin C. Harding 99e2a9f530
Remove unnecessary rustdocs
The `deprecated` attribute already fully explains the status of a
deprecated function and the replacement - no need to repeat this.
2024-12-13 09:00:20 +11:00
Tobin C. Harding 463fbd16f1
Update to arbitrary v1.4
Out with the old in with the new, update to the latest minor version of
arbitrary.

No real reason to do this except that I wanted to add the minor version
instead of using just `1` so that we don't accidentally pull a new minor
version in during a patch release (after we 1.0).
2024-12-12 15:44:45 +11:00
Tobin C. Harding 0135cddc32
Refactor non_input_size
Looks like the formatter has put code comments in the wrong place.

Refactor the `non_input_size` line so that the formatter does not mess
with it.
2024-12-12 15:34:22 +11:00
Tobin C. Harding f42f13cd8d
Simplify closures in call to fold
Remove unnecessary code comments and make the closure variable names more
terse with no loss of clarity.

Refactor only, no logic changes.
2024-12-12 15:34:12 +11:00
Tobin C. Harding 3c8c956511
Remove Weight::from_wu_usize function
This constructor is an anomaly in this repo. Also it is ugly to have the
type parameter hard coded in the function name.

The problem the constructor is trying to solve is that we don't like
casts that don't obviously loose data. We have a solution for that
already in `internals::ToU64`. This trait cannot be used in const
contexts though so we do introduce a single cast in this patch.
2024-12-12 15:21:29 +11:00
Tobin C. Harding 3855d3cc83
Move script hashes to primitives
Woops, this should have been done before v0.101.0 was released.

Move the `ScriptHash` and `WScriptHash` types to `primitives`.

Requires moving constants and error types as well. We re-export the
errors because they are in the `mod.rs` file so they should appear in
both `primitives::script::FooError` and `bitcoin::script::FooError`.
2024-12-12 15:14:00 +11:00
Tobin C. Harding d1dd63d6d4
Remove wildcard in script re-exports
We don't like wildcard re-exports anymore; explicitly re-export the
types from `primitives::script`.
2024-12-12 15:14:00 +11:00
merge-script e2de5162d9
Merge rust-bitcoin/rust-bitcoin#3717: base58ck: Bump version to 0.2.0
5b3e4ab95b base58ck: Bump version to 0.2.0 (Tobin C. Harding)

Pull request description:

  In preparation for release add a changelog entry, bump the version, and update the lock files.

ACKs for top commit:
  storopoli:
    ACK 5b3e4ab95b
  apoelstra:
    ACK 5b3e4ab95b015b5bba5b73db2052cbb63a901466; successfully ran local tests

Tree-SHA512: 8347b0540ccdfc29f4a03f0a3554142b4fbd39b519512dcc886c28cae75666201aa8a7e4a07999e70c0348e59f02c4c0d67541a20102153b36150f5e4748a89e
2024-12-11 16:58:08 +00:00
Tobin C. Harding adaf4ac086
Set avoid-breaking-exported-api to false
These lints are valuable, lets get at em.

Changes are API breaking but because the changes make functions consume
self for types that are `Copy` downstream should not notice the breaks.
2024-12-11 10:11:50 +11:00
Tobin C. Harding 5b3e4ab95b
base58ck: Bump version to 0.2.0
In preparation for release add a changelog entry, bump the version, and
update the lock files.
2024-12-10 13:47:29 +11:00
merge-script 8eda92ee7b
Merge rust-bitcoin/rust-bitcoin#3699: Explicitly define Ord for NodeInfo
428e9787d1 Explicitly define Ord for NodeInfo (Shing Him Ng)

Pull request description:

  Fixes #3654 by explicitly defining Ord so that we avoid potentially catastrophically changing addresses out from under users

ACKs for top commit:
  sanket1729:
    utACK 428e9787d1
  apoelstra:
    ACK 428e9787d181a462d06a18b7a45701790cbc0929; successfully ran local tests

Tree-SHA512: e900e07b2c53f643e3239bf7d26567b56275899b408a94e45f1cddd81217141c304c87159ce413a7a4660f1c09a0db2bbc1146948a2d9e7600abf14cd73ac691
2024-12-09 22:13:58 +00:00
Shing Him Ng 428e9787d1 Explicitly define Ord for NodeInfo 2024-12-09 09:15:12 -06:00
merge-script b579e1238f
Merge rust-bitcoin/rust-bitcoin#3693: Change `Amount::MAX` from `u64::MAX` to `Amount::MAX_MONEY`
6950c0a7b5 Change `Amount::MAX` to equal `MAX_MONEY` (Jamil Lambert, PhD)

Pull request description:

  As discussed in #3688 and #3691 using `u64::MAX` causes errors when converting to `f64` so `MAX_MONEY` is should be used as the maximum `Amount`.

   - `Amount::MAX` changed to equal `MAX_MONEY`
   - Add a check to add, multiply and from_str functions
   - Change tests to account for new lower maximum

  Different approach to the existing PR #3692.  I have only done Amount and not SignedAmount until there is feedback on which approach to use.

ACKs for top commit:
  tcharding:
    ACK 6950c0a7b5
  apoelstra:
    ACK 6950c0a7b507f9d70c1ebdab540634482f73b247; successfully ran local tests

Tree-SHA512: 03ebf39c47b19ba88d95235538039f28bfa29f4499618fab25c9b627684c348ed41caef682e8f0e01ca62cf9ced8a1183fe3ed861bffeb9609b09440ddfb1c92
2024-12-09 14:54:39 +00:00
Jamil Lambert, PhD 6950c0a7b5
Change `Amount::MAX` to equal `MAX_MONEY`
To prevent rounding errors converting to and from f64 change
`Amount::MAX` to `MAX_MONEY` which is below the limit in f64 that has
issues.

Add checks to `from_str_in`, `checked_add` and `checked_mul` that the
result is below MAX, where previously a u64 overflow was relied on.

Change tests to account for new lower MAX that is within the range of
SignedAmount and does not overflow so easily

Remove overflow tests

`Amount::MAX` is now below `u64::MAX` and within the range of values for
`SignedAmount`.   These tests therefore do not overflow.
In effective_value there is no error with `Amount::MAX` and the correct
value is returned.
In psbt the removed test is effectively the same as the previous test.

Modify `Amount` tests to work with new `MAX`

Tests need to be changed that checked values above the new `MAX` or
`Amount::MAX` was out of range for `SignedAmount` which it isn't anymore
2024-12-04 14:17:00 +00:00