Branch rvv040 - Get Sapling Human Readable representation - In proccess

Bug - Bech32m error calculating checksum - to resolve
This commit is contained in:
Rene V. Vergara A. 2024-04-09 20:23:16 -04:00
parent 817c52dacf
commit 1f8a4cbd2b
3 changed files with 25 additions and 0 deletions

View file

@ -153,3 +153,21 @@ decryptOrchardAction key encAction =
decodedAction = decodedAction =
withPureBorshVarBuffer $ withPureBorshVarBuffer $
rustWrapperOrchardNoteDecode (o_key key) encAction rustWrapperOrchardNoteDecode (o_key key) encAction
chrToByteString :: [Char] -> C.ByteString
chrToByteString = C.pack
getSaplingFromUA :: BS.ByteString -> T.Text
getSaplingFromUA uadd = do
let a = isValidUnifiedAddress uadd
case a of
Nothing -> "xxx"
Just a -> do
let sraw = s_rec a
case sraw of
Nothing -> "xxx"
Just sraw -> do
let net = ua_net a
case net of
MainNet -> encodeBech32m (chrToByteString sapPaymentAddressHrp) ( getBytes sraw )
TestNet -> encodeBech32m (chrToByteString sapTestPaymentAddressHrp) ( getBytes sraw )

View file

@ -115,3 +115,4 @@ readZebraTransaction hex =
else Just rawTx else Just rawTx
where where
rawTx = (withPureBorshVarBuffer . rustWrapperTxRead) $ hexBytes hex rawTx = (withPureBorshVarBuffer . rustWrapperTxRead) $ hexBytes hex

View file

@ -844,6 +844,12 @@ main = do
let tb = zt_tBundle t' let tb = zt_tBundle t'
print tb print tb
show tb `shouldNotBe` "" show tb `shouldNotBe` ""
describe "Extract Sapling Address" $ do
let sr = getSaplingFromUA "u1y3224rl7f5tz262apkmj33z6pe5rn3z4y6pqtces45valg9qsvuer688crr8xvvqq4u7umhrvt0qaj5jv05ec7jd66qedq97dvrhhzryq69lrm8mc25ql0zt6yk2yks9zyp0qv7tgtfqw5zgl7q3p660v37f0ra5aj2g8y75mrzkgrgr8fl5cmur07tcqcrvzf96t4ennh45vnxemp8"
it "Extract sapling address" $ do
print sr
sr `shouldBe` "zs1algtrzkczkl5708yaw2sr58jkutm8wcx2tj0a9ex3ns8nu8l3wtlusemfcpllnfmhyhw7vk9m0h"
-- | Properties -- | Properties
prop_PhraseLength :: Property prop_PhraseLength :: Property