Update Zebra block deserialization for block time #48
5 changed files with 996 additions and 20 deletions
969
librustzcash-wrapper/Cargo.lock
generated
969
librustzcash-wrapper/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -17,6 +17,9 @@ zcash_primitives = "0.13.0"
|
||||||
zcash_client_backend = "0.10.0"
|
zcash_client_backend = "0.10.0"
|
||||||
zip32 = "0.1.0"
|
zip32 = "0.1.0"
|
||||||
proc-macro2 = "1.0.66"
|
proc-macro2 = "1.0.66"
|
||||||
|
reqwest = "0.12.1"
|
||||||
|
tokio = { version="1.36.0", features = ["full"] }
|
||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
capi = []
|
capi = []
|
||||||
|
|
|
@ -66,6 +66,7 @@ use zcash_client_backend::keys::sapling::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use zcash_primitives::zip32::DiversifierIndex;
|
use zcash_primitives::zip32::DiversifierIndex;
|
||||||
|
use zcash_primitives::block::BlockHeader;
|
||||||
|
|
||||||
use orchard::{
|
use orchard::{
|
||||||
Action,
|
Action,
|
||||||
|
|
|
@ -102,3 +102,42 @@ makeZebraCall host port m params = do
|
||||||
case result zebraResp of
|
case result zebraResp of
|
||||||
Nothing -> return $ Left "Empty response from Zebra"
|
Nothing -> return $ Left "Empty response from Zebra"
|
||||||
Just zR -> return $ Right zR
|
Just zR -> return $ Right zR
|
||||||
|
|
||||||
|
-- |
|
||||||
|
hexDigitToInt :: Char -> Int
|
||||||
|
hexDigitToInt x = case x of
|
||||||
|
'0' -> 0
|
||||||
|
'1' -> 1
|
||||||
|
'2' -> 2
|
||||||
|
'3' -> 3
|
||||||
|
'4' -> 4
|
||||||
|
'5' -> 5
|
||||||
|
'6' -> 6
|
||||||
|
'7' -> 7
|
||||||
|
'8' -> 8
|
||||||
|
'9' -> 9
|
||||||
|
'a' -> 10
|
||||||
|
'b' -> 11
|
||||||
|
'c' -> 12
|
||||||
|
'd' -> 13
|
||||||
|
'e' -> 14
|
||||||
|
'f' -> 15
|
||||||
|
'A' -> 10
|
||||||
|
'B' -> 11
|
||||||
|
'C' -> 12
|
||||||
|
'D' -> 13
|
||||||
|
'E' -> 14
|
||||||
|
'F' -> 15
|
||||||
|
|
||||||
|
hexStringToInt :: String -> Int -> Int -> Int
|
||||||
|
hexStringToInt [] val _ = val
|
||||||
|
hexStringToInt (x:y:xs) val e =
|
||||||
|
hexStringToInt xs (val + ((hexDigitToInt x)*16 + (hexDigitToInt y))*256^e) (e+1)
|
||||||
|
|
||||||
|
|
||||||
|
getBlockTime :: String -> Int
|
||||||
|
getBlockTime hex_block = do
|
||||||
|
let hex_date = take 8 (drop 200 hex_block)
|
||||||
|
hexStringToInt hex_date 0 0
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -765,6 +765,10 @@ main = do
|
||||||
let bscAdr = SaplingReceiver $ BS.pack cAdr
|
let bscAdr = SaplingReceiver $ BS.pack cAdr
|
||||||
let ca = genSaplingInternalAddress (SaplingSpendingKey $ BS.pack sk)
|
let ca = genSaplingInternalAddress (SaplingSpendingKey $ BS.pack sk)
|
||||||
fromMaybe (SaplingReceiver "") ca `shouldBe` bscAdr
|
fromMaybe (SaplingReceiver "") ca `shouldBe` bscAdr
|
||||||
|
describe "Call zebra to get Block data" $ do
|
||||||
|
it "Call genBlockResponse" $ do
|
||||||
|
let blkdata <- genBlockResponse
|
||||||
|
return $ Just blkdata `shouldBe` ""
|
||||||
|
|
||||||
-- | Properties
|
-- | Properties
|
||||||
prop_PhraseLength :: Property
|
prop_PhraseLength :: Property
|
||||||
|
|
Loading…
Reference in a new issue