Fix payment scan
This commit is contained in:
parent
aa81880c65
commit
54a8c2e183
3 changed files with 24 additions and 5 deletions
|
@ -6,8 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- New `Config` type to house the configuration parameters
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
- Refactored code to use new `Config` type
|
||||||
- Enhance `decodeHexText` to support Unicode
|
- Enhance `decodeHexText` to support Unicode
|
||||||
- Enhance `encodeHexText` to support Unicode
|
- Enhance `encodeHexText` to support Unicode
|
||||||
- Update tests for encode/decode of memos
|
- Update tests for encode/decode of memos
|
||||||
|
@ -15,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed test for looking for an order with incorrect ID
|
- Fixed test for looking for an order with incorrect ID
|
||||||
|
- Fixed payment scan to focus only on new transactions
|
||||||
|
|
||||||
## [0.1.0.2] - 2022-05-25
|
## [0.1.0.2] - 2022-05-25
|
||||||
|
|
||||||
|
|
14
src/Owner.hs
14
src/Owner.hs
|
@ -37,11 +37,12 @@ data Owner =
|
||||||
, ozats :: Bool
|
, ozats :: Bool
|
||||||
, oinvoices :: Bool
|
, oinvoices :: Bool
|
||||||
, oexpiration :: UTCTime
|
, oexpiration :: UTCTime
|
||||||
|
, oviewkey :: T.Text
|
||||||
}
|
}
|
||||||
deriving (Eq, Show, Generic, Typeable)
|
deriving (Eq, Show, Generic, Typeable)
|
||||||
|
|
||||||
instance ToJSON Owner where
|
instance ToJSON Owner where
|
||||||
toJSON (Owner i a n c t tV v vV f l e s ct st p ph w co paid zats inv eTs) =
|
toJSON (Owner i a n c t tV v vV f l e s ct st p ph w co paid zats inv eTs vk) =
|
||||||
case i of
|
case i of
|
||||||
Just oid ->
|
Just oid ->
|
||||||
object
|
object
|
||||||
|
@ -67,6 +68,7 @@ instance ToJSON Owner where
|
||||||
, "zats" .= zats
|
, "zats" .= zats
|
||||||
, "invoices" .= inv
|
, "invoices" .= inv
|
||||||
, "expiration" .= eTs
|
, "expiration" .= eTs
|
||||||
|
, "viewKey" .= vk
|
||||||
]
|
]
|
||||||
Nothing ->
|
Nothing ->
|
||||||
object
|
object
|
||||||
|
@ -92,6 +94,7 @@ instance ToJSON Owner where
|
||||||
, "zats" .= zats
|
, "zats" .= zats
|
||||||
, "invoices" .= inv
|
, "invoices" .= inv
|
||||||
, "expiration" .= eTs
|
, "expiration" .= eTs
|
||||||
|
, "viewKey" .= vk
|
||||||
]
|
]
|
||||||
|
|
||||||
instance FromJSON Owner where
|
instance FromJSON Owner where
|
||||||
|
@ -119,6 +122,7 @@ instance FromJSON Owner where
|
||||||
zats <- obj .: "zats"
|
zats <- obj .: "zats"
|
||||||
inv <- obj .: "invoices"
|
inv <- obj .: "invoices"
|
||||||
ets <- obj .: "expiration"
|
ets <- obj .: "expiration"
|
||||||
|
vk <- obj .: "viewKey"
|
||||||
pure $
|
pure $
|
||||||
Owner
|
Owner
|
||||||
(if not (null i)
|
(if not (null i)
|
||||||
|
@ -145,6 +149,7 @@ instance FromJSON Owner where
|
||||||
zats
|
zats
|
||||||
inv
|
inv
|
||||||
ets
|
ets
|
||||||
|
vk
|
||||||
|
|
||||||
instance Val Owner where
|
instance Val Owner where
|
||||||
cast' (Doc d) = do
|
cast' (Doc d) = do
|
||||||
|
@ -170,9 +175,10 @@ instance Val Owner where
|
||||||
zats <- B.lookup "zats" d
|
zats <- B.lookup "zats" d
|
||||||
inv <- B.lookup "invoices" d
|
inv <- B.lookup "invoices" d
|
||||||
ets <- B.lookup "expiration" d
|
ets <- B.lookup "expiration" d
|
||||||
Just (Owner i a n c t tV v vV f l e s ct st p ph w co paid zats inv ets)
|
vk <- B.lookup "viewKey" d
|
||||||
|
Just (Owner i a n c t tV v vV f l e s ct st p ph w co paid zats inv ets vk)
|
||||||
cast' _ = Nothing
|
cast' _ = Nothing
|
||||||
val (Owner i a n c t tV v vV f l e s ct st p ph w co paid zats inv ets) =
|
val (Owner i a n c t tV v vV f l e s ct st p ph w co paid zats inv ets vk) =
|
||||||
case i of
|
case i of
|
||||||
Just oid ->
|
Just oid ->
|
||||||
Doc
|
Doc
|
||||||
|
@ -198,6 +204,7 @@ instance Val Owner where
|
||||||
, "zats" =: zats
|
, "zats" =: zats
|
||||||
, "invoices" =: inv
|
, "invoices" =: inv
|
||||||
, "expiration" =: ets
|
, "expiration" =: ets
|
||||||
|
, "viewKey" =: vk
|
||||||
]
|
]
|
||||||
Nothing ->
|
Nothing ->
|
||||||
Doc
|
Doc
|
||||||
|
@ -222,6 +229,7 @@ instance Val Owner where
|
||||||
, "zats" =: zats
|
, "zats" =: zats
|
||||||
, "invoices" =: inv
|
, "invoices" =: inv
|
||||||
, "expiration" =: ets
|
, "expiration" =: ets
|
||||||
|
, "viewKey" =: vk
|
||||||
]
|
]
|
||||||
|
|
||||||
-- Database actions
|
-- Database actions
|
||||||
|
|
|
@ -583,10 +583,15 @@ scanZcash config pipe = do
|
||||||
let p =
|
let p =
|
||||||
mkRegex
|
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}).*"
|
".*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 k = map zToZGoTx (filter (matchTest r . T.unpack . zmemo) txs)
|
let k = map zToZGoTx (filter (isRelevant r) txs)
|
||||||
mapM_ (access pipe master (c_dbName config) . upsertZGoTx "txs") k
|
mapM_ (access pipe master (c_dbName config) . upsertZGoTx "txs") k
|
||||||
let j = map zToZGoTx (filter (matchTest p . T.unpack . zmemo) txs)
|
let j = map zToZGoTx (filter (isRelevant p) txs)
|
||||||
mapM_ (access pipe master (c_dbName config) . upsertPayment) j
|
mapM_ (access pipe master (c_dbName config) . upsertPayment) j
|
||||||
|
where
|
||||||
|
isRelevant :: Text.Regex.Regex -> ZcashTx -> Bool
|
||||||
|
isRelevant re t
|
||||||
|
| zconfirmations t < 10 && (matchTest re . T.unpack . zmemo) t = True
|
||||||
|
| otherwise = False
|
||||||
|
|
||||||
-- | Function to generate users from login txs
|
-- | Function to generate users from login txs
|
||||||
updateLogins :: Pipe -> Config -> IO ()
|
updateLogins :: Pipe -> Config -> IO ()
|
||||||
|
|
Loading…
Reference in a new issue