diff --git a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs index 08300309d8f..a05a137b85a 100644 --- a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs +++ b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs @@ -658,8 +658,6 @@ balanceTransactionWithSelectionStrategyAndNoZeroAdaAdjustment (balance0, minfee0, _) <- balanceAfterSettingMinFee (partialTx ^. #tx) - - -- NOTE: It is not possible to know the script execution cost in -- advance because it actually depends on the final transaction. Inputs -- selected as part of the fee balancing might have an influence on the @@ -675,7 +673,8 @@ balanceTransactionWithSelectionStrategyAndNoZeroAdaAdjustment when (UTxOSelection.availableSize utxoSelection == 0) $ throwE ErrBalanceTxUnableToCreateInput - (Selection extraInputs extraCollateral' extraOutputs extraInputScripts, s') + + (Selection{extraInputs,extraCollateral,extraOutputs,extraInputScripts}, s') <- selectAssets pp utxoAssumptions @@ -708,7 +707,6 @@ balanceTransactionWithSelectionStrategyAndNoZeroAdaAdjustment -- doing such a thing is considered bonkers and this is not a behavior we -- ought to support. - let extraCollateral = fst <$> extraCollateral' candidateTx <- assembleTransaction $ TxUpdate { extraInputs , extraCollateral @@ -904,8 +902,8 @@ balanceTransactionWithSelectionStrategyAndNoZeroAdaAdjustment SJust _ -> throwE ErrBalanceTxExistingReturnCollateral data Selection = Selection - { extraInputs :: [(W.TxIn, W.TxOut)] - , extraCollateral :: [(W.TxIn, W.TxOut)] + { extraInputs :: [W.TxIn] + , extraCollateral :: [W.TxIn] , extraOutputs :: [W.TxOut] , extraInputScripts :: [CA.Script CA.KeyHash] } deriving (Eq, Show) @@ -1090,7 +1088,12 @@ selectAssets pp utxoAssumptions outs' redeemers . view #address . snd ) <$> inputs <> collateral - in ( Selection inputs collateral change inputScripts + in ( Selection + { extraInputs = map fst inputs + , extraCollateral = map fst collateral + , extraOutputs = change + , extraInputScripts = inputScripts + } , s' ) @@ -1167,7 +1170,7 @@ splitSignedValue v = (bNegative, bPositive) -- | Describes modifications that can be made to a `Tx` using `updateTx`. data TxUpdate = TxUpdate - { extraInputs :: [(W.TxIn, W.TxOut)] + { extraInputs :: [W.TxIn] , extraCollateral :: [W.TxIn] -- ^ Only used in the Alonzo era and later. Will be silently ignored in -- previous eras. @@ -1267,7 +1270,7 @@ modifyShelleyTxBody txUpdate = era = recentEra @era TxUpdate extraInputs extraCollateral extraOutputs _ feeUpdate = txUpdate extraOutputs' = StrictSeq.fromList $ map (toLedgerTxOut era) extraOutputs - extraInputs' = Set.fromList (Convert.toLedger . fst <$> extraInputs) + extraInputs' = Set.fromList (Convert.toLedger <$> extraInputs) extraCollateral' = Set.fromList $ Convert.toLedger <$> extraCollateral modifyFee old = case feeUpdate of