{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
module Cardano.CLI.Byron.Run
( ByronClientCmdError
, renderByronClientCmdError
, runByronClientCommand
)
where
import Cardano.Api hiding (GenesisParameters, UpdateProposal, txId)
import Cardano.Api.Byron
( SigningKey (ByronSigningKey, ByronSigningKeyLegacy)
, SomeByronSigningKey (..)
, VerificationKey (ByronVerificationKey)
)
import Cardano.Api.Byron qualified as Byron
import Cardano.CLI.Byron.Command
import Cardano.CLI.Byron.Delegation
import Cardano.CLI.Byron.Genesis
import Cardano.CLI.Byron.Key
import Cardano.CLI.Byron.Tx
import Cardano.CLI.Byron.UpdateProposal
import Cardano.CLI.Byron.Vote
import Cardano.CLI.Compatible.Exception
import Cardano.CLI.Helper
import Cardano.CLI.Type.Common
import Cardano.Crypto.Hashing qualified as Crypto
import Cardano.Crypto.Signing qualified as Crypto
import Data.ByteString.Char8 qualified as BS
import Data.Text.IO qualified as Text
import Data.Text.Lazy.Builder qualified as Builder
import Data.Text.Lazy.IO qualified as TL
import Formatting qualified as F
newtype ByronClientCmdError
= ByronCmdKeyFailure ByronKeyFailure
deriving Int -> ByronClientCmdError -> ShowS
[ByronClientCmdError] -> ShowS
ByronClientCmdError -> String
(Int -> ByronClientCmdError -> ShowS)
-> (ByronClientCmdError -> String)
-> ([ByronClientCmdError] -> ShowS)
-> Show ByronClientCmdError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ByronClientCmdError -> ShowS
showsPrec :: Int -> ByronClientCmdError -> ShowS
$cshow :: ByronClientCmdError -> String
show :: ByronClientCmdError -> String
$cshowList :: [ByronClientCmdError] -> ShowS
showList :: [ByronClientCmdError] -> ShowS
Show
instance Error ByronClientCmdError where
prettyError :: forall ann. ByronClientCmdError -> Doc ann
prettyError = ByronClientCmdError -> Doc ann
forall ann. ByronClientCmdError -> Doc ann
renderByronClientCmdError
renderByronClientCmdError :: ByronClientCmdError -> Doc ann
renderByronClientCmdError :: forall ann. ByronClientCmdError -> Doc ann
renderByronClientCmdError = \case
ByronCmdKeyFailure ByronKeyFailure
e -> ByronKeyFailure -> Doc ann
forall ann. ByronKeyFailure -> Doc ann
renderByronKeyFailure ByronKeyFailure
e
runByronClientCommand :: ByronCommand -> CIO e ()
runByronClientCommand :: forall e. ByronCommand -> CIO e ()
runByronClientCommand ByronCommand
c =
case ByronCommand
c of
NodeCmds NodeCmds
bc -> NodeCmds -> CIO e ()
forall e. NodeCmds -> CIO e ()
runNodeCmds NodeCmds
bc
Genesis NewDirectory
outDir GenesisParameters
params -> NewDirectory -> GenesisParameters -> CIO e ()
forall e. NewDirectory -> GenesisParameters -> CIO e ()
runGenesisCommand NewDirectory
outDir GenesisParameters
params
ValidateCBOR CBORObject
cborObject String
fp -> CBORObject -> String -> CIO e ()
forall e. CBORObject -> String -> CIO e ()
runValidateCBOR CBORObject
cborObject String
fp
PrettyPrintCBOR String
fp -> String -> CIO e ()
forall e. String -> CIO e ()
runPrettyPrintCBOR String
fp
PrettySigningKeyPublic ByronKeyFormat
bKeyFormat SigningKeyFile 'In
skF -> ByronKeyFormat -> SigningKeyFile 'In -> CIO e ()
forall e. ByronKeyFormat -> SigningKeyFile 'In -> CIO e ()
runPrettySigningKeyPublic ByronKeyFormat
bKeyFormat SigningKeyFile 'In
skF
MigrateDelegateKeyFrom SigningKeyFile 'In
oldKey NewSigningKeyFile
nskf ->
SigningKeyFile 'In -> NewSigningKeyFile -> CIO e ()
forall e. SigningKeyFile 'In -> NewSigningKeyFile -> CIO e ()
runMigrateDelegateKeyFrom SigningKeyFile 'In
oldKey NewSigningKeyFile
nskf
PrintGenesisHash GenesisFile
genFp -> GenesisFile -> CIO e ()
forall e. GenesisFile -> CIO e ()
runPrintGenesisHash GenesisFile
genFp
PrintSigningKeyAddress ByronKeyFormat
bKeyFormat NetworkId
networkid SigningKeyFile 'In
skF -> ByronKeyFormat -> NetworkId -> SigningKeyFile 'In -> CIO e ()
forall e.
ByronKeyFormat -> NetworkId -> SigningKeyFile 'In -> CIO e ()
runPrintSigningKeyAddress ByronKeyFormat
bKeyFormat NetworkId
networkid SigningKeyFile 'In
skF
Keygen NewSigningKeyFile
nskf -> NewSigningKeyFile -> CIO e ()
forall e. NewSigningKeyFile -> CIO e ()
runKeygen NewSigningKeyFile
nskf
ToVerification ByronKeyFormat
bKeyFormat SigningKeyFile 'In
skFp NewVerificationKeyFile
nvkFp -> ByronKeyFormat
-> SigningKeyFile 'In -> NewVerificationKeyFile -> CIO e ()
forall e.
ByronKeyFormat
-> SigningKeyFile 'In -> NewVerificationKeyFile -> CIO e ()
runToVerification ByronKeyFormat
bKeyFormat SigningKeyFile 'In
skFp NewVerificationKeyFile
nvkFp
SubmitTx SocketPath
socketPath NetworkId
network TxFile 'In
fp -> SocketPath -> NetworkId -> TxFile 'In -> CIO e ()
forall e. SocketPath -> NetworkId -> TxFile 'In -> CIO e ()
runSubmitTx SocketPath
socketPath NetworkId
network TxFile 'In
fp
GetTxId TxFile 'In
fp -> TxFile 'In -> CIO e ()
forall e. TxFile 'In -> CIO e ()
runGetTxId TxFile 'In
fp
SpendGenesisUTxO GenesisFile
genFp NetworkId
nw ByronKeyFormat
era NewTxFile
nftx SigningKeyFile 'In
ctKey Address ByronAddr
genRichAddr [TxOut CtxTx ByronEra]
outs ->
GenesisFile
-> NetworkId
-> ByronKeyFormat
-> NewTxFile
-> SigningKeyFile 'In
-> Address ByronAddr
-> [TxOut CtxTx ByronEra]
-> CIO e ()
forall e.
GenesisFile
-> NetworkId
-> ByronKeyFormat
-> NewTxFile
-> SigningKeyFile 'In
-> Address ByronAddr
-> [TxOut CtxTx ByronEra]
-> CIO e ()
runSpendGenesisUTxO GenesisFile
genFp NetworkId
nw ByronKeyFormat
era NewTxFile
nftx SigningKeyFile 'In
ctKey Address ByronAddr
genRichAddr [TxOut CtxTx ByronEra]
outs
SpendUTxO NetworkId
nw ByronKeyFormat
era NewTxFile
nftx SigningKeyFile 'In
ctKey [TxIn]
ins [TxOut CtxTx ByronEra]
outs ->
NetworkId
-> ByronKeyFormat
-> NewTxFile
-> SigningKeyFile 'In
-> [TxIn]
-> [TxOut CtxTx ByronEra]
-> CIO e ()
forall e.
NetworkId
-> ByronKeyFormat
-> NewTxFile
-> SigningKeyFile 'In
-> [TxIn]
-> [TxOut CtxTx ByronEra]
-> CIO e ()
runSpendUTxO NetworkId
nw ByronKeyFormat
era NewTxFile
nftx SigningKeyFile 'In
ctKey [TxIn]
ins [TxOut CtxTx ByronEra]
outs
runNodeCmds :: NodeCmds -> CIO e ()
runNodeCmds :: forall e. NodeCmds -> CIO e ()
runNodeCmds (CreateVote NetworkId
nw SigningKeyFile 'In
sKey String
upPropFp Bool
voteBool String
outputFp) =
NetworkId
-> SigningKeyFile 'In -> String -> Bool -> String -> CIO e ()
forall e.
NetworkId
-> SigningKeyFile 'In -> String -> Bool -> String -> CIO e ()
runVoteCreation NetworkId
nw SigningKeyFile 'In
sKey String
upPropFp Bool
voteBool String
outputFp
runNodeCmds (SubmitUpdateProposal SocketPath
nodeSocketPath NetworkId
network String
proposalFp) = do
SocketPath -> NetworkId -> String -> CIO e ()
forall e. SocketPath -> NetworkId -> String -> CIO e ()
submitByronUpdateProposal SocketPath
nodeSocketPath NetworkId
network String
proposalFp
runNodeCmds (SubmitVote SocketPath
nodeSocketPath NetworkId
network String
voteFp) = do
SocketPath -> NetworkId -> String -> CIO e ()
forall e. SocketPath -> NetworkId -> String -> CIO e ()
submitByronVote SocketPath
nodeSocketPath NetworkId
network String
voteFp
runNodeCmds (UpdateProposal NetworkId
nw SigningKeyFile 'In
sKey ProtocolVersion
pVer SoftwareVersion
sVer SystemTag
sysTag InstallerHash
insHash String
outputFp ByronProtocolParametersUpdate
params) =
NetworkId
-> SigningKeyFile 'In
-> ProtocolVersion
-> SoftwareVersion
-> SystemTag
-> InstallerHash
-> String
-> ByronProtocolParametersUpdate
-> CIO e ()
forall e.
NetworkId
-> SigningKeyFile 'In
-> ProtocolVersion
-> SoftwareVersion
-> SystemTag
-> InstallerHash
-> String
-> ByronProtocolParametersUpdate
-> CIO e ()
runProposalCreation NetworkId
nw SigningKeyFile 'In
sKey ProtocolVersion
pVer SoftwareVersion
sVer SystemTag
sysTag InstallerHash
insHash String
outputFp ByronProtocolParametersUpdate
params
runGenesisCommand :: NewDirectory -> GenesisParameters -> CIO e ()
runGenesisCommand :: forall e. NewDirectory -> GenesisParameters -> CIO e ()
runGenesisCommand NewDirectory
outDir GenesisParameters
params = do
(genData, genSecrets) <- GenesisParameters -> CIO e (GenesisData, GeneratedSecrets)
forall e.
GenesisParameters -> CIO e (GenesisData, GeneratedSecrets)
mkGenesis GenesisParameters
params
fromExceptTCli $ dumpGenesis outDir genData genSecrets
runValidateCBOR :: CBORObject -> FilePath -> CIO e ()
runValidateCBOR :: forall e. CBORObject -> String -> CIO e ()
runValidateCBOR CBORObject
cborObject String
fp = do
bs <- ExceptT HelpersError IO ByteString -> RIO e ByteString
forall e (m :: * -> *) a.
(HasCallStack, MonadIO m, Show e, Typeable e, Error e) =>
ExceptT e IO a -> m a
fromExceptTCli (ExceptT HelpersError IO ByteString -> RIO e ByteString)
-> ExceptT HelpersError IO ByteString -> RIO e ByteString
forall a b. (a -> b) -> a -> b
$ String -> ExceptT HelpersError IO ByteString
readCBOR String
fp
res <- fromEitherCli $ validateCBOR cborObject bs
liftIO $ Text.putStrLn res
runPrettyPrintCBOR :: FilePath -> CIO e ()
runPrettyPrintCBOR :: forall e. String -> CIO e ()
runPrettyPrintCBOR String
fp = do
bs <- ExceptT HelpersError IO ByteString -> RIO e ByteString
forall e (m :: * -> *) a.
(HasCallStack, MonadIO m, Show e, Typeable e, Error e) =>
ExceptT e IO a -> m a
fromExceptTCli (ExceptT HelpersError IO ByteString -> RIO e ByteString)
-> ExceptT HelpersError IO ByteString -> RIO e ByteString
forall a b. (a -> b) -> a -> b
$ String -> ExceptT HelpersError IO ByteString
readCBOR String
fp
fromExceptTCli $ pPrintCBOR bs
runPrettySigningKeyPublic
:: ByronKeyFormat -> SigningKeyFile In -> CIO e ()
runPrettySigningKeyPublic :: forall e. ByronKeyFormat -> SigningKeyFile 'In -> CIO e ()
runPrettySigningKeyPublic ByronKeyFormat
bKeyFormat SigningKeyFile 'In
skF = do
sK <- ExceptT ByronKeyFailure IO SomeByronSigningKey
-> RIO e SomeByronSigningKey
forall e (m :: * -> *) a.
(HasCallStack, MonadIO m, Show e, Typeable e, Error e) =>
ExceptT e IO a -> m a
fromExceptTCli (ExceptT ByronKeyFailure IO SomeByronSigningKey
-> RIO e SomeByronSigningKey)
-> ExceptT ByronKeyFailure IO SomeByronSigningKey
-> RIO e SomeByronSigningKey
forall a b. (a -> b) -> a -> b
$ ByronKeyFormat
-> SigningKeyFile 'In
-> ExceptT ByronKeyFailure IO SomeByronSigningKey
readByronSigningKey ByronKeyFormat
bKeyFormat SigningKeyFile 'In
skF
liftIO . Text.putStrLn . prettyPublicKey $ byronWitnessToVerKey sK
runMigrateDelegateKeyFrom
:: SigningKeyFile In
-> NewSigningKeyFile
-> CIO e ()
runMigrateDelegateKeyFrom :: forall e. SigningKeyFile 'In -> NewSigningKeyFile -> CIO e ()
runMigrateDelegateKeyFrom oldKey :: SigningKeyFile 'In
oldKey@(File String
fp) (NewSigningKeyFile String
newKey) = do
sk <- ExceptT ByronKeyFailure IO SomeByronSigningKey
-> RIO e SomeByronSigningKey
forall e (m :: * -> *) a.
(HasCallStack, MonadIO m, Show e, Typeable e, Error e) =>
ExceptT e IO a -> m a
fromExceptTCli (ExceptT ByronKeyFailure IO SomeByronSigningKey
-> RIO e SomeByronSigningKey)
-> ExceptT ByronKeyFailure IO SomeByronSigningKey
-> RIO e SomeByronSigningKey
forall a b. (a -> b) -> a -> b
$ ByronKeyFormat
-> SigningKeyFile 'In
-> ExceptT ByronKeyFailure IO SomeByronSigningKey
readByronSigningKey ByronKeyFormat
LegacyByronKeyFormat SigningKeyFile 'In
oldKey
migratedWitness <- case sk of
AByronSigningKeyLegacy (ByronSigningKeyLegacy SigningKey
sKey) ->
SomeByronSigningKey -> RIO e SomeByronSigningKey
forall a. a -> RIO e a
forall (m :: * -> *) a. Monad m => a -> m a
return (SomeByronSigningKey -> RIO e SomeByronSigningKey)
-> (SigningKey ByronKey -> SomeByronSigningKey)
-> SigningKey ByronKey
-> RIO e SomeByronSigningKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SigningKey ByronKey -> SomeByronSigningKey
AByronSigningKey (SigningKey ByronKey -> RIO e SomeByronSigningKey)
-> SigningKey ByronKey -> RIO e SomeByronSigningKey
forall a b. (a -> b) -> a -> b
$ SigningKey -> SigningKey ByronKey
ByronSigningKey SigningKey
sKey
AByronSigningKey SigningKey ByronKey
_ ->
ByronClientCmdError -> RIO e SomeByronSigningKey
forall e (m :: * -> *) a.
(HasCallStack, Show e, Typeable e, Error e, MonadIO m) =>
e -> m a
throwCliError (ByronClientCmdError -> RIO e SomeByronSigningKey)
-> (ByronKeyFailure -> ByronClientCmdError)
-> ByronKeyFailure
-> RIO e SomeByronSigningKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByronKeyFailure -> ByronClientCmdError
ByronCmdKeyFailure (ByronKeyFailure -> RIO e SomeByronSigningKey)
-> ByronKeyFailure -> RIO e SomeByronSigningKey
forall a b. (a -> b) -> a -> b
$ String -> ByronKeyFailure
CannotMigrateFromNonLegacySigningKey String
fp
fromExceptTCli $ ensureNewFileLBS newKey $ serialiseByronWitness migratedWitness
runPrintGenesisHash :: GenesisFile -> CIO e ()
runPrintGenesisHash :: forall e. GenesisFile -> CIO e ()
runPrintGenesisHash GenesisFile
genFp = do
genesis <-
ExceptT ByronGenesisError IO Config -> RIO e Config
forall e (m :: * -> *) a.
(HasCallStack, MonadIO m, Show e, Typeable e, Error e) =>
ExceptT e IO a -> m a
fromExceptTCli (ExceptT ByronGenesisError IO Config -> RIO e Config)
-> ExceptT ByronGenesisError IO Config -> RIO e Config
forall a b. (a -> b) -> a -> b
$ GenesisFile -> NetworkId -> ExceptT ByronGenesisError IO Config
readGenesis GenesisFile
genFp NetworkId
dummyNetwork
liftIO . Text.putStrLn $ formatter genesis
where
dummyNetwork :: NetworkId
dummyNetwork :: NetworkId
dummyNetwork = NetworkId
Mainnet
formatter :: Byron.Config -> Text
formatter :: Config -> Text
formatter =
Format Text (AbstractHash Blake2b_256 Raw -> Text)
-> AbstractHash Blake2b_256 Raw -> Text
forall a. Format Text a -> a
F.sformat Format Text (AbstractHash Blake2b_256 Raw -> Text)
forall r algo a. Format r (AbstractHash algo a -> r)
Crypto.hashHexF
(AbstractHash Blake2b_256 Raw -> Text)
-> (Config -> AbstractHash Blake2b_256 Raw) -> Config -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenesisHash -> AbstractHash Blake2b_256 Raw
Byron.unGenesisHash
(GenesisHash -> AbstractHash Blake2b_256 Raw)
-> (Config -> GenesisHash)
-> Config
-> AbstractHash Blake2b_256 Raw
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Config -> GenesisHash
Byron.configGenesisHash
runPrintSigningKeyAddress
:: ByronKeyFormat
-> NetworkId
-> SigningKeyFile In
-> CIO e ()
runPrintSigningKeyAddress :: forall e.
ByronKeyFormat -> NetworkId -> SigningKeyFile 'In -> CIO e ()
runPrintSigningKeyAddress ByronKeyFormat
bKeyFormat NetworkId
networkid SigningKeyFile 'In
skF = do
sK <- ExceptT ByronKeyFailure IO SomeByronSigningKey
-> RIO e SomeByronSigningKey
forall e (m :: * -> *) a.
(HasCallStack, MonadIO m, Show e, Typeable e, Error e) =>
ExceptT e IO a -> m a
fromExceptTCli (ExceptT ByronKeyFailure IO SomeByronSigningKey
-> RIO e SomeByronSigningKey)
-> ExceptT ByronKeyFailure IO SomeByronSigningKey
-> RIO e SomeByronSigningKey
forall a b. (a -> b) -> a -> b
$ ByronKeyFormat
-> SigningKeyFile 'In
-> ExceptT ByronKeyFailure IO SomeByronSigningKey
readByronSigningKey ByronKeyFormat
bKeyFormat SigningKeyFile 'In
skF
let sKeyAddr = Address ByronAddr -> Text
prettyAddress (Address ByronAddr -> Text)
-> (VerificationKey ByronKey -> Address ByronAddr)
-> VerificationKey ByronKey
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NetworkId -> VerificationKey ByronKey -> Address ByronAddr
makeByronAddress NetworkId
networkid (VerificationKey ByronKey -> Text)
-> VerificationKey ByronKey -> Text
forall a b. (a -> b) -> a -> b
$ SomeByronSigningKey -> VerificationKey ByronKey
byronWitnessToVerKey SomeByronSigningKey
sK
liftIO $ Text.putStrLn sKeyAddr
runKeygen :: NewSigningKeyFile -> CIO e ()
runKeygen :: forall e. NewSigningKeyFile -> CIO e ()
runKeygen (NewSigningKeyFile String
skF) = do
sK <- AsType ByronKey -> RIO e (SigningKey ByronKey)
forall (m :: * -> *) keyrole.
(MonadIO m, Key keyrole) =>
AsType keyrole -> m (SigningKey keyrole)
generateSigningKey AsType ByronKey
AsByronKey
fromExceptTCli $ ensureNewFileLBS skF $ serialiseToRawBytes sK
runToVerification
:: ByronKeyFormat -> SigningKeyFile In -> NewVerificationKeyFile -> CIO e ()
runToVerification :: forall e.
ByronKeyFormat
-> SigningKeyFile 'In -> NewVerificationKeyFile -> CIO e ()
runToVerification ByronKeyFormat
bKeyFormat SigningKeyFile 'In
skFp (NewVerificationKeyFile String
vkFp) = do
sk <- ExceptT ByronKeyFailure IO SomeByronSigningKey
-> RIO e SomeByronSigningKey
forall e (m :: * -> *) a.
(HasCallStack, MonadIO m, Show e, Typeable e, Error e) =>
ExceptT e IO a -> m a
fromExceptTCli (ExceptT ByronKeyFailure IO SomeByronSigningKey
-> RIO e SomeByronSigningKey)
-> ExceptT ByronKeyFailure IO SomeByronSigningKey
-> RIO e SomeByronSigningKey
forall a b. (a -> b) -> a -> b
$ ByronKeyFormat
-> SigningKeyFile 'In
-> ExceptT ByronKeyFailure IO SomeByronSigningKey
readByronSigningKey ByronKeyFormat
bKeyFormat SigningKeyFile 'In
skFp
let ByronVerificationKey vK = byronWitnessToVerKey sk
let vKey = Builder -> Text
Builder.toLazyText (Builder -> Text) -> Builder -> Text
forall a b. (a -> b) -> a -> b
$ VerificationKey -> Builder
Crypto.formatFullVerificationKey VerificationKey
vK
fromExceptTCli $ ensureNewFile TL.writeFile vkFp vKey
runSubmitTx :: SocketPath -> NetworkId -> TxFile In -> CIO e ()
runSubmitTx :: forall e. SocketPath -> NetworkId -> TxFile 'In -> CIO e ()
runSubmitTx SocketPath
nodeSocketPath NetworkId
network TxFile 'In
fp = do
tx <- ExceptT ByronTxError IO (ATxAux ByteString)
-> RIO e (ATxAux ByteString)
forall e (m :: * -> *) a.
(HasCallStack, MonadIO m, Show e, Typeable e, Error e) =>
ExceptT e IO a -> m a
fromExceptTCli (ExceptT ByronTxError IO (ATxAux ByteString)
-> RIO e (ATxAux ByteString))
-> ExceptT ByronTxError IO (ATxAux ByteString)
-> RIO e (ATxAux ByteString)
forall a b. (a -> b) -> a -> b
$ TxFile 'In -> ExceptT ByronTxError IO (ATxAux ByteString)
readByronTx TxFile 'In
fp
fromExceptTCli $ nodeSubmitTx nodeSocketPath network (normalByronTxToGenTx tx)
runGetTxId :: TxFile In -> CIO e ()
runGetTxId :: forall e. TxFile 'In -> CIO e ()
runGetTxId TxFile 'In
fp = do
tx <- ExceptT ByronTxError IO (ATxAux ByteString)
-> RIO e (ATxAux ByteString)
forall e (m :: * -> *) a.
(HasCallStack, MonadIO m, Show e, Typeable e, Error e) =>
ExceptT e IO a -> m a
fromExceptTCli (ExceptT ByronTxError IO (ATxAux ByteString)
-> RIO e (ATxAux ByteString))
-> ExceptT ByronTxError IO (ATxAux ByteString)
-> RIO e (ATxAux ByteString)
forall a b. (a -> b) -> a -> b
$ TxFile 'In -> ExceptT ByronTxError IO (ATxAux ByteString)
readByronTx TxFile 'In
fp
let txId = ATxAux ByteString -> TxId
getTxIdByron ATxAux ByteString
tx
liftIO . BS.putStrLn $ serialiseToRawBytesHex txId
runSpendGenesisUTxO
:: GenesisFile
-> NetworkId
-> ByronKeyFormat
-> NewTxFile
-> SigningKeyFile In
-> Address ByronAddr
-> [TxOut CtxTx ByronEra]
-> CIO e ()
runSpendGenesisUTxO :: forall e.
GenesisFile
-> NetworkId
-> ByronKeyFormat
-> NewTxFile
-> SigningKeyFile 'In
-> Address ByronAddr
-> [TxOut CtxTx ByronEra]
-> CIO e ()
runSpendGenesisUTxO GenesisFile
genesisFile NetworkId
nw ByronKeyFormat
bKeyFormat (NewTxFile String
ctTx) SigningKeyFile 'In
ctKey Address ByronAddr
genRichAddr [TxOut CtxTx ByronEra]
outs = do
genesis <- ExceptT ByronGenesisError IO Config -> RIO e Config
forall e (m :: * -> *) a.
(HasCallStack, MonadIO m, Show e, Typeable e, Error e) =>
ExceptT e IO a -> m a
fromExceptTCli (ExceptT ByronGenesisError IO Config -> RIO e Config)
-> ExceptT ByronGenesisError IO Config -> RIO e Config
forall a b. (a -> b) -> a -> b
$ GenesisFile -> NetworkId -> ExceptT ByronGenesisError IO Config
readGenesis GenesisFile
genesisFile NetworkId
nw
sk <- fromExceptTCli $ readByronSigningKey bKeyFormat ctKey
let tx = Config
-> NetworkId
-> SomeByronSigningKey
-> Address ByronAddr
-> [TxOut CtxTx ByronEra]
-> ATxAux ByteString
txSpendGenesisUTxOByronPBFT Config
genesis NetworkId
nw SomeByronSigningKey
sk Address ByronAddr
genRichAddr [TxOut CtxTx ByronEra]
outs
fromExceptTCli $
ensureNewFileLBS ctTx $
teRawCBOR $
serialiseByronTx tx
runSpendUTxO
:: NetworkId
-> ByronKeyFormat
-> NewTxFile
-> SigningKeyFile In
-> [TxIn]
-> [TxOut CtxTx ByronEra]
-> CIO e ()
runSpendUTxO :: forall e.
NetworkId
-> ByronKeyFormat
-> NewTxFile
-> SigningKeyFile 'In
-> [TxIn]
-> [TxOut CtxTx ByronEra]
-> CIO e ()
runSpendUTxO NetworkId
nw ByronKeyFormat
bKeyFormat (NewTxFile String
ctTx) SigningKeyFile 'In
ctKey [TxIn]
ins [TxOut CtxTx ByronEra]
outs = do
sk <- ExceptT ByronKeyFailure IO SomeByronSigningKey
-> RIO e SomeByronSigningKey
forall e (m :: * -> *) a.
(HasCallStack, MonadIO m, Show e, Typeable e, Error e) =>
ExceptT e IO a -> m a
fromExceptTCli (ExceptT ByronKeyFailure IO SomeByronSigningKey
-> RIO e SomeByronSigningKey)
-> ExceptT ByronKeyFailure IO SomeByronSigningKey
-> RIO e SomeByronSigningKey
forall a b. (a -> b) -> a -> b
$ ByronKeyFormat
-> SigningKeyFile 'In
-> ExceptT ByronKeyFailure IO SomeByronSigningKey
readByronSigningKey ByronKeyFormat
bKeyFormat SigningKeyFile 'In
ctKey
let gTx = NetworkId
-> SomeByronSigningKey
-> [TxIn]
-> [TxOut CtxTx ByronEra]
-> ATxAux ByteString
txSpendUTxOByronPBFT NetworkId
nw SomeByronSigningKey
sk [TxIn]
ins [TxOut CtxTx ByronEra]
outs
fromExceptTCli $
ensureNewFileLBS ctTx $
teRawCBOR $
serialiseByronTx gTx