Sapling Spending keys and receivers #27
3 changed files with 18 additions and 13 deletions
|
@ -612,9 +612,14 @@ pub extern "C" fn rust_wrapper_recover_seed(
|
||||||
pub extern "C" fn rust_wrapper_sapling_spendingkey(
|
pub extern "C" fn rust_wrapper_sapling_spendingkey(
|
||||||
input: *const u8,
|
input: *const u8,
|
||||||
input_len: usize,
|
input_len: usize,
|
||||||
|
coin: u32,
|
||||||
|
acc_id: u32,
|
||||||
out: *mut u8,
|
out: *mut u8,
|
||||||
out_len: &mut usize
|
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
|
// - Retrieve parameters
|
||||||
|
|
||||||
// let extsk = sapling::spending_key(&seed[0..32],
|
// let extsk = sapling::spending_key(&seed[0..32],
|
||||||
|
|
|
@ -128,9 +128,9 @@ 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'&
|
||||||
, toBorshFixed Int
|
, `Int'
|
||||||
, toBorshFixed Int
|
, `Int'
|
||||||
, getVarBuffer `Buffer (BS.ByteString)'&
|
, getVarBuffer `Buffer (BS.ByteString)'&
|
||||||
}
|
}
|
||||||
-> `()'
|
-> `()'
|
||||||
#}
|
#}
|
||||||
|
|
|
@ -21,15 +21,16 @@ import C.Zcash
|
||||||
( rustWrapperIsShielded
|
( rustWrapperIsShielded
|
||||||
, rustWrapperSaplingCheck
|
, rustWrapperSaplingCheck
|
||||||
, rustWrapperSaplingNoteDecode
|
, rustWrapperSaplingNoteDecode
|
||||||
|
, rustWrapperSaplingSpendingkey
|
||||||
, rustWrapperSaplingVkDecode
|
, rustWrapperSaplingVkDecode
|
||||||
, rustWrapperTxParse
|
, rustWrapperTxParse
|
||||||
, rustWrapperSaplingSpendingkey
|
|
||||||
)
|
)
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
import qualified Data.ByteString as BS
|
import qualified Data.ByteString as BS
|
||||||
import Data.ByteString.Lazy as BL
|
import Data.ByteString.Lazy as BL
|
||||||
import Data.HexString (HexString(..), toBytes)
|
import Data.HexString (HexString(..), toBytes)
|
||||||
import Foreign.Rust.Marshall.Variable
|
import Data.Word
|
||||||
|
import Foreign.Rust.Marshall.Variable
|
||||||
( withPureBorshVarBuffer
|
( withPureBorshVarBuffer
|
||||||
, withPureBorshVarBuffer
|
, withPureBorshVarBuffer
|
||||||
)
|
)
|
||||||
|
@ -37,12 +38,11 @@ import ZcashHaskell.Types
|
||||||
( DecodedNote(..)
|
( DecodedNote(..)
|
||||||
, RawData(..)
|
, RawData(..)
|
||||||
, RawTxResponse(..)
|
, RawTxResponse(..)
|
||||||
|
, SaplingSKeyParams(..)
|
||||||
, ShieldedOutput(..)
|
, ShieldedOutput(..)
|
||||||
, decodeHexText
|
, decodeHexText
|
||||||
, SaplingSKeyParams(..)
|
|
||||||
)
|
)
|
||||||
import ZcashHaskell.Utils
|
import ZcashHaskell.Utils
|
||||||
import Data.Word
|
|
||||||
|
|
||||||
-- | Check if given bytesting is a valid encoded shielded address
|
-- | Check if given bytesting is a valid encoded shielded address
|
||||||
isValidShieldedAddress :: BS.ByteString -> Bool
|
isValidShieldedAddress :: BS.ByteString -> Bool
|
||||||
|
@ -90,12 +90,12 @@ 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 ::
|
genSaplingSpendingKey :: BS.ByteString -> Int -> Int -> Maybe BS.ByteString
|
||||||
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
|
||||||
else Nothing
|
else Nothing
|
||||||
where
|
where
|
||||||
res = (withPureBorshVarBuffer . rustWrapperSaplingSpendingkey) seed coin_type account_id
|
res =
|
||||||
|
withPureBorshVarBuffer
|
||||||
|
(rustWrapperSaplingSpendingkey seed coin_type account_id)
|
||||||
|
|
Loading…
Reference in a new issue