Sapling Spending keys and receivers #27
3 changed files with 12 additions and 5 deletions
|
@ -128,8 +128,8 @@ import ZcashHaskell.Types
|
||||||
|
|
||||||
{# fun unsafe rust_wrapper_sapling_spendingkey as rustWrapperSaplingSpendingkey
|
{# fun unsafe rust_wrapper_sapling_spendingkey as rustWrapperSaplingSpendingkey
|
||||||
{ toBorshVar* `BS.ByteString'&
|
{ toBorshVar* `BS.ByteString'&
|
||||||
, `Int'
|
, `Word32'
|
||||||
, `Int'
|
, `Word32'
|
||||||
, getVarBuffer `Buffer (BS.ByteString)'&
|
, getVarBuffer `Buffer (BS.ByteString)'&
|
||||||
}
|
}
|
||||||
-> `()'
|
-> `()'
|
||||||
|
|
|
@ -90,7 +90,7 @@ instance FromJSON RawTxResponse where
|
||||||
pure $ RawTxResponse i h (getShieldedOutputs h) a ht c b
|
pure $ RawTxResponse i h (getShieldedOutputs h) a ht c b
|
||||||
|
|
||||||
-- | Attempts to obtain a sapling SpendinKey using a HDSeed, a Coin Type and an Account ID
|
-- | Attempts to obtain a sapling SpendinKey using a HDSeed, a Coin Type and an Account ID
|
||||||
genSaplingSpendingKey :: BS.ByteString -> Int -> Int -> Maybe BS.ByteString
|
genSaplingSpendingKey :: BS.ByteString -> Word32 -> Word32 -> Maybe BS.ByteString
|
||||||
genSaplingSpendingKey seed coin_type account_id = do
|
genSaplingSpendingKey seed coin_type account_id = do
|
||||||
if BS.length res > 0
|
if BS.length res > 0
|
||||||
then Just res
|
then Just res
|
||||||
|
|
11
test/Spec.hs
11
test/Spec.hs
|
@ -62,6 +62,10 @@ import Foreign.C.Types
|
||||||
import Data.Word
|
import Data.Word
|
||||||
import Haskoin.Crypto.Keys.Extended
|
import Haskoin.Crypto.Keys.Extended
|
||||||
|
|
||||||
|
m2bs :: Maybe BS.ByteString -> BS.ByteString
|
||||||
|
m2bs x = fromMaybe "" x
|
||||||
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
hspec $ do
|
hspec $ do
|
||||||
|
@ -512,5 +516,8 @@ main = do
|
||||||
] :: [Word8]
|
] :: [Word8]
|
||||||
let coin = 1 :: Word32
|
let coin = 1 :: Word32
|
||||||
let account = 0 :: Word32
|
let account = 0 :: Word32
|
||||||
res <- genSaplingSpendingKey (word8ArrayToByteString hdseed) coin account
|
let msg = genSaplingSpendingKey (word8ArrayToByteString hdseed) coin account
|
||||||
res `shouldBe` "genSaplingSpendingKey Function called."
|
case msg of
|
||||||
|
Nothing -> "Bad response from genSapingSpendingKey"
|
||||||
|
Just msg -> fromMaybe "BadResponse" msg
|
||||||
|
"mm " `shouldBe` "genSaplingSpendingKey Function called."
|
Loading…
Reference in a new issue