Commit Graph

2370 Commits

Author SHA1 Message Date
Andrew Poelstra d581207cb8
Merge rust-bitcoin/rust-bitcoin#1450: hashes: Do not implement `Deref`
b7a84d0c68 hashes: Do not implement Deref (Tobin C. Harding)

Pull request description:

  Currently we implement `Deref` for hashes. From the docs [0]

   > Deref should only be implemented for smart pointers to avoid confusion

  Furthermore because we implement `Deref` as well as implement `internals::hex::display::DisplayHex` for slices hashes get coerced into slices and `to_lower_hex_string` can be called on them, this is incorrect because `DisplayHex` does not account for hashes that display backwards so we end up with the wrong string.

  This is an API breaking change, and I have not built any other crates in our stack to check if anything breaks.

  [0] https://doc.rust-lang.org/std/ops/trait.Deref.html

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

Tree-SHA512: 573169095dd9f9032e3f685e3b0af3b569f1cb5368e1b2f37940504fd887592f46488abcfbe84107baf9c5453c7db47bc342a6bc273ff98cb0570ffacb549c21
2022-12-13 20:59:41 +00:00
Tobin C. Harding b7a84d0c68 hashes: Do not implement Deref
Currently we implement `Deref` for hashes. From the docs [0]

 > Deref should only be implemented for smart pointers to avoid confusion

Furthermore because we implement `Deref` as well as implement
`internals::hex::display::DisplayHex` for slices hashes get coerced into
slices and `to_lower_hex_string` can be called on them, this is
incorrect because `DisplayHex` does not account for hashes that display
backwards so we end up with the wrong string.

[0] https://doc.rust-lang.org/std/ops/trait.Deref.html
2022-12-12 12:05:54 +11:00
Andrew Poelstra 32afe5ae48
Merge rust-bitcoin/rust-bitcoin#1400: Add trait `FromStrHex` for tuple structs with single `u32` member
e00dfa9806 impl FromHexStr for structs with single u32 member (connormullett)

Pull request description:

  Closes: #1112

   - Adds new trait `FromStrHex` with 2 methods: `from_hex_str` and `from_hex_str_no_prefix`
   -  Impl new trait on each tuple struct with single u32 member. eg `Time(u32)`

  As stated in the issue, grep through codebase with `\(u32\)` and `\(pub u32\)` to see all implementations and verify none were missed.

  NonStandardSighashType is an error type and should never be constructed from a hex string. Therefore, it has been omitted from this change.

  Tests are somewhat redundant, but cover 4 cases each. 2 happy paths, 1 for each function. 1 case for malformed/invalid hex input, and 1 for calling no_prefix without a prefix

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

Tree-SHA512: 221faef7fc1fa8fdb4cba79cfae317a0b63984937c345c6ca2287123a078f38911cdc07db7589a88b7bc6fbecf389e9bcff47952728410510ffcfc1857e0f91f
2022-12-11 18:47:32 +00:00
connormullett e00dfa9806 impl FromHexStr for structs with single u32 member
Adds new module `string` to be later converted to its own
crate. The module currently contains the FromHexStr trait and an error
type to be used for implementing hex parsing on types. This change
also adds implementations of FromHexStr for types with a single u32
member such as `Sequence(pub u32)`. All structs that match the
following regex have been given this implementation
`\(u32\)` and `\(pub u32\)`. All implementations have associated
unit tests matching all possible cases. NonStandardSighashType has
been ommitted from this change as it is an error and should not be
constructed using the methods added in this change.

Adds parse::hex_u32 for future use to be made generic to allow
different sizes of integers to be parsed from hex strings.

The error type FromHexError implements required traits such as
Display and std::error::Error
2022-12-11 00:01:58 -05:00
Andrew Poelstra c93e83e94b
Merge rust-bitcoin/rust-bitcoin#1428: Adds Network::from_core_arg and links it to Network::from_str
d7006ef80d Adds roundtrip tests for Network::from_core_arg (Sergi Delgado Segura)
bd1eb29f61 Adds Network::to_core_arg (Sergi Delgado Segura)

