Copyright | No rights reserved |
---|---|
License | MIT |
Maintainer | jprupp@protonmail.ch |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Base58, CashAddr, Bech32 address and WIF private key serialization support.
Synopsis
- data Address
- = PubKeyAddress { }
- | ScriptAddress { }
- | WitnessPubKeyAddress { }
- | WitnessScriptAddress { }
- | WitnessAddress {
- version :: !Word8
- bytes :: !ByteString
- isPubKeyAddress :: Address -> Bool
- isScriptAddress :: Address -> Bool
- isWitnessAddress :: Address -> Bool
- isWitnessPubKeyAddress :: Address -> Bool
- isWitnessScriptAddress :: Address -> Bool
- addrToText :: Network -> Address -> Maybe Text
- textToAddr :: Network -> Text -> Maybe Address
- bech32ToAddr :: Network -> Text -> Maybe Address
- cashToAddr :: Network -> Text -> Maybe Address
- base58ToAddr :: Network -> Text -> Maybe Address
- pubKeyAddr :: Ctx -> PublicKey -> Address
- pubKeyWitnessAddr :: Ctx -> PublicKey -> Address
- pubKeyCompatWitnessAddr :: Ctx -> PublicKey -> Address
- p2pkhAddr :: Hash160 -> Address
- p2wpkhAddr :: Hash160 -> Address
- p2shAddr :: Hash160 -> Address
- p2wshAddr :: Hash256 -> Address
- inputAddress :: Ctx -> ScriptInput -> Maybe Address
- outputAddress :: Ctx -> ScriptOutput -> Maybe Address
- addressToScript :: Ctx -> Address -> Script
- addressToScriptBS :: Ctx -> Address -> ByteString
- addressToOutput :: Address -> ScriptOutput
- payToScriptAddress :: Ctx -> ScriptOutput -> Address
- payToWitnessScriptAddress :: Ctx -> ScriptOutput -> Address
- payToNestedScriptAddress :: Ctx -> ScriptOutput -> Address
- scriptToAddress :: Ctx -> Script -> Either String Address
- scriptToAddressBS :: Ctx -> ByteString -> Either String Address
- module Haskoin.Address.Base58
- module Haskoin.Address.Bech32
- module Haskoin.Address.CashAddr
Addresses
Address format for Bitcoin and Bitcoin Cash.
PubKeyAddress | pay to public key hash (regular) |
ScriptAddress | pay to script hash |
WitnessPubKeyAddress | pay to witness public key hash |
WitnessScriptAddress | pay to witness script hash |
WitnessAddress | other witness address |
|
Instances
isWitnessAddress :: Address -> Bool Source #
isWitnessPubKeyAddress :: Address -> Bool Source #
Address
pays to a witness public key hash. Only valid for SegWit
networks.
isWitnessScriptAddress :: Address -> Bool Source #
addrToText :: Network -> Address -> Maybe Text Source #
Convert address to human-readable string. Uses Base58
, Bech32Encoding
, or
CashAddr
depending on network.
textToAddr :: Network -> Text -> Maybe Address Source #
Parse Base58
, Bech32Encoding
or CashAddr
address, depending on network.
pubKeyAddr :: Ctx -> PublicKey -> Address Source #
Obtain a standard pay-to-public-key-hash address from a public key.
pubKeyWitnessAddr :: Ctx -> PublicKey -> Address Source #
Obtain a SegWit pay-to-witness-public-key-hash (P2WPKH) address from a public key.
pubKeyCompatWitnessAddr :: Ctx -> PublicKey -> Address Source #
Obtain a backwards-compatible SegWit P2SH-P2WPKH address from a public key.
p2pkhAddr :: Hash160 -> Address Source #
Obtain a standard pay-to-public-key-hash (P2PKH) address from a Hash160
.
p2wpkhAddr :: Hash160 -> Address Source #
Obtain a SegWit pay-to-witness-public-key-hash (P2WPKH) address from a
Hash160
.
p2shAddr :: Hash160 -> Address Source #
Obtain a standard pay-to-script-hash (P2SH) address from a Hash160
.
p2wshAddr :: Hash256 -> Address Source #
Obtain a SegWit pay-to-witness-script-hash (P2WSH) address from a Hash256
inputAddress :: Ctx -> ScriptInput -> Maybe Address Source #
Infer the Address
of a ScriptInput
.
outputAddress :: Ctx -> ScriptOutput -> Maybe Address Source #
Get the Address
of a ScriptOutput
.
addressToScriptBS :: Ctx -> Address -> ByteString Source #
Encode address as output script in ByteString
form.
addressToOutput :: Address -> ScriptOutput Source #
Encode an output script from an address. Will fail if using a pay-to-witness address on a non-SegWit network.
payToScriptAddress :: Ctx -> ScriptOutput -> Address Source #
Compute a standard pay-to-script-hash (P2SH) address for an output script.
payToWitnessScriptAddress :: Ctx -> ScriptOutput -> Address Source #
Compute a SegWit pay-to-witness-script-hash (P2WSH) address for an output script.
payToNestedScriptAddress :: Ctx -> ScriptOutput -> Address Source #
Compute a backwards-compatible SegWit P2SH-P2WSH address.
scriptToAddress :: Ctx -> Script -> Either String Address Source #
Decode an output script into an Address
if it has such representation.
scriptToAddressBS :: Ctx -> ByteString -> Either String Address Source #
Decode a serialized script into an Address
.
module Haskoin.Address.Base58
module Haskoin.Address.Bech32
module Haskoin.Address.CashAddr