From 9acbe5b98c48c64868f3d5db34fdbd28eaf5e9e0 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Tue, 5 Mar 2024 07:36:45 -0600 Subject: [PATCH] Fix compilation for Spending Key --- librustzcash-wrapper/src/lib.rs | 5 +++++ src/C/Zcash.chs | 6 +++--- src/ZcashHaskell/Sapling.hs | 20 ++++++++++---------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/librustzcash-wrapper/src/lib.rs b/librustzcash-wrapper/src/lib.rs index 045a7b9..702879b 100644 --- a/librustzcash-wrapper/src/lib.rs +++ b/librustzcash-wrapper/src/lib.rs @@ -612,9 +612,14 @@ pub extern "C" fn rust_wrapper_recover_seed( pub extern "C" fn rust_wrapper_sapling_spendingkey( input: *const u8, input_len: usize, + coin: u32, + acc_id: u32, out: *mut u8, out_len: &mut usize ){ + let seed: Vec = marshall_from_haskell_var(input, input_len, RW); + let fake_response = "It's working"; + marshall_to_haskell_var(&fake_response.as_bytes().to_vec(), out, out_len, RW); // - Retrieve parameters // let extsk = sapling::spending_key(&seed[0..32], diff --git a/src/C/Zcash.chs b/src/C/Zcash.chs index 0526a45..f0ad1b8 100644 --- a/src/C/Zcash.chs +++ b/src/C/Zcash.chs @@ -128,9 +128,9 @@ import ZcashHaskell.Types {# fun unsafe rust_wrapper_sapling_spendingkey as rustWrapperSaplingSpendingkey { toBorshVar* `BS.ByteString'& - , toBorshFixed Int - , toBorshFixed Int + , `Int' + , `Int' , getVarBuffer `Buffer (BS.ByteString)'& } -> `()' -#} \ No newline at end of file +#} diff --git a/src/ZcashHaskell/Sapling.hs b/src/ZcashHaskell/Sapling.hs index 1f564f9..81d6507 100644 --- a/src/ZcashHaskell/Sapling.hs +++ b/src/ZcashHaskell/Sapling.hs @@ -21,15 +21,16 @@ import C.Zcash ( rustWrapperIsShielded , rustWrapperSaplingCheck , rustWrapperSaplingNoteDecode + , rustWrapperSaplingSpendingkey , rustWrapperSaplingVkDecode , rustWrapperTxParse - , rustWrapperSaplingSpendingkey ) import Data.Aeson import qualified Data.ByteString as BS -import Data.ByteString.Lazy as BL +import Data.ByteString.Lazy as BL import Data.HexString (HexString(..), toBytes) -import Foreign.Rust.Marshall.Variable +import Data.Word +import Foreign.Rust.Marshall.Variable ( withPureBorshVarBuffer , withPureBorshVarBuffer ) @@ -37,12 +38,11 @@ import ZcashHaskell.Types ( DecodedNote(..) , RawData(..) , RawTxResponse(..) + , SaplingSKeyParams(..) , ShieldedOutput(..) , decodeHexText - , SaplingSKeyParams(..) ) -import ZcashHaskell.Utils -import Data.Word +import ZcashHaskell.Utils -- | Check if given bytesting is a valid encoded shielded address isValidShieldedAddress :: BS.ByteString -> Bool @@ -90,12 +90,12 @@ 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 -> Word32 -> Word32 -> Maybe BS.ByteString +genSaplingSpendingKey :: BS.ByteString -> Int -> Int -> Maybe BS.ByteString genSaplingSpendingKey seed coin_type account_id = do if BS.length res > 0 then Just res else Nothing where - res = (withPureBorshVarBuffer . rustWrapperSaplingSpendingkey) seed coin_type account_id - + res = + withPureBorshVarBuffer + (rustWrapperSaplingSpendingkey seed coin_type account_id)