Pull request description:

  Comming from https://github.com/rust-bitcoin/rust-bitcoincore-rpc/pull/247

  `Network::from_str` only considers `rust-bitcoin` string as possible inputs to create a `Network` instance. This PR adds a new method to `Network`, `from_core_arg`, which is complementary to the existing `Network::to_core_arg`. This method allows the conversion between `bitcoind -network` string and `Network` variants.

  This also links `Network::from_str` to `Network::from_core_arg` so the default case on the former calls the latter, and an error is only returned if none of the cases match.

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

Tree-SHA512: 97a66f858a7d4a3642bdef9016457833cfc1181e276f7ead7c6b87f6fcdcb7c5d1cfdb4b621225b806bc5949c3c5cc6a32b7df934157542d7c79aa00a9e20f41
2022-12-08 15:12:40 +00:00
Andrew Poelstra ca563c4b27
Merge rust-bitcoin/rust-bitcoin#1234: Serde derive in tests
c822fcf435 Remove helper variables (Martin Habovstiak)
70d1a0348e Use serde derive rather than manual parsing (Martin Habovstiak)

Pull request description:

  Manual parsing Json is tedious and error-prone. It contained a bunch of
  `unwrap`s and was hard to read.

  This replaces manual Json parsing with serde_derive implementation.

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

ACKs for top commit:
  apoelstra:
    ACK c822fcf435
  tcharding:
    ACK c822fcf435

Tree-SHA512: 0e1df6a62dc8438d67979a00658f8a2820135beebdd01d7275149b06feacd0d18accb86cecbf8c85f9a02ddc724575eaffff079b45cfe0e7765c8559c5eb03f7
2022-12-08 14:21:18 +00:00
Sergi Delgado Segura d7006ef80d Adds roundtrip tests for Network::from_core_arg 2022-12-08 07:19:22 -05:00
Sergi Delgado Segura bd1eb29f61 Adds Network::to_core_arg
This allows users to create `Network` instances from `bitcoind -chain` values
2022-12-08 06:33:24 -05:00
Andrew Poelstra fd5c5e43d2
Merge rust-bitcoin/rust-bitcoin#1357: Do some rustdoc cleanups
26be9ddd27 Make RBF rustdoc more scrary (Tobin C. Harding)
c9a49d5be7 blockdata: Improve content of rustdocs (Tobin C. Harding)
e1e5974065 consensus: Improve rustdocs (Tobin C. Harding)
c553299ace Remove uninformative code comments (Tobin C. Harding)
bbd39e5ecc Use longer column width (Tobin C. Harding)
31740710ee blockdata: Improve rustdocs (Tobin C. Harding)
fb708ca74b Add newline after brief description (Tobin C. Harding)

Pull request description:

  Put some effort into our documentation, this is all pretty non-controversial. Patches separated to ease review.

ACKs for top commit:
  Kixunil:
    ACK 26be9ddd27
  apoelstra:
    ACK 26be9ddd27

Tree-SHA512: 8990ed812b3bb55f722ac7e85a8655b65744eb21ad3b16dae77e05d9273f86e248f1ef4945a35d7767241038986bc23e0a8024347e600f0c1e53f8de992208e2
2022-12-07 13:48:11 +00:00
Tobin C. Harding 26be9ddd27 Make RBF rustdoc more scrary
In order to really bring the security risks of RBF to peoples attention
make the docs more scary.
2022-12-06 12:25:30 +11:00
Tobin C. Harding c9a49d5be7 blockdata: Improve content of rustdocs
Recently we (tcharding) do some mechanical improvements to the rustdocs
in the `blockdata` module without considering the content. On review a
bunch of improvements were suggested.

Improve the content of various rustdoc comments in the `blockdata`
module.

Suggested content came from reviewers, all mistakes are my own :)
2022-12-06 12:25:30 +11:00
Tobin C. Harding e1e5974065 consensus: Improve rustdocs
Do an audit of the `consensus` module and clean up rustdocs.
2022-12-06 12:25:30 +11:00
Tobin C. Harding c553299ace Remove uninformative code comments
The comments add no value to the code, remove them.
2022-12-06 12:25:30 +11:00
Tobin C. Harding bbd39e5ecc Use longer column width
Reduce the number of lines of code by using a longer column width, 100
as is more-or-less standard in this repo.

