Merge rust-bitcoin/rust-bitcoin#3737: Improve rustdocs on addresses module
f85456a726
Improve rustdocs on addresses module (Tobin C. Harding) Pull request description: These docs are stale, update them. - Mention segwit and legacy - Improve example code to show feature gating - Fix headings to be as typical ACKs for top commit: storopoli: ACKf85456a726
apoelstra: ACK f85456a726a201b26eac58d22eb0eb6a58ad411b; successfully ran local tests Tree-SHA512: c1cdde744fb960c4119805e6b3fb0cc971eaa94173fb85f8f7a34daab7985a0f14c9be477d7dda430c6873fed7265c598b8dcfbffe0ed6a99ca8590a2b2b724e
This commit is contained in:
commit
c40e2516ae
|
@ -2,28 +2,25 @@
|
|||
|
||||
//! Bitcoin addresses.
|
||||
//!
|
||||
//! Support for ordinary base58 Bitcoin addresses and private keys.
|
||||
//! Support for segwit and legacy addresses (bech32 and base58 respectively).
|
||||
//!
|
||||
//! # Example: creating a new address from a randomly-generated key pair
|
||||
//! # Examples
|
||||
//!
|
||||
//! ### Creating a new address from a randomly-generated key pair.
|
||||
//!
|
||||
//! ```rust
|
||||
//! # #[cfg(feature = "rand-std")] {
|
||||
//! use bitcoin::{Address, PublicKey, Network};
|
||||
//! #[cfg(feature = "rand-std")] {
|
||||
//! use bitcoin::secp256k1::{rand, Secp256k1};
|
||||
//! use bitcoin::{Address, Network, PublicKey};
|
||||
//!
|
||||
//! // Generate random key pair.
|
||||
//! let s = Secp256k1::new();
|
||||
//! let public_key = PublicKey::new(s.generate_keypair(&mut rand::thread_rng()).1);
|
||||
//! let secp = Secp256k1::new();
|
||||
//! let (_sk, pk) = secp.generate_keypair(&mut rand::thread_rng());
|
||||
//! let public_key = PublicKey::new(pk); // Or `PublicKey::from(pk)`.
|
||||
//!
|
||||
//! // Generate pay-to-pubkey-hash address.
|
||||
//! // Generate a mainnet pay-to-pubkey-hash address.
|
||||
//! let address = Address::p2pkh(&public_key, Network::Bitcoin);
|
||||
//! # }
|
||||
//! ```
|
||||
//!
|
||||
//! # Note: creating a new address requires the rand-std feature flag
|
||||
//!
|
||||
//! ```toml
|
||||
//! bitcoin = { version = "...", features = ["rand-std"] }
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
pub mod error;
|
||||
|
|
Loading…
Reference in New Issue