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
This commit is contained in:
Andrew Poelstra 2022-11-29 14:11:36 +00:00
commit 410b820814
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 6 additions and 0 deletions

View File

@ -21,6 +21,12 @@
//! // Generate pay-to-pubkey-hash address. //! // Generate pay-to-pubkey-hash address.
//! let address = Address::p2pkh(&public_key, Network::Bitcoin); //! let address = Address::p2pkh(&public_key, Network::Bitcoin);
//! ``` //! ```
//!
//! # Note: creating a new address requires the rand feature flag
//!
//! ```toml
//! bitcoin = { version = "...", features = ["rand"] }
//! ```
use core::convert::TryFrom; use core::convert::TryFrom;
use core::fmt; use core::fmt;