Skip to content

Commit

Permalink
Add txOutAddCoin function to primitives for transaction.
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Oct 12, 2021
1 parent 2c6f1a2 commit a0ff4ab
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/core/src/Cardano/Wallet/Primitive/Types/Tx.hs
Expand Up @@ -65,6 +65,7 @@ module Cardano.Wallet.Primitive.Types.Tx
, txIns
, txMetadataIsNull
, txOutCoin
, txOutAddCoin
, failedScriptValidation

-- * Constants
Expand Down Expand Up @@ -316,6 +317,11 @@ data TxOut = TxOut
txOutCoin :: TxOut -> Coin
txOutCoin = TokenBundle.getCoin . view #tokens

-- Add a fixed coin value to an existing output.
txOutAddCoin :: Coin -> TxOut -> TxOut
txOutAddCoin val (TxOut addr tokens) =
TxOut addr (tokens <> TokenBundle.fromCoin val)

-- Since the 'TokenBundle' type deliberately does not provide an 'Ord' instance
-- (as that would lead to arithmetically invalid orderings), this means we can't
-- automatically derive an 'Ord' instance for the 'TxOut' type.
Expand Down

0 comments on commit a0ff4ab

Please sign in to comment.