bitcoin-address-0.1: Bitcoin address generation and rendering. Parsing coming soon.
Safe HaskellNone
LanguageHaskell2010

Bitcoin.Address

Description

Bitcoin address generation and rendering. Parsing is comming soon.

Most of what you'll normally need for safely dealing with Bitcoin addresses is exported from this module.

Synopsis

Network settings

btc :: Settings Source #

BTC mainnet network settings.

  • P2PKH addresses, when rendered, start with 1.
  • P2SH addresses, when rendered, start with 3.
  • SegWit addresses, when rendered, start with bc1.

btcTestnet :: Settings Source #

BTC testnet network settings.

  • P2PKH addresses, when rendered, start with m or n.
  • P2SH addresses, when rendered, start with 2.
  • SegWit addresses, when rendered, start with tb1.

Addresses

data Address Source #

A Bitcoin compatible address.

These constructors are safe to use. However, you may find the similarly named helper functions in Bitcoin.Address more practical.

Constructors

P2PKH PrefixP2PKH PubHash160

A “pay to public-key hash” address. See p2pkh.

P2SH PrefixP2SH ScriptHash160

A “pay to script hash” address. See p2sh, p2sh_multiSig, p2sh_p2wpkh, p2sh_p2wsh_multiSig.

SegWit PrefixSegWit Program

A native SegWit address. See p2wpkh, p2wsh, p2wsh_multiSig.

Instances

Instances details
Eq Address Source # 
Instance details

Defined in Bitcoin.Address

Methods

(==) :: Address -> Address -> Bool #

(/=) :: Address -> Address -> Bool #

Ord Address Source # 
Instance details

Defined in Bitcoin.Address

Show Address Source #

As renderAddress.

Instance details

Defined in Bitcoin.Address

renderAddress :: Address -> ByteString Source #

Render and Address to its human readable form.

addressScript :: Address -> Script Source #

Obtain the Script associated with a particular Address.

This will be one of p2pkh, p2sh or segWit from the Bitcoin.Address.Script module.

P2PKH

p2pkh :: Settings -> Pub -> Address Source #

P2PKH Address for a Public key.

This is the address format associated with BIP-0032 derivation path m/44'/0'

P2SH

p2sh :: Settings -> Script -> Address Source #

P2SH Address for a Script.

See p2sh_p2wpkh, p2sh_p2wpkh or p2sh_p2wsh_multiSig for some of the typical constructions using p2sh. It's unlikely that you'll need to use p2sh directly unless you are deploying a non-standard Script.

p2sh_multiSig Source #

Arguments

:: Settings 
-> [Pub]

Public keys. Total number in range [1 … 16]

-> Int

Required number of signatures in range [1 … 16]

-> Maybe Address

Nothing if any of the inputs is invalid.

P2SH Address for a standard m-of-n multiSig Script.

p2sh_p2wpkh :: Settings -> Pub -> Address Source #

P2SH “P2WPKH-in-P2SHAddress for a Public key.

This is the address format associated with BIP-0032 derivation path m/49'/0'

p2sh_p2wsh :: Settings -> Script -> Address Source #

P2SH “P2WSH-in-P2SHAddress for a Script.

WARNING SegWit does not support uncompressed SEC Public addresses (i.e., pubUncompressed and pubUncompressedHash160), so be sure to only mention compressed SEC Public addresses in your Scripts (i.e., pubCompressed and pubHash160).

p2sh_p2wsh_multiSig Source #

Arguments

:: Settings 
-> [Pub]

Public keys. Total number in range [1 … 16]

-> Int

Required number of signatures in range [1 … 16]

-> Maybe Address

Nothing if any of the inputs is invalid.

P2SH “P2WSH-in-P2SHAddress for a standard m-of-n multiSig Script.

SegWit P2WPKH

p2wpkh :: Settings -> Pub -> Address Source #

SegWit “P2WPKH” Address for a Public key.

This is the address format associated with BIP-0032 derivation path m/84'/0'

SegWit P2WSH

p2wsh :: Settings -> Script -> Address Source #

SegWit “P2WSH” Address for a Script.

Please see p2wsh_multiSig for some of the typical constructions using p2wsh. It's unlikely that you'll need to use p2wsh directly unless you are deploying a non-standard Script.

WARNING SegWit does not support uncompressed SEC Public addresses (i.e., pubUncompressed and pubUncompressedHash160), so be sure to only mention compressed SEC Public addresses in your Scripts (i.e., pubCompressed and pubHash160).

p2wsh_multiSig Source #

Arguments

:: Settings 
-> [Pub]

Public keys. Total number in range [1 … 16]

-> Int

Required number of signatures in range [1 … 16]

-> Maybe Address

Nothing if any of the inputs is invalid.

SegWit “P2WSH” Address for a standard m-of-n multiSig Script.