Commit Graph

124 Commits

Author SHA1 Message Date
Michal Kucharczyk 33c3d131ef
Use rand crate re-exports when available
Re-exports from `rand` crate shall be used. Otherwise trait bounds in
`Mnemonic::generate_in_with` for `rand::thread_rng` object can get
unsatisfied if crate deps get ouf of sync.

This commit is fixing following errors:
```
error[E0277]: the trait bound `ThreadRng: rand_core::RngCore` is not satisfied
   --> /home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bip39-2.0.0/src/lib.rs:292:30
    |
292 |         Mnemonic::generate_in_with(&mut rand::thread_rng(), language, word_count)
    |         -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^ the trait `rand_core::RngCore` is not implemented for `ThreadRng`
    |         |
    |         required by a bound introduced by this call
    |::
    = help: the following other types implement trait `rand_core::RngCore`:
...
note: required by a bound in `Mnemonic::generate_in_with`
   --> /home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bip39-2.0.0/src/lib.rs:266:6
    |
260 |     pub fn generate_in_with<R>(
    |            ---------------- required by a bound in this associated function
...
266 |         R: rand_core::RngCore + rand_core::CryptoRng,
    |            ^^^^^^^^^^^^^^^^^^ required by this bound in `Mnemonic::generate_in_with`

```

```
error[E0277]: the trait bound `ThreadRng: rand_core::CryptoRng` is not satisfied
   --> /home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bip39-2.0.0/src/lib.rs:292:30
    |
292 |         Mnemonic::generate_in_with(&mut rand::thread_rng(), language, word_count)
    |         -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^ the trait `rand_core::CryptoRng` is not implemented for `ThreadRng`
    |         |
    |         required by a bound introduced by this call
    |
    = help: the following other types implement trait `rand_core::CryptoRng`:
...
note: required by a bound in `Mnemonic::generate_in_with`
   --> /home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bip39-2.0.0/src/lib.rs:266:27
    |
260 |     pub fn generate_in_with<R>(
    |            ---------------- required by a bound in this associated function
...
266 |         R: rand_core::RngCore + rand_core::CryptoRng,
    |                                 ^^^^^^^^^^^^^^^^^^^^ required by this bound in `Mnemonic::generate_in_with`

```

Co-authored-by: Tobin C. Harding <me@tobin.cc>
2024-02-10 12:16:03 +01:00
Steven Roose a84eb0012e
Merge pull request #66 from rust-bitcoin/fix-msrv
Fix MSRV build and tests
2024-02-10 01:41:50 +07:00
Steven Roose 28991bd150
readme: Inform user bitcoin_hashes needs to be pinned for MSRV 2024-02-09 18:32:38 +00:00
Steven Roose 5dcdac9c74
Fix MSRV build and tests 2024-02-09 18:30:16 +00:00
Steven Roose 7f554391ae
Change hashes dep spec to >=0.12,<0.14 2024-01-29 18:42:19 +00:00
Steven Roose 37915dc0ae
Merge pull request #60 from kayabaNerve/master
bitcoin_hashes >= 0.12, <= 0.13
2024-01-30 01:41:52 +07:00
Steven Roose b11619d72a
Merge pull request #62 from pezcore/feature/checksum
Add interface to expose the mnemonic checksum
2024-01-30 01:37:21 +07:00
Steven Roose 54358b9feb
Run uni tests for each individual language 2024-01-29 18:33:43 +00:00
Steven Roose 8bf5b20629
Add unit test to check ordering of supposedly ordered word lists 2024-01-29 18:33:42 +00:00
Steven Roose d8b046da28
Replace unreachable_patterns tag with explicit feature use 2024-01-29 18:33:40 +00:00
pezcore 51fd048e86
feat: optimize impl of Language::find_word
For languages that support it, the implementation of
`Language::find_word` now uses binary search to find the word index. For
languages that do not support it, the old linear search is used.

