Commit Graph

3873 Commits

Author SHA1 Message Date
Andrew Poelstra 6a04ca12e0
Merge rust-bitcoin/rust-bitcoin#1887: Remove doc(hidden) from error conversion functions
042dcaa4b7 Remove doc(hidden) from error conversion functions (Tobin C. Harding)

Pull request description:

  Give people access to the error type conversion docs, its no harm and it may be useful when the compiler does not give enough information.

  Done based on discussion here: https://github.com/rust-bitcoin/rust-bitcoin/pull/1846#discussion_r1209583520

ACKs for top commit:
  Kixunil:
    ACK 042dcaa4b7
  apoelstra:
    ACK 042dcaa4b7

Tree-SHA512: 9d975845ba84213b203062282b68f06f6790d03dbc88d66dce82e9bedff4696fc01da6216920de9e9e4130f6469b32ff9c168d0800d057ec0bae51702d4a139e
2023-05-30 16:37:58 +00:00
Martin Habovstiak 783e1e81dc Move `impl_std_error` to `bitcoin-internals`
The macro is useful for all other crates thus it is moved to the
internals crate in this commit.
2023-05-30 18:04:54 +02:00
Tobin C. Harding 042dcaa4b7
Remove doc(hidden) from error conversion functions
Give people access to the error type conversion docs, its no harm and it
may be useful when the compiler does not give enough information.
2023-05-30 15:54:40 +10:00
Steven Roose 7bf0a106dd
Merge pull request #1872 from tcharding/05-24-rm-prevouts-export
psbt: Remove reexport of Prevouts
2023-05-30 02:48:34 +01:00
Andrew Poelstra 80efdb065a
Merge rust-bitcoin/rust-bitcoin#1873: Improve `hashes::Error`
06afd52a12 Improve hashes::Error (Tobin C. Harding)

Pull request description:

  We are trying to make error types stable on the way to v1.0

  The current `hashes::Error` is a "general" enum error type with a single variant, better to use a struct and make the error usecase specific.

  Improve the `hashes::Error` by doing:

  - Make it a struct
  - Rename to `FromSliceError`
  - Move it to the crate root (remove `error` module)

  Includes usage in `bitcoin`.

ACKs for top commit:
  apoelstra:
    ACK 06afd52a12
  Kixunil:
    ACK 06afd52a12

Tree-SHA512: 20a517daaf3e9e09744e2a65cde6e238c8f2d1224899a6c04142a3a4e635d54112b0a2e846d25256071bb27cb70f7482380f98e9a535a5498aa4c7dc0d52cc54
2023-05-29 22:58:17 +00:00
Andrew Poelstra ca17257884
Merge rust-bitcoin/rust-bitcoin#1882: made ckd_priv function private and impl AsRef for ChildNumber
4be019180b correcting formatting (startup-dreamer)

Pull request description:

  closes #1866

ACKs for top commit:
  Kixunil:
    ACK 4be019180b
  junderw:
    ACK 4be019180b
  apoelstra:
    ACK 4be019180b

Tree-SHA512: 9539c987a9636f3c50dde2d4448ca0c30c239f5a8e852e7bf560cc27a2681777fa1a91ace21bdf1fd67b1f60679dfb8eecef45b81506618285536599ad741f7e
2023-05-29 12:19:09 +00:00
Andrew Poelstra c041aea51a
Merge rust-bitcoin/rust-bitcoin#1876: hashes: Fix stale repository name
3717a549f9 hashes: Fix stale repository name (Tobin C. Harding)

Pull request description:

  The repository name is stale since we moved the `hashes` crate into the `rust-bitcoin` repo a while ago.

ACKs for top commit:
  apoelstra:
    ACK 3717a549f9
  Kixunil:
    ACK 3717a549f9

