Commit Graph

24 Commits

Author SHA1 Message Date
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
Tobin C. Harding 9f7d934f5d Move the locktime module to absolute
In preparation for adding a relative lock time type move the `locktime`
module to a new module called `absolute`. Use qualified path for
locktime types (e.g. `absolute::PackedLockTime`) to improve readability.
2022-08-24 15:14:26 +10:00
Tobin C. Harding 22fd107e16 Run rustfmt
We just moved the `address` module out of `util` which is currently
ignored by `rustfmt`.

Run `rustfmt`, no other changes other than those made by the tool.
2022-08-12 07:35:15 +10:00
Tobin C. Harding e1ae9d86bb Move the address module out of util
The identifier 'util' does not convey any information. We have a whole
bunch of modules inside the `util` module.

As part of work to reduce the amount of arbitrary things in the `util`
module move the `address` module to the crate root level.
2022-08-12 07:35:15 +10:00
Tobin C. Harding 0ed78e543b Add lock time types
Add a `LockTime` type to hold the nLockTime `u32` value. Use it in
`Transaction` for `lock_time` instead of a `u32`. Make it public so this
new type can be used by rust-miniscript and other downstream projects.

Add a `PackedLockTime` type that wraps a raw `u32` and derives `Ord`,
this type is for wrapping a consensus lock time value for nesting in
types that would like to derive `Ord`.
2022-07-27 08:39:19 +10:00
Tobin C. Harding c1d74a3eae Run the formatter
We recently merged a PR that enables the formatter on the `examples/`
directory, at the same time we merged `examples/ecdsa-psbt.rs` but CI
had already run so the formatter was not run.

Run `cargo +nightly fmt` to format the `examples/` directory.
2022-07-20 11:32:54 +10:00
sanket1729 e5acc07789
Merge rust-bitcoin/rust-bitcoin#1040: Introduce rustfmt in a non-invasive manner
ee9a3ec6a1 Enable formatter for "src" (Tobin C. Harding)
743b197124 Add use for Unexpected (Tobin C. Harding)
fd217e72c3 Use f instead of formatter (Tobin C. Harding)
7b50a96ade Do not format prelude module (Tobin C. Harding)
01471f7e65 Shield hash_newtypes from rustfmt (Tobin C. Harding)
65d19d9044 Refactor compile_error message (Tobin C. Harding)
6461e2db8d Run formatter on examples/ (Tobin C. Harding)
fd1c6589ba Add a rustfmt configuration file with explicit ignores (Tobin C. Harding)

Pull request description:

  Looks like we are getting to a place that rustfmt _might_ be able to be used. In an effort to introduce `rustfmt` without requiring devs to do excessively mundane reviews introduce `rustfmt` in a non-invasive manner. What this means is

  - Add a fully fleshed out `rustfmt` config file that explicitly ignores all the source files
  - Enable sections of code one by one so review is easier (including preparatory patches before doing each section).

  This PR currently does `examples` and all the source files at the root level of the crate (i.e. excludes all directories in `src/`). The other directories can then be done one at a time.

  Please see discussion on: https://github.com/rust-bitcoin/rust-bitcoin/pull/959 for more context.

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

Tree-SHA512: f4ff3c031b5d685777e09bac2df59ed8217576b807da7699f44fe00aa509d0b7fe47617a8b3eff00d3125aeece3e010b8f9dd8733d315ccb2adc0e9a7d7f07e3
2022-07-19 13:38:28 -07:00
Tobin C. Harding 6461e2db8d Run formatter on examples/
Remove "examples" from the rustfmt ignore list.
2022-07-19 13:43:12 +10:00
Tobin Harding 6967c0ed6f Add psbt example
Add an example PSBT workflow. The workflow we simulate is that of a
setup using a watch-only online wallet (contains only public keys) and a
cold-storage wallet (contains the private keys).

We create and update a PSBT using the watch-only wallet then pass the
PSBT to the cold-storage wallet to sign.

Co-authored-by: Dan Gould <d@ngould.dev>
2022-07-19 10:59:48 +10:00
KaFai Choi bb70820fed
improve example: take hex-encoded seed instead of WIF in bip32 example 2022-01-10 06:59:49 +07:00
Dr Maxim Orlovsky e6a3d603c9 BIP32 extended key `to_ecdsa()` and `to_schnorr()` methods 2022-01-09 07:17:02 +01:00
Dr Maxim Orlovsky b72f56c4ae BIP32 extended keys are using Scep256k1 keys instead of bitcoin ECDSA
According to #588, BIP32 does not support uncompressed keys and using type with compression flag is a mistake
2022-01-09 07:16:49 +01:00
Riccardo Casatta 5dfb93df71
Deprecate StreamReader
StreamReader before this commit is trying to repeatedly parse big object like
blocks at every read, causing useless overhead.
consensus_encode deal with partial data by simply blocking.

After this changes it doesn't look what remain of the StreamReader is really giving
value, so it's deprecated
2021-12-31 10:44:14 +01: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
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
Margarita Kitic 1278e68611 add bip32 example 2020-10-17 10:54:14 +02:00
Elias Rohrer 827d98d821 Fixed for rust 1.22.0. 2020-03-03 12:18:37 +01:00
Elias Rohrer aa46618da7 Intialize stream reader only once. 2020-03-03 10:48:01 +01:00
Elias Rohrer 40431f3d4f Formatted. 2020-03-03 10:48:01 +01:00
Elias Rohrer b5f5abe0b4 Removed pre-configured IP, now takes IP as argument. 2020-03-03 10:48:01 +01:00
Elias Rohrer 62f5f8e3f9 Removed explicit dependency on rand. 2020-03-03 10:48:01 +01:00
Elias Rohrer 2852083ff3 Using write_all(). 2020-03-03 10:48:01 +01:00
Elias Rohrer c4f0056856 No clone needed. 2020-03-03 10:48:01 +01:00
Elias Rohrer 9d212da0ba Added a simple handshake example. 2020-03-03 10:48:01 +01:00