Commit Graph

180 Commits

Author SHA1 Message Date
Andrew Poelstra 5a5158e120
Merge pull request #198 from sgeisler/safe-opcodes
Safe opcodes 1.14.0
2018-12-14 16:32:29 +00:00
Andrew Poelstra bb7ca63776
Merge pull request #196 from sgeisler/separate-fuzzing
Move fuzzing code out of utils
2018-12-09 16:33:21 +00:00
Sebastian Geisler 79a88e1612 Move fuzzing code out of utils 2018-12-03 16:31:13 -08:00
Sebastian Geisler e88612d617 add test case and cleanup 2018-12-03 14:51:55 -08:00
Sebastian Geisler 4a27c1369a avoid heap use when encoding base58 2018-12-03 14:51:53 -08:00
Kaz Wesley 6b67c8cdff squashme: work around lack of associated constants 2018-11-11 14:58:33 -08:00
Andrew Poelstra 7813c0ae3d
Merge pull request #178 from stevenroose/wif
Add explicit WIF methods for Privkey
2018-10-22 15:28:09 +00:00
Steven Roose 5f912bdeae Implement Debug for PrivKey
It returns a fixed string to prevent accidental data leakage.
2018-10-22 00:06:46 +01:00
Steven Roose f7b95c7533 Add explicit WIF methods for Privkey 2018-10-22 00:05:59 +01:00
Jeff Barg 1c2564fc08 Added example for creating an address from a public key
Added an example to the address rustdoc (addresses https://github.com/rust-bitcoin/rust-bitcoin/issues/160)
2018-09-29 17:43:28 -04:00
evgeniy.scherbina bc41772f89 added p2wkh, p2sh-p2wkh tests 2018-09-27 18:54:20 +03:00
Carl Dong c42252c1da Use default impl for Encoder for Sha256dEncoder 2018-09-25 21:20:24 +08:00
Carl Dong 0f42ca69b0 Move relevant names into consensus::encode
- Move network::encodable::* to consensus::encode::*
- Rename Consensus{En,De}codable to {En,De}codable (now under
  consensus::encode)
- Move network::serialize::Error to consensus::encode::Error
- Remove Raw{En,De}coder, implement {En,De}coder for T: {Write,Read}
  instead
- Move network::serialize::Simple{En,De}coder to
  consensus::encode::{En,De}coder
- Rename util::Error::Serialize to util::Error::Encode
- Modify comments to refer to new names
- Modify files to refer to new names
- Expose {En,De}cod{able,er}, {de,}serialize, Params
- Do not return Result for serialize{,_hex} as serializing to a Vec
  should never fail
2018-09-25 21:19:35 +08:00
Carl Dong 8e0e4eb55a Move serialize::BitcoinHash to util:#️⃣:BitcoinHash
- Use Sha256dEncoder for calculating merkle root
- Remove BitcoinHash implementation for Vec<u8>
2018-09-25 21:19:10 +08:00
Thomas Eizinger 50e3a4abf2 Add FromStr for Sha256dHash
The FromStr implementation just delegates to the `from_hex` method for
the actual parsing.
2018-09-20 12:18:45 +10:00
Steven Roose 8edfbec1cb Implement serde serialiation for Address 2018-09-11 18:37:36 +01:00
Andrew Poelstra 08db6fe29f script: let Instructions iterator enforce minimal pushes; remove `IntoIter` impl to force users to choose 2018-08-22 19:55:31 +00:00
Andrew Poelstra dbefaef25c
Merge pull request #142 from jeandudey/2018-08-decimal-fromstr
Implement `FromStr` for `UDecimal`/`Decimal`.
2018-08-22 19:00:02 +00:00
Jean Pierre Dudey 9cdc75a930 Forbid exponents larger than 18.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-22 14:00:30 -04:00
Jean Pierre Dudey 6902bf826c Fix negative symbol bug in `FromStr` display implementation.
The negative symbol wasn't there when `int_part` was equal to zero.

Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-22 11:26:05 -04:00
Jean Pierre Dudey a915bc194d Fix multiplication logic in decimal parsing functions.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-22 07:22:47 -04:00
Jean Pierre Dudey e48e559740 Fix `UDecimal::parse_udecimal` identation.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-21 21:31:02 -04:00
Jean Pierre Dudey 455bc66d3c Fix parsing for numbers that are too big to fit in a `Decimal`/`UDecimal`.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-21 21:29:07 -04:00
Andrew Poelstra a61ad5d382
Merge pull request #137 from dongcarl/2018-8-better-errors
Fix Error type for SimpleDecoder and SimpleEncoder
2018-08-22 00:55:54 +00:00
Jean Pierre Dudey 07838568f9 Implement `FromStr` for `Decimal`/`UDecimal`.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-21 16:13:58 -04:00
Andrew Poelstra d16fdd63d3
Merge pull request #141 from jeandudey/2018-08-display
Implement `Display` instead of `ToString` for `Address` and `PrivKey`.
2018-08-21 16:41:58 +00:00
Carl Dong bccdd06794 Replace catch-all match arms with specific ones 2018-08-21 01:58:40 -07:00
Carl Dong 0c172941af Replace serialize::Error::Detail with variants
- Add serialize::Error::ParseFailed(&'static str) variant for
  serialization errors without context
- Add appropriate variants to replace network::Error::Detail for
  serialization error with context
- Remove error method from SimpleDecoders
2018-08-21 01:58:40 -07:00
Carl Dong e5b5cbfadb Fix Error type for SimpleDecoder and SimpleEncoder
- Separate serialize::Error and network::Error from util::Error
- Remove unneeded propagate_err and consume_err
- Change fuzzing code to ignore Err type
2018-08-21 01:58:40 -07:00
Jean Pierre Dudey df7f084e96 Implement `Display` instead of `ToString` for `Address` and `PrivKey`.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-20 19:46:56 -04:00
Andrew Poelstra 77e2fe3dda
Merge pull request #144 from jeandudey/2018-08-address-starts-with
trivial: Use `str::starts_with` method to check bech32 address prefixes.
2018-08-20 23:12:03 +00:00
Jean Pierre Dudey b78d7a7428 Use `str::starts_with` method to check bech32 address prefixes.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-20 18:11:14 -04:00
Jean Pierre Dudey 4dfb98bd70 Use `as_`,`to_`,`into_` conventions for array types.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-20 17:20:43 -04:00
Andrew Poelstra 2d961412af
Merge pull request #139 from jeandudey/2018-08-18-outpoint
Rename `TxOutRef` to `OutPoint` and use it in `TxIn`.
2018-08-20 18:18:00 +00:00
Jean Pierre Dudey 32631e44ad Rename `TxOutRef` to `OutPoint` and use it in `TxIn`.
Previously this structure was unused, it's now being used by the `TxIn`
structure to simplify the code a little bit and avoid confusions. Also
the rust-lightning source code has an `OutPoint` similar to this one
but with the `vout` index as an `u16` to avoid unsafe conversions.

I've added to new methods to `OutPoint`:

- `null`: Creates a new "null" `OutPoint`.
- `is_null`: Checks if the given `OutPoint` is null.

Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-20 13:46:10 -04:00
Jean Pierre Dudey 1b4aba1d80 Update serde to 1.0 and strason to 0.4
The `serde_struct_impl!` macro has been modified to be compatible
with the serde 1.0 crate, we use this macro and not the `serde_derive`
crate because the latter doesn't support Rust 1.14.0 which is shipped
on Debian stable and we should remain compatible with it.

Two new features were added:

- "serde": enables serialization/deserialization for common types, it pulls
the serde 1.0 dependency.
- "serde-decimal": enables serialization/deserialization for `UDecimal`/`Decimal`,
this pulls the strason 0.4 depdendency and the serde 1.0 dependency.

Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-20 13:42:34 -04:00
Andrew Poelstra 94f3d4b0f9 update to secp256k1 0.10.0 2018-08-20 15:28:43 +00:00
Aleksei 356d13e465 Add some useful standard trait implementations 2018-08-20 12:11:17 +03:00
Carl Dong 60577f286d Add derive_* methods to Extended*Key
- Add derive_pub to ExtendedPubKey
- Add derive_priv to ExtendedPrivKey
- Removed from_path from ExtendedPrivKey as it is superseded by
  derive_priv
- Add checking of derive_pub and derive_priv to test_path
- Add checking of correct error when invoking ckd_pub on a hardened
  ChildNumber
- Add test vector 3 from BIP32 specification
2018-08-12 17:16:33 -07:00
Andrew Poelstra bc7125e955
Merge pull request #119 from jeandudey/2018-08-08-try-op
Remove `try!` macro usage and use the `?` operator instead.
2018-08-12 23:44:43 +00:00
Jean Pierre Dudey 6e99d2d33c Hidde `From<T>` implementations for error types in Rustdoc.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-12 12:57:59 -04:00
Jean Pierre Dudey b2594087db Use the `?` (try) instead of the `try!` macro.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-12 12:47:31 -04:00
Andrew Poelstra 24c0f1a3fc
Merge pull request #118 from jeandudey/2018-08-08-bip32-tostring
Implement `Display` trait instead of implementing `ToString` directly.
2018-08-12 13:48:39 +00:00
Carl Dong c485a74c09 Add helper methods is_normal, is_hardened
- Fix documentation links
2018-08-11 13:29:10 -07:00
Carl Dong 4a5bf52ed9 Improve consistency for bip32::ChildNumber
There seemed to be some confusion as to whether the internal
represenation of a ChildNumber is supposed to be the index (0..2^31-1
for _both_ Normal and Hardened) or the actual number (0..2^31-1 for
Normal and 2^31..2^32-1 for Hardened). This commits fixes this
confusion.

- Make clear that the internal representation is the index rather
  than the actual number
- Make the internal representation non-public
- Provide methods for creating valid ChildNumbers
- Change relevant callers and tests to conform to this new ChildNumber

My rationale for using index rather than the actual number as internal
representation is that the difference between the two enum variants
already encode wether a ChildNumber is a normal one or a hardened one,
so the only bit of extra information left to be encoded is its index.
2018-08-11 12:46:46 -07:00
Andrew Poelstra ebe5133d1a
Merge pull request #110 from D4nte/regtest
Regtest bech32 address support
2018-08-11 17:21:12 +00:00
Andrew Poelstra 259c5902f1
Merge pull request #116 from jeandudey/2018-08-08-module-docs
Fix modules documentation title.
2018-08-11 17:12:50 +00:00
Andrew Poelstra ee9802d813
Merge pull request #120 from dpc/from_secret_key-doc-fix
Simple doc fix for `from_secret_key`
2018-08-11 17:05:29 +00:00
Carl Dong d4f28b6785 Add conversion between u32 and ChildNumber, fix docs 2018-08-10 13:49:45 -07:00
Dawid Ciężarkiewicz 1646a80f77 Simple doc fix for `from_secret_key` 2018-08-09 15:41:48 -07:00