cardano-wallet-core-2022.7.1: The Wallet Backend for a Cardano node.
Safe Haskell None
Language Haskell2010

Cardano.Wallet.Primitive.Collateral

Description

For a UTxO to be considered a suitable collateral input, it must: - Be a pure ADA UTxO (no tokens) - Require a verification key witness to be spent - Not be locked by a script

UTxOs of this kind are sometimes referred to as VK inputs.

Synopsis

Data types

data AddressType Source #

Address type | Payment Credential | Stake Credential | Header, first nibble | |--------------------+--------------------+------------------+----------------------| | Base address | keyhash | keyhash | 0000 | | | scripthash | keyhash | 0001 | | | keyhash | scripthash | 0010 | | | scripthash | scripthash | 0011 | | Pointer address | keyhash | ptr | 0100 | | | scripthash | ptr | 0101 | | Enterprise address | keyhash | - | 0110 | | | scripthash | 0 | 0111 | | Bootstrap address | keyhash | - | 1000 | | Stake address | - | keyhash | 1110 | | | - | scripthash | 1111 | | Future formats | ? | ? | 1001-1101 |

We represent these types of addresses with the following data types:

The type of the address.

Classifying address types

asCollateral Source #

Arguments

:: TxOut

TxOut from a UTxO entry

-> Maybe Coin

The total ADA value of that UTxO if it is suitable for collateral, otherwise Nothing.

If the given TxOut represents a UTxO that is suitable for use as a collateral input, returns Just along with the total ADA value of the UTxO. Otherwise returns Nothing if it is not a suitable collateral value.

addressSuitableForCollateral :: Address -> Bool Source #

Indicates whether or not the given address is suitable for collateral.

addressTypeSuitableForCollateral :: AddressType -> Bool Source #

A simple function which determines if an AddressType is suitable for use as collateral. Only AddressType s with a "key hash" payment credential are considered suitable for use as collateral.

Reading address types

addressTypeFromHeaderNibble :: Word4 -> Maybe AddressType Source #

Construct an AddressType from the binary representation.

getAddressType :: Get AddressType Source #

Get an AddressType from a binary stream.

addressType :: Address -> Maybe AddressType Source #

Get the address type of a given address.

Writing address types

addressTypeToHeaderNibble :: AddressType -> Word4 Source #

Return the binary representation of an AddressType .

putAddressType :: AddressType -> Put Source #

Write an AddressType to a binary stream.