rvv001 - Synchronize branch with recent changes
This commit is contained in:
parent
cc4ce8a280
commit
ff6168b45e
2 changed files with 25 additions and 41 deletions
|
@ -512,7 +512,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
]) <=>
|
]) <=>
|
||||||
renderForm (st ^. deshieldForm) <=>
|
renderForm (st ^. deshieldForm) <=>
|
||||||
C.hCenter
|
C.hCenter
|
||||||
(hBox [capCommand "P" "roceed", capCommand "<esc> " "Cancel"]))
|
(hBox [capCommand "P" "roceed", capCommand3 "" "<esc> " "Cancel"]))
|
||||||
ShieldForm ->
|
ShieldForm ->
|
||||||
D.renderDialog
|
D.renderDialog
|
||||||
(D.dialog (Just (str " Shield ZEC ")) Nothing 50)
|
(D.dialog (Just (str " Shield ZEC ")) Nothing 50)
|
||||||
|
@ -523,7 +523,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
then displayZec (st ^. tBalance)
|
then displayZec (st ^. tBalance)
|
||||||
else displayTaz (st ^. tBalance) ++ "?") <=>
|
else displayTaz (st ^. tBalance) ++ "?") <=>
|
||||||
C.hCenter
|
C.hCenter
|
||||||
(hBox [capCommand "P" "roceed", capCommand "<esc> " "Cancel"]))
|
(hBox [capCommand "P" "roceed", capCommand3 "" "<esc> " "Cancel"]))
|
||||||
ViewingKeyShow ->
|
ViewingKeyShow ->
|
||||||
D.renderDialog
|
D.renderDialog
|
||||||
(D.dialog
|
(D.dialog
|
||||||
|
@ -651,7 +651,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
(str
|
(str
|
||||||
" _____ _ _ _ \n|__ /___ _ __ (_) |_| |__\n / // _ \\ '_ \\| | __| '_ \\\n / /| __/ | | | | |_| | | |\n/____\\___|_| |_|_|\\__|_| |_|") <=>
|
" _____ _ _ _ \n|__ /___ _ __ (_) |_| |__\n / // _ \\ '_ \\| | __| '_ \\\n / /| __/ | | | | |_| | | |\n/____\\___|_| |_|_|\\__|_| |_|") <=>
|
||||||
C.hCenter
|
C.hCenter
|
||||||
(withAttr titleAttr (str "Zcash Wallet v0.7.0.0-beta")) <=>
|
(withAttr titleAttr (str "Zcash Wallet v0.7.1.0-beta")) <=>
|
||||||
C.hCenter (withAttr blinkAttr $ str "Press any key..."))
|
C.hCenter (withAttr blinkAttr $ str "Press any key..."))
|
||||||
else emptyWidget
|
else emptyWidget
|
||||||
capCommand3 :: String -> String -> String -> Widget Name
|
capCommand3 :: String -> String -> String -> Widget Name
|
||||||
|
@ -854,29 +854,7 @@ mkDeshieldForm tbal =
|
||||||
isAmountValid b i = fromIntegral b >= (i * scientific 1 8)
|
isAmountValid b i = fromIntegral b >= (i * scientific 1 8)
|
||||||
label s w =
|
label s w =
|
||||||
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
|
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
|
||||||
|
{--
|
||||||
mkDeshieldForm :: Integer -> ShDshEntry -> Form ShDshEntry e Name
|
|
||||||
mkDeshieldForm bal =
|
|
||||||
newForm
|
|
||||||
[ label "Total Transp. : " @@=
|
|
||||||
editShowableFieldWithValidate
|
|
||||||
totalTransparent
|
|
||||||
TotalTranspField
|
|
||||||
(isAmountValid bal)
|
|
||||||
, label "Total Shielded : " @@=
|
|
||||||
editShowableFieldWithValidate
|
|
||||||
totalShielded
|
|
||||||
TotalShieldedField
|
|
||||||
(isAmountValid bal)
|
|
||||||
, label "Amount: " @@=
|
|
||||||
editShowableFieldWithValidate shAmt AmtField (isAmountValid bal)
|
|
||||||
]
|
|
||||||
where
|
|
||||||
isAmountValid :: Integer -> Float -> Bool
|
|
||||||
isAmountValid b i = (fromIntegral b / 100000000.0) >= i
|
|
||||||
label s w =
|
|
||||||
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
|
|
||||||
|
|
||||||
mkShieldForm :: Integer -> ShDshEntry -> Form ShDshEntry e Name
|
mkShieldForm :: Integer -> ShDshEntry -> Form ShDshEntry e Name
|
||||||
mkShieldForm bal =
|
mkShieldForm bal =
|
||||||
newForm
|
newForm
|
||||||
|
@ -884,11 +862,11 @@ mkShieldForm bal =
|
||||||
editShowableFieldWithValidate shAmt AmtField (isAmountValid bal)
|
editShowableFieldWithValidate shAmt AmtField (isAmountValid bal)
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
isAmountValid :: Integer -> Float -> Bool
|
isAmountValid :: Integer -> Scientific -> Bool
|
||||||
isAmountValid b i = (fromIntegral b / 100000000.0) >= i
|
isAmountValid b i = (fromIntegral b / 100000000.0) >= i
|
||||||
label s w =
|
label s w =
|
||||||
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
|
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
|
||||||
|
--}
|
||||||
mkNewABForm :: AdrBookEntry -> Form AdrBookEntry e Name
|
mkNewABForm :: AdrBookEntry -> Form AdrBookEntry e Name
|
||||||
mkNewABForm =
|
mkNewABForm =
|
||||||
newForm
|
newForm
|
||||||
|
|
|
@ -311,20 +311,26 @@ parseQuery query = map (breakOn '=') (splitOn '&' query)
|
||||||
-- Parse a ZIP-321 encoded string into a ZcashPayment structure
|
-- Parse a ZIP-321 encoded string into a ZcashPayment structure
|
||||||
parseZcashPayment :: String -> Either String ZcashPaymentURI
|
parseZcashPayment :: String -> Either String ZcashPaymentURI
|
||||||
parseZcashPayment input
|
parseZcashPayment input
|
||||||
| not (T.isPrefixOf "zcash:" (T.pack input)) =
|
| not (T.isPrefixOf "zcash:" (T.pack input)) = Left "Invalid scheme: must start with 'zcash:'"
|
||||||
Left "Invalid scheme: must start with 'zcash:'"
|
|
||||||
| otherwise =
|
| otherwise =
|
||||||
let (addrPart, queryPart) = break (== '?') (drop 6 input)
|
let (addrPart, queryPart) = break (== '?') (drop 6 input)
|
||||||
queryParams = parseQuery (drop 1 queryPart)
|
queryParams = parseQuery (drop 1 queryPart)
|
||||||
in Right
|
in Right ZcashPaymentURI
|
||||||
ZcashPaymentURI
|
|
||||||
{ uriAddress = addrPart
|
{ uriAddress = addrPart
|
||||||
, uriAmount = lookup "amount" queryParams >>= readMaybe
|
, uriAmount = lookup "amount" queryParams >>= readMaybe
|
||||||
, uriMemo =
|
, uriMemo = case lookup "memo" queryParams of
|
||||||
case lookup "memo" queryParams of
|
Just m -> T.pack ( BC.unpack (processEither $ decodeBase64Unpadded (BC.pack m) ) )
|
||||||
Just m ->
|
|
||||||
T.pack (BC.unpack (processEither $ B64.decode $ BC.pack m))
|
|
||||||
_ -> ""
|
_ -> ""
|
||||||
, uriLabel = lookup "label" queryParams
|
, uriLabel = lookup "label" queryParams
|
||||||
, uriMessage = lookup "message" queryParams
|
, uriMessage = lookup "message" queryParams
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Function to pad a base64 string if it's not a multiple of 4
|
||||||
|
padBase64 :: BC.ByteString -> BC.ByteString
|
||||||
|
padBase64 bs = bs <> BC.replicate paddingLength '='
|
||||||
|
where
|
||||||
|
paddingLength = (4 - BC.length bs `mod` 4) `mod` 4
|
||||||
|
|
||||||
|
-- Function to decode a base64 un-padded string
|
||||||
|
decodeBase64Unpadded :: BC.ByteString -> Either String BC.ByteString
|
||||||
|
decodeBase64Unpadded = B64.decode . padBase64
|
||||||
|
|
Loading…
Reference in a new issue