Commit Graph

16 Commits

Author SHA1 Message Date
Erick Cestari c11772a768
Accept flexible input types for Taproot-related functions
Refactor Taproot functions to accept any type implementing `Into<XOnlyPublicKey>`,
instead of requiring `XOnlyPublicKey` directly. This improves ergonomics when working
with compatible types, avoiding unnecessary `.into()` conversions at call sites.
2025-05-06 09:01:27 -03:00
Erick Cestari 2a518d62e6
Wrap secp256k1::XOnlyPublicKey to improve error handling
This commit creates a wrapper type for XOnlyPublicKey instead of
directly re-exporting it from the secp256k1 library.
2025-05-06 09:01:17 -03:00
Fmt Bot 19c5fcc78f 2025-04-13 automated rustfmt nightly 2025-04-13 02:50:07 +00:00
tushar994 52f9c13358 Implement Copy for Address and AddressInner
Enables by-value Address semantics for easier use; large sizes can use Box.
2025-04-09 12:25:43 +05:30
Tobin C. Harding ab4ea7c13d
Enforce the MAX_MONEY invariant in amount types
Enforcing the MAX_MONEY invariant is quite involved because it means
multiple things:

- Constructing amounts is now fallible
- Converting from unsigned to signed is now infallible
- Taking the absolute value is now infallible
- Integer overflow is illuminated in various places

Details:

- Update from_sat to check the invariant
- Fix all docs including examples
- Use the unchecked constructor in test code
- Comment any other use of the unchecked constructor
- Deprecate unchecked_abs
- Fail serde (using the horrible string error variant)
- Try not to use the unchecked constructor in rustdocs, no need to encourage unsuspecting users to use it.
- Use ? in rustdoc examples (required by Rust API guidlines)
- Remove TryFrom<Amount> for SignedAmount because the conversion is now infallible. Add a From impl.
- Fix the arbitrary impls
- Maintain correct formatting
- Remove private check_max function as its no longer needed
2025-03-13 09:07:14 +11:00
jrakibi 6c69b66b0d Use Version constant
Replace Version(2) with predefined Version::TWO constant
2025-02-23 04:19:48 +07:00
Tobin C. Harding db40297f87
script: deprecate to_bytes
Deprecate the `Script::to_bytes` function in favour of `to_vec` as we
are doing elsewhere.

Note that `ScriptBuf` has `into_bytes` because it does not copy.
Potentially this should be deprecated in favour of `into_vec`?

Note that in regards to the `to_` prefix this naming as valid according
to convention because the `Script` type is borrowed and `to_vec` copies
the underlying bytes.
2024-11-01 07:09:53 +11:00
BinChengZhao afa91a2030 Introduce TestnetVersion enum with only TestnetV3 2024-10-03 18:40:06 +08:00
Nadav Ivgi 055aa9d4dc
Refactor GetKey to take the KeyRequest by reference
To avoid cloning when looking it up in sets.
2024-09-13 14:49:54 +03:00
Jamil Lambert, PhD 9fce57b738
Change T::from_str(s) to s.parse::<T>() in tests
`s.parse` is more idiomatic and produces more helpful error messages.

This has been changed repo wide in tests.
2024-08-28 16:13:03 +01:00
Martin Habovstiak 0857697665 Replace impl blocks with extension traits
In preparation to move script types to `primitives` we replace impl
block with extension traits by replacing the temporary modules with
`define_extension_trait`.
2024-08-13 13:14:00 +02:00
Fmt Bot 3417c576ed 2024-04-21 automated rustfmt nightly 2024-04-21 01:03:30 +00:00
Tobin C. Harding 830c1e9cfe
Allow m prefix in derivation paths
Recently in #2451 we disallowed bip32 derivation paths with the leading
'm' variable.

There is some confusion as to what exactly the bip specifies however
Bitcoin Core RPC call `getaddressinfo` returns a derivation path with a
leading "m/". This means we need to be able to parse it irrespective of
what the bip says.

Be more liberal in what we accept as a derivation path, including both
with and without the leading 'm/'.

Leave the full investigation of the bip to a later date.

Change back some of the test strings as makes sense and include test
strings to showcase the full current behaviour.
2024-04-11 07:23:30 +10:00
Andrew Poelstra 12be5c0d27
clippy: fix a couple of nits in `clippy --no-default-features`
We only check clippy in CI with --all-features, which usually is the
best way to get maximum coverage. But if you try a couple other feature
combos, especially those related to nostd, you can hit more code.
2024-04-07 15:16:09 +00:00
Fmt Bot a565db9fdd 2024-03-31 automated rustfmt nightly 2024-03-31 01:03:18 +00:00
yu 41e8fb0863 Support signing taproot in psbt 2024-02-22 10:42:44 +08:00