RPC Server #103
3 changed files with 50 additions and 23 deletions
|
@ -108,7 +108,7 @@ import Zenith.Utils
|
|||
, displayZec
|
||||
, isRecipientValid
|
||||
, jsonNumber
|
||||
, parseAddress
|
||||
, parseAddressUA
|
||||
, showAddress
|
||||
, validBarValue
|
||||
)
|
||||
|
@ -618,16 +618,16 @@ mkInputForm =
|
|||
mkSendForm :: Integer -> SendInput -> Form SendInput e Name
|
||||
mkSendForm bal =
|
||||
newForm
|
||||
[ label "To: " @@= editTextField sendTo RecField (Just 1)
|
||||
[ label "Privacy Level :" @@=
|
||||
radioField policyField [ (Full, PrivacyFullField, "Full")
|
||||
, (Medium, PrivacyMediumField, "Medium")
|
||||
, (Low, PrivacyLowField, "Low")
|
||||
, (None, PrivacyNoneField, "None")
|
||||
]
|
||||
, label "To: " @@= editTextField sendTo RecField (Just 1)
|
||||
, label "Amount: " @@=
|
||||
editShowableFieldWithValidate sendAmt AmtField (isAmountValid bal)
|
||||
, label "Memo: " @@= editTextField sendMemo MemoField (Just 1)
|
||||
, label "Privacy Level :" @@=
|
||||
radioField policyField [ (None, PrivacyNoneField, "None")
|
||||
, (Low, PrivacyLowField, "Low")
|
||||
, (Medium, PrivacyMediumField, "Medium")
|
||||
, (Full, PrivacyFullField, "Full")
|
||||
]
|
||||
]
|
||||
where
|
||||
isAmountValid :: Integer -> Float -> Bool
|
||||
|
@ -1160,7 +1160,7 @@ appEvent (BT.VtyEvent e) = do
|
|||
(addressBookAbaddress (entityVal a))
|
||||
0.0
|
||||
""
|
||||
None)
|
||||
Full)
|
||||
BT.modify $ set dialogBox SendTx
|
||||
_ -> do
|
||||
BT.modify $
|
||||
|
@ -1332,7 +1332,7 @@ appEvent (BT.VtyEvent e) = do
|
|||
V.EvKey (V.KChar 's') [] -> do
|
||||
BT.modify $
|
||||
set txForm $
|
||||
mkSendForm (s ^. balance) (SendInput "" 0.0 "" None)
|
||||
mkSendForm (s ^. balance) (SendInput "" 0.0 "" Full)
|
||||
BT.modify $ set dialogBox SendTx
|
||||
V.EvKey (V.KChar 'b') [] ->
|
||||
BT.modify $ set dialogBox AdrBook
|
||||
|
@ -1467,7 +1467,7 @@ runZenithTUI config = do
|
|||
1.0
|
||||
eventChan
|
||||
0
|
||||
(mkSendForm 0 $ SendInput "" 0.0 "" None)
|
||||
(mkSendForm 0 $ SendInput "" 0.0 "" Full)
|
||||
(L.list ABList (Vec.fromList abookList) 1)
|
||||
(mkNewABForm (AdrBookEntry "" ""))
|
||||
""
|
||||
|
@ -1689,7 +1689,7 @@ sendTransaction ::
|
|||
-> IO ()
|
||||
sendTransaction pool chan zHost zPort znet accId bl amt ua memo = do
|
||||
BC.writeBChan chan $ TickMsg "Preparing transaction..."
|
||||
case parseAddress ua znet of
|
||||
case parseAddressUA ua znet of
|
||||
Nothing -> BC.writeBChan chan $ TickMsg "Incorrect address"
|
||||
Just outUA -> do
|
||||
res <-
|
||||
|
|
|
@ -57,7 +57,7 @@ import Zenith.Utils
|
|||
, isValidString
|
||||
, jsonNumber
|
||||
, padWithZero
|
||||
, parseAddress
|
||||
, parseAddressUA
|
||||
, showAddress
|
||||
, validBarValue
|
||||
)
|
||||
|
@ -1537,7 +1537,7 @@ sendTransaction ::
|
|||
-> IO ()
|
||||
sendTransaction config znet accId bl amt ua memo sendMsg = do
|
||||
sendMsg $ ShowModal "Preparing transaction..."
|
||||
case parseAddress ua znet of
|
||||
case parseAddressUA ua znet of
|
||||
Nothing -> sendMsg $ ShowError "Incorrect address"
|
||||
Just outUA -> do
|
||||
let dbPath = c_dbPath config
|
||||
|
|
|
@ -13,7 +13,7 @@ import qualified Data.Text.Encoding as E
|
|||
import System.Directory
|
||||
import System.Process (createProcess_, shell)
|
||||
import Text.Regex.Posix
|
||||
import ZcashHaskell.Orchard (encodeUnifiedAddress, isValidUnifiedAddress)
|
||||
import ZcashHaskell.Orchard (encodeUnifiedAddress, isValidUnifiedAddress, parseAddress)
|
||||
import ZcashHaskell.Sapling (decodeSaplingAddress, isValidShieldedAddress)
|
||||
import ZcashHaskell.Transparent
|
||||
( decodeExchangeAddress
|
||||
|
@ -148,12 +148,39 @@ isExchangeAddressValid xa =
|
|||
|
||||
isRecipientValidGUI :: PrivacyPolicy -> T.Text -> Bool
|
||||
isRecipientValidGUI p a = do
|
||||
let adr = parseAddress a
|
||||
let adr = parseAddress (E.encodeUtf8 a)
|
||||
case p of
|
||||
Full -> True
|
||||
Medium -> True
|
||||
Low -> False
|
||||
None -> False
|
||||
Full -> case adr of
|
||||
Just a ->
|
||||
case a of
|
||||
Unified ua -> True
|
||||
Sapling sa -> True
|
||||
_ -> False
|
||||
Nothing -> False
|
||||
Medium -> case adr of
|
||||
Just a ->
|
||||
case a of
|
||||
Unified ua -> True
|
||||
Sapling sa -> True
|
||||
_ -> False
|
||||
Nothing -> False
|
||||
Low -> case adr of
|
||||
Just a ->
|
||||
case a of
|
||||
Unified ua -> True
|
||||
Sapling sa -> True
|
||||
Transparent ta -> True
|
||||
Exchange ea -> True
|
||||
_ -> False
|
||||
Nothing -> False
|
||||
|
||||
None -> case adr of
|
||||
Just a ->
|
||||
case a of
|
||||
Transparent ta -> True
|
||||
Exchange ea -> True
|
||||
_ -> False
|
||||
Nothing -> False
|
||||
|
||||
isZecAddressValid :: T.Text -> Bool
|
||||
isZecAddressValid a = do
|
||||
|
@ -168,8 +195,8 @@ isZecAddressValid a = do
|
|||
Just _a4 -> True
|
||||
Nothing -> False)
|
||||
|
||||
parseAddress :: T.Text -> ZcashNet -> Maybe UnifiedAddress
|
||||
parseAddress a znet =
|
||||
parseAddressUA :: T.Text -> ZcashNet -> Maybe UnifiedAddress
|
||||
parseAddressUA a znet =
|
||||
case isValidUnifiedAddress (E.encodeUtf8 a) of
|
||||
Just a1 -> Just a1
|
||||
Nothing ->
|
||||
|
|
Loading…
Reference in a new issue