Tree-SHA512: ac4553547f1912c8242e3b87d3cc8951598999b5512ad1b49494b3c504449939e0e60905d96464b22c71b67ca975d18814a92af6e0aa66ff4f46effb97ac0733
2023-05-29 02:39:42 +00:00
Andrew Poelstra 5729b034d8
Merge rust-bitcoin/rust-bitcoin#1874: Add `ValidationError`
0f74eb6876 Remove the unused crate::Error (Tobin C. Harding)
74154c2294 Add block::ValidationError (Tobin C. Harding)
3a9b5526b3 Move BlockHash From impls (Tobin C. Harding)

Pull request description:

  Remove the `crate::Error` and replace its usage with `block::ValidationError`.

ACKs for top commit:
  apoelstra:
    ACK 0f74eb6876
  Kixunil:
    ACK 0f74eb6876

Tree-SHA512: 80b2c98d3d8f7c3f060c8ea2d94e1ebe118c07d0dcf91f6d13aed00df2cb0b15bf5e295ec0976d88d81e029cf7d3e8e4a1fe70120db57e49bbd8dd229291836b
2023-05-28 23:08:32 +00:00
Andrew Poelstra 7315eac5ee
Merge rust-bitcoin/rust-bitcoin#1871: Fix conditional configuration options usage
0046bb8ad8 Fix usage of cfg(rust_1_53) (Tobin C. Harding)
c3450f3913 Remove stale usage of doc(cfg) (Tobin C. Harding)

Pull request description:

  These build cfg options are not features, fix broken usage. And remove stale docsrs attribute while we are at it. Bad rust-bitcoin devs.

  Found while reviewing #1870

ACKs for top commit:
  apoelstra:
    ACK 0046bb8ad8
  Kixunil:
    ACK 0046bb8ad8

Tree-SHA512: 7053affef6654ff203c93590bf081e165f019feb040aa8c55259ffe4e15eaf0e7522f6e5a4f6f62e8f578420b0313f4b7b17c46b741b7fcfd05750e5c5976589
2023-05-28 22:27:27 +00:00
Andrew Poelstra ce44711219
Merge rust-bitcoin/rust-bitcoin#1879: embedded: Document how to clean up linker flags
3af9258025 embedded: Document how to clean up linker flags (Tobin C. Harding)

Pull request description:

  Our embedded crate includes instructions to source a shell script that sets the `RUSTFLAGS` env var. Having the env var set like this in ones environment breaks linkage when trying to do "regular" builds.

  Document how to clean up.

ACKs for top commit:
  apoelstra:
    ACK 3af9258025
  Kixunil:
    ACK 3af9258025

Tree-SHA512: 72758fba4dede873da299f01d75fd64b549fe21f954c2720ba3b7fc3c29fd4ed28fd0a749bbe987a7de1551aa32192253dd0033a18c877e877c9960343a5b07c
2023-05-28 21:47:03 +00:00
Andrew Poelstra f64982d9fc
Merge rust-bitcoin/rust-bitcoin#1885: rename bitcoin-private to bitcoin-internals
ca06d64455 rename bitcoin-private to bitcoin-internals (Andrew Poelstra)

Pull request description:

  Since we now have control over the name on crates.io.

ACKs for top commit:
  tcharding:
    ACK ca06d64455
  Kixunil:
    ACK ca06d64455

Tree-SHA512: 8b3285b5ce9e3f1788ab9a3efa29b3e96f1f21dcfc0bb13f5940caf22cd43f74463b28bd85309e0200956dc11fe0102fd041b79bcd5f45fb8edb8449893bd287
2023-05-28 20:54:03 +00:00
startup-dreamer 4be019180b correcting formatting 2023-05-29 00:26:01 +05:30
Andrew Poelstra ca06d64455
rename bitcoin-private to bitcoin-internals
Since we now have control over the name on crates.io.
2023-05-26 19:49:52 +00:00
Tobin C. Harding 3af9258025
embedded: Document how to clean up linker flags
Our embedded crate includes instructions to source a shell script that
sets the `RUSTFLAGS` env var. Having the env var set like this in ones
environment breaks linkage when trying to do "regular" builds.

