slip32-0.2.1: SLIP-0032: Extended serialization format for BIP-32 wallets
Safe HaskellNone
LanguageHaskell2010

SLIP32

Description

SLIP-0032 is an extended serialization format for BIP-0032 wallets.

This implementation is based on the draft SLIP-0032 spec.

Please refer to the BIP32 module from the bip32 library to find more about Index and Chain.

Please refer to the Bitcoin.Keys module from the bitcoin-keys library to find more about Pub and Prv.

Synopsis

Parsing

parse :: ByteString -> Maybe (Either XPub XPrv) Source #

Parse either an XPub or an XPrv from its SLIP-0032 representation.

parseXPub :: ByteString -> Maybe XPub Source #

Parse an XPub from its SLIP-0032 representation.

parseXPrv :: ByteString -> Maybe XPrv Source #

Parse an XPrv from its SLIP-0032 representation.

Text

parseText :: Text -> Maybe (Either XPub XPrv) Source #

Parse either an XPub or an XPrv from its SLIP-0032 representation.

Like parse, but takes Text.

parseXPubText :: Text -> Maybe XPub Source #

Parse an XPub from its SLIP-0032 representation.

Like parseXPub, but takes Text.

parseXPrvText :: Text -> Maybe XPrv Source #

Parse an XPrv from its SLIP-0032 representation.

Like parseXPrv, but takes Text.

Rendering

renderXPub :: XPub -> ByteString Source #

Render an XPub using the SLIP-0032 encoding.

renderXPrv :: XPrv -> ByteString Source #

Render an XPub using the SLIP-0032 encoding.

Text

renderXPubText :: XPub -> Text Source #

Render an XPub using the SLIP-0032 encoding.

The rendered Text is ASCII compatible.

renderXPrvText :: XPrv -> Text Source #

Render an XPub using the SLIP-0032 encoding.

The rendered Text is ASCII compatible.

Public key

data XPub Source #

Extended public key.

Constructors

XPub !Path !Chain !Pub 

Instances

Instances details
Eq XPub Source # 
Instance details

Defined in SLIP32

Methods

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

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

Show XPub Source # 
Instance details

Defined in SLIP32

Methods

showsPrec :: Int -> XPub -> ShowS #

show :: XPub -> String #

showList :: [XPub] -> ShowS #

Private key

data XPrv Source #

Extended private key.

Constructors

XPrv !Path !Chain !Prv 

Instances

Instances details
Eq XPrv Source # 
Instance details

Defined in SLIP32

Methods

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

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

Show XPrv Source # 
Instance details

Defined in SLIP32

Methods

showsPrec :: Int -> XPrv -> ShowS #

show :: XPrv -> String #

showList :: [XPrv] -> ShowS #

Path

data Path Source #

Derivation path.

Construct with path.

Instances

Instances details
Eq Path Source # 
Instance details

Defined in SLIP32

Methods

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

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

Show Path Source # 
Instance details

Defined in SLIP32

Methods

showsPrec :: Int -> Path -> ShowS #

show :: Path -> String #

showList :: [Path] -> ShowS #

path :: [Index] -> Maybe Path Source #

Construct a derivation Path.

Hardened keys start from \(2^{31}\).

m            = path []
m/0          = path [0]
m/0'         = path [0 + 2^31]
m/1          = path [1]
m/1'         = path [1 + 2^31]
m/0'/1'/2'/2 = path [0 + 2^31, 1 + 2^31, 2 + 2^31, 2]

See Bitcoin's BIP-0032 for details.

Returns Nothing if the list length is more than 255.

unPath :: Path -> [Index] Source #

Obtains the derivation path as a list of up to 255 elements.