Sapling Spending keys and receivers #27

Merged
pitmutt merged 12 commits from rvv040 into dev040 2024-03-10 15:07:10 +00:00
3 changed files with 12 additions and 5 deletions
Showing only changes of commit 7b65d322e6 - Show all commits

View file

@ -128,8 +128,8 @@ import ZcashHaskell.Types
{# fun unsafe rust_wrapper_sapling_spendingkey as rustWrapperSaplingSpendingkey
{ toBorshVar* `BS.ByteString'&
, `Int'
, `Int'
, `Word32'
, `Word32'
, getVarBuffer `Buffer (BS.ByteString)'&
}
-> `()'

View file

@ -90,7 +90,7 @@ instance FromJSON RawTxResponse where
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
genSaplingSpendingKey :: BS.ByteString -> Int -> Int -> Maybe BS.ByteString
genSaplingSpendingKey :: BS.ByteString -> Word32 -> Word32 -> Maybe BS.ByteString
genSaplingSpendingKey seed coin_type account_id = do
if BS.length res > 0
then Just res

View file

@ -62,6 +62,10 @@ import Foreign.C.Types
import Data.Word
import Haskoin.Crypto.Keys.Extended
m2bs :: Maybe BS.ByteString -> BS.ByteString
m2bs x = fromMaybe "" x
main :: IO ()
main = do
hspec $ do
@ -512,5 +516,8 @@ main = do
] :: [Word8]
let coin = 1 :: Word32
let account = 0 :: Word32
res <- genSaplingSpendingKey (word8ArrayToByteString hdseed) coin account
res `shouldBe` "genSaplingSpendingKey Function called."
let msg = genSaplingSpendingKey (word8ArrayToByteString hdseed) coin account
case msg of
Nothing -> "Bad response from genSapingSpendingKey"
Just msg -> fromMaybe "BadResponse" msg
"mm " `shouldBe` "genSaplingSpendingKey Function called."