#57 - Sapling address in Human Readable format #57
2 changed files with 15 additions and 8 deletions
|
@ -157,17 +157,17 @@ decryptOrchardAction key encAction =
|
|||
chrToByteString :: [Char] -> C.ByteString
|
||||
chrToByteString = C.pack
|
||||
|
||||
getSaplingFromUA :: BS.ByteString -> T.Text
|
||||
getSaplingFromUA :: BS.ByteString -> Maybe T.Text
|
||||
getSaplingFromUA uadd = do
|
||||
let a = isValidUnifiedAddress uadd
|
||||
case a of
|
||||
Nothing -> "xxx"
|
||||
Nothing -> Nothing
|
||||
Just a -> do
|
||||
let sraw = s_rec a
|
||||
case sraw of
|
||||
Nothing -> "xxx"
|
||||
Nothing -> Nothing
|
||||
Just sraw -> do
|
||||
let net = ua_net a
|
||||
case net of
|
||||
MainNet -> encodeBech32 (chrToByteString sapPaymentAddressHrp) ( getBytes sraw )
|
||||
TestNet -> encodeBech32 (chrToByteString sapTestPaymentAddressHrp) ( getBytes sraw )
|
||||
MainNet -> Just $ encodeBech32 (chrToByteString sapPaymentAddressHrp) ( getBytes sraw )
|
||||
TestNet -> Just $ encodeBech32 (chrToByteString sapTestPaymentAddressHrp) ( getBytes sraw )
|
13
test/Spec.hs
13
test/Spec.hs
|
@ -844,11 +844,18 @@ main = do
|
|||
let tb = zt_tBundle t'
|
||||
print tb
|
||||
show tb `shouldNotBe` ""
|
||||
describe "Extract Sapling Address" $ do
|
||||
describe "Extract Sapling Address - UA Valid" $ do
|
||||
let sr = getSaplingFromUA "u14a5c4ufn9feqvxssnvscep29j5cse4gjpg0w3w5vjhafn74hg9k73xgnxqv6m255n23weggr6j97c8kdwvn4pkz7rz6my52z8248gjmr7knlw536tcurs5km7knqnzez4cywudt3q6shr553hurduvljfeqvfzgegenfjashslkz3y4ykhxel6mrjp9gsm9xk7k6kdxn9y84kccmv8l"
|
||||
it "Extract sapling address" $ do
|
||||
print sr
|
||||
sr `shouldBe` "zs1waxrpde36rlrjdwfhnvw030sn29lzwmvmeupd8x2uuqgypaafx7mqcy0ep8yf2xtg30n5424t60"
|
||||
case sr of
|
||||
Nothing -> assertFailure "UA invalid or does not contain a Sapling receiver"
|
||||
Just t -> do
|
||||
print t
|
||||
t `shouldBe` "zs1waxrpde36rlrjdwfhnvw030sn29lzwmvmeupd8x2uuqgypaafx7mqcy0ep8yf2xtg30n5424t60"
|
||||
describe "Extract Sapling Address - UA Invalid" $ do
|
||||
let sr = getSaplingFromUA "u14a5c4ufn9qfevxssnvscep29j5cse4gjpg0w3w5vjhafn74hg9k73xgnxqv6m255n23weggr6j97c8kdwvn4pkz7rz6my52z8248gjmr7knlw536tcurs5km7knqnzez4cywudt3q6shr553hurduvljfeqvfzgegenfjashslkz3y4ykhxel6mrjp9gsm9xk7k6kdxn9y84kccmv8l"
|
||||
it "Try to extract sapling address from invalid UA" $ do
|
||||
sr `shouldBe` Nothing
|
||||
|
||||
|
||||
-- | Properties
|
||||
|
|
Loading…
Reference in a new issue