Safe Haskell | None |
---|---|
Language | Haskell2010 |
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 AddressType
- data Credential
- asCollateral :: TxOut -> Maybe Coin
- addressSuitableForCollateral :: Address -> Bool
- addressTypeSuitableForCollateral :: AddressType -> Bool
- addressTypeFromHeaderNibble :: Word4 -> Maybe AddressType
- getAddressType :: Get AddressType
- addressType :: Address -> Maybe AddressType
- addressTypeToHeaderNibble :: AddressType -> Word4
- putAddressType :: AddressType -> Put
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.
BaseAddress Credential Credential | |
PointerAddress Credential | |
EnterpriseAddress Credential | |
StakeAddress Credential | |
BootstrapAddress |
A Bootstrap (a.k.a. Byron) address |
Instances
Eq AddressType Source # | |
Defined in Cardano.Wallet.Primitive.Collateral (==) :: AddressType -> AddressType -> Bool Source # (/=) :: AddressType -> AddressType -> Bool Source # |
|
Show AddressType Source # | |
Defined in Cardano.Wallet.Primitive.Collateral |
data Credential Source #
The type of the credential used in an address.
Instances
Eq Credential Source # | |
Defined in Cardano.Wallet.Primitive.Collateral (==) :: Credential -> Credential -> Bool Source # (/=) :: Credential -> Credential -> Bool Source # |
|
Show Credential Source # | |
Defined in Cardano.Wallet.Primitive.Collateral |
Classifying address types
:: 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.