Document how to clean up.
2023-05-26 14:39:14 +10:00
Tobin C. Harding aa7b3a7d0c
ci: Remove stal DO_ALLOC_TESTS variable
We never enable the `DO_ALLOC_TESTS` variable, and hence never test the
"alloc" feature in `hashes`.

Remove the `DO_ALLOC_TESTS` variable and add "alloc" to the `FEATURES`
array.
2023-05-25 18:16:26 +10:00
Tobin C. Harding 4dfaec952c
hashes: Remove stale status badge
We do not use travis in our CI pipeline anymore, remove the stale badge.
2023-05-25 14:34:28 +10:00
Tobin C. Harding 3717a549f9
hashes: Fix stale repository name
The repository name is stale since we moved the `hashes` crate into
the `rust-bitcoin` repo a while ago.
2023-05-25 14:12:06 +10:00
Tobin C. Harding 0f74eb6876
Remove the unused crate::Error
The `crate::Error` type is now unused, remove it.
2023-05-25 13:35:49 +10:00
Tobin C. Harding 74154c2294
Add block::ValidationError
Add a `ValidationError` to the `block` module and remove the two
variants out of `crate::Error`.

This error is only used by the `validate_pow` function, a specific error
better serves our purposes.
2023-05-25 13:35:49 +10:00
Tobin C. Harding 3a9b5526b3
Move BlockHash From impls
Move the `From` impls on `BlockHash` to below the `BlockHash` impl
block.

Code move only, no other changes.
2023-05-25 13:32:25 +10:00
Tobin C. Harding 06afd52a12
Improve hashes::Error
We are trying to make error types stable on the way to v1.0

The current `hashes::Error` is a "general" enum error type with a single
variant, better to use a struct and make the error usecase specific.

Improve the `hashes::Error` by doing:

- Make it a struct
- Rename to `FromSliceError`
- Move it to the crate root (remove `error` module)

Includes usage in `bitcoin`.
2023-05-25 13:25:13 +10:00
Tobin C. Harding ab4e6d6f27
psbt: Remove reexport of Prevouts
No idea why this re-export is here, the `Prevouts` type is not even used
in the `psbt` module.

Remove the re-export of `crate::sighash::Prevouts` from `pstb`.
2023-05-24 22:10:40 +10:00
Tobin C. Harding 0046bb8ad8
Fix usage of cfg(rust_1_53)
Our custom conditional configuration options enables for various
versions of the compiler are not features.

Fix the incorrect usage.
2023-05-24 22:03:57 +10:00
Tobin C. Harding c3450f3913
Remove stale usage of doc(cfg)
We no longer need to use `doc(cfg())` because we use `doc_cfg_auto`,
remove it.
2023-05-24 22:02:24 +10:00
Andrew Poelstra b5aa482532
Merge rust-bitcoin/rust-bitcoin#1857: tests: Use script hash functions
013dffa65d tests: Use script hash methods (Tobin C. Harding)

Pull request description:

  The `ScriptBuf` type can be serialized using it's `to_bytes` function. Do not use the `psbt::Serialize` trait to do so in test code.

  No logic changes, since the impl of `psbt::Serialize` for `ScriptBuf` just calls `to_bytes`.

ACKs for top commit:
  Kixunil:
    ACK 013dffa65d
  apoelstra:
    ACK 013dffa65d

Tree-SHA512: 08959e065f1528f2ca69c12d5e34bceea3ddd17eefcee45094f071b3fa7357dbf289f6fe54d18fea02eecd1d0a7cd04598bbf014a5f10676387dbe27bb490395
2023-05-22 20:31:42 +00:00
Andrew Poelstra 8d111f20ef
Merge rust-bitcoin/rust-bitcoin#1864: Add a checked version of weight mul fee_rate
b03c24db8c Add a checked version of weight mul fee_rate (yancy)

Pull request description:

  Add a checked version of fee_rate * weight.  While I like the trait version of just being able to multiply `feerate * weight`, it's not really very useful imo since a large input feerate could cause an overflow.  Instead of changing the trait in https://github.com/rust-bitcoin/rust-bitcoin/pull/1849 (not idiomatic enough I guess) I added a `checked_weight_mul` method to `FeeRate`.

