Commit Graph

14 Commits

Author SHA1 Message Date
Tobin C. Harding a7c44cebf9
Use _unchecked to construct amounts
We have a `_unchecked` constructor now for both `Amount` and
`SignedAmount`. In preparation for enforcing the `MAX_MONEY` invariant
use the `_unchecked` constructor throughout the codebase to construct
amounts from hard coded integer values.
2025-01-06 13:14:21 +11:00
Jamil Lambert, PhD 1649b68589
Standardize wording to `constructs a new`
There is a range of different wordings used in the docs of constructor
type functions.

Change all to start with `Constructs a new` or `Constructs an empty`.
2024-11-05 13:02:26 +00:00
Jamil Lambert, PhD 27f94d5540
Replace `creates` with `constructs`
In functions that act like constructors there is a mixture of the usage
of `creates` and `constructs`.

Replace all occurrences of `creates` with `constructs` in the first line
of docs of constructor like functions.
2024-11-05 12:47:28 +00:00
Tobin C. Harding c1eccfde25
Move Witness to primitives
Move the `Witness` over to `primitives` leaving behind any method that
takes or returns a `Script` or a signature.

Includes addition of a feature gate to unit test.
2024-10-18 14:02:03 +11:00
ChrisCho-H 3565f70df9 feat: replace ENABLE_RBF_NO_LOCKTIME with ENABLE_LOCKTIME_AND_RBF 2024-10-12 12:42:43 +09:00
Tobin C. Harding 832b726d03
Stop using all_zeros
Recently we deprecated the `all_zeros` functions on `Wtxid` and
`Txid` but for some reason our usage of them is not triggering a lint
warning.

Note please that this changes logic slightly, for example by using an
array of `0xFF` bytes instead of all zeros. Done in an effort to make it
even more obvious that the value is a dummy value and not mix it up with
the all zeros being used for coinbase thing.
2024-09-11 10:39:49 +10:00
Fmt Bot fa71b0e044 2024-09-01 automated rustfmt nightly 2024-09-01 01:22:04 +00:00
Jamil Lambert, PhD 4ad86148c7
Change Address::from_str(s) to s.parse
`s.parse` is more idiomatic and produces more helpful error messages.

This has been changed for parsing a string as an `Address`.
2024-08-28 13:50:43 +01:00
Tobin C. Harding bcf6d2839e
Introduce scriptPubkey extension traits
Done in preparation for moving the script types to `primitives`.

The script types have a bunch of functionality to support scriptPubkeys,
and scriptPubkeys are an address thing.

Create a module under `address` and in it create a bunch of extension
traits to hold all scriptPubkey functionality.

Includes adding an ugly-as-hell macro to create the traits.
2024-07-13 08:43:06 +10:00
Tobin C. Harding 6b7d02e5ae
Add inherent functions to hashes
Currently we have a trait `Hash` that is required for `Hmac`, `Hkdf`,
and other use cases. However, it is unegonomic for users who just want
to do a simple hash to have to import the trait.

Add inherent functions to all hash types including those created with
the new wrapper type macros.

This patch introduces some duplicate code but we are trying to make
progress in the hashes API re-write. We can come back and de-dublicate
later.

Includes making `to_byte_array`,`from_byte_array`, `as_byte_array`, and
`all_zeros` const where easily possible.
2024-06-14 10:17:00 +10:00
Tobin C. Harding e1869340be
Upgrade secp dependency
Upgrade `rust-secp256k1` to the latest version `v0.29.0`. This removes
the duplicate deps as well.
2024-04-03 09:24:41 +11:00
Tobin C. Harding 6715e93e89
Add Witness::p2tr_key_spend function
Add a function for creating the witness when doing a key path spend for
a P2TR output.

This mirrors what we did for P2WPKH when adding `Witness::p2wpkh`.

Includes update to the taproot signing example to use the new constructor.
2024-01-24 15:21:31 +11:00
Tobin C. Harding 271b45299f
Improve Signature field names
Applies to both `ecdsa::Signature` and `taproot::Signature`.

Re-name the `Signature` fields with more descriptive names. The
names used were decided upon in the issue discussion.

Impove rustdocs while we are at it.

Note, the change to `sign-tx-segwit-v0` is refactor only, the diff does
not show it but we have a local variable already called `sighash_type`
that is equal to `EcdsaSighashType::All`.

Includes a function argument rename as well, just to be uniform.

Fix: #2139
2024-01-15 10:26:40 +11:00
Tobin C. Harding fa104aefa5
bitcoin: Add signing examples
Add two signing examples to showcase signing a simple one input two
output transaction using both segwit v0 outputs and taproot outputs.

This patch is the result of the recent rust-bitcoin TABConf workshop,
wit bug fix by Sanket, updated to use APIs from tip of master branch.

This code, depending on v0.30.0 is what is being introduced to the
cookbook at the moment.
2023-10-31 10:11:48 +11:00