This patch only changes column width (line length), no other changes.
2022-12-06 12:25:30 +11:00
Tobin C. Harding 31740710ee blockdata: Improve rustdocs
Do an audit of the `blockdata` module and clean up rustdocs.
2022-12-06 12:25:26 +11:00
Tobin C. Harding fb708ca74b Add newline after brief description
rustdocs should contain a newline to separate the brief description from
the rest of long description.
2022-12-06 12:25:04 +11:00
Martin Habovstiak c822fcf435 Remove helper variables 2022-12-05 22:23:44 +01:00
Martin Habovstiak 70d1a0348e Use serde derive rather than manual parsing
Manual parsing Json is tedious and error-prone. It contained a bunch of
`unwrap`s and was hard to read.

This replaces manual Json parsing with serde_derive implementation.

Closes #1231
2022-12-05 22:23:36 +01:00
Andrew Poelstra 52fbb043b6
Merge rust-bitcoin/rust-bitcoin#1254: Consensus encoding based serialization
1a2cf2681d Implement consensus encoding adapter for serde (Martin Habovstiak)
a6ecc58a5e Add `put_bytes_min` and `space_remaining` methods (Martin Habovstiak)

Pull request description:

  In some protocols it is preferred to serialize consensus-encodable types
  using consensus encoding. E.g. serialize `Transaction` as hex-encoded
  string in Json in Bitcoin Core RPC protocol. This change provides
  adapter to make this easier.

  The adapter allows providing custom byte-to-string encoder for more
  exotic cases and provides a hex implementation which should be useful in
  majority of the cases.

  Should help with #765

  Based on #1252

  Required by #1234

ACKs for top commit:
  tcharding:
    ACK 1a2cf2681d
  apoelstra:
    ACK 1a2cf2681d

Tree-SHA512: 96e10cf6ea0e7dfecfb58ee97453e0e7c8a2cfbb8af1e73a23c3afb67b985b394976361ac237528991fbb7344cc9f24644869199008245a91838309aff34bb97
2022-12-05 16:25:55 +00:00
Andrew Poelstra 4fccd3fb84
Merge rust-bitcoin/rust-bitcoin#1437: Add log2 to Work
df90c50242 Add log2 to Work (Jiri Jakes)

