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) <=>
|
||||
C.hCenter
|
||||
(hBox [capCommand "P" "roceed", capCommand "<esc> " "Cancel"]))
|
||||
(hBox [capCommand "P" "roceed", capCommand3 "" "<esc> " "Cancel"]))
|
||||
ShieldForm ->
|
||||
D.renderDialog
|
||||
(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)
|
||||
else displayTaz (st ^. tBalance) ++ "?") <=>
|
||||
C.hCenter
|
||||
(hBox [capCommand "P" "roceed", capCommand "<esc> " "Cancel"]))
|
||||
(hBox [capCommand "P" "roceed", capCommand3 "" "<esc> " "Cancel"]))
|
||||
ViewingKeyShow ->
|
||||
D.renderDialog
|
||||
(D.dialog
|
||||
|
@ -651,7 +651,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
|||
(str
|
||||
" _____ _ _ _ \n|__ /___ _ __ (_) |_| |__\n / // _ \\ '_ \\| | __| '_ \\\n / /| __/ | | | | |_| | | |\n/____\\___|_| |_|_|\\__|_| |_|") <=>
|
||||
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..."))
|
||||
else emptyWidget
|
||||
capCommand3 :: String -> String -> String -> Widget Name
|
||||
|
@ -854,29 +854,7 @@ mkDeshieldForm tbal =
|
|||
isAmountValid b i = fromIntegral b >= (i * scientific 1 8)
|
||||
label s 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 bal =
|
||||
newForm
|
||||
|
@ -884,11 +862,11 @@ mkShieldForm bal =
|
|||
editShowableFieldWithValidate shAmt AmtField (isAmountValid bal)
|
||||
]
|
||||
where
|
||||
isAmountValid :: Integer -> Float -> Bool
|
||||
isAmountValid :: Integer -> Scientific -> Bool
|
||||
isAmountValid b i = (fromIntegral b / 100000000.0) >= i
|
||||
label s w =
|
||||
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
|
||||
|
||||
--}
|
||||
mkNewABForm :: AdrBookEntry -> Form AdrBookEntry e Name
|
||||
mkNewABForm =
|
||||
newForm
|
||||
|
|
|
@ -311,20 +311,26 @@ parseQuery query = map (breakOn '=') (splitOn '&' query)
|
|||
-- Parse a ZIP-321 encoded string into a ZcashPayment structure
|
||||
parseZcashPayment :: String -> Either String ZcashPaymentURI
|
||||
parseZcashPayment input
|
||||
| not (T.isPrefixOf "zcash:" (T.pack input)) =
|
||||
Left "Invalid scheme: must start with 'zcash:'"
|
||||
| not (T.isPrefixOf "zcash:" (T.pack input)) = Left "Invalid scheme: must start with 'zcash:'"
|
||||
| otherwise =
|
||||
let (addrPart, queryPart) = break (== '?') (drop 6 input)
|
||||
queryParams = parseQuery (drop 1 queryPart)
|
||||
in Right
|
||||
ZcashPaymentURI
|
||||
let (addrPart, queryPart) = break (== '?') (drop 6 input)
|
||||
queryParams = parseQuery (drop 1 queryPart)
|
||||
in Right ZcashPaymentURI
|
||||
{ uriAddress = addrPart
|
||||
, uriAmount = lookup "amount" queryParams >>= readMaybe
|
||||
, uriMemo =
|
||||
case lookup "memo" queryParams of
|
||||
Just m ->
|
||||
T.pack (BC.unpack (processEither $ B64.decode $ BC.pack m))
|
||||
_ -> ""
|
||||
, uriLabel = lookup "label" queryParams
|
||||
, uriAmount = lookup "amount" queryParams >>= readMaybe
|
||||
, uriMemo = case lookup "memo" queryParams of
|
||||
Just m -> T.pack ( BC.unpack (processEither $ decodeBase64Unpadded (BC.pack m) ) )
|
||||
_ -> ""
|
||||
, uriLabel = lookup "label" 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