Fix compilation for Spending Key #19

Merged
pitmutt merged 1 commit from rvv040b into rvv040 2024-03-05 18:22:12 +00:00
3 changed files with 18 additions and 13 deletions
Showing only changes of commit 9acbe5b98c - Show all commits

View file

@ -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<u8> = 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],

View file

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

View file

@ -21,14 +21,15 @@ 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.HexString (HexString(..), toBytes)
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
-- | 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)