diff --git a/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs b/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs index ee85121e2d1..3036ddf4889 100644 --- a/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs +++ b/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs @@ -1212,24 +1212,8 @@ estimateKeyWitnessCount utxo txbody@(Cardano.TxBody txbodycontent) = dummyKeyRole = Payment - apiScriptHashes = - let walletScripts = mapMaybe toTimelockScript scripts - toScriptHash = - Cardano.hashScript - . Cardano.SimpleScript - . toCardanoSimpleScript - toPair s = (s, toScriptHash s) - in toPair <$> walletScripts - - estimateWitNumForCred = \case - Cardano.StakeCredentialByKey _ -> 1 - Cardano.StakeCredentialByScript scriptHash -> - let pair = filter (\(_,sh) -> sh == scriptHash) apiScriptHashes - in case pair of - [(delScript,_)] -> - estimateMaxWitnessRequiredPerInput delScript - _ -> error "there should be delegation script in the tx body" + estimateDelegSigningKeys :: Cardano.Certificate -> Integer estimateDelegSigningKeys = \case Cardano.StakeAddressRegistrationCertificate _ -> 0 Cardano.StakeAddressDeregistrationCertificate cred -> @@ -1237,6 +1221,13 @@ estimateKeyWitnessCount utxo txbody@(Cardano.TxBody txbodycontent) = Cardano.StakeAddressDelegationCertificate cred _ -> estimateWitNumForCred cred _ -> 1 + where + -- Does not include the key witness needed for script credentials. + -- They are accounted for separately in @scriptVkWitsUpperBound@. + estimateWitNumForCred = \case + Cardano.StakeCredentialByKey _ -> 1 + Cardano.StakeCredentialByScript _ -> 0 + toTimelockScript :: Ledger.Script (Cardano.ShelleyLedgerEra era)