MJ6R42RCK2ASXAJ6QXDPMAW56RBOJ4F4HI2LFIV3KXFIKWYMQK3QC
HMDM3B557TO5RYP2IGFFC2C2VN6HYZTDQ47CJY2O37BW55DSMFZAC
2XQD6KKKD6QVHFHAEMVE3XXY7X2T7BLTLL7XIILZAXNJJH2YONUQC
64C6AWH66FDKU6UE6Z6JPX2J2GBM2JOPTH2GL6LHKAIUBGNGDZ5AC
NEDDHXUK3GNFMOFO3KLU7NRIHCTYNWBT3D6HTKZAOXFDE6HMDZ6AC
V2VDN77HCSRYYWXDJJ2XOVHV4P6PVWNJZLXZ7JUYPQEZQIH5BZ3QC
6L5BK5EHPAOQX3JCKUJ273UDNAC23LPQL4HIJGM4AV3P3QK5OKIQC
LCBJULKEU4I5FRUGYNRQSHXYLY5X3LRTSNWDCTZLS7YE4BBBDE6AC
DFOBMSAODB3NKW37B272ZXA2ML5HMIH3N3C4GT2DPEQS7ZFK4SNAC
Q5X5RYQLP5K7REYD6VLHOKC4W36ZELJYA45V6YFKTD5S6MPN3NDQC
, x509
, x509-store
readBtcConfig :: CT.Config -> IO BtcConfig
readBtcConfig cfg =
let parseNetwork :: String -> B.Network
parseNetwork "main" = B.MainNet
parseNetwork _ = B.TestNet
in (BtcConfig . parseNetwork) <$> C.require cfg "network"
readBillingConfig :: CT.Config -> IO BillingConfig
readBillingConfig cfg =
BillingConfig <$> (parseNetwork <$> C.require cfg "network")
<*> C.require cfg "signingKeyFile"
<*> C.require cfg "certsFile"
where parseNetwork :: String -> BT.Network
parseNetwork "main" = BT.MainNet
parseNetwork _ = BT.TestNet
toBillingConfig :: BillingConfig -> IO AP.BillingConfig
toBillingConfig c = do
privKeys <- readKeyFile (signingKeyFile c)
pkiEntries <- readSignedObject (certsFile c)
privKey <- case headMay privKeys of
Just (PrivKeyRSA k) -> pure k
Just (PrivKeyDSA _) -> fail "DSA keys not supported for payment request signing."
Nothing -> fail $ "No keys found in private key file " <> signingKeyFile c
let pkiData = BT.X509SHA256 . CertificateChain $ pkiEntries
pure $ AP.BillingConfig (network c) privKey pkiData