From 6605fa1517e7b51c116936fe4262304bab7e0dce Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Wed, 26 Aug 2026 13:27:32 +0000 Subject: [PATCH] Derive the accepted era list when reading transaction witnesses readFileTxKeyWitness rejected TxWitness DijkstraEra envelopes because it enumerated the accepted eras by hand and stopped at Conway; derive the list from the api's era enumeration instead, so future eras are accepted the moment the api exposes them. --- ...o-cli_palas_accept_newer_era_witnesses.yml | 6 ++++ cardano-cli/src/Cardano/CLI/Read.hs | 34 ++++++------------- 2 files changed, 16 insertions(+), 24 deletions(-) create mode 100644 .changes/20260827_111653_cardano-cli_palas_accept_newer_era_witnesses.yml diff --git a/.changes/20260827_111653_cardano-cli_palas_accept_newer_era_witnesses.yml b/.changes/20260827_111653_cardano-cli_palas_accept_newer_era_witnesses.yml new file mode 100644 index 0000000000..ee7c8b3022 --- /dev/null +++ b/.changes/20260827_111653_cardano-cli_palas_accept_newer_era_witnesses.yml @@ -0,0 +1,6 @@ +description: | + Fixed `transaction assemble` (also known as `transaction sign-witness`) rejecting witness files from eras after Conway: witness files from every supported era, including Dijkstra, are now accepted. +kind: +- bugfix +pr: 1426 +project: cardano-cli diff --git a/cardano-cli/src/Cardano/CLI/Read.hs b/cardano-cli/src/Cardano/CLI/Read.hs index 7e11c21e51..a82e22a79b 100644 --- a/cardano-cli/src/Cardano/CLI/Read.hs +++ b/cardano-cli/src/Cardano/CLI/Read.hs @@ -341,7 +341,16 @@ readFileTxKeyWitness -> IO (Either (FileError TextEnvelopeError) (InAnyShelleyBasedEra KeyWitness)) readFileTxKeyWitness fp = do file <- fileOrPipe fp - readFileInAnyShelleyBasedEra AsKeyWitness file + readFileOrPipeTextEnvelopeAnyOf fromSomeShelleyTxWitness file + +fromSomeShelleyTxWitness :: [FromSomeType HasTextEnvelope (InAnyShelleyBasedEra KeyWitness)] +fromSomeShelleyTxWitness = + [ shelleyBasedEraConstraints sbe $ FromSomeType (makeWitnessProxy sbe) (InAnyShelleyBasedEra sbe) + | AnyShelleyBasedEra sbe <- [minBound .. maxBound] + ] + where + makeWitnessProxy :: HasTypeProxy era => ShelleyBasedEra era -> AsType (KeyWitness era) + makeWitnessProxy _ = AsKeyWitness (proxyToAsType (Proxy :: Proxy era)) txWitnessTextEnvelopeTypes :: [Text] txWitnessTextEnvelopeTypes = @@ -614,29 +623,6 @@ readCostModels (File fp) = do when (null $ fromAlonzoCostModels costModels) $ throwE $ CostModelsErrorEmpty fp return costModels --- Misc - -readFileInAnyShelleyBasedEra - :: ( HasTextEnvelope (thing ShelleyEra) - , HasTextEnvelope (thing AllegraEra) - , HasTextEnvelope (thing MaryEra) - , HasTextEnvelope (thing AlonzoEra) - , HasTextEnvelope (thing BabbageEra) - , HasTextEnvelope (thing ConwayEra) - ) - => (forall era. AsType era -> AsType (thing era)) - -> FileOrPipe - -> IO (Either (FileError TextEnvelopeError) (InAnyShelleyBasedEra thing)) -readFileInAnyShelleyBasedEra asThing = - readFileOrPipeTextEnvelopeAnyOf - [ FromSomeType (asThing AsShelleyEra) (InAnyShelleyBasedEra ShelleyBasedEraShelley) - , FromSomeType (asThing AsAllegraEra) (InAnyShelleyBasedEra ShelleyBasedEraAllegra) - , FromSomeType (asThing AsMaryEra) (InAnyShelleyBasedEra ShelleyBasedEraMary) - , FromSomeType (asThing AsAlonzoEra) (InAnyShelleyBasedEra ShelleyBasedEraAlonzo) - , FromSomeType (asThing AsBabbageEra) (InAnyShelleyBasedEra ShelleyBasedEraBabbage) - , FromSomeType (asThing AsConwayEra) (InAnyShelleyBasedEra ShelleyBasedEraConway) - ] - -- | We need a type for handling files that may be actually be things like -- pipes. Currently the CLI makes no guarantee that a "file" will only -- be read once. This is a problem for a user who who expects to be able to pass