Add documentation for new functions
This commit is contained in:
parent
d5c50d58c5
commit
d1b0436af2
5 changed files with 27 additions and 18 deletions
|
@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Types for Spending Keys and Receivers for Sapling and Orchard
|
||||
- Function to generate an Orchard receiver
|
||||
- Function to generate a Sapling receiver
|
||||
- Function to generate a Transparent receiver
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -37,7 +37,10 @@ import ZcashHaskell.Utils (encodeBech32m, f4Jumble)
|
|||
|
||||
-- | Derives an Orchard spending key for the given seed and account ID
|
||||
genOrchardSpendingKey ::
|
||||
Seed -> CoinType -> AccountId -> Maybe OrchardSpendingKey
|
||||
Seed -- ^ The cryptographic seed for the wallet
|
||||
-> CoinType -- ^ The coin type constant
|
||||
-> AccountId -- ^ The index of the account to be used
|
||||
-> Maybe OrchardSpendingKey
|
||||
genOrchardSpendingKey s coinType accountId =
|
||||
if BS.length k /= 32
|
||||
then Nothing
|
||||
|
@ -52,7 +55,10 @@ genOrchardSpendingKey s coinType accountId =
|
|||
|
||||
-- | Derives an Orchard receiver for the given spending key and index
|
||||
genOrchardReceiver ::
|
||||
Int -> Scope -> OrchardSpendingKey -> Maybe OrchardReceiver
|
||||
Int -- ^ The index of the address to be created
|
||||
-> Scope -- ^ `External` for wallet addresses, `Internal` for change addresses
|
||||
-> OrchardSpendingKey -- ^ The spending key
|
||||
-> Maybe OrchardReceiver
|
||||
genOrchardReceiver i scope osk =
|
||||
if BS.length k /= 43
|
||||
then Nothing
|
||||
|
|
|
@ -41,7 +41,11 @@ import ZcashHaskell.Types
|
|||
, getValue
|
||||
)
|
||||
|
||||
encodeTransparent :: ZcashNet -> TransparentAddress -> T.Text
|
||||
-- | Encodes a `TransparentAddress` into the human-readable format per the Zcash Protocol section 5.6.1.1
|
||||
encodeTransparent ::
|
||||
ZcashNet -- ^ The network, `MainNet` or `TestNet`
|
||||
-> TransparentAddress -- ^ The address to encode
|
||||
-> T.Text
|
||||
encodeTransparent zNet t =
|
||||
encodeTransparent' (getTransparentPrefix zNet (ta_type t)) $
|
||||
toBytes $ ta_bytes t
|
||||
|
@ -56,7 +60,11 @@ encodeTransparent zNet t =
|
|||
checksum = sha256 $ sha256 digest
|
||||
|
||||
-- | Generate an Extended Private Key from a known HDSeed.
|
||||
genTransparentPrvKey :: Seed -> CoinType -> AccountId -> IO XPrvKey
|
||||
genTransparentPrvKey ::
|
||||
Seed -- ^ The cryptographic seed of the wallet
|
||||
-> CoinType -- ^ The coin type constant to be used
|
||||
-> AccountId -- ^ The index of the account to be used
|
||||
-> IO XPrvKey
|
||||
genTransparentPrvKey hdseed ctype accid = do
|
||||
let coin = getValue ctype
|
||||
ioCtx <- createContext
|
||||
|
@ -64,18 +72,12 @@ genTransparentPrvKey hdseed ctype accid = do
|
|||
let prvKey = makeXPrvKey $ getBytes hdseed
|
||||
return $ derivePath ioCtx path prvKey
|
||||
|
||||
genTransparentPubKey :: XPrvKey -> IO XPubKey
|
||||
genTransparentPubKey xPrvKey = do
|
||||
ioCtx <- createContext
|
||||
return $ deriveXPubKey ioCtx xPrvKey
|
||||
|
||||
genTransparentPubAddress :: XPubKey -> IO Address
|
||||
genTransparentPubAddress xPubKey = do
|
||||
ioCtx <- createContext
|
||||
return $ xPubAddr ioCtx xPubKey
|
||||
|
||||
-- | Generate a transparent receiver
|
||||
genTransparentReceiver :: Int -> Scope -> XPrvKey -> IO TransparentAddress
|
||||
genTransparentReceiver ::
|
||||
Int -- ^ The index of the address to be created
|
||||
-> Scope -- ^ `External` for wallet addresses or `Internal` for change addresses
|
||||
-> XPrvKey -- ^ The transparent private key
|
||||
-> IO TransparentAddress
|
||||
genTransparentReceiver i scope xprvk = do
|
||||
ioCtx <- createContext
|
||||
let s =
|
||||
|
|
|
@ -65,8 +65,8 @@ instance ToBytes Phrase where
|
|||
|
||||
-- | Scope for addresses/receivers
|
||||
data Scope
|
||||
= External
|
||||
| Internal
|
||||
= External -- ^ Addresses used publically to receive payments
|
||||
| Internal -- ^ Addresses used internally by wallets for change and shielding
|
||||
deriving (Eq, Prelude.Show, Read)
|
||||
|
||||
-- | Type to represent data after Bech32 decoding
|
||||
|
|
|
@ -5,7 +5,7 @@ cabal-version: 3.0
|
|||
-- see: https://github.com/sol/hpack
|
||||
|
||||
name: zcash-haskell
|
||||
version: 0.5.0.0
|
||||
version: 0.5.0.1
|
||||
synopsis: Utilities to interact with the Zcash blockchain
|
||||
description: Please see the README on the repo at <https://git.vergara.tech/Vergara_Tech/zcash-haskell#readme>
|
||||
category: Blockchain
|
||||
|
|
Loading…
Reference in a new issue