ACKs for top commit:
  apoelstra:
    ACK b03c24db8c
  Kixunil:
    ACK b03c24db8c

Tree-SHA512: 231ade94291becadcea9ea2a40a5daf96b77f01a29cca2494d7bbe4f7de5b412fa8fc816ea249268569f5378410185d9349fd687533bf3a422a752997e107a2b
2023-05-22 19:36:17 +00:00
Andrew Poelstra 88e92bc767
Merge rust-bitcoin/rust-bitcoin#1861: Add changelog entry for removal of `FromHex`
c2f33f60b8 Add changelo entry for removal of FromHex (Tobin C. Harding)

Pull request description:

  During the last round of releases (bitcoin 0.30, hashes 0.12) we removed the `FromHex` implementation from all types except vecs and arrays. We added `FromStr` impls for types that roundtrip with `Display`.

  We never added a changelog mention to either `bitcoin` or `hashes`, lets retroactively add an entry.

  Fix: #1747

ACKs for top commit:
  Kixunil:
    ACK c2f33f60b8
  apoelstra:
    ACK c2f33f60b8

Tree-SHA512: 7affc492104be2be17861c55511407e66d8c821f35b18eeb62f6852a669253d23af67cbd44323ff568d2f143af57e37212455c7af3ed0b1d58313135b0783ea6
2023-05-22 15:27:35 +00:00
Tobin C. Harding 013dffa65d
tests: Use script hash methods
We have methods to convert a script to a `WScritpHash` and `ScriptHash`,
no need to do this manually, let alone use the `psbt::Serialize` trait
to do so.
2023-05-20 07:31:54 +10:00
yancy b03c24db8c Add a checked version of weight mul fee_rate 2023-05-19 10:17:57 +02:00
TATHAGATA ROY 6a18997e3c Removed only available in 1.46.0 line 2023-05-18 12:14:38 +00:00
Tobin C. Harding c2f33f60b8
Add changelo entry for removal of FromHex
During the last round of releases (bitcoin 0.30, hashes 0.12) we removed
the `FromHex` implementation from all types except vecs and arrays. We
added `FromStr` impls for types that roundtrip with `Display`.

We never added a changelog mention to either `bitcoin` or `hashes`, lets
retroactively add an entry.

Fix: #1747
2023-05-18 14:18:42 +10:00
Andrew Poelstra ff08caf17c
Merge rust-bitcoin/rust-bitcoin#1835: Fix associated constants of `InputWeightPrediction`
6cec19f6d3 Update documentation of `InputWeightPrediction` (Martin Habovstiak)
6fec1789b9 Fix associated constants of `InputWeightPrediction` (Martin Habovstiak)

Pull request description:

  These constants had an error that they had `script_size` set to 0 which
  was incorrect because it's not length of the script but serialized size.
  Rather than just bumping the value this uses the `from_slice` method
  which is less error-prone.

  Closes https://github.com/rust-bitcoin/rust-bitcoin/issues/1834

ACKs for top commit:
  apoelstra:
    ACK 6cec19f6d3
  tcharding:
    ACK 6cec19f6d3

Tree-SHA512: 4e05be2c05795e8c4f9c67374491be71d2bde8233446f22bf458cfeb542d81043f03f90f65e59e769fce8275925dff28fc3dfce48fd62bd20be7fca22b71ca3c
2023-05-12 13:14:48 +00:00
Martin Habovstiak 6cec19f6d3 Update documentation of `InputWeightPrediction`
The doc was written before alternative constructors existed, update it.
2023-05-11 20:38:32 +02:00
Martin Habovstiak 6fec1789b9 Fix associated constants of `InputWeightPrediction`
These constants had an error that they had `script_size` set to 0 which
was incorrect because it's not length of the script but serialized size.
Rather than just bumping the value this uses the `from_slice` method
which is less error-prone.

This also deletes a useless test of the constants.

Closes #1834
2023-05-11 20:38:32 +02:00
Andrew Poelstra 7769221921
Merge rust-bitcoin/rust-bitcoin#1848: Fix formatting
0555695757 Fix formatting (Martin Habovstiak)

Pull request description:

  This slipped in and is breaking builds.

ACKs for top commit:
  RCasatta:
    ACK 0555695757
  apoelstra:
    ACK 0555695757

Tree-SHA512: de93667f10fa99c51f1119353e3d59c587b7eb737a9bb92355e1f57bf2beadd1515133431bd510e6dd9b81a0d08fdd263e663117cae288eec92d207a9dabc0b3
2023-05-11 18:23:49 +00:00
Martin Habovstiak 0555695757 Fix formatting
This slipped in and is breaking builds.
2023-05-11 13:03:22 +02:00
Riccardo Casatta 2df9b2c8b2
Merge rust-bitcoin/rust-bitcoin#1844: make bip21 schema lowercase
8835d5d2f1 make bip21 schema lowercase (Riccardo Casatta)

Pull request description:

  The spec RFC3986 specifies the scheme is case insensitive and we were uppercasing to optimize QR code representation.
  Unfortunately, common platform such as Android seems to fail to recognize uppercase schema, so for compatibility reason we use lowercase.

  close #1843

ACKs for top commit:
  Kixunil:
    ACK 8835d5d2f1
  apoelstra:
    ACK 8835d5d2f1

Tree-SHA512: 02d228b52fe4df20edb71ba8e2ab8a2bae4b912252e30a3150ee3af74e65a6e91b165c9579273b57e894366c9792a8312ea973723cd8c5d98037aaba80d7cf07
2023-05-11 10:41:35 +02:00
Andrew Poelstra 684e14caee
Merge rust-bitcoin/rust-bitcoin#1768: Allow parsing sub-sat denominations with decimal points
6c6a89b1d1 Add sub-sat fractions parsing regression test (Martin Habovstiak)
f1a3dc6719 Allow parsing sub-sat denoms with decimal points (Martin Habovstiak)
b3d9a267ea Add a few more amount parsing tests (Martin Habovstiak)

Pull request description:

  Numbers with only zeros after decimal points are valid if they are also
  multiples of `10^precision` (e.g. 1000 for msats). These were
  artificially disallowed as "too precise" which was at least misleading.

  This change allows parsing such numbers.

  And yes, I know this is not perfectly efficient (unless the compiler figures out some magic opts) but so isn't the rest of the code. TBH this parsing code drives me crazy and I'd love to rewrite it to be more efficient and readable.

ACKs for top commit:
  apoelstra:
    ACK 6c6a89b1d1

Tree-SHA512: 03cf4b416f2eac25e0aac57ef964ed06fa36c7fe8244bdcf97852cc58e1613b1ec6132379b834da58ad3240fdd61508a384202f63aa9ffa335c18cd7b2b724d3
2023-05-10 20:30:54 +00:00
Riccardo Casatta 8835d5d2f1
make bip21 schema lowercase
The spec RFC3986 specifies the scheme is case insensitive and we were uppercasing
to optimize QR code representation.
Unfortunately, common platform such as Android seems to fail to recognize
uppercase schema, so for compatibility reason we use lowercase.
2023-05-10 20:36:15 +02:00
Andrew Poelstra 4fc6a6a145
Merge rust-bitcoin/rust-bitcoin#1842: ci: fix -run syntax
a1aaf5f12c ci: fix run syntax in fuzz job (Andrew Poelstra)

Pull request description:

  I think our CI failures started with #1821 when we added an extra `run:` line to `fuzz.yml` without prefixing it with `-`.

  Fix the syntax to use a multi-line `run` instead.

ACKs for top commit:
  tcharding:
    ACK a1aaf5f12c
  Kixunil:
    ACK a1aaf5f12c

Tree-SHA512: 7214291dc629b6417f8dfaf4a68bfcdc23078a57759717cef92344e1873d475f597fe447e037d15c568a1d5b04ec764ebf8477d18274f52a4b93c50d8a1615f5
2023-05-10 15:05:14 +00:00
Andrew Poelstra d93e781148
Merge rust-bitcoin/rust-bitcoin#1838: Move and rename TxOut default trait to a const called NULL
75b3f19b96 Move and rename TxOut default trait to a const called NULL (yancy)

Pull request description:

  Create an associated constant `const TxOut::NULL` for consensus signing code and remove the default trait.  Note I tried to deprecate the `default()` fn instead of just removing it but it doesn't seem to be possible.  Also because `TxOut::NULL` is `const`, `ScriptBuf::new()` needed to be changed to `const fn`.

ACKs for top commit:
  apoelstra:
    ACK 75b3f19b96
  Kixunil:
    ACK 75b3f19b96

Tree-SHA512: ff61a2b1641a1ba32f183c27205af2d868dbc2eb47cf758c3d8315329d2c23e0b8a82ea0ab59d1de9add0d238f927165e2e4df014aab1ef066d74d4feda0700b
2023-05-09 18:31:34 +00:00
sanket1729 7c6a7c34b8
Merge rust-bitcoin/rust-bitcoin#1841: docs: Add doc comments for external crates
639c548aed docs: Add doc comments for external crates (yancy)

Pull request description:

  A new version of rust nightly is causing a test failure for external crates that are not documented.  This is currently causing a failure on my branch here: https://github.com/rust-bitcoin/rust-bitcoin/pull/1838

  As a side note, it feels like this should be locked to a specific version of nightly in the CI tests and then updated as a choir instead of having it create a new problem in a branch that's not related.

ACKs for top commit:
  apoelstra:
    ACK 639c548aed
  tcharding:
    ACK 639c548aed

Tree-SHA512: 764999edc448bff88013301bef287b16ac750af560931470257f2b4475747d52546e73d7fd9a7bdf2cedb18178f370150351e40f176f3da929edf686f02f5c1a
2023-05-08 18:35:10 -07:00
Andrew Poelstra a1aaf5f12c
ci: fix run syntax in fuzz job 2023-05-08 22:11:40 +00:00
yancy 639c548aed docs: Add doc comments for external crates 2023-05-08 10:57:49 +02:00
yancy 75b3f19b96 Move and rename TxOut default trait to a const called NULL 2023-05-08 09:11:06 +02:00
Andrew Poelstra dea628276c
Merge rust-bitcoin/rust-bitcoin#1837: feat: generate PrivateKey
995c797e0d feat: generate PrivateKey (kshitjj)

Pull request description:

  added a function to generate a private key

  Resolves: #1823

ACKs for top commit:
  apoelstra:
    ACK 995c797e0d
  tcharding:
    ACK 995c797e0d

Tree-SHA512: 29ba54be8cb777e71a4683835686cbf2978b23736f629d7bbff468074235fece261ca170c23f358d1bd878987566d09e4488c3f1a106c59a5c8bdf52b98abffe
2023-05-08 03:13:51 +00:00
kshitjj 995c797e0d feat: generate PrivateKey 2023-05-07 21:56:39 +05:30
Martin Habovstiak 6c6a89b1d1 Add sub-sat fractions parsing regression test
This test triggers the bug fixed in previous commit.
2023-05-07 08:47:53 +02:00
Martin Habovstiak f1a3dc6719 Allow parsing sub-sat denoms with decimal points
Numbers with only zeros after decimal points are valid if they are also
multiples of `10^precision` (e.g. 1000 for msats). These were
artificially disallowed as "too precise" which was at least misleading.

This change allows parsing such numbers.
2023-05-07 08:45:25 +02:00
Martin Habovstiak b3d9a267ea Add a few more amount parsing tests
These tests try to stress various edge cases that should return
`ParseAmountError::TooPrecise`.
2023-05-07 08:39:24 +02:00