Safe Haskell | None |
---|---|
Language | Haskell2010 |
BIP-0032 Hierarchical Deterministic Wallets, for bitcoin and other cryptocurrencies.
Synopsis
- encodeXPrv :: XPrv -> ByteString
- encodeXPub :: XPub -> ByteString
- decodeXPrv :: ByteString -> Maybe XPrv
- decodeXPub :: ByteString -> Maybe XPub
- decode :: ByteString -> Maybe (Either XPub XPrv)
- encodeXPrvRaw :: XPrv -> ByteString
- encodeXPubRaw :: XPub -> ByteString
- decodeXPrvRaw :: ByteString -> Maybe XPrv
- decodeXPubRaw :: ByteString -> Maybe XPub
- decodeRaw :: ByteString -> Maybe (Either XPub XPrv)
- data XPrv = XPrv !Version !Depth !Fingerprint !Index !Chain !Prv
- xprvToXPub :: Version -> XPrv -> XPub
- data Prv
- prv :: ByteString -> Maybe Prv
- unPrv :: Prv -> ByteString
- prvToPub :: Prv -> Pub
- data XPub = XPub !Version !Depth !Fingerprint !Index !Chain !Pub
- data Pub
- pub :: ByteString -> Maybe Pub
- unPub :: Pub -> ByteString
- data Chain
- chain :: ByteString -> Maybe Chain
- unChain :: Chain -> ByteString
- newtype Index = Index Word32
- indexIsHardened :: Index -> Bool
- subXPubXPub :: XPub -> Index -> Maybe XPub
- subXPrvXPrv :: XPrv -> Index -> Maybe XPrv
- subXPrvXPub :: Version -> XPrv -> Index -> Maybe XPub
- subPubPub :: Chain -> Pub -> Index -> Maybe (Chain, Pub)
- subPrvPrv :: Chain -> Prv -> Index -> Maybe (Chain, Prv)
- subPrvPub :: Chain -> Prv -> Index -> Maybe (Chain, Pub)
- newtype Depth = Depth {}
- newtype Fingerprint = Fingerprint {}
- fingerprint :: Pub -> Fingerprint
- newtype Version = Version {}
- version_xprv :: Version
- version_xpub :: Version
- version_tprv :: Version
- version_tpub :: Version
- version_Ltpv :: Version
- version_Ltub :: Version
- version_ttpv :: Version
- version_ttub :: Version
Base58 serialization
encodeXPrv :: XPrv -> ByteString Source #
Obtain the Base58 representation for an XPrv
.
It can be either 111 or 112 bytes in length, and when rendered as ASCII it looks something like this:
xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi
encodeXPub :: XPub -> ByteString Source #
Obtain the Base58 representation for an XPub
.
It can be either 111 or 112 bytes in length, and when rendered as ASCII it looks something like this:
xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8
decodeXPrv :: ByteString -> Maybe XPrv Source #
Decode the Base58-encoded XPrv
representation. See encodeXPrv
.
decodeXPub :: ByteString -> Maybe XPub Source #
Decode the Base58-encoded XPub
representation. See encodeXPub
.
Raw serialization
encodeXPrvRaw :: XPrv -> ByteString Source #
Encode the 78 raw XPrv
bytes.
encodeXPubRaw :: XPub -> ByteString Source #
Encode the 78 raw XPub
bytes.
decodeXPrvRaw :: ByteString -> Maybe XPrv Source #
Decode the 78 raw XPrv
bytes.
decodeXPubRaw :: ByteString -> Maybe XPub Source #
Decode the 78 raw XPub
bytes.
Private key
Extended private key.
Private key.
Construct with prv
.
Public key
Extended private key.
Public key.
Construct with pub
.
unPub :: Pub -> ByteString Source #
Chain code
Chain code.
Construct with chain
.
chain :: ByteString -> Maybe Chain Source #
Construct a Chain
code.
See Bitcoin's BIP-0032 for details.
Nothing
if the ByteString
length is not 32.
Derivation path
indexIsHardened :: Index -> Bool Source #
Whether a derivation path Index
is hardened. That is, \(2^{31}\) or
larger.
Subkeys
subXPrvXPub :: Version -> XPrv -> Index -> Maybe XPub Source #
Derive a child XPub
subkey from a parent a parent XPrv
key.
Notice that while
will fail with a
hardened subXPubXPub
(xprvToXPub
v) xprv iIndex
,
may succeed.subXPrvXPub
v xprv i
Returns Nothing
if the given inputs result in an invalid key.
Bare
Depth
Derivation path depth.
0
for master nodes —m
1
for level-1 derived keys —m/0'
, orm/13
, or …2
for level-2 derived keys —m/0'/28
, orm/44'/0'
, or …- … up to
255
.
Fingerprint
newtype Fingerprint Source #
4-byte fingerprint of a Pub
key.
Instances
Eq Fingerprint Source # | |
Defined in BIP32 (==) :: Fingerprint -> Fingerprint -> Bool # (/=) :: Fingerprint -> Fingerprint -> Bool # | |
Show Fingerprint Source # | |
Defined in BIP32 showsPrec :: Int -> Fingerprint -> ShowS # show :: Fingerprint -> String # showList :: [Fingerprint] -> ShowS # |
fingerprint :: Pub -> Fingerprint Source #
Version
Version bytes.
Example versions
version_xprv :: Version Source #
0x0488ade4
, “xprv”, Bitcoin mainnet private.
version_xpub :: Version Source #
0x0488b21e
, “xpub”, Bitcoin mainnet public.
version_tprv :: Version Source #
0x04358394
, “tprv”, Bitcoin testnet private.
version_tpub :: Version Source #
0x043587cf
, “tpub”, Bitcoin testnet public.
version_Ltpv :: Version Source #
0x019d9cfe
, “Ltpv”, Litecoin mainnet private.
version_Ltub :: Version Source #
0x019da462
, “Ltub”, Litecoin mainnet public.
version_ttpv :: Version Source #
0x0436ef7d
, “ttpv”, Litecoin testnet private.
version_ttub :: Version Source #
0x0436f6e1
, “ttub”, Litecoin testnet public.