This substantially improves the runtime performance of
`Language::find_word`. For affected languages, average lookup rate is
increased ~25x on release builds and ~100x on debug builds.
2024-01-29 18:33:39 +00:00
Marko Bencun c02046c031
fix some important std unit tests that were not running due to typo
`#[cfg(features = "std")]` is invalid and always disabled the whole block.
2024-01-29 18:16:49 +00:00
pezcore 778527cd4f feat: add checksum interface for Mnemonic 2024-01-25 21:11:07 -05:00
Luke Parker 256a00e7c2
bitcoin_hashes >= 0.12, <= 0.13 2023-11-27 23:07:42 -05:00
Steven Roose a7649ae740
Merge pull request #50 from Foundation-Devices/jeandudey/iter
Iterator improvements
2023-10-19 09:53:55 -04:00
Steven Roose 405b290fbd
Merge pull request #53 from flemosr/add-portuguese-support
Add Portuguese language support
2023-10-19 09:29:45 -04:00
Rafael Lemos e0102ba431
Update `README` 2023-10-13 16:27:33 -03:00
Rafael Lemos 75d4f0c559
Add Portuguese language support 2023-10-13 15:05:49 -03:00
Rafael Lemos b2f49fd2b2
Update `Cargo.toml`
Enable the "rand" feature by default in the dev-dependencies, in order to run
the benches.
2023-10-13 14:25:15 -03:00
Jean-Pierre De Jesus DIAZ 0b92d8db6c
Add iterator over word indices.
Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2023-09-20 13:09:22 +02:00
Jean-Pierre De Jesus DIAZ 73f0c112aa
Add words and deprecate word_iter method
To follow the convention for Rust iterators, for example, in `str`
the method for a char iterator is `chars` not `char_iter`.

Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2023-09-20 13:05:20 +02:00
Steven Roose aa6609ac2b
Merge pull request #49 from Foundation-Devices/jeandudey/editorconfig
Fix .editorconfig indent style
2023-08-27 20:36:14 -05:00
Steven Roose d93a017ec3
Merge pull request #51 from Foundation-Devices/jeandudey/docs
Fix typo and remove extern crate in documentation
2023-08-27 20:31:14 -05:00
Steven Roose d6681c0871
Merge pull request #52 from pezcore/doc/feature-gated-items
Enable documentation of feature-gated items in docsrs
2023-08-27 20:30:48 -05:00
pezcore 53090ea50d doc: fix reference to Vec<u8> 2023-03-24 13:26:27 -04:00
pezcore 36fc016a16 Make reference to source BIP a hyperlink 2023-03-24 13:26:10 -04:00
pezcore c7ae12fb64 doc: enable documentation of feature-gated items in docsrs 2023-03-24 13:22:53 -04:00
Jean-Pierre De Jesus DIAZ 795574e73b
Remove extern crate from examples documentation
Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2023-03-13 12:13:01 +01:00
Jean-Pierre De Jesus DIAZ a0bb29c05e
Fix typo in variable documentation
Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2023-03-13 12:12:39 +01:00
Jean-Pierre De Jesus DIAZ f429e9b68e
Fix .editorconfig indent style
Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2023-03-13 11:46:34 +01:00
Steven Roose 0f52eca5d9
Merge pull request #47 from rust-bitcoin/ci-rm-nightly
ci: Remove nightly section that is unused
2023-03-01 21:45:52 +00:00
Steven Roose c641cccad9
ci: Remove nightly section that is unused 2023-02-28 03:42:03 +00:00
Steven Roose a30760beac
Merge pull request #41 from rust-bitcoin/msrv-1.41
Enable 2018 edition, bump MSRV to 1.41 and bump to v2.0.0
2023-02-28 02:53:10 +00:00
Steven Roose 8f43d91d3f
Merge pull request #45 from rust-bitcoin/github-ci
Add github actions files for CI
2023-02-28 02:52:48 +00:00
Steven Roose f41bf1789d
Update CHANGELOG and bump to v2.0.0 2023-02-27 21:24:00 +00:00
Steven Roose c827c39943
Bump unicode-normalization dependency to 0.1.22 2023-02-27 21:23:59 +00:00
Steven Roose 8e6ba6de9b
Make rand_core optional and expose rand and rand_core crates 2023-02-27 21:23:57 +00:00
Steven Roose f348415f11
Reorganize dependencies in Cargo.toml 2023-02-27 21:23:56 +00:00
Steven Roose 8d0f5e0d2f
Bump MSRV to 1.41.1 in README
s!Bump MSRV to 1.41 in README and CI
2023-02-27 21:23:55 +00:00
Steven Roose 6662e7566b
Make rand and rand_core deps more flexible 2023-02-27 21:23:53 +00:00
Steven Roose c821ec4aa8
Remove [lib] section from manifest 2023-02-27 21:20:49 +00:00
Steven Roose 71d4329979
Set edition to 2018 2023-02-27 21:20:47 +00:00
Steven Roose 893a777400
Remove .travis.yml 2023-02-27 21:19:25 +00:00
Steven Roose 49d4369838
Add github actions files for CI 2023-02-27 21:16:26 +00:00
Steven Roose ca53ee34a8
Make serde usable in no_std 2023-02-27 21:16:24 +00:00
Steven Roose e7155f153d
Merge pull request #44 from rust-bitcoin/bump-1.2.0
Rename new method to be in line with existing API and release v1.2.0
2023-02-26 23:35:49 +00:00
Steven Roose 1d83393b8d
Bump to v1.2.0 and update changelog 2023-02-26 18:37:01 +00:00
Steven Roose d3c96b1448
Rename new method to Mnemonic::parse_in_normalized_without_checksum_check
This is according with the other methods in the API.
2023-02-26 18:36:34 +00:00
Steven Roose 6b79d78c80
Make normalize_utf8_cow public 2023-02-26 18:36:09 +00:00
Steven Roose 89bf46164a
Merge pull request #43 from ayrat-forks/ayrat555/parse-without-checksum-check
Parse a mnemonic without checksum check
2023-02-26 15:54:19 +00:00