Unified Address support #8
3 changed files with 24 additions and 20 deletions
|
@ -1176,19 +1176,20 @@ routes pipe config = do
|
||||||
case cast' . Doc =<< u of
|
case cast' . Doc =<< u of
|
||||||
Nothing -> status unauthorized401
|
Nothing -> status unauthorized401
|
||||||
Just u' -> do
|
Just u' -> do
|
||||||
if isValidSaplingViewingKey qBytes
|
if isValidSaplingViewingKey $ C.pack q
|
||||||
then if matchSaplingAddress
|
then do
|
||||||
qBytes
|
if matchSaplingAddress
|
||||||
(bytes . decodeBech32 . C.pack . T.unpack $ uaddress u')
|
qBytes
|
||||||
then do
|
(bytes . decodeBech32 . C.pack . T.unpack $ uaddress u')
|
||||||
owner <- liftAndCatchIO $ run (findOwner $ uaddress u')
|
then do
|
||||||
case cast' . Doc =<< owner of
|
owner <- liftAndCatchIO $ run (findOwner $ uaddress u')
|
||||||
Nothing -> status badRequest400
|
case cast' . Doc =<< owner of
|
||||||
Just o' -> do
|
Nothing -> status badRequest400
|
||||||
unless (oviewkey o' /= "") $ do
|
Just o' -> do
|
||||||
liftAndCatchIO $ run (upsertViewingKey o' q)
|
unless (oviewkey o' /= "") $ do
|
||||||
status created201
|
liftAndCatchIO $ run (upsertViewingKey o' q)
|
||||||
else status forbidden403
|
status created201
|
||||||
|
else status forbidden403
|
||||||
else case decodeUfvk (C.pack q) of
|
else case decodeUfvk (C.pack q) of
|
||||||
Nothing -> status badRequest400
|
Nothing -> status badRequest400
|
||||||
Just fvk ->
|
Just fvk ->
|
||||||
|
|
|
@ -157,7 +157,7 @@ pMsg = do
|
||||||
pMemo :: Parser MemoToken
|
pMemo :: Parser MemoToken
|
||||||
pMemo = do
|
pMemo = do
|
||||||
optional $ some spaceChar
|
optional $ some spaceChar
|
||||||
t <- pSession <|> pSaplingAddress <|> pMsg
|
t <- pSession <|> pSaplingAddress <|> pUnifiedAddress <|> pMsg
|
||||||
optional $ some spaceChar
|
optional $ some spaceChar
|
||||||
return t
|
return t
|
||||||
|
|
||||||
|
|
15
test/Spec.hs
15
test/Spec.hs
|
@ -101,8 +101,9 @@ main = do
|
||||||
case m of
|
case m of
|
||||||
Left e -> putStrLn $ errorBundlePretty e
|
Left e -> putStrLn $ errorBundlePretty e
|
||||||
Right m' ->
|
Right m' ->
|
||||||
m_session m' `shouldBe`
|
m_address m' `shouldBe`
|
||||||
U.fromString "5d3d4494-51c0-432d-8495-050419957aea"
|
Just
|
||||||
|
"u17n7hpwaujyq7ux8f9jpyymtnk5urw7pyrf60smp5mawy7jgz325hfvz3jn3zsfya8yxryf9q7ldk8nu8df0emra5wne28zq9d9nm2pu4x6qwjha565av9aze0xgujgslz74ufkj0c0cylqwjyrh9msjfh7jzal6d3qzrnhkkqy3pqm8j63y07jxj7txqeac982778rmt64f32aum94x"
|
||||||
it "parse YWallet memo - Orchard" $ do
|
it "parse YWallet memo - Orchard" $ do
|
||||||
let m =
|
let m =
|
||||||
runParser
|
runParser
|
||||||
|
@ -112,8 +113,9 @@ main = do
|
||||||
case m of
|
case m of
|
||||||
Left e -> putStrLn $ errorBundlePretty e
|
Left e -> putStrLn $ errorBundlePretty e
|
||||||
Right m' ->
|
Right m' ->
|
||||||
m_session m' `shouldBe`
|
m_address m' `shouldBe`
|
||||||
U.fromString "ad8477d3-4fdd-4c97-90b2-76630b5f77e1"
|
Just
|
||||||
|
"u17n7hpwaujyq7ux8f9jpyymtnk5urw7pyrf60smp5mawy7jgz325hfvz3jn3zsfya8yxryf9q7ldk8nu8df0emra5wne28zq9d9nm2pu4x6qwjha565av9aze0xgujgslz74ufkj0c0cylqwjyrh9msjfh7jzal6d3qzrnhkkqy3pqm8j63y07jxj7txqeac982778rmt64f32aum94x"
|
||||||
it "parse Zingo memo - Orchard" $ do
|
it "parse Zingo memo - Orchard" $ do
|
||||||
let m =
|
let m =
|
||||||
runParser
|
runParser
|
||||||
|
@ -123,8 +125,9 @@ main = do
|
||||||
case m of
|
case m of
|
||||||
Left e -> putStrLn $ errorBundlePretty e
|
Left e -> putStrLn $ errorBundlePretty e
|
||||||
Right m' ->
|
Right m' ->
|
||||||
m_session m' `shouldBe`
|
m_address m' `shouldBe`
|
||||||
U.fromString "5d3d4494-51c0-432d-8495-050419957aea"
|
Just
|
||||||
|
"u17n7hpwaujyq7ux8f9jpyymtnk5urw7pyrf60smp5mawy7jgz325hfvz3jn3zsfya8yxryf9q7ldk8nu8df0emra5wne28zq9d9nm2pu4x6qwjha565av9aze0xgujgslz74ufkj0c0cylqwjyrh9msjfh7jzal6d3qzrnhkkqy3pqm8j63y07jxj7txqeac982778rmt64f32aum94x"
|
||||||
describe "PIN generator" $ do
|
describe "PIN generator" $ do
|
||||||
it "should give a 7 digit" $ do
|
it "should give a 7 digit" $ do
|
||||||
pin <- generatePin
|
pin <- generatePin
|
||||||
|
|
Loading…
Reference in a new issue