Module bitcoins::nets[][src]

Expand description

The bitcoin::nets module cotains Bitcoin network definitions. These are the main interface for accessing the library.

Expected user flow is to import the network and access the transaction builder through it. This gives the user immediate access to the full bitcoin toolchain via a single import.

use bitcoins::{BitcoinMainnet, enc::Address, types::Outpoint};
use coins_core::{
    nets::Network,
    builder::TxBuilder,
    ser::ByteFormat,
};

let address = BitcoinMainnet::string_to_address("bc1qvyyvsdcd0t9863stt7u9rf37wx443lzasg0usy").unwrap();

let b = BitcoinMainnet::tx_builder();
b.version(2)
 .spend(Outpoint::default(), 0xaabbccdd)
 .pay(0x8888_8888_8888_8888, &address)
 .pay(0x7777_7777_7777_7777, &Address::Sh("377mKFYsaJPsxYSB5aFfx8SW3RaN5BzZVh".to_owned()))
 .build()
 .unwrap()
 .serialize_hex();

let script = BitcoinMainnet::decode_address(&address);
let re_encoded = BitcoinMainnet::encode_address(&script).unwrap();
assert_eq!(address, re_encoded);

Structs

A newtype for Bitcoin networks, parameterized by an encoder. We change the encoder to differentiate between main, test, and signet.

Traits

A trait for a Bitcoin network. Specifies that Witness Txns must use the same Input and Output format as Legacy transactions.

Type Definitions

A fully-parameterized BitcoinMainnet. This is the main interface for accessing the library.

A fully-parameterized BitcoinSignet. This is the main interface for accessing the library.

A fully-parameterized BitcoinTestnet. This is the main interface for accessing the library.