Add parameter for confirmation window
This commit is contained in:
parent
aff5e4f03d
commit
f632b48f32
4 changed files with 9 additions and 30 deletions
|
@ -26,6 +26,7 @@ data Config =
|
|||
, c_smtpPort :: Integer
|
||||
, c_smtpUser :: String
|
||||
, c_smtpPwd :: String
|
||||
, c_confirmations :: Integer
|
||||
}
|
||||
deriving (Eq, Show)
|
||||
|
||||
|
@ -48,6 +49,7 @@ loadZGoConfig path = do
|
|||
mailPort <- require config "smtpPort"
|
||||
mailUser <- require config "smtpUser"
|
||||
mailPwd <- require config "smtpPwd"
|
||||
conf <- require config "confirmations"
|
||||
return $
|
||||
Config
|
||||
dbHost
|
||||
|
@ -66,3 +68,4 @@ loadZGoConfig path = do
|
|||
mailPort
|
||||
mailUser
|
||||
mailPwd
|
||||
conf
|
||||
|
|
|
@ -1388,36 +1388,10 @@ listTxs user pwd a confs = do
|
|||
Just e -> return $ Left $ "Error reading transactions: " <> emessage e
|
||||
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
|
||||
isRelevant :: Text.Regex.Regex -> ZcashTx -> Bool
|
||||
isRelevant re t
|
||||
| zconfirmations t < 100 && (matchTest re . T.unpack . zmemo) t = True
|
||||
isRelevant :: Integer -> Text.Regex.Regex -> ZcashTx -> Bool
|
||||
isRelevant conf re t
|
||||
| zconfirmations t < conf && (matchTest re . T.unpack . zmemo) t = True
|
||||
| otherwise = False
|
||||
|
||||
-- | New function to scan transactions with parser
|
||||
|
@ -1447,7 +1421,7 @@ scanPayments config pipe = do
|
|||
case paidTxs of
|
||||
Right txs -> do
|
||||
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
|
||||
let j = map (getOrderId r) k
|
||||
mapM_ (recordPayment p (c_dbName config) z) j
|
||||
|
|
1
zgo.cfg
1
zgo.cfg
|
@ -6,6 +6,7 @@ dbUser = "zgo"
|
|||
dbPassword = "zcashrules"
|
||||
nodeUser = "zecwallet"
|
||||
nodePassword = "rdsxlun6v4a"
|
||||
confirmations = 100
|
||||
port = 3000
|
||||
tls = false
|
||||
certificate = "/path/to/cert.pem"
|
||||
|
|
|
@ -6,6 +6,7 @@ dbUser = "zgo"
|
|||
dbPassword = "zcashrules"
|
||||
nodeUser = "zecwallet"
|
||||
nodePassword = "rdsxlun6v4a"
|
||||
confirmations = 100
|
||||
port = 3000
|
||||
tls = false
|
||||
certificate = "/path/to/cert.pem"
|
||||
|
|
Loading…
Reference in a new issue