Commit Graph

103 Commits

Author SHA1 Message Date
Dr Maxim Orlovsky c1991d748f
Improving error information for address parser 2021-09-21 12:45:17 +02:00
Clark Moody eeeb722155
Bump bech32 to 0.8.0 and use BIP-0350 Bech32m checksum
Replace BIP-0173 test vectors with those in BIP-0350.
2021-09-21 12:45:17 +02:00
Dr Maxim Orlovsky 5573a546ca
Taproot P2TR address 2021-09-21 12:45:17 +02:00
Vikas S Shetty 48c732e934 Changes for checking script size and returning Error appropriately 2021-09-15 16:16:20 +05:30
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
Dr Maxim Orlovsky 64c1ec0b76
WitnessVersion type 2021-08-10 10:34:15 +02:00
Dr. Maxim Orlovsky 4e3c2c32fc
Merge pull request #632 from tcharding/prefixes 2021-08-09 23:26:15 +02:00
Dr. Maxim Orlovsky 8ae030b951
Merge pull request #618 from elsirion/possible_networks 2021-08-09 23:25:06 +02:00
Tobin Harding adc1543e7c
Use consts for address prefix values
Instead of using magic numbers we can define constants for the address
prefix bytes. This makes it easier for future readers of the code to see
what these values are if they don't know them and/or see that they are
correct if they do know them.
2021-07-22 10:31:14 +10: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
elsirion 94229ae964 Implement is_valid_for_network function for Address 2021-06-26 19:34:33 +02:00
Andrew Poelstra abff973e83
Merge pull request #601 from LNP-BP/feat/bech32m-1
Bech32m adoption
2021-06-18 21:14:12 +00:00
Dr Maxim Orlovsky aa5c36df12
Covering all BIP-173 and BIP-350 test vectors 2021-06-16 08:43:18 +02:00
Sebastian b0ae2a6842
Merge pull request #521 from RCasatta/errors_enum
Errors enum improvements
2021-06-15 14:01:56 +02:00
Riccardo Casatta 9613181601
Split invalid version for address and extended key, saving also 16 bytes on the stack 2021-06-13 22:39:32 +02:00
Devrandom 95aa3bf153 std -> core 2021-06-11 17:28:04 +02:00
Dr Maxim Orlovsky c1fae03686
Non-API breaking Bech32m adoption 2021-06-08 08:43:39 +02:00
Andrew Poelstra 052aaf1d80
Merge pull request #559 from LNP-BP/fix/error-derives-2
Fix/error derives 2
2021-05-19 15:02:10 +00:00
Andrew Poelstra e5f37b817d
Merge pull request #581 from RCasatta/qr_string
Address to optimized QR string
2021-05-06 17:12:17 +00:00
Dr Maxim Orlovsky c0b7defc86
More non-API breaking error derives depending on upstream PRs 2021-05-04 03:58:56 +02:00
Dr Maxim Orlovsky 18b6bd0d15
Adopting new ECDSA key constructors throughout the library 2021-05-01 13:34:31 +02:00
Riccardo Casatta 0a91496570
rename to_qr_string into to_qr_uri returning also the schema 2021-04-15 10:40:57 +02:00
Dr Maxim Orlovsky b17d7fc31c
Moving keys under `util::ecdsa`, re-exporting them at `util::key`
This is the first step in introducing Schnorr key support as per #588
2021-04-12 14:17:42 +02:00
Riccardo Casatta 3158cedea0
document alternate formatting 2021-04-11 18:14:28 +02:00
Martin Habovstiak bc406bfdd6 Use &mut dyn fmt::Write instead of bool
This replaces manually-written dynamic dispatch with `&mut dyn
fmt::Write` which is hopefully more readable.
2021-04-09 17:58:35 +02:00
Riccardo Casatta 85ae82febb
use the char trick to avoid allocation 2021-04-07 16:56:54 +02:00
Riccardo Casatta 104836a042
implements alternate formatting for address 2021-04-07 15:49:58 +02:00
Riccardo Casatta cac3f460a2
improve to_qr_string doc 2021-03-23 09:42:58 +01:00
Riccardo Casatta d18554e756
Address to string conversion optimized for qr codes 2021-03-22 13:58:59 +01:00
Riccardo Casatta b9d5200448
Access Display and Formatter with fmt:: like in other places 2021-03-22 13:42:32 +01:00
Andrew Poelstra d3210b39fb
Merge pull request #507 from stevenroose/pubkey-write-result
Change PublicKey::write_into to return Result
2020-11-05 19:21:39 +00:00
Andrew Poelstra 93df7cbd3e
Merge pull request #291 from kallewoof/2019-07-signet
add signet support
2020-10-26 19:46:10 +00:00
Steven Roose 9699c622fc
Return Result<(), io::Error> from PublicKey::write_into 2020-10-23 21:31:12 +01:00
Elichai Turkel 2d70623356
Remove deprecated Error::description impl 2020-10-08 17:11:18 +03:00
Elichai Turkel 023fae1f65
Add the dyn keyword where appropriate 2020-10-08 17:11:16 +03:00
Karl-Johan Alm a3d9899cb1
add signet support 2020-09-18 16:32:33 +09:00
Dr Maxim Orlovsky 38a412c4d5 Fixing review comments for script generators refactoring 2020-09-10 14:44:44 +02:00
Dr Maxim Orlovsky 9143fd3888 All script generation functionality moved to standalone methods in Script 2020-09-10 12:09:04 +02:00
Andrew Poelstra 45da3add10
Merge pull request #428 from stevenroose/no-witness-uncompressed
Don't allow uncompressed pks in witness addresses
2020-09-09 16:37:06 +00:00
Steven Roose ed9bf41ff5
Don't allow uncompressed pks in witness addresses 2020-05-23 23:20:46 +01:00
Steven Roose 59b5a73a55
Fix typo and minor formatting in address::Error 2020-05-23 23:20:19 +01:00
Andrew Poelstra 7efde3ae47
Merge pull request #419 from elichai/2020-03-description
Deprecate Error::description
2020-05-23 17:26:38 +00:00
Elichai Turkel 654232a3dc
Deprecate Error::description 2020-04-13 02:15:28 +03:00
Elichai Turkel a473d01b17
Made some idiomatic changes 2020-03-29 17:15:15 +03:00
Elichai Turkel c19b736566
Remove the hex dependency 2020-01-20 18:50:02 +02:00
Dr Maxim Orlovsky d20ab1dbc4 Switching to XpubIdentifier 2020-01-01 13:46:44 +01:00
Dr Maxim Orlovsky 5f4f629bb1 Replaced all hash160, sha256 and sha256d with the new hash types throughout the code
Embedding Txid's in the doc exaples
2020-01-01 13:44:34 +01:00
Dr Maxim Orlovsky 5ef39e34fa Implementing (W)Pubkey/ScriptHash and BlockHash 2020-01-01 13:42:22 +01:00
Steven Roose 48f4c1989f
Rename bitcoin_hashes dependency to hashes 2019-08-16 15:52:27 +01:00
Steven Roose 09a65023a2
Add tests for p2shwpkh and p2shwsh 2019-08-15 22:29:09 +01:00