Module

Ctl.Internal.Types.UsedTxOuts

The set of wallets utxos selected as inputs for any subsequent transaction might actually be already submitted by a previous one and pending to be spent. This module provides a simple, in-memory cache that helps with keeping submitted utxos in-check.

#UsedTxOuts

newtype UsedTxOuts

Tracks UTxOs that have already been spent to avoid double-spending attempts.

Constructors

Instances

#TxOutRefCache

#isTxOutRefUsed

isTxOutRefUsed :: forall (m :: Type -> Type) (a :: Type). MonadAsk UsedTxOuts m => MonadEffect m => { index :: UInt, transactionId :: TransactionHash } -> m Boolean

Query if TransactionInput is marked as used.

#lockTransactionInputs

lockTransactionInputs :: forall (m :: Type -> Type). MonadAsk UsedTxOuts m => MonadError Error m => MonadEffect m => Transaction -> m TxOutRefUnlockKeys

Mark transaction's inputs as used. Returns the set of TxOuts that was locked by this call

#lockRemainingTransactionInputs

lockRemainingTransactionInputs :: forall (m :: Type -> Type). MonadAsk UsedTxOuts m => MonadError Error m => MonadEffect m => TxOutRefUnlockKeys -> Transaction -> m TxOutRefUnlockKeys

lockRemainingTransactionInputs alreadyLocked tx

Mark 'tx's inputs as used, except for those which are contained in 'alreadylocked' (which have been locked in a previous step).

#LockTransactionError

#newUsedTxOuts

newUsedTxOuts :: forall (m :: Type -> Type) (t :: Type -> Type). MonadEffect m => m UsedTxOuts

Creates a new empty filter.

#unlockTxOutRefs

unlockTxOutRefs :: forall (m :: Type -> Type) (t :: Type -> Type) (a :: Type). MonadAsk UsedTxOuts m => MonadEffect m => Foldable t => t { index :: UInt, transactionId :: TransactionHash } -> m Unit

Remove used marks from TxOutRefs given directly.

#unlockTxOutKeys

unlockTxOutKeys :: forall (m :: Type -> Type) (a :: Type). MonadAsk UsedTxOuts m => MonadEffect m => TxOutRefUnlockKeys -> m Unit

Remove used marks from all inputs that are saved in a TxOutRefUnlockKeys. Use this on the result of a previous lockTransactionInputs

#unlockTransactionInputs

unlockTransactionInputs :: forall (m :: Type -> Type). MonadAsk UsedTxOuts m => MonadEffect m => Transaction -> m Unit

Remove transaction's inputs used marks.

#withLockedTransactionInputs

withLockedTransactionInputs :: forall (m :: Type -> Type) (a :: Type). MonadAsk UsedTxOuts m => MonadError Error m => MonadEffect m => Transaction -> m a -> m a

Lock the inputs of a transaction and then run a monadic action. Will throw Error if any of the inputs are already locked. In case of any error, locks will be released.

Modules