Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow witness count override in transaction build command #3025

Merged
merged 1 commit into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cardano-cli/src/Cardano/CLI/Shelley/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ data TransactionCmd
AnyCardanoEra
AnyConsensusModeParams
NetworkId
(Maybe Word)
-- ^ Override the required number of tx witnesses
[(TxIn, Maybe (ScriptWitnessFiles WitCtxTxIn))]
-- ^ Transaction inputs with optional spending scripts
[TxIn]
Expand Down
9 changes: 9 additions & 0 deletions cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ pTransaction =
TxBuild <$> pCardanoEra
<*> pConsensusModeParams
<*> pNetworkId
<*> optional pWitnessOverride
<*> some (pTxIn AutoBalance)
<*> many pTxInCollateral
<*> many pTxOut
Expand Down Expand Up @@ -1789,6 +1790,14 @@ pTxInCollateral =
<> Opt.help "TxId#TxIx"
)

pWitnessOverride :: Parser Word
pWitnessOverride = Opt.option Opt.auto
( Opt.long "witness-override"
<> Opt.metavar "WORD"
<> Opt.help "Specify and override the number of \
\witnesses the transaction requires."
)

parseTxIn :: Parsec.Parser TxIn
parseTxIn = TxIn <$> parseTxId <*> (Parsec.char '#' *> parseTxIx)

Expand Down
14 changes: 8 additions & 6 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@ renderFeature TxFeatureTxOutDatum = "Transaction output datums"
runTransactionCmd :: TransactionCmd -> ExceptT ShelleyTxCmdError IO ()
runTransactionCmd cmd =
case cmd of
TxBuild era consensusModeParams nid txins txinsc txouts changeAddr mValue mLowBound
mUpperBound certs wdrls metadataSchema scriptFiles
metadataFiles mpparams mUpProp out ->
TxBuild era consensusModeParams nid mOverrideWits txins txinsc txouts
changeAddr mValue mLowBound mUpperBound certs wdrls metadataSchema
scriptFiles metadataFiles mpparams mUpProp out ->
runTxBuild era consensusModeParams nid txins txinsc txouts changeAddr mValue mLowBound
mUpperBound certs wdrls metadataSchema scriptFiles
metadataFiles mpparams mUpProp out
metadataFiles mpparams mUpProp out mOverrideWits
TxBuildRaw era txins txinsc txouts mValue mLowBound mUpperBound
fee certs wdrls metadataSchema scriptFiles
metadataFiles mpparams mUpProp out ->
Expand Down Expand Up @@ -383,10 +383,12 @@ runTxBuild
-> Maybe ProtocolParamsSourceSpec
-> Maybe UpdateProposalFile
-> TxBodyFile
-> Maybe Word
-> ExceptT ShelleyTxCmdError IO ()
runTxBuild (AnyCardanoEra era) (AnyConsensusModeParams cModeParams) networkId txins txinsc txouts
(TxOutChangeAddress changeAddr) mValue mLowerBound mUpperBound certFiles withdrawals
metadataSchema scriptFiles metadataFiles mpparams mUpdatePropFile outBody@(TxBodyFile fpath) = do
metadataSchema scriptFiles metadataFiles mpparams mUpdatePropFile outBody@(TxBodyFile fpath)
mOverrideWits = do
SocketPath sockPath <- firstExceptT ShelleyTxCmdSocketEnvError readEnvSocketPath

let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId sockPath
Expand Down Expand Up @@ -443,7 +445,7 @@ runTxBuild (AnyCardanoEra era) (AnyConsensusModeParams cModeParams) networkId tx
. hoistEither
$ makeTransactionBodyAutoBalance eInMode systemStart eraHistory
pparams Set.empty utxo txBodyContent
cAddr Nothing
cAddr mOverrideWits

firstExceptT ShelleyTxCmdWriteFileError . newExceptT
$ writeFileTextEnvelope fpath Nothing balancedTxBody
Expand Down