Pull request description:

  Adds method `Work::log2()` providing value equivalent to Bitcoin Core's `log2_work` in its logs. Fixes #1326.

  Questions:

  - The original issue (#1326) also suggests to add log2 to Target but it does not seem to be meaningful, does it? Bitcoin Core, to which the issue refers, also displays only log2 of work.
  - Although work should not be 0, the type allows it. In this case, log2 would return -inf. I think we could leave it like that but if there are suggestions to deal with it in a different way, please let me know.

ACKs for top commit:
  Kixunil:
    ACK df90c50242
  tcharding:
    ACK df90c50242
  apoelstra:
    ACK df90c50242

Tree-SHA512: 24e83c849ea3e16cad6f1636920883967cdac90b1b98ab19e86d1a5d0ac4585079740b54c1315afecabc1943d29a8b94316e3586bd2d10f1b61cc5cf7ad5b273
2022-12-03 21:19:38 +00:00
Jiri Jakes df90c50242 Add log2 to Work
Bitcoin Core displays log2 of chain work in certain situations. This
new log2 method returns equivalent value.
2022-12-03 17:24:41 +01:00
Andrew Poelstra 29704f2872
Merge rust-bitcoin/rust-bitcoin#1410: Change `max_money` to a constant.
e9dffb1b7b Change `max_money` to a constant. (Martin Habovstiak)

Pull request description:

  The value is statically known which is better expressed as a constant. Also allows usage in const context.

ACKs for top commit:
  apoelstra:
    ACK e9dffb1b7b
  tcharding:
    ACK e9dffb1b7b
  ariard:
    ACK e9dffb1
  sanket1729:
    ACK e9dffb1b7b

Tree-SHA512: b9b80d573531fe75dce22e185a1c84b2885160334418d1cfbd7279684fd4229c3c6c4041d3a3badb3652c5723e90ff52d3c761cbc3bff7b73978776694a67422
2022-12-03 14:04:53 +00:00
Andrew Poelstra af1d22b9f9
Merge rust-bitcoin/rust-bitcoin#1430: Remove no_run
13d94cbc47 Remove no_run (Tobin C. Harding)

Pull request description:

  `no_run` is not needed since we already mark this up as `bash` which rustc doesn't run when running examples.

  While the keyword `bash` is not currently supported it may well be in the future and since only the `rust` keyword causes code to run any other string is effectively a wildcard, `no_run` is therefore meaningful only as a convention. Lets keep `bash` in case support is added later on.

  cc sr-gi

ACKs for top commit:
  sr-gi:
    ACK 13d94cbc47
  Kixunil:
    ACK 13d94cbc47
  sanket1729:
    ACK 13d94cbc47
  apoelstra:
    ACK 13d94cbc47

Tree-SHA512: 90cbe8c5ea30577fc148d8e8b388008ea7f6c4975ea8b9e249e6058de901afca084d59e6a89eb9bda0a8e3112fb89336b622acd23046299c5e5ad7723ae26148
2022-12-02 13:52:31 +00:00
Martin Habovstiak 1a2cf2681d Implement consensus encoding adapter for serde
In some protocols it is preferred to serialize consensus-encodable types
using consensus encoding. E.g. serialize `Transaction` as hex-encoded
string in Json in Bitcoin Core RPC protocol. This change provides
adapter to make this easier.

The adapter allows providing custom byte-to-string encoder for more
exotic cases and provides a hex implementation which should be useful in
majority of the cases.

Should help with #765
2022-12-02 10:48:05 +01:00
Martin Habovstiak a6ecc58a5e Add `put_bytes_min` and `space_remaining` methods
Pnicking on oversized slice is useful to catch errors in code that's
supposed to know the exact sizes but this is undesirable in code that
doesn't. These two methods help with handling the case when `buf.len()`
is not known upfront.
2022-12-02 10:48:05 +01:00
sanket1729 55b93e95f5
Merge rust-bitcoin/rust-bitcoin#1432: Hotfix: Fix broken serde
5fc40baa73 Fix new clippy warnings (sanket1729)
3a923980e1 Hotfix: Fix broken serde (sanket1729)

Pull request description:

  My local scripts did not test serde feature on the merge commit. While merging #734, I accidentally broke the serde feature on the latest master. This PR fixes it.

  Sorry about that, I will update my local script to be the same as of CI check.

ACKs for top commit:
  tcharding:
    ACK 5fc40baa73
  Kixunil:
    ACK 5fc40baa73

Tree-SHA512: 99d348262239c53ab86ecf66bc64461958f181df0c102beddae486c813ab6d0c7a0b5af505fa5c7e60d5b59554e0bcf8547a71bf713020ddee1cc3d4b3a631f4
2022-12-02 01:22:42 -08:00
sanket1729 5fc40baa73 Fix new clippy warnings 2022-12-01 15:59:08 -08:00
sanket1729 3a923980e1 Hotfix: Fix broken serde
My local scripts did not test serde feature on merge commit. While
merging 734, I accidently broke the serde feature on latest master. This
PR fixes it.
2022-12-01 15:57:37 -08:00
sanket1729 df57a195c1
Merge rust-bitcoin/rust-bitcoin#724: Serde regression tests
962abcc963 Add serde regression tests (Tobin Harding)

Pull request description:

  Attempts to add regression tests for _all_ types defined in `rust-bitcoin` that implement `Serialize`/`Deserialize`.

  - Add a `tests` directory and implement regression tests in there
  - Use files for input hex and output bincode to reduce source file clutter
  - Copy test block and `include_bytes!` usage from RCasatta's [PR](https://github.com/rust-bitcoin/rust-bitcoin/pull/750)
  - Uses Kixunil's macro suggested below
  - Adds a single regression test to `util/taproot.rs` for private types

  ## Note to reviewers
  - Uses JSON for opcodes in a separate file (`tests/regression_opcodes.rs`), for all other tests uses bincode.
  - Bypasses the order issue for maps by only serializing maps with a single element - is this correct?

  Fixes #723

ACKs for top commit:
  apoelstra:
    ACK 962abcc963
  sanket1729:
    ACK 962abcc963. This has been open for a long time. Merging this in the interest of progress.

Tree-SHA512: e34e48e1c56fab5898bc74e7fb867435ed387d828dd3daf0c7d6df8f305e1da6883e91487115ac428618eb7d95bd16aa2cd209ca219684959bc95587ef0b4083
2022-12-01 15:29:12 -08:00
sanket1729 22c6406c2b
Merge rust-bitcoin/rust-bitcoin#1417: Move `base58` to the crate root
4c8570b512 base58: Run formatter (Tobin C. Harding)
2780e6cdaa Move base58 module to crate root (Tobin C. Harding)

Pull request description:

  Move `base58` module to the carte root, direct `rustfmt` to not format the digits array. Run formatter as a separate patch.

ACKs for top commit:
  apoelstra:
    ACK 4c8570b512
  sanket1729:
    ACK 4c8570b512

Tree-SHA512: 3ab7afe089b9866a59f3f67c74c3e6657ca51d2d0ea1aaee0218a400b90826d36eaca7d491006a9448359ae3de5755d20b2d2df71e0fa3d6497fbaca270dcf42
2022-12-01 15:12:34 -08:00
Tobin C. Harding 13d94cbc47 Remove no_run
`no_run` is not needed since we already mark this up as `bash` which
rustc doesn't run when running examples.

While the keyword `bash` is not currently supported it may well be in
the future and since only the `rust` keyword causes code to run any
other string is effectively a wildcard, `no_run` is therefore meaningful
only as a convention. Lets keep `bash` in case support is added later on.
2022-12-02 07:25:41 +11:00
Andrew Poelstra 4cc4178b0c
Merge rust-bitcoin/rust-bitcoin#1412: Implement `Script::p2pk_public_key(&self) -> Option<PublicKey>`
25f781bef3 Implement p2pk_public_key + tests (connormullett)

Pull request description:

  closes #1408

  Adds logic to extract a `PublicKey` (if able) from a p2pk script

ACKs for top commit:
  tcharding:
    ACK 25f781bef3
  apoelstra:
    ACK 25f781bef3
  Kixunil:
    ACK 25f781bef3

Tree-SHA512: 139f588ca4b6ccc45f8df0b35c19bebae66cb7b07cbad22bbf5d3059118ed54c8e1716d64dc528de59c7c8f4eb684944ce029fbce97a303f385281e990fc3bf0
2022-12-01 13:47:21 +00:00
Tobin C. Harding 4c8570b512 base58: Run formatter
Run `cargo +nightly fmt` and commit the changes to the `base58` module.
No manual changes, only those done by the formatter.
2022-12-01 09:56:34 +11:00
Tobin C. Harding 2780e6cdaa Move base58 module to crate root
In preparation for removing the `util` module move the `base58` module
to the crate root. This is likely not the final resting place for this
module but it is a step in the right direction.

Includes addition of rustfmt attribute to skip formatting the digits
array. No other changes to the `base58` module.
2022-12-01 09:56:33 +11:00
Andrew Poelstra cde120bb0f
Merge rust-bitcoin/rust-bitcoin#1373: Move the taproot module to crate root
dce88b09ff taproot: Run the formatter (Tobin C. Harding)
db5c8fe61c Move the taproot module to crate root (Tobin C. Harding)

Pull request description:

  We are trying to flatten the `util` module. The `taproot` module can live in the crate root. If/when we create a `crypto` module/crate we may wish to pull some stuff out of this module but for now moving it gets us closer to removing `util` without making the directory structure any worse.

  CC sanket1729, I did this after reviewing the `taproot` module during work on https://github.com/rust-bitcoin/rust-bitcoin/pull/1260 and your review comment.

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

Tree-SHA512: 5498401a6ef92239568b8c338d5a531f5509043b82a52d2e221a37f6432cf38ca1145ce47adb526e9ed4c9d2fe9833011eec24e27353e64f68e2eded795ae9e4
2022-11-30 22:49:18 +00:00
connormullett 25f781bef3 Implement p2pk_public_key + tests
For some applications, such as block explorers, it's useful to be able
to obtain the public key used in case of P2PK. This is considered
general enough for addition into bitcoin library,
so this change adds it.

The public key is returned only when it's valid and the script is P2PK.
To avoid duplicating the logic checking whether a script is P2PK the
logic is moved to a new p2pk_pubkey_bytes() method which returns raw
bytes and is then called from both is_p2pk() and p2pk_public_key()
2022-11-30 13:51:59 -05:00
Tobin C. Harding dce88b09ff taproot: Run the formatter
Run `cargo +nightly fmt` and commit changes to the `taproot` module.

No manual changes, only those introduced by `rustfmt`.
2022-11-30 12:04:20 +11:00
Tobin C. Harding db5c8fe61c Move the taproot module to crate root
We are trying to flatten the `util` module. The `taproot` module can
live in the crate root. If/when we create a `crypto` module/crate we may
wish to pull some stuff out of this module but for now moving it gets us
closer to removing `util` without making the directory structure any
worse.

Includes adding rustfmt attributes to skip formatting of macros.
2022-11-30 12:03:39 +11:00
Andrew Poelstra 9266b1bbe0
Merge rust-bitcoin/rust-bitcoin#1260: Create `crypto` module
2df51dae15 Create crypto module (Tobin C. Harding)

Pull request description:

  Done as part of [util flattening](https://github.com/rust-bitcoin/rust-bitcoin/issues/639).

  Create a `crypto` module and move into it (out of `util`):
  - ecdsa
  - schnorr
  - key

  After review, this PR now includes some type re-names
  - EcdsaSig -> ecdsa::Signature
  - SchnorrSig -> schnorr::Signature
  - EcdsaSigError -> ecdsa::Error
  - SchnorrSigError -> schnorr::Error
  - InvalidSchnorrSigSize -> InvalidSignatureSize  (this is an error enum variant)

ACKs for top commit:
  apoelstra:
    ACK 2df51dae15
  sanket1729:
    ACK 2df51dae15

Tree-SHA512: 7cf63d51ed5fdc737cd59767d9bb96b1e3501634e3aee855493f6a51ad5c5397ce4b25c77f9929abd70d6ceb351fc6520e835da108f4c9a46df5b9c2b52ca6b3
2022-11-29 15:33:18 +00:00
Andrew Poelstra 410b820814
Merge rust-bitcoin/rust-bitcoin#1416: Add rand feature flag to the example documentation
f7a6d17143 Add rand feature flag to the example documentation (yancy)

Pull request description:

  It's confusing trying to follow the documentation [here](https://docs.rs/bitcoin/latest/bitcoin/util/address/index.html) unless you know to enable the `rand` feature flag.  This PR updates the docs so people know to enable the flag.

  ```
  22:35 < control> hello, how can i generate a simple wallet address using rust bitcoin? cant find working example
  22:45 < andytoshi> control: do you have a private key?
  22:45 < andytoshi> what kind of address do you want to generate?
  22:46 < andytoshi> my guess would be that you want to use bdk rather than rust-bitcoin directl
  22:48 < control> P2PKH address and generate private key. just as simple as bit library in python does
  22:52 < control> im trying to run this example
  22:52 < control> https://docs.rs/bitcoin/latest/bitcoin/util/address/index.html
  22:52 < control> but it says ^^^^ could not find `rand` in `secp256k1`
  ```

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

Tree-SHA512: 6d94f8ffa7797d1e7720a840d4f8bb0ac274507118597dff60631ad3d28dbe57e2341b87d6101e2a9f5fbcc2b1f0beb6d06f9dde48a480cb10a9a45c887f83a4
2022-11-29 14:22:18 +00:00
yancy f7a6d17143 Add rand feature flag to the example documentation 2022-11-28 17:10:24 +01:00
Andrew Poelstra a39ffea8a1
Merge rust-bitcoin/rust-bitcoin#1415: amount: use Kani to prove some arithmetic properties
d4bfc3d7b1 github: add Kani to Github CI (Andrew Poelstra)
c11645b7e5 amount: use kani to check some arithmetic properties (Andrew Poelstra)

Pull request description:

  A first exploration into using Kani. See #1370.

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

Tree-SHA512: 431ba1c1c42521bc36ab5260ea338c5c8154edd7f037928ba36a6c901551d05e420e8a886f772ea205009f718a16a5793a2e408818de88602968b52492a910cd
2022-11-28 13:56:55 +00:00
Andrew Poelstra d4bfc3d7b1
github: add Kani to Github CI 2022-11-27 19:01:32 +00:00
Andrew Poelstra c11645b7e5
amount: use kani to check some arithmetic properties
Kani can't really handle string processing, and appears to be unable
to check integer multiplication (for now), but we do several checks
for addition and subtraction, and conversion between signedness,
that Kani can easily prove.
2022-11-27 19:01:26 +00:00
Martin Habovstiak e9dffb1b7b Change `max_money` to a constant.
The value is statically known which is better expressed as a constant.
Also allows usage in const context.
2022-11-22 21:08:40 +01:00
Andrew Poelstra e16b9bdb20
Merge rust-bitcoin/rust-bitcoin#1407: Fix typo in the SHA512 documentation
57165d3f7f Fix typo in the SHA512 documentation (Calvin Kim)

Pull request description:

  Saw the typo and since this typo also exists in crates.io, I thought it'd be good to quickly change it.

  Though maybe this should be replaced altogether with the `hash_type` macro since every other hash function implementation is using that.

ACKs for top commit:
  Kixunil:
    ACK 57165d3f7f
  apoelstra:
    ACK 57165d3f7f

Tree-SHA512: dba54a71073bf58cafe4a248ec25c5f6a691f565d6bda749d5b50786d353a30cd59f09e10f600cb95b8f635ab1ce38aef8decb178b586c80df1b6cc9a7943a49
2022-11-22 16:40:50 +00:00
Calvin Kim 57165d3f7f
Fix typo in the SHA512 documentation 2022-11-22 15:13:29 +09:00
Tobin C. Harding 2df51dae15 Create crypto module
Done as part of flattening util.

Currently in `util` module we have a bunch of modules that provide
cryptography related functionality.

Create a `crypto` module and move into it the following:

- ecdsa
- schnorr
- key

To improve uniformity and ergonomics, do the following re-names while we
are at it:

- EcdsaSig -> ecdsa::Signature
- SchnorrSig -> schnorr::Signature
- EcdsaSigError -> ecdsa::Error
- SchnorrSigError -> schnorr::Error
- InvalidSchnorrSigSize -> InvalidSignatureSize  (this is an error enum variant)
2022-11-22 14:09:33 +11:00
Andrew Poelstra ac583202cf
Merge rust-bitcoin/rust-bitcoin#1397: Add Network::to_core_arg() method
519db4d951 add Network::to_core_arg() method (connormullett)

Pull request description:

  closes: #1207

  Adds converting `Network` to its `bitcoind` equivalent.
  The arguments for -chain can be found in the documentation and is one of the following:
  main, test, signet, regtest

ACKs for top commit:
  apoelstra:
    ACK 519db4d951
  Kixunil:
    ACK 519db4d951

Tree-SHA512: 5fd805d654f7c30f87ff877fe90e19490d0deb73b46ce87cc6b43d30595eb9d2de3f646f58a5d72180c3e8cc6a9b614bfe6753ecd6c21b8d193a8d862e3f887f
2022-11-21 15:48:53 +00:00
Andrew Poelstra 1e4b5e34ae
Merge rust-bitcoin/rust-bitcoin#1404: Check for rustdocs build warnings in CI
108a1f73ca Fail CI if docs build throws warnings (Tobin C. Harding)
b014f0fdcb Fix rustdocs build warnings (Tobin C. Harding)

Pull request description:

  Currently we do not fail the CI script if the docs build throws warnings, since we are a group of super anal, easily triggered, code cleanliness obsessed devs this causes a mild rash to develop on the lower back [0]. We can easily fix this by checking for build warnings in CI.

  [0] - Amusingly my rash has been playing up since Friday but I thought I'd fixed the warnings in an open PR someplace so I was ignoring it, seeing Kixunil's [issue](https://github.com/rust-bitcoin/rust-bitcoin/issues/1403) this morning prompted me to fix it :)

  Fix #1403

ACKs for top commit:
  Kixunil:
    ACK 108a1f73ca
  apoelstra:
    ACK 108a1f73ca

Tree-SHA512: 0f86c318b2ec8bf7aa6a0d0f355f8fe8e3eb8ad5eb74d95f8dab882d6729c386c3e0ef4cc2378645e15460ff2b9b47d66e3603958f8b188f5e2b07272739d755
2022-11-21 15:39:03 +00:00