Commit Graph

108 Commits

Author SHA1 Message Date
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 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
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
Martin Habovstiak 43827a1e1c Hex macro clean up
There were some duplicated hex macros in the `address` module as well as
several macros outputing specific types instead of working with any type
deserializable from hex.

This cleanup moves the macros and deduplicates them, introduces a new
`TestFromHex` trait to generalize parsing hex and rewrites the code to
use hex parsing generally. `hex_script` is still kept because its usage
is very frequent.
2022-08-30 15:04:31 +02:00
Martin Habovstiak 4dedf7d555 Remove duplicated `#[cfg(test)]` conditions
Several macros used in tests had `#[cfg(test)]` condition on each of
them. This deduplicates them by putting them into a separate module and
reexporting (with one condition for module and one for re-export).
2022-08-30 15:04:31 +02:00
hrouis 4c1dc4594d Implementing a macro to define debug from display and adding Display trait implementation where needed
Display should not be implemented as Debug trait, but the existing macro promotes this figure of use.
The macro has been replaced with implement_debug_from_display and the Display trait has been implemented where needed.
The LowerHex trait has been implemented instead of Display for UintX types.
2022-08-24 14:04:11 +02:00
Tobin C. Harding 0786d92a5c Take self by value
Turns out by default clippy does not lint certain parts of the public
API. Specifically, by setting

  avoid-breaking-exported-api = false

we can get clippy to lint the public API for various things including
`wrong_self_convention`.

Clippy emits:

 warning: methods with the following characteristics: (`to_*` and `self`
 type is `Copy`) usually take `self` by value

As suggested, take `self` by value for methods named `to_*`.
2022-08-02 08:54:53 +10:00
Martin Habovstiak c39bc3909d Extend `ParseIntError` to carry more context
When debugging parsing errors it's very useful to know some context:
what the input was and what integer type was parsed. `ParseIntError`
from `core` doesn't contain this information.

In this commit a custom `ParseIntError` type is crated that carries the
one from `core` as well as additional information. Its `Display`
implementation displays this additional information as a well-formed
English sentence to aid users with understanding the problem. A helper
function parses any integer type from common string types returning the
new `ParseIntError` type on error.

To clean up the error code a bit some new macros are added and used.
New modules are added to organize the types, functions and macros.

Closes #1113
2022-07-27 18:51:53 +02:00
Tobin C. Harding 21a1cc791c Use pub(crate) for macros instead of macro_use
For internal macros used only in this crate we do not need to use
`macro_use` and pollute the top level namespace now that we have edition
2018. We can add a `pub(crate) use` statement to each and then path
imports work for the macros like normal types.
2022-07-20 11:25:54 +10:00
Tobin C. Harding ee9a3ec6a1 Enable formatter for "src"
Remove the ignore for the "src" directory, this enables the formatter
for all source files in the `src/` directory.
2022-07-19 13:43:12 +10:00
Tobin C. Harding 743b197124 Add use for Unexpected
In preparation for running the formatter on `src/` and a function local
use statement for `$crate::serde:🇩🇪:Unexpected`, this shortens the
line of code that uses this type preventing the formatter for later
munging that line.
2022-07-19 13:43:12 +10:00
Tobin C. Harding fd217e72c3 Use f instead of formatter
The local variable `formatter` can be shortened to `f` with no loss of
clarity since it is so common.

Done in preparation for running `rustfmt` on `src`.
2022-07-19 13:43:12 +10:00
Andrew Poelstra 0c22359618
Merge rust-bitcoin/rust-bitcoin#1001: Remove leading colons
73bc2bb058 Remove leading colons from ::core::cmp::Ordering (Tobin C. Harding)
bffe0e840d Remove _most_ leading double colons (Tobin C. Harding)

