Commit Graph

2150 Commits

Author SHA1 Message Date
Andrew Poelstra 5e83c602fd
Merge rust-bitcoin/rust-bitcoin#1276: Fix deprecated v0.28.0
3f275f7f2b Remove code deprecated in v0.28.0 (Tobin C. Harding)
c4eb218cd0 schnorr:: Remove incorrect deprecated (Tobin C. Harding)

Pull request description:

  We have a bunch of things deprecated since v0.28.0, I believe we agreed to deprecate for two release cycles so this stuff can all be deleted now.

  - Patch one does the `schnorr` module; the deprecated attribute usage is just plain wrong (see https://github.com/rust-bitcoin/rust-bitcoin/discussions/1275). Also, in an attempt to make the API more ergonomic, patch one adds re-exports of secp types.

  - Patch 2 deletes all other code deprecated since v0.28.0

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

Tree-SHA512: 501d792c48830d28c9ad04335a56d75cf31e0bd8dc1f4e184d7d6906dbf2468369d809954709014ee5ec32ac330b56008d4be14d5f3cc89226032e642556e945
2022-09-15 13:38:01 +00:00
Andrew Poelstra f41ec20ee4
Merge rust-bitcoin/rust-bitcoin#1273: Redesign `hex::BufEncoder` to accept owned arrays
1bf885550e Redesign `hex::BufEncoder` to accept owned arrays (Martin Habovstiak)

Pull request description:

  Not being able to create an owned `BufEncoder` prevented returning it from functions which need to allocate the buffer on stack. Such is the case in WIP serde via consensus serialzation.

  This change refactors `OutBytes` to be unsized, adds an `AsOutBytes` trait and uses that one instead of `Into` to perform the conversion.

  Closes #1270

  This is meant as potentially mergeable demonstration. Interestingly, it was easier than I expected.

ACKs for top commit:
  tcharding:
    Except for the question about the `out_bytes` module, ACK 1bf885550e
  apoelstra:
    ACK 1bf885550e

Tree-SHA512: 39bc48e54ae0e66b988ba5ad6ea7ecbe03e5f4c71792df0f8e2b03aa2e97e2c0fac1cb03e84ecac12ec6f13649554b57e1000710c34c638d17d9bb575d0ac0a1
2022-09-15 13:17:36 +00:00
Tobin C. Harding 3f275f7f2b Remove code deprecated in v0.28.0
I believe we said we'd keep deprecated code around for two release
cycles so this code can  all be deleted now.
2022-09-15 13:29:02 +10:00
Tobin C. Harding c4eb218cd0 schnorr:: Remove incorrect deprecated
Currently we attempt to have deprecated key types in the `schnorr`
module. The `deprecated` attribute does not work on types, only on
functions.

Remove the broken deprecation logic and re-export key types instead of
using type alias', this allows a bunch of qualified paths to be
simplified also.

Add `pub use` re-exports of all secp256k1 types that are part of the
public API of the `schnorr` module. This makes the module more ergonomic
to use.
2022-09-15 12:34:51 +10:00
Andrew Poelstra 836063dbad
Merge rust-bitcoin/rust-bitcoin#1269: Hex fixups
6b96050d1f Document `cfg` (Martin Habovstiak)
6fc4860813 Activate `rust_v_1_46` when on high-enough rustc (Martin Habovstiak)

Pull request description:

  This fixes minor mistakes that I made in previous PR.

ACKs for top commit:
  apoelstra:
    ACK 6b96050d1f
  tcharding:
    tACK 6b96050d1f

Tree-SHA512: a926d1b642058538c3a61760593c387a9316050d7468c3eefd18c7a6c1109e736032ac49704b16f418dc0649fe110d48e188cb6b267f002ac60803f0f5a9fedb
2022-09-14 23:56:03 +00:00
Martin Habovstiak 1bf885550e Redesign `hex::BufEncoder` to accept owned arrays
Not being able to create an owned `BufEncoder` prevented returning it
from functions which need to allocate the buffer on stack. Such is the
case in WIP serde via consensus serialzation.

This change refactors `OutBytes` to be unsized, adds an `AsOutBytes`
trait and uses that one instead of `Into` to perform the conversion.
2022-09-14 19:41:58 +02:00
Andrew Poelstra 779668879d
Merge rust-bitcoin/rust-bitcoin#1125: Update docs on rustfmt
b7eea6cb26 Update docs on rustfmt (Tobin C. Harding)

Pull request description:

  We have introduced `rustfmt` but forgot to update the docs section about
  it. Since a large portion of the codebase is currently ignored by our
  `rustfmt` configuration, point out that `rusntfmt` is work in progress.

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

Tree-SHA512: c3a01e38e9787f7554847c657de8d2aeb512f237f68e97973ffa04e92decd282126abf16edb369c13dbeb9eed3587e20dbfb3ab77e06551a006a7aa2c70a71ad
2022-09-14 13:34:49 +00:00
Andrew Poelstra 3b59b3b266
Merge rust-bitcoin/rust-bitcoin#1267: Fix serde versions
4d54b161e7 Fix serde versions (Martin Habovstiak)

Pull request description:

  `Cargo.toml` claimed that this crate works with very old versions of `serde` which wasn't the case. This commit changes the versions to minimal known-to-work values.

  Adding `trivial` tag because the text change is trivial even though figuring it out wasn't. :)
  If you manually decrease any of the versions by 1 (in both `Cargo.toml` and `Cargo.lock`) the build should fail.

ACKs for top commit:
  apoelstra:
    ACK 4d54b161e7
  tcharding:
    utACK 4d54b161e7

Tree-SHA512: 81ff3e9612aae4f3279d4dcb76ef4942d5047e7ddff84741e0ca269ee69a7631d062f6b5e6e43094e5d5f3e0b8799ddc224b716f630c9f0161185ed81fa0e96a
2022-09-14 12:50:16 +00:00
Martin Habovstiak 6b96050d1f Document `cfg`
This adds previously-forgotten documentation of items only available on
`alloc` feature.
2022-09-14 09:06:25 +02:00
Martin Habovstiak 6fc4860813 Activate `rust_v_1_46` when on high-enough rustc
This adds a build script that automatically activates the cfg if the
version is sufficient. We don't make API changes here, just improve
debugging by enabling `track_caller`.
2022-09-14 08:55:02 +02:00
Andrew Poelstra 720af690fc
Merge rust-bitcoin/rust-bitcoin#1268: Implement basic support for fast hex encoding
040b14ef1a Implement basic support for fast hex encoding (Martin Habovstiak)

Pull request description:

  There's a `hex` module in `bitcoin_hashes` which is a bit out of place and not very fast - it passes each *digit* through dynamic dispatch not only adding overhead but also not allowing `String` to make better allocations.

  This change adds basic support for hex encoding using a stack-allocated buffer which minimizes the overhead of dynamic dispatch. It also provides a new `DisplayHex` trait designed to replace `ToHex` found in `bitcoin_hashes`.

ACKs for top commit:
  apoelstra:
    ACK 040b14ef1a
  tcharding:
    ACK 040b14ef1a

Tree-SHA512: ffb2f46d5e0aa97c73a14067bdde92b7577651de1daee89fcb38b6e464b78a6ce40d39ac6bd573a9eec7274aa4e112ebc537604dca2c0d38da7d647cb548482a
2022-09-14 01:37:34 +00:00
Martin Habovstiak 040b14ef1a Implement basic support for fast hex encoding
There's a `hex` module in `bitcoin_hashes` which is a bit out of place
and not very fast - it passes each *digit* through dynamic dispatch not
only adding overhead but also not allowing `String` to make better
allocations.

This change adds basic support for hex encoding using a stack-allocated
buffer which minimizes the overhead of dynamic dispatch. It also
provides a new `DisplayHex` trait designed to replace `ToHex` found in
`bitcoin_hashes`.
2022-09-13 22:17:31 +02:00
Martin Habovstiak 4d54b161e7 Fix serde versions
`Cargo.toml` claimed that this crate works with very old versions of
`serde` which wasn't the case. This commit changes the versions to
minimal known-to-work values.
2022-09-13 16:19:07 +02:00
Andrew Poelstra 4e85cd0065
Merge rust-bitcoin/rust-bitcoin#1239: Introduce `bitcoin-internals` crate
834bbf461f Introduce bitcoin-internals crate (Tobin C. Harding)
12c5fb042e Refactor import statements (Tobin C. Harding)
022730bd8d Add a workspace to the top level directory. (Tobin C. Harding)
a59e0544ec Remove trailing whitespace (Tobin C. Harding)

Pull request description:

  Add a new crate `bitcoin-internals` to be used for internal code needed by multiple soon-to-be-created crates. Add the `write_err` macro to `bitcoin-internals`, nothing else.

  ### Notes

  This PR uses a `path` dependency which means `rust-bitcoin` cannot be released in its current state, will need to be changed once we release the `bitcoin-internals` crate on `crates.io`.

  Please note also the testing strategy imposed by this PR - each new crate to have its own `contrib/test.sh` run from the top level `test.sh`.

  Please excuse the mid-series import statement refactor, I had a moment of weakness and got uncontrollably triggered by the messy imports in one file, I managed to keep myself together on the others :)

ACKs for top commit:
  apoelstra:
    ACK 834bbf461f
  Kixunil:
    ACK 834bbf461f

Tree-SHA512: 327cced077b6d8bf6b4407a930ff8c0a6a8488256453cab168fc0d172ebb03976f8e64ff26a9b178f856c2ffa4342b5ef1a2c6eabcadf9bfa3cf787157a1d1ec
2022-09-13 13:24:27 +00:00
Tobin C. Harding 834bbf461f Introduce bitcoin-internals crate
Add a new crate `bitcoin-internals` to be used for internal code needed
by multiple soon-to-be-created crates.

Add the `write_err` macro to `bitcoin-internals`, nothing else.

This patch uses a `path` dependency which means `rust-bitcoin` cannot be
released in its current state, will need to be changed once we release
the `bitcoin-internals` crate on `crates.io`.
2022-09-13 08:59:57 +10:00
Tobin C. Harding 12c5fb042e Refactor import statements
Refactor import statements to adhere to core/other/crate with white
space between groups.

Refactor only, no logic changes.
2022-09-13 08:44:57 +10:00
Tobin C. Harding 022730bd8d Add a workspace to the top level directory.
Create a directory `bitcoin` and move into it the following as is with
no code changes:

- src
- Cargo.toml
- contrib
- test_data
- examples

Then do:

- Add a workspace to the repository root directory.
- Add the newly created `bitcoin` crate to the workspace.
- Exclude `fuzz` and `embedded` crates from the workspace.
- Add a contrib/test.sh script that runs contrib/test.sh in each
  sub-crate
- Fix the bitcoin/contrib/test.sh script
2022-09-13 08:44:57 +10:00
Tobin C. Harding a59e0544ec Remove trailing whitespace
Whitespace only, no other changes.
2022-09-13 08:44:57 +10:00
Andrew Poelstra 29bbe4042f
Merge rust-bitcoin/rust-bitcoin#1183: Use `Borrow` trait bound for bip158 `Iterator::Item`
d8116de56a Use Borrow trait bound for bip158 Iterator::Item (Tobin C. Harding)

Pull request description:

  Currently the generic iterators in `bip158` return items of type slice reference. We can make the code cleaner (no explicit lifetimes) and more general if the generic iterator argument iterates over `Borrow<[u8]>`

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

Tree-SHA512: ce8111130d70a8c6f8d97f2c3f6c07bffd534461fdb599185129fc3cc4fc6c209e3187444082e47b7b55e4ec71fd8652fb2b86d2037573b99560ffd094175dc1
2022-09-12 20:47:29 +00:00
Andrew Poelstra 0f5a585cb9
Merge rust-bitcoin/rust-bitcoin#1255: Add a comment to delineate test_macros re-export
a9d1e08833 Add a comment to delineate test_macros re-export (Tobin C. Harding)

Pull request description:

  The formatter removes an empty line that is clearly better to have. Add a rustdoc comment to at least delineate the line a bit.

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

Tree-SHA512: 0d962200a9d359825f3db50c2fcf3cf254f4f2ae55148d4a6524062bad8536160ae5f17256d4a86d746e66e5892e969b8efc14372f046ab7b4ce2950ce4bd25b
2022-09-12 20:38:20 +00:00
Tobin C. Harding d8116de56a Use Borrow trait bound for bip158 Iterator::Item
Currently the generic iterators in `bip158` return items of type slice
reference. We can make the code cleaner (no explicit lifetimes) and more
general if the generic iterator argument iterates over `Borrow<[u8]>`.

Note, includes adding `Borrow` to `crate::prelude`.
2022-09-12 14:22:10 +10:00
Tobin C. Harding a9d1e08833 Add a comment to delineate test_macros re-export
The formatter removes an empty line that is clearly better to have. Add
a rustdoc comment to at least delineate the line a bit.
2022-09-12 09:04:27 +10:00
sanket1729 3cbab2870c
Merge rust-bitcoin/rust-bitcoin#1250: Simplify `PublicKey` serialization code
b9a512330a Simplify `PublicKey` serialization code (Martin Habovstiak)

Pull request description:

  There were a bunch of `if self.serialized` expressions repeated in the code. This change simplifies it by putting the `if` in a function that calls a closure with a slice containing the serialized bytes.

ACKs for top commit:
  apoelstra:
    ACK b9a512330a
  sanket1729:
    utACK b9a512330a. I don't have strong preferences on naming. `serialize_and_call` sounds better because so far I have only seen `with_*` used with constructors.
  tcharding:
    ACK b9a512330a

Tree-SHA512: 5d90a73f87fa36bd45a5765542ec24994d601d32ad6529fff5d5140ded2b86eb40e00bfba4955e94d2c468983e3e7683ca5f8ece7a205d9b9944334a19b06015
2022-09-11 15:34:57 -07:00
Andrew Poelstra 4b662f8c57
Merge rust-bitcoin/rust-bitcoin#1248: implement `From<PublicKey>` for `PubkeyHash`
81f81caa04 implement `From<PublicKey>` for `PubkeyHash` (Noah Lanson)

Pull request description:

  Part of #1245.

  Do we also want a method on `PubkeyHash` or is the `From` impl sufficient?

ACKs for top commit:
  tcharding:
    ACK 81f81caa04
  Kixunil:
    ACK 81f81caa04
  sanket1729:
    ACK 81f81caa04
  apoelstra:
    ACK 81f81caa04

Tree-SHA512: 760ea2991de60fd72d0aae18d375024f001f331d8a57b1e6e39b5933efa3a5af379effecb89cde0defb960b25c997b417fc126248589953655fb83db8b8dd608
2022-09-09 21:02:40 +00:00
Noah Lanson 81f81caa04 implement `From<PublicKey>` for `PubkeyHash` 2022-09-09 11:02:05 +10:00
Andrew Poelstra 816d24e385
Merge rust-bitcoin/rust-bitcoin#1136: Impl std error using macro
86218ad240 Use macro to implement `std::erorr::Error` (Martin Habovstiak)

Pull request description:

  There was a bunch of manual implemntations that can be converted to
  macro call. This commit replaces them except for enums because those are
  currently not supported by the macro and we want to protect against
  forgetting to handle newly added variants.

  Depends on #1129 and is **not** urgent for the next release.

ACKs for top commit:
  apoelstra:
    ACK 86218ad240
  tcharding:
    ACK 86218ad240

Tree-SHA512: a4ca91e023d66b5ad9408004b201cfe4cea85efb5a6e7f2241367934a954659c9196561295a491d2b2ed15c1a69c0ffb17a297d710cec4ce1d0f1ec8c12492e6
2022-09-09 00:32:56 +00:00
Andrew Poelstra 3ebf3d57b4
Merge rust-bitcoin/rust-bitcoin#1252: Remove unused consensus encoding error variants
57c4283220 Remove unused consensus encoding error variants (Martin Habovstiak)

Pull request description:

  The error variants `UnexpectedNetworkMagic` and `UnknownNetworkMagic` were not only duplicated but also completely unused. This removes both of them.

ACKs for top commit:
  tcharding:
    ACK 57c4283220
  apoelstra:
    ACK 57c4283220

Tree-SHA512: 3e686f54dee038500712e6960aeb3a633d95a6302f782b9b756a8a32f6b9eff805a7b63f2190c57ed806d6dfd7585b2f335bd8d5c5bfbe2c1b27e4761fd96625
2022-09-09 00:24:33 +00:00
Andrew Poelstra 7056490de2
Merge rust-bitcoin/rust-bitcoin#1249: Run cargo fmt
0e425acad3 Run cargo fmt (Tobin C. Harding)

Pull request description:

  A few trivial formatting errors have snuck into the codebase.

  Run `cargo +nightly fmt`

  FTR we have an open PR to run formatter in CI: https://github.com/rust-bitcoin/rust-bitcoin/pull/1111

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

Tree-SHA512: b42ba57fab25baf6ed7cfb3c207389df09d192840c591178fb3f43f1f0ff3e9381e1416c976fa4da8104dd3c18a32f54338ed98b997a31aba5c37a1b6c261210
2022-09-09 00:17:29 +00:00
Andrew Poelstra 94a4c51c10
Merge rust-bitcoin/rust-bitcoin#1244: BIP 34: Check last minimal encoding accoriding of heights
840520042a BIP 34: Check last minimal encoding of encoded heights in coinbase tx (sanket1729)
fd3e01d6e3 Fix minimality of reading/writing CScriptNums (sanket1729)

Pull request description:

  See: https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki

  The BIP was updated with commit: 08844fd6ef

  Found while reviewing #1240

  Also cleanly deals with negative heights as errors.

ACKs for top commit:
  apoelstra:
    ACK 840520042a
  tcharding:
    ACK 840520042a

Tree-SHA512: 85eb1fbb428fb600f864390c3ac2e8e62efc1fc4b03b842e384ddb4ed9273c66d2274d0de219f1c7a6bad7b02bd8723f8f257c864577614df674b44bfc02010a
2022-09-08 23:23:02 +00:00
Martin Habovstiak 86218ad240 Use macro to implement `std::erorr::Error`
There was a bunch of manual implemntations that can be converted to
macro call. This commit replaces them except for enums because those are
currently not supported by the macro and we want to protect against
forgetting to handle newly added variants.
2022-09-08 21:36:49 +02:00
Martin Habovstiak 57c4283220 Remove unused consensus encoding error variants
The error variants `UnexpectedNetworkMagic` and `UnknownNetworkMagic`
were not only duplicated but also completely unused. This removes both
of them.
2022-09-08 16:58:46 +02:00
Martin Habovstiak b9a512330a Simplify `PublicKey` serialization code
There were a bunch of `if self.serialized` expressions repeated in the
code. This change simplifies it by putting the `if` in a function that
calls a closure with a slice containing the serialized bytes.
2022-09-08 10:04:20 +02:00
Tobin C. Harding 0e425acad3 Run cargo fmt
A few trivial formatting errors have snuck into the codebase.

Run `cargo +nightly fmt`
2022-09-08 15:48:21 +10:00
Andrew Poelstra ed9012c25c
Merge rust-bitcoin/rust-bitcoin#1240: Add new type for block version
947dcf5675 Add new type for block version (Noah Lanson)

Pull request description:

  Added new type `BlockVersion` for block header version field with inspiration from [Kixunil 's comment on #1215.](https://github.com/rust-bitcoin/rust-bitcoin/issues/1215#issue-1352273532)

  I previously knew very little about the upgrading process so it was fun learning about it in writing this PR, however that also means it's probably not perfect yet, especially around BIP-9 signalling (fingers crossed it's all correct).

  API for the type is kept simple but happy to change it up to add more functionality.

ACKs for top commit:
  sanket1729:
    ACK 947dcf5675.
  apoelstra:
    ACK 947dcf5675

Tree-SHA512: 1ce9720d50f0ab50e08308e56bdc047567b64dbe446dcdcd9db2f14f5c9d4603a7b9d58a5fa38b769581789fdbc4e1ef6083be32b9b59cef59714e07b2f8be5f
2022-09-07 13:24:38 +00:00
Andrew Poelstra f048cd9132
Merge rust-bitcoin/rust-bitcoin#1246: Use correct path for bip158 in rustdoc
d780ea3c48 Use correct path for bip158 in rustdoc (Tobin C. Harding)

Pull request description:

  Recently we moved the `bip158` module but I missed one of the import statements in rustdoc - if only I could work out how to lint rustdocs.

ACKs for top commit:
  apoelstra:
    ACK d780ea3c48
  sanket1729:
    ACK d780ea3c48

Tree-SHA512: 2fcb7f1ad8883d17370b37786be34597ae6ab0a858d4636db831d80e779888307bc99cf247449ae285e43719cf955ea3bb9ebb3f045aafe644c815c5f5e21724
2022-09-07 13:21:03 +00:00
Tobin C. Harding d780ea3c48 Use correct path for bip158 in rustdoc
Recently we moved the `bip158` module but I missed one of the import
statements in rustdoc - if only I could work out how to lint rustdocs.
2022-09-07 10:47:20 +10:00
sanket1729 840520042a BIP 34: Check last minimal encoding of encoded heights in coinbase tx
See: https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki
2022-09-06 14:14:44 -07:00
sanket1729 fd3e01d6e3 Fix minimality of reading/writing CScriptNums 2022-09-06 14:01:26 -07:00
Andrew Poelstra 501821404d
Merge rust-bitcoin/rust-bitcoin#1238: CI clean ups
37cd6503f1 ci: Remove TOOLCHAIN env var (Tobin C. Harding)
8eb6c23eaf ci: Remove inner quotes from shell variable (Tobin C. Harding)
58ede47ef1 ci: Use set -ex instead of /bin/sh -ex (Tobin C. Harding)
4c4846f82a Remove double blank line at EOF (Tobin C. Harding)

Pull request description:

  Clean up the CI script. These patches are part of #1225, are beneficial to have before that PR resolves, and are trivial.

ACKs for top commit:
  sanket1729:
    utACK 37cd6503f1
  apoelstra:
    ACK 37cd6503f1

Tree-SHA512: f6b3379c8a1be7a3519461faeed35e35560e4228bddb59ef28ab3fb3ef2679afabfaccfeaffd78adbb66879aed02c092f3d9d1d1eb3193c811067ee75e876732
2022-09-06 13:31:27 +00:00
Andrew Poelstra 2bb3552e4f
Merge rust-bitcoin/rust-bitcoin#1211: Move bip158 module to crate root
01161e66ee Run formmater on bip158 (Tobin C. Harding)
95393aadbc Move bip158 module to crate root (Tobin C. Harding)

Pull request description:

  We are attempting to flatten the `util` module.

  Move the `bip158` module to the crate root out of `util`.

  Currently `src/util/` is ignored by the formatter so this move requires `bip158` module to be formatted. Formatting is done as a separate patch so reviewers can run `cargo +nightly fmt` and compare the diffs if so desired.

ACKs for top commit:
  apoelstra:
    ACK 01161e66ee
  sanket1729:
    ACK 01161e66ee

Tree-SHA512: 192279d8d1466aa939ecad1f7beae12c4c7b5067871f6f1297fc80094a4ab736de4c1ed82a0b1d9d8e1cdba15c0342b90722002a9ba02ab1eff901edbd0fb356
2022-09-06 13:19:03 +00:00
Noah Lanson 947dcf5675 Add new type for block version 2022-09-06 13:27:52 +10:00
Tobin C. Harding 37cd6503f1 ci: Remove TOOLCHAIN env var
Cargo already has an env var for controlling the toolchain, we should
use it instead of our current custom `TOOLCHAIn`.

While we are at it fix the missing `$` from variables (found by
`shellcheck`).

Use RUSTUP_TOOLCHAIN to allow control of the toolchain.
2022-09-05 10:48:47 +10:00
Tobin C. Harding 8eb6c23eaf ci: Remove inner quotes from shell variable
shellcheck emits:

 SC2027: The surrounding quotes actually unquote this. Remove or escape them.

Remove inner quotes from shell variable so the feature is correctly printed.
2022-09-05 10:48:47 +10:00
Tobin C. Harding 58ede47ef1 ci: Use set -ex instead of /bin/sh -ex
Setting `-ex` in the shebang makes it a little hard to see since folks
are used to glancing up and looking for `set -ex`. Both styles achieve
the same result, so this does not change the logic of the script.
2022-09-05 10:48:47 +10:00
Tobin C. Harding 4c4846f82a Remove double blank line at EOF
There should only be a single blank line at end of file.
2022-09-05 10:48:47 +10:00
Andrew Poelstra 1d8d04dd59
Merge rust-bitcoin/rust-bitcoin#1235: Correctly handle bicoinconsensus::Error
a013847bd3 Correctly handle bicoinconsensus::Error (Tobin C. Harding)

Pull request description:

  With the latest release of `rust-bitcoinconsensus` the
  `bicoinconsensus::Error` now implements `std::error::Error`.

  Correctly handle `bicoinconsensus::Error` by returning `Some(e)` and
  using `write_err` as is standard across the code base.

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

Tree-SHA512: d9ea4ce0b01277f7c6e2f1a8b877720dba111ecfbb5de7fe5bb35bf659f5c47ee4436f021f9293717000b4cc3ccfc5dc6a893e879aca4db12bb7570be8ccaee0
2022-09-02 14:31:49 +00:00
Tobin C. Harding a013847bd3 Correctly handle bicoinconsensus::Error
With the latest release of `rust-bitcoinconsensus` the
`bicoinconsensus::Error` now implements `std::error::Error`.

Correctly handle `bicoinconsensus::Error` by returning `Some(e)` and
using `write_err` as is standard across the code base.
2022-09-02 13:19:02 +10:00
Andrew Poelstra 556f85d993
Merge rust-bitcoin/rust-bitcoin#1227: Remove some easy todo's
fea908c8af Add private::Sealed trait bound to SerdeAmount (Tobin C. Harding)
08e4b28dd0 Add integer serialization tests (Tobin C. Harding)
a8f9e8ad96 Add serde roundtrip tests (Tobin C. Harding)

Pull request description:

  Remove some easy todos from the code. The three patches are unrelated except each removes a single `TODO`. Patch 1 and 2 are unit tests and trivial to review. Patch 3 requires more thought, it was't clear exactly why it was left as a todo and not done at the time.

  cc JeremyRubin for patch 3 as the original author of that code.

ACKs for top commit:
  apoelstra:
    utACK fea908c8af

Tree-SHA512: 70a041820fe52bc3d70cc110c16acfa86469fd8556793c4204671ddcb7457f336e57b43b0f03cb68d3c6b96217502f29f1628d1acbe7381a9e9d8d21c67759d2
2022-09-01 14:53:06 +00:00
Andrew Poelstra 7efe30c5e8
Merge rust-bitcoin/rust-bitcoin#1196: Add relative lock time type
da95c3a489 Add newtype `relative::LockTime` (Tobin C. Harding)
cbfa8cff4c Improve lock time docs (Tobin C. Harding)
9f7d934f5d Move the locktime module to absolute (Tobin C. Harding)

Pull request description:

  Patches 1 and 2 are preparation. Patch 3 adds a new `relative::LockTime` type.

  Please see https://github.com/rust-bitcoin/rust-miniscript/pull/455 for demo of use of the new API in miniscript.

  ### Some links to help during review
  - https://medium.com/summa-technology/bitcoins-time-locks-27e0c362d7a1
  - https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki
  - https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki

ACKs for top commit:
  apoelstra:
    ACK da95c3a489
  sanket1729:
    ACK da95c3a489. Left a minor nit

Tree-SHA512: 00137161eee354faa803f74dd33dbaaf58ced58cf54d334200be28e10281bb98cb72dff38b3205d1741b8d42100c3b8229e4cfa2155e46bb74b418b612c12dec
2022-09-01 14:51:25 +00:00
Tobin C. Harding fea908c8af Add private::Sealed trait bound to SerdeAmount
As suggested by the todo seal the `SerdeAmount` so users of the library
explicitly cannot implement it.

Its not obvious to me why this wasn't done at the time.

Remove the associated TODO from the code.
2022-09-01 16:53:33 +10:00