Add parameter for confirmation window

This commit is contained in:
Rene Vergara 2023-06-20 07:54:24 -05:00
parent aff5e4f03d
commit f632b48f32
Signed by: pitmutt
GPG Key ID: 65122AD495A7F5B2
4 changed files with 9 additions and 30 deletions

View File

@ -26,6 +26,7 @@ data Config =
, c_smtpPort :: Integer , c_smtpPort :: Integer
, c_smtpUser :: String , c_smtpUser :: String
, c_smtpPwd :: String , c_smtpPwd :: String
, c_confirmations :: Integer
} }
deriving (Eq, Show) deriving (Eq, Show)
@ -48,6 +49,7 @@ loadZGoConfig path = do
mailPort <- require config "smtpPort" mailPort <- require config "smtpPort"
mailUser <- require config "smtpUser" mailUser <- require config "smtpUser"
mailPwd <- require config "smtpPwd" mailPwd <- require config "smtpPwd"
conf <- require config "confirmations"
return $ return $
Config Config
dbHost dbHost
@ -66,3 +68,4 @@ loadZGoConfig path = do
mailPort mailPort
mailUser mailUser
mailPwd mailPwd
conf

View File

@ -1388,36 +1388,10 @@ listTxs user pwd a confs = do
Just e -> return $ Left $ "Error reading transactions: " <> emessage e Just e -> return $ Left $ "Error reading transactions: " <> emessage e
Left ex -> return $ Left $ (T.pack . show) ex Left ex -> return $ Left $ (T.pack . show) ex
-- | Function to check the ZGo full node for new txs
scanZcash :: Config -> Pipe -> IO ()
scanZcash config pipe = do
myTxs <-
listTxs (c_nodeUser config) (c_nodePwd config) (c_nodeAddress config) 1
case myTxs of
Right txs -> do
let r =
mkRegex
".*ZGO::([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12})\\sReply-To:\\s(zs[a-z0-9]{76}).*"
let p =
mkRegex
".*ZGOp::([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}).*"
let y =
mkRegex
".*MSG\\s(zs[a-z0-9]{76})\\s+ZGO::([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}).*"
let k = map zToZGoTx (filter (isRelevant r) txs)
mapM_ (access pipe master (c_dbName config) . upsertZGoTx "txs") k
let j = map zToZGoTx (filter (isRelevant p) txs)
mapM_ (upsertPayment pipe (c_dbName config)) j
let l = map zToZGoTx (filter (isRelevant y) txs)
mapM_ (access pipe master (c_dbName config) . upsertZGoTx "txs") l
Left e -> do
putStrLn $ "Error scanning node transactions: " ++ T.unpack e
return ()
-- | Function to filter transactions -- | Function to filter transactions
isRelevant :: Text.Regex.Regex -> ZcashTx -> Bool isRelevant :: Integer -> Text.Regex.Regex -> ZcashTx -> Bool
isRelevant re t isRelevant conf re t
| zconfirmations t < 100 && (matchTest re . T.unpack . zmemo) t = True | zconfirmations t < conf && (matchTest re . T.unpack . zmemo) t = True
| otherwise = False | otherwise = False
-- | New function to scan transactions with parser -- | New function to scan transactions with parser
@ -1447,7 +1421,7 @@ scanPayments config pipe = do
case paidTxs of case paidTxs of
Right txs -> do Right txs -> do
let r = mkRegex ".*ZGo Order::([0-9a-fA-F]{24}).*" let r = mkRegex ".*ZGo Order::([0-9a-fA-F]{24}).*"
let k = filter (isRelevant r) txs let k = filter (isRelevant (c_confirmations c) r) txs
print k print k
let j = map (getOrderId r) k let j = map (getOrderId r) k
mapM_ (recordPayment p (c_dbName config) z) j mapM_ (recordPayment p (c_dbName config) z) j

View File

@ -6,6 +6,7 @@ dbUser = "zgo"
dbPassword = "zcashrules" dbPassword = "zcashrules"
nodeUser = "zecwallet" nodeUser = "zecwallet"
nodePassword = "rdsxlun6v4a" nodePassword = "rdsxlun6v4a"
confirmations = 100
port = 3000 port = 3000
tls = false tls = false
certificate = "/path/to/cert.pem" certificate = "/path/to/cert.pem"

View File

@ -6,6 +6,7 @@ dbUser = "zgo"
dbPassword = "zcashrules" dbPassword = "zcashrules"
nodeUser = "zecwallet" nodeUser = "zecwallet"
nodePassword = "rdsxlun6v4a" nodePassword = "rdsxlun6v4a"
confirmations = 100
port = 3000 port = 3000
tls = false tls = false
certificate = "/path/to/cert.pem" certificate = "/path/to/cert.pem"