Pull request description:

  Leading double colons are a relic of edition 2015. Attempt to remove _all_ leading double colons (assuming I didn't miss any).

  - Patch 1 is done mechanically so it can be repeated by reviewers, just search-and-replace ' ::' with '::' (note the leading space).
  - Patch 2 does a single other instance of leading `::`

ACKs for top commit:
  apoelstra:
    ACK 73bc2bb058
  sanket1729:
    utACK 73bc2bb058.

Tree-SHA512: 8f7aafdda1aed5b69dcc83f544e65085dfec6590765839f0a6f259b99872805d1f00602fd9deac05c80a5cac3bc222d454dde0117dff4484e5cd34ea930fdfa1
2022-07-19 01:39:04 +00:00
Andrew Poelstra 5d06177644
Merge rust-bitcoin/rust-bitcoin#1076: Introduce SPDX license identifiers
91ff2f628c Introduce SPDX license identifiers (Tobin C. Harding)

Pull request description:

  When `rust-bitcoin` was started in 2014 the SPDX license list and short identifiers where not a thing. Now that we have short identifiers and they are gaining popularity in other projects we can consider using them.

  - Add links to the SPDX website in the readme
  - Shorten the author section to a single line
  - Remove all the licence information in each file and replace it with an
  SPDX ID (see https://spdx.dev/ids/#how)

  Of note:

  - If the author of a file is explicitly listed, maintain this information
  - If the 'author' is listed as the generic 'Rust Bitcoin developers' just remove the attribution, this is implicit. This does loose the date info but that can be seen at any time from the git index using

    `git log --follow --format=%ad --date default <FILE> | tail -1`

  apoelstra, please confirm that I'm not treading on your toes here, especially, are you ok with the new 'written by' string format?

  ### Ref
  - https://spdx.dev/ids/#how
  - https://spdx.org/licenses/CC0-1.0.html
  - https://spdx.dev/ids/

ACKs for top commit:
  apoelstra:
    ACK 91ff2f628c
  sanket1729:
    ACK 91ff2f628c. I am also in IDGAF camp, but I like more red lines in diff.
  Kixunil:
    ACK 91ff2f628c

Tree-SHA512: ca8aac00f015c18ec18de83dfeb50dd6f4f840653c7def85daa2436a339021ada5f3c34ad0cdf6b18e3e39c45a6d58a8313742e4001d467785b10eee7fdbc938
2022-07-11 15:11:03 +00:00
Tobin C. Harding bffe0e840d Remove _most_ leading double colons
Leading double colons are a relic of edition 2015. Remove all leading
double colons that follow a space, done like this so that reviewers can
do the same and verify the diff. Done with

search-and-replace ' ::' '::'

And, for the record:

```bash
function search-and-replace() {
    if (($# != 2))
    then
        echo "Usage: $0 <this> <that>"
        return
    fi

    local this="$1"
    local that="$2"

    for file in $(git grep -l "$this")
    do
        perl -pi -e "s/$this/$that/g" "$file"
    done
}
```
2022-07-11 15:20:05 +10:00
Tobin C. Harding 64152ff6fc Remove unused lifetimes
We somehow have two lifetimes that are unused and causing clippy
warnings, remove them.
2022-07-01 11:56:50 +10:00
Andrew Poelstra 30baeea738
Merge rust-bitcoin/rust-bitcoin#1014: Use fragment-specifier literal
4d2291930b Use fragment-specifier literal (Tobin C. Harding)

Pull request description:

  Currently we are using the fragment-specifier `expr` in a bunch of
  macros for captures that are only used for literals. If we use `literal`
  instead it allows the compiler to give slightly more specific error
  messages.

  The benefits of this change are minor. Of note, this patch found one
  unusual macro call site (removed unnecessary `&`).

  The macros changed are all internal macros, this is not a breaking change.

ACKs for top commit:
  Kixunil:
    ACK 4d2291930b
  apoelstra:
    ACK 4d2291930b

Tree-SHA512: 51c109fe3a884191bf623508555c1d5ad337a3f3b48538d18aec13e581f2c5fbbd055be49600ced19f38541412c34090bd8bac61fd05d5aa9702c96ff521364f
2022-06-30 15:01:50 +00:00
Tobin C. Harding 91ff2f628c Introduce SPDX license identifiers
When `rust-bitcoin` was started in 2014 the SPDX license list and short
identifiers where not a thing. Now that we have short identifiers and
they are gaining popularity in other projects we can consider using
them.

- Add links to the SPDX website in the readme
- Shorten the author section to a single line
- Remove all the licence information in each file and replace it with an
SPDX ID (see https://spdx.dev/ids/#how)

Of note:

- If the author of a file is explicitly listed, maintain this
information
- If the 'author' is listed as the generic 'Rust Bitcoin developers'
just remove the attribution, this is implicit. This does loose the date
info but that can be seen at any time from the git index using

  `git log --follow --format=%ad --date default <FILE> | tail -1`
2022-06-29 14:12:02 +10:00
Dawid Ciężarkiewicz 1fea098dfb Support unsized `R` and `W` in consensus encode/decode 2022-06-28 18:49:17 -07:00
Dawid Ciężarkiewicz 9c754ca4de Take Writer/Reader by `&mut` in consensus en/decoding
Fix #1020 (see more relevant discussion there)

This definitely makes the amount of generics compiler
has to generate by avoding generating the same functions
for `R`, &mut R`, `&mut &mut R` and so on.

old:

```
> ls -al target/release/deps/bitcoin-07a9dabf1f3e0266
-rwxrwxr-x 1 dpc dpc 9947832 Jun  2 22:42 target/release/deps/bitcoin-07a9dabf1f3e0266
> strip target/release/deps/bitcoin-07a9dabf1f3e0266
> ls -al target/release/deps/bitcoin-07a9dabf1f3e0266
-rwxrwxr-x 1 dpc dpc 4463024 Jun  2 22:46 target/release/deps/bitcoin-07a9dabf1f3e0266
```

new:

```

> ls -al target/release/deps/bitcoin-07a9dabf1f3e0266
-rwxrwxr-x 1 dpc dpc 9866800 Jun  2 22:44 target/release/deps/bitcoin-07a9dabf1f3e0266
> strip target/release/deps/bitcoin-07a9dabf1f3e0266
> ls -al target/release/deps/bitcoin-07a9dabf1f3e0266
-rwxrwxr-x 1 dpc dpc 4393392 Jun  2 22:45 target/release/deps/bitcoin-07a9dabf1f3e0266
```

In the unit-test binary itself, it saves ~100KB of data.

I did not expect much performance gains, but turn out I was wrong(*):

old:

```
test blockdata::block::benches::bench_block_deserialize                 ... bench:   1,072,710 ns/iter (+/- 21,871)
test blockdata::block::benches::bench_block_serialize                   ... bench:     191,223 ns/iter (+/- 5,833)
test blockdata::block::benches::bench_block_serialize_logic             ... bench:      37,543 ns/iter (+/- 732)
test blockdata::block::benches::bench_stream_reader                     ... bench:   1,872,455 ns/iter (+/- 149,519)
test blockdata::transaction::benches::bench_transaction_deserialize     ... bench:         136 ns/iter (+/- 3)
test blockdata::transaction::benches::bench_transaction_serialize       ... bench:          51 ns/iter (+/- 8)
test blockdata::transaction::benches::bench_transaction_serialize_logic ... bench:           5 ns/iter (+/- 0)
test blockdata::transaction::benches::bench_transaction_size            ... bench:           3 ns/iter (+/- 0)
```

new:

```
test blockdata::block::benches::bench_block_deserialize                 ... bench:   1,028,574 ns/iter (+/- 10,910)
test blockdata::block::benches::bench_block_serialize                   ... bench:     162,143 ns/iter (+/- 3,363)
test blockdata::block::benches::bench_block_serialize_logic             ... bench:      30,725 ns/iter (+/- 695)
test blockdata::block::benches::bench_stream_reader                     ... bench:   1,437,071 ns/iter (+/- 53,694)
test blockdata::transaction::benches::bench_transaction_deserialize     ... bench:          92 ns/iter (+/- 2)
test blockdata::transaction::benches::bench_transaction_serialize       ... bench:          17 ns/iter (+/- 0)
test blockdata::transaction::benches::bench_transaction_serialize_logic ... bench:           5 ns/iter (+/- 0)
test blockdata::transaction::benches::bench_transaction_size            ... bench:           4 ns/iter (+/- 0)
```

(*) - I'm benchmarking on a noisy laptop. Take this with a grain of salt. But I think
at least it doesn't make anything slower.

While doing all this manual labor that will probably generate conflicts,
I took a liberty of changing generic type names and variable names to
`r` and `R` (reader) and `w` and `W` for writer.
2022-06-23 15:55:14 -07:00
Tobin C. Harding 63f4ff6406 Remove redundant field names
clippy emits two warnings of form:

 warning: redundant field names in struct initialization

Remove the redundant field names.
2022-06-23 13:45:16 +10:00
Tobin C. Harding 4d2291930b Use fragment-specifier literal
Currently we are using the fragment-specifier `expr` in a bunch of
macros for captures that are only used for literals. If we use `literal`
instead it allows the compiler to give slightly more specific error
messages.

The benefits of this change are minor. Of note, this patch found one
unusual macro call site (removed unnecessary `&`).

The macros changed are all internal macros, this is not a breaking change.
2022-06-20 14:43:06 +10:00
Tobin C. Harding 7a3bb7d3ec Replace runtime size check with compile time check
Add a macro `const_assert` that uses some const declaration trickery to
trigger a compile time error if a boolean expression is false.

Replace runtime checks using `debug_assert_eq!` with the newly defined
`const_assert!` macro.
2022-06-20 14:40:51 +10:00
sanket1729 165cae959a
Merge rust-bitcoin/rust-bitcoin#1003: Improve error `Display` implementations
57dd6739c3 Do not print error when displaying for std builds (Tobin C. Harding)
b80cfeed85 Bind to error_kind instead of e (Tobin C. Harding)
241ec72497 Bind to b instead of e (Tobin C. Harding)
01f481bf5c Bind to s instead of e (Tobin C. Harding)
5c6d369289 network: Remove unused error variants (Tobin C. Harding)
e67e97bb37 Put From impl below std::error::Error impl (Tobin C. Harding)
6ca98e5275 Remove error TODO (Tobin C. Harding)

Pull request description:

  As part of the ongoing error improvement work and as a direct result of [this comment](https://github.com/rust-bitcoin/rust-bitcoin/pull/987#issuecomment-1135563287) improve the `Display` implementations of all our error types so as to not repeat the source error when printing.

  The first 5 patches are trivial clean ups around the errors. Patch 6 is the real work.

  EDIT: ~CC @Kixunil, have I got the right idea here bro?~ Patch 6 now includes a macro as suggested.

ACKs for top commit:
  Kixunil:
    ACK 57dd6739c3
  apoelstra:
    ACK 57dd6739c3
  sanket1729:
    ACK 57dd6739c3. Did not check if we covered all cases. We need to remember to use `write_err!` instead of `write!` in future.

Tree-SHA512: 1ed26b0cc5f9a0f71684c431cbb9f94404c116c9136be696434c56a2f56fd93cb5406b0955edbd0dc6f8612e77345c93fa70a70650118968cc58e680333a41de
2022-06-01 15:17:24 -07:00
sanket1729 e9a3379228
Merge rust-bitcoin/rust-bitcoin#878: Add chain hash type using consts
8e29f2b493 Add ChainHash type (Tobin Harding)
cd8f511fcb blockdata: constants: Use wildcard import in unit tests (Tobin Harding)
71bf19621a Use fully qualified path in macro (Tobin Harding)

Pull request description:

  The Lightning network defines a type called 'chain hash' that is used to uniquely represent the various Bitcoin networks as a 32 byte hash value. Chain hash is now being used by the DLC folks, as such it is useful to have it implemented in rust-bitcoin.

  One method of calculating a chain hash is by hashing the genesis block for the respective network.

  Add a `ChainHash` type that can be used to get the unique identifier of each of the 4 Bitcoin networks we support. Add a method that calculates the chain hash for a network using the double sha256 of the genesis block. Do so using hard coded consts and add unit tests (regression/sanity) that show these hard coded byte arrays match the hash of the data we return for the genesis block for the respective network.

  The chain hash for the main Bitcoin network can be verified from LN docs (BOLT 0), add a link to this document.

  Closes: #481

ACKs for top commit:
  Kixunil:
    ACK 8e29f2b493
  sanket1729:
    ACK 8e29f2b493.

Tree-SHA512: 8156bb55838b73694ddf77a606cbe403f53a31d363aa0dee11b97dc31aa9b62609d7d84b8f0f92c08e90372a3e8c7b416fb07989d6da9633763373b41339b1f5
2022-06-01 12:34:07 -07:00
Dawid Ciężarkiewicz 082e185711 Add `consensus_decode_from_finite_reader` optimization
As things are right now, memory exhaustion protection in `Decodable`
is based on checking input-decoded lengths against arbitrary limits,
and ad-hoc wrapping collection deserialization in `Take`.

The problem with that are two-fold:

* Potential consensus bugs due to incorrect limits.
* Performance degradation when decoding nested structured,
  due to recursive `Take<Take<..>>` readers.

This change introduces a systematic approach to the problem.

A concept of a "size-limited-reader" is introduced to rely on
the input data to finish at enforced limit and fail deserialization.

Memory exhaustion protection is now achived by capping allocations
to reasonable values, yet allowing the underlying collections
to grow to accomodate rare yet legitmately oversized data (with tiny
performance cost), and reliance on input data size limit.

A set of simple rules allow avoiding recursive `Take` wrappers.

Fix #997
2022-05-30 21:15:34 -07:00
Tobin C. Harding 57dd6739c3 Do not print error when displaying for std builds
We implement `source` for all our error types. This means that we should
not display the source error explicitly because users can call `source`
to get the source error.

However, `std::Error::source()` is only available for "std" builds, so
that we do not loose the error source information in "no-std" builds add
a macro that conditionally adds the source onto the error message.
2022-05-27 08:38:52 +10:00
Tobin Harding 71bf19621a Use fully qualified path in macro
As we do for the rest of the macros use the fully qualified path to
`fmt` so users of the macro do not have to import it.
2022-05-19 14:14:32 +10:00
Tobin C. Harding 9f0c687d89 Enable edition 2018
Add 'edition = "2018"' to the manifest and do a bunch of manual path
fixups (use statements and fully qualified paths).
2022-05-11 10:16:48 +10:00
ass3rt add100c20d Removed reimplementations of default methods
The default methods do the exact same thing thus our overrides are
useless, potentially even problematic.

Credit to Kixunil for this fix: https://github.com/rust-bitcoin/rust-bitcoin/pull/905#issuecomment-1092756343
2022-04-25 09:53:52 -05:00
Dr. Maxim Orlovsky 86c6ab7529
Merge rust-bitcoin/rust-bitcoin#903: Improve `SchnorrSigHashType`
35b682d495 Implement Display/FromStr for SchnorrSigHashType (Tobin Harding)
46c4164d67 Improve SigHashTypeParseError field (Tobin Harding)
c009210d4c Use full path for String in macro (Tobin Harding)

Pull request description:

  Implement Display/FromStr for SchnorrSigHashType

  We currently implement `Display` and `FromStr` on `EcdsaSigHashType` and use them in the `serde_string_impl` macro to implement ser/de.

  Mirror this logic in `SchnorrSigHashType`.

  Patch 1 and 2 are preparatory patches for patch 3.

  ## Notes to reviewers

  This PR has some conflicts with https://github.com/rust-bitcoin/rust-bitcoin/pull/898 but is pushing in the same direction, I'm happy to let 898 go in first and rebase on top.

ACKs for top commit:
  sanket1729:
    ACK 35b682d495. Thanks, much easier to review now that the diff is small
  dr-orlovsky:
    ACK 35b682d495

Tree-SHA512: 481f192a3064ff39acf8904737dfb25b54ef128a37e0ca765ebb39138edac772d4f01ed10aa98ff185a8ed5668d64fa5d5957206b920ffe87950cafcf5a3b516
2022-03-24 08:02:27 +02:00
sanket1729 ea80e6568a
Merge rust-bitcoin/rust-bitcoin#805: Remove impl_index_newtype macro
63e36fe6b4 Remove impl_index_newtype macro (Tobin Harding)

Pull request description:

  This macro is no longer needed since we bumped MSRV to 1.29.

  ~We can implement `SliceIndex` to get the `Index` implementations.~
  We can implement `core::ops::Index` directly since all the inner types implement `Index` already.

  Original ~Idea shamelessly stolen from @elichai [in this comment](https://github.com/rust-bitcoin/rust-bitcoin/issues/352#issuecomment-560331856).~

  New idea proposed by @Kixunil during review below. Thanks.

ACKs for top commit:
  apoelstra:
    ACK 63e36fe6b4
  dr-orlovsky:
    utACK 63e36fe6b4
  sanket1729:
    ACK 63e36fe6b4

Tree-SHA512: f7b4555c7fd9a2d458dcd53ec8caece0d12f3af77a10e850f35201bd7a580ba8fd7cb1d47a7f78ba6582e777dffa13416916ecacac6e0e874bdbb1c866132dc2
2022-03-23 19:01:56 -07:00
Tobin Harding c009210d4c Use full path for String in macro
As is done in the rest of the `internal_macros` module use the fully
qualified path for the `String` type.

Done in preparation for using `serde_string_impl` in the `sighash`
module.
2022-03-24 11:01:15 +11:00
Tobin Harding 63e36fe6b4 Remove impl_index_newtype macro
This macro is no longer needed since we bumped MSRV to 1.29.

We can implement `core::ops::Index` directly since all the inner types
implement `Index` already.
2022-03-17 08:12:09 +11:00
Tobin Harding a8ed95ea07 Refactor where statements
Our usage of `where` statements is not uniform, nor is it inline with
the typical layout suggested by `rustfmt`.

Make an effort to be more uniform with usage of `where` statements.
However, explicitly do _not_ do every usage since sometimes our usage
favours terseness (all on a single line).
2022-03-14 13:52:13 +11:00
Tobin Harding 533120899e Put rustdocs above attributes
Rust idiomatic style is to put the rustdoc _above_ any attributes on
types, functions, etc.

Audit the codebase and move comments/attributes to the correct place.
Add a trailing full stop at times to neaten things up a little extra.
2022-01-06 13:04:47 +11:00
sanket1729 92ee5a7e5f Test BIP341 sighash code 2022-01-01 04:12:46 +05:30
Tobin Harding 3f5caa501f Clean up module level rustdocs
Docs can always do with a bit of love.

Clean up the module level (`//!`) rustdocs for all public modules.

I claim uniform is better than any specific method/style. I tried to fit
in with what ever was either most sane of most prevalent, therefore
attaining uniformity without unnecessary code churn (one exception being
the changes to headings described below).

Notes:

* Headings - use heading as a regular sentence for all modules e.g.,

```
//! Bitcoin network messages.
```

as opposed to
```
//! # Bitcoin Network Messages
```

It was not clear which style to use so I picked a 'random' mature
project and copied their style.

* Added 'This module' in _most_ places as the start of the module
description, however I was not religious about this one.

* Fixed line length if necessary since most of our code seems to follow
short (80 char) line lengths for comments anyways.

* Added periods and fixed obvious (and sometimes not so obvious)
grammatically errors.

* Added a trailing `//!` to every block since this was almost universal
already. I don't really like this one but I'm guessing it is Andrew's
preferred style since its on the copyright notices as well.
2021-11-06 10:59:53 +11:00
Martin Habovstiak 95fb4e01f9 Document cargo features
This documents cargo features in two ways: explictly in text and in code
using `#[doc(cfg(...))]` attribute where possible. Notably, this is
impossible for `serde` derives. The attribute is contitional and only
activated for docs.rs or explicit local builds.

This change also adds `package.metadata.docs.rs` field to `Cargo.toml`
which instructs docs.rs to build with relevant features and with
`docsrs` config activated enabling `#[doc(cfg(...))] attributes.

I also took the opportunity to fix a few missing spaces in nearby code.
2021-09-14 12:24:57 +02:00
Devrandom 4826d0c6cc no_std support
Based on the original work by Justin Moon.

*MSRV unchanged from 1.29.0.*

When `std` is off, `no-std` must be on, and we use the [`alloc`](https://doc.rust-lang.org/alloc/) and core2 crates. The `alloc` crate requires the user define a global allocator.

* Import from `core` and `alloc` instead of `std`
* `alloc` only used if `no-std` is on
* Create `std` feature
* Create `no-std` feature which adds a core2 dependency to polyfill `std::io` features. This is an experimental feature and should be
used with caution.
* CI runs tests `no-std`
* MSRV for `no-std` is 1.51 or so
2021-07-15 09:04:49 +02:00
Devrandom 95aa3bf153 std -> core 2021-06-11 17:28:04 +02:00
Riccardo Casatta f692c4a938
Limit bytes read with Take 2021-04-28 09:33:37 +02:00
Steven Roose 61918dfe81
Change the signature of consensus_encode to return io::Error's
This is instead of encode::Errors because the encoders should
not be allowed to return errors that don't originate in the writer
they are writing into.

This is a part of the method definition that has been relied upon for a
while already.
2021-01-12 17:39:41 +00:00
Andrew Poelstra ffe452ac0b script: add FromHex and FromStr implementations 2021-01-05 18:45:14 +01:00
Steven Roose 94b7371424 Replace serde_struct_impl with derive-based impls 2020-12-30 16:32:52 +01:00
Steven Roose d527a2c2cf Remove the impl_array_newtype_show macro
Instead, implement Debug in impl_bytes_newtype.
2020-12-30 16:32:52 +01:00
Elichai Turkel fdd6f4f196
Derive macros instead of implementing via macro_rules 2020-10-08 16:17:14 +03:00
Dr Maxim Orlovsky 257ca8e504 Using :: for std namespaces in macro 2020-07-21 22:28:05 +02:00
Dr Maxim Orlovsky 3a5e8d8504 Namespace hygiene for internal macros 2020-07-21 22:25:59 +02:00
Steven Roose a9173d61d3
Merge pull request #375 from canndrew/fix-serde-struct-macros
Fix serde struct macros deserialization impls
2020-04-19 19:56:27 +01:00