Skip to content

Commit

Permalink
Adjust availableUTxO to account for collateral inputs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed Aug 12, 2021
1 parent cd90151 commit 5915731
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/core/src/Cardano/Wallet/Primitive/Model.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ import Cardano.Wallet.Primitive.Types.Tx
, TxOut (..)
, TxStatus (..)
, inputs
, txIns
, txOutCoin
)
import Cardano.Wallet.Primitive.Types.UTxO
Expand Down Expand Up @@ -107,6 +106,7 @@ import GHC.Generics
( Generic )

import qualified Cardano.Wallet.Primitive.Types.TokenBundle as TB
import qualified Data.Foldable as F
import qualified Data.List.NonEmpty as NE
import qualified Data.Map as Map
import qualified Data.Set as Set
Expand Down Expand Up @@ -299,7 +299,16 @@ availableUTxO
-> Wallet s
-> UTxO
availableUTxO pending (Wallet u _ _) =
u `excluding` txIns pending
u `excluding` entriesToExclude
where
entriesToExclude :: Set TxIn
entriesToExclude = F.foldMap' entriesToExcludeForTx pending

entriesToExcludeForTx :: Tx -> Set TxIn
entriesToExcludeForTx tx = Set.fromList $ fst <$> mconcat
[ tx ^. #resolvedInputs
, tx ^. #resolvedCollateralInputs
]

-- | Total UTxO = 'availableUTxO' @<>@ 'changeUTxO'
totalUTxO
Expand Down

0 comments on commit 5915731

Please sign in to comment.