Safe Haskell | None |
---|---|
Language | Haskell2010 |
Cardano.Api.Address
Description
Cardano addresses: payment and stake addresses.
Synopsis
- data Address addrtype where
- ByronAddress :: Address -> Address ByronAddr
- ShelleyAddress :: Network -> PaymentCredential StandardCrypto -> StakeReference StandardCrypto -> Address ShelleyAddr
- data ByronAddr
- makeByronAddress :: NetworkId -> VerificationKey ByronKey -> Address ByronAddr
- data ShelleyAddr
- makeShelleyAddress :: NetworkId -> PaymentCredential -> StakeAddressReference -> Address ShelleyAddr
- data PaymentCredential
- data StakeAddressReference
- newtype StakeAddressPointer = StakeAddressPointer {
- unStakeAddressPointer :: Ptr
- data AddressAny
- lexPlausibleAddressString :: Parser Text
- parseAddressAny :: Parser AddressAny
- data AddressInEra era where
- AddressInEra :: AddressTypeInEra addrtype era -> Address addrtype -> AddressInEra era
- data AddressTypeInEra addrtype era where
- byronAddressInEra :: Address ByronAddr -> AddressInEra era
- shelleyAddressInEra :: ShelleyBasedEra era -> Address ShelleyAddr -> AddressInEra era
- anyAddressInShelleyBasedEra :: ShelleyBasedEra era -> AddressAny -> AddressInEra era
- anyAddressInEra :: CardanoEra era -> AddressAny -> Either String (AddressInEra era)
- toAddressAny :: Address addr -> AddressAny
- makeByronAddressInEra :: NetworkId -> VerificationKey ByronKey -> AddressInEra era
- makeShelleyAddressInEra :: ShelleyBasedEra era -> NetworkId -> PaymentCredential -> StakeAddressReference -> AddressInEra era
- data StakeAddress where
- StakeAddress :: Network -> StakeCredential StandardCrypto -> StakeAddress
- data StakeCredential
- makeStakeAddress :: NetworkId -> StakeCredential -> StakeAddress
- stakeAddressCredential :: StakeAddress -> StakeCredential
- data StakeKey
- data StakeExtendedKey
- shelleyPayAddrToPlutusPubKHash :: Address ShelleyAddr -> Maybe PubKeyHash
- toShelleyAddr :: AddressInEra era -> Addr StandardCrypto
- toShelleyStakeAddr :: StakeAddress -> RewardAcnt StandardCrypto
- toShelleyStakeCredential :: StakeCredential -> StakeCredential StandardCrypto
- fromShelleyAddr :: ShelleyBasedEra era -> Addr StandardCrypto -> AddressInEra era
- fromShelleyAddrIsSbe :: ShelleyBasedEra era -> Addr StandardCrypto -> AddressInEra era
- fromShelleyAddrToAny :: Addr StandardCrypto -> AddressAny
- fromShelleyPaymentCredential :: PaymentCredential StandardCrypto -> PaymentCredential
- fromShelleyStakeAddr :: RewardAcnt StandardCrypto -> StakeAddress
- fromShelleyStakeCredential :: StakeCredential StandardCrypto -> StakeCredential
- fromShelleyStakeReference :: StakeReference StandardCrypto -> StakeAddressReference
- class HasTypeProxy addr => SerialiseAddress addr where
- serialiseAddress :: addr -> Text
- deserialiseAddress :: AsType addr -> Text -> Maybe addr
- data family AsType t
- isKeyAddress :: AddressInEra era -> Bool
Payment addresses
Constructing and inspecting normal payment addresses
data Address addrtype where Source #
Addresses are used as locations where assets live. The address determines the rights needed to spend assets at the address: in particular holding some signing key or being able to satisfy the conditions of a script.
There are currently two types of address:
- Byron addresses, which use the type tag
ByronAddr
; and - Shelley addresses, which use the type tag
ShelleyAddr
. Notably, Shelley addresses support scripts and stake delegation.
The address type is subtly from the ledger era in which each
address type is valid: while Byron addresses are the only choice in the
Byron era, the Shelley era and all subsequent eras support both Byron and
Shelley addresses. The Address
type param only says the type of the address
(either Byron or Shelley). The AddressInEra
type connects the address type
with the era in which it is supported.
Constructors
ByronAddress :: Address -> Address ByronAddr | Byron addresses were the only supported address type in the original Byron era. |
ShelleyAddress :: Network -> PaymentCredential StandardCrypto -> StakeReference StandardCrypto -> Address ShelleyAddr | Shelley addresses allow delegation. Shelley addresses were introduced in Shelley era and are thus supported from the Shelley era onwards |
Instances
Byron addresses
A type used as a tag to distinguish Byron addresses.
Instances
HasTypeProxy ByronAddr Source # | |
FromJSON (Address ByronAddr) Source # | |
Defined in Cardano.Api.Address | |
ToJSON (Address ByronAddr) Source # | |
SerialiseAsRawBytes (Address ByronAddr) Source # | |
Defined in Cardano.Api.Address Methods serialiseToRawBytes :: Address ByronAddr -> ByteString Source # deserialiseFromRawBytes :: AsType (Address ByronAddr) -> ByteString -> Either SerialiseAsRawBytesError (Address ByronAddr) Source # | |
SerialiseAddress (Address ByronAddr) Source # | |
Defined in Cardano.Api.Address | |
data AsType ByronAddr Source # | |
Defined in Cardano.Api.Address |
Shelley addresses
data ShelleyAddr Source #
A type used as a tag to distinguish Shelley addresses.
Instances
makeShelleyAddress :: NetworkId -> PaymentCredential -> StakeAddressReference -> Address ShelleyAddr Source #
data PaymentCredential Source #
Constructors
PaymentCredentialByKey (Hash PaymentKey) | |
PaymentCredentialByScript ScriptHash |
Instances
Eq PaymentCredential Source # | |
Defined in Cardano.Api.Address Methods (==) :: PaymentCredential -> PaymentCredential -> Bool Source # (/=) :: PaymentCredential -> PaymentCredential -> Bool Source # | |
Ord PaymentCredential Source # | |
Defined in Cardano.Api.Address Methods compare :: PaymentCredential -> PaymentCredential -> Ordering Source # (<) :: PaymentCredential -> PaymentCredential -> Bool Source # (<=) :: PaymentCredential -> PaymentCredential -> Bool Source # (>) :: PaymentCredential -> PaymentCredential -> Bool Source # (>=) :: PaymentCredential -> PaymentCredential -> Bool Source # max :: PaymentCredential -> PaymentCredential -> PaymentCredential Source # min :: PaymentCredential -> PaymentCredential -> PaymentCredential Source # | |
Show PaymentCredential Source # | |
Defined in Cardano.Api.Address |
data StakeAddressReference Source #
Constructors
StakeAddressByValue StakeCredential | |
StakeAddressByPointer StakeAddressPointer | |
NoStakeAddress |
Instances
Eq StakeAddressReference Source # | |
Defined in Cardano.Api.Address Methods (==) :: StakeAddressReference -> StakeAddressReference -> Bool Source # (/=) :: StakeAddressReference -> StakeAddressReference -> Bool Source # | |
Show StakeAddressReference Source # | |
Defined in Cardano.Api.Address |
newtype StakeAddressPointer Source #
Constructors
StakeAddressPointer | |
Fields
|
Instances
Eq StakeAddressPointer Source # | |
Defined in Cardano.Api.Address Methods (==) :: StakeAddressPointer -> StakeAddressPointer -> Bool Source # (/=) :: StakeAddressPointer -> StakeAddressPointer -> Bool Source # | |
Show StakeAddressPointer Source # | |
Defined in Cardano.Api.Address |
Addresses in any era
data AddressAny Source #
Either a Byron address or a Shelley address.
Sometimes we need to be able to work with either of the two types of address (Byron or Shelley addresses), but without reference to an era in which the address will be used. This type serves that purpose.
Constructors
AddressByron !(Address ByronAddr) | |
AddressShelley !(Address ShelleyAddr) |
Instances
lexPlausibleAddressString :: Parser Text Source #
parseAddressAny :: Parser AddressAny Source #
Addresses in specific eras
data AddressInEra era where Source #
An Address
that can be used in a particular ledger era.
All current ledger eras support Byron addresses. Shelley addresses are
supported in the ShelleyEra
and later eras.
Constructors
AddressInEra :: AddressTypeInEra addrtype era -> Address addrtype -> AddressInEra era |
Instances
data AddressTypeInEra addrtype era where Source #
Constructors
ByronAddressInAnyEra :: AddressTypeInEra ByronAddr era | |
ShelleyAddressInEra :: ShelleyBasedEra era -> AddressTypeInEra ShelleyAddr era |
Instances
Show (AddressTypeInEra addrtype era) Source # | |
Defined in Cardano.Api.Address | |
NFData (AddressTypeInEra addrtype era) Source # | |
Defined in Cardano.Api.Address Methods rnf :: AddressTypeInEra addrtype era -> () Source # |
byronAddressInEra :: Address ByronAddr -> AddressInEra era Source #
shelleyAddressInEra :: ShelleyBasedEra era -> Address ShelleyAddr -> AddressInEra era Source #
anyAddressInShelleyBasedEra :: ShelleyBasedEra era -> AddressAny -> AddressInEra era Source #
anyAddressInEra :: CardanoEra era -> AddressAny -> Either String (AddressInEra era) Source #
toAddressAny :: Address addr -> AddressAny Source #
makeByronAddressInEra :: NetworkId -> VerificationKey ByronKey -> AddressInEra era Source #
makeShelleyAddressInEra :: ShelleyBasedEra era -> NetworkId -> PaymentCredential -> StakeAddressReference -> AddressInEra era Source #
Stake addresses
Constructing and inspecting stake addresses
data StakeAddress where Source #
Constructors
StakeAddress :: Network -> StakeCredential StandardCrypto -> StakeAddress |
Instances
data StakeCredential Source #
Constructors
StakeCredentialByKey (Hash StakeKey) | |
StakeCredentialByScript ScriptHash |
Instances
stakeAddressCredential :: StakeAddress -> StakeCredential Source #
Get a stake credential from a stake address. This drops the network information.
Instances
data StakeExtendedKey Source #
Shelley-era stake keys using extended ed25519 cryptographic keys.
They can be used for Shelley stake addresses and witnessing transactions that use stake addresses.
These extended keys are used by HD wallets. So this type provides interoperability with HD wallets. The ITN CLI also supported this key type.
The extended verification keys can be converted (via castVerificationKey
)
to ordinary keys (i.e. VerificationKey
StakeKey
) but this is not the
case for the signing keys. The signing keys can be used to witness
transactions directly, with verification via their non-extended verification
key (VerificationKey
StakeKey
).
This is a type level tag, used with other interfaces like Key
.
Instances
Conversion functions
shelleyPayAddrToPlutusPubKHash :: Address ShelleyAddr -> Maybe PubKeyHash Source #
Converts a Shelley payment address to a Plutus public key hash.
Internal conversion functions
toShelleyAddr :: AddressInEra era -> Addr StandardCrypto Source #
toShelleyStakeAddr :: StakeAddress -> RewardAcnt StandardCrypto Source #
toShelleyStakeCredential :: StakeCredential -> StakeCredential StandardCrypto Source #
fromShelleyAddr :: ShelleyBasedEra era -> Addr StandardCrypto -> AddressInEra era Source #
fromShelleyAddrIsSbe :: ShelleyBasedEra era -> Addr StandardCrypto -> AddressInEra era Source #
fromShelleyAddrToAny :: Addr StandardCrypto -> AddressAny Source #
fromShelleyPaymentCredential :: PaymentCredential StandardCrypto -> PaymentCredential Source #
fromShelleyStakeAddr :: RewardAcnt StandardCrypto -> StakeAddress Source #
fromShelleyStakeCredential :: StakeCredential StandardCrypto -> StakeCredential Source #
fromShelleyStakeReference :: StakeReference StandardCrypto -> StakeAddressReference Source #
Serialising addresses
class HasTypeProxy addr => SerialiseAddress addr where Source #
Address serialisation uses different serialisation formats for different kinds of addresses, so it needs its own class.
In particular, Byron addresses are typically formatted in base 58, while Shelley addresses (payment and stake) are formatted using Bech32.
Methods
serialiseAddress :: addr -> Text Source #
deserialiseAddress :: AsType addr -> Text -> Maybe addr Source #
Instances
SerialiseAddress StakeAddress Source # | |
Defined in Cardano.Api.Address Methods serialiseAddress :: StakeAddress -> Text Source # deserialiseAddress :: AsType StakeAddress -> Text -> Maybe StakeAddress Source # | |
SerialiseAddress AddressAny Source # | |
Defined in Cardano.Api.Address Methods serialiseAddress :: AddressAny -> Text Source # deserialiseAddress :: AsType AddressAny -> Text -> Maybe AddressAny Source # | |
IsCardanoEra era => SerialiseAddress (AddressInEra era) Source # | |
Defined in Cardano.Api.Address Methods serialiseAddress :: AddressInEra era -> Text Source # deserialiseAddress :: AsType (AddressInEra era) -> Text -> Maybe (AddressInEra era) Source # | |
SerialiseAddress (Address ShelleyAddr) Source # | |
Defined in Cardano.Api.Address Methods serialiseAddress :: Address ShelleyAddr -> Text Source # deserialiseAddress :: AsType (Address ShelleyAddr) -> Text -> Maybe (Address ShelleyAddr) Source # | |
SerialiseAddress (Address ByronAddr) Source # | |
Defined in Cardano.Api.Address |
Data family instances
A family of singleton types used in this API to indicate which type to use where it would otherwise be ambiguous or merely unclear.
Values of this type are passed to deserialisation functions for example.
Instances
Helpers
isKeyAddress :: AddressInEra era -> Bool Source #
Is the UTxO at the address only spendable via a key witness.