| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cometa.Address.Shelley
Description
Base, enterprise and pointer payment addresses. Construction and byte conversion
are pure. Byron and reward addresses return UnsupportedAddressType when imported as bytes.
import qualified Cometa.Address.Shelley as Address import qualified Cometa.Credential as Credential receivingAddress :: Credential.KeyHash Credential.Payment -> Address.Address receivingAddress key = Address.enterprise Address.mainnet (Credential.KeyCredential key)
Synopsis
- data NetworkId
- mkNetworkId :: Integer -> Either Error NetworkId
- networkIdValue :: NetworkId -> Word8
- mainnet :: NetworkId
- testnet :: NetworkId
- data Address
- data StakePointer = StakePointer {
- slot :: !Word32
- transactionIndex :: !Word32
- certificateIndex :: !Word32
- pointer :: NetworkId -> Credential Payment -> StakePointer -> Address
- pointerRef :: Address -> Maybe StakePointer
- base :: NetworkId -> Credential Payment -> Credential Stake -> Address
- enterprise :: NetworkId -> Credential Payment -> Address
- networkId :: Address -> NetworkId
- paymentCredential :: Address -> Credential Payment
- stakeCredential :: Address -> Maybe (Credential Stake)
- fromBytes :: ByteString -> Either Error Address
- toBytes :: Address -> ByteString
- fromText :: Text -> Either Error Address
- toText :: Address -> Text
Networks
Four-bit network tag, 0 through 15. Tag 1 denotes mainnet; every other
tag uses the test-network Bech32 prefix. This tag is not a network magic.
Equality and ordering compare the number; Show is diagnostic.
minBound is 0 and maxBound is 15.
Instances
| Bounded NetworkId Source # | |
| Show NetworkId Source # | |
| Eq NetworkId Source # | |
| Ord NetworkId Source # | |
mkNetworkId :: Integer -> Either Error NetworkId Source #
Validate a network tag. Values outside 0..15 return InvalidNetworkId.
networkIdValue :: NetworkId -> Word8 Source #
Numeric four-bit tag.
Conventional test-network tag 0. Does not distinguish preview or preprod.
Construction
An immutable address. Equality and ordering compare form (base,
enterprise, pointer), network, then credentials; Show is diagnostic.
data StakePointer Source #
Location of a stake registration. Each component is an unsigned 32-bit value.
Constructors
| StakePointer | |
Fields
| |
Instances
| Show StakePointer Source # | |
Defined in Cometa.Address.Shelley Methods showsPrec :: Int -> StakePointer -> ShowS # show :: StakePointer -> String # showList :: [StakePointer] -> ShowS # | |
| Eq StakePointer Source # | |
Defined in Cometa.Address.Shelley | |
| Ord StakePointer Source # | |
Defined in Cometa.Address.Shelley Methods compare :: StakePointer -> StakePointer -> Ordering # (<) :: StakePointer -> StakePointer -> Bool # (<=) :: StakePointer -> StakePointer -> Bool # (>) :: StakePointer -> StakePointer -> Bool # (>=) :: StakePointer -> StakePointer -> Bool # max :: StakePointer -> StakePointer -> StakePointer # min :: StakePointer -> StakePointer -> StakePointer # | |
pointer :: NetworkId -> Credential Payment -> StakePointer -> Address Source #
Assemble a pointer address from payment authority and a registration location.
pointerRef :: Address -> Maybe StakePointer Source #
Registration location, present only in pointer addresses.
base :: NetworkId -> Credential Payment -> Credential Stake -> Address Source #
Assemble a base address from network, payment authority and stake authority, in that order. Key and script credentials are supported in both positions.
enterprise :: NetworkId -> Credential Payment -> Address Source #
Assemble an address with payment authority and no staking rights.
Inspection
paymentCredential :: Address -> Credential Payment Source #
Payment authority carried by every payment address.
stakeCredential :: Address -> Maybe (Credential Stake) Source #
Staking authority; absent for enterprise and pointer addresses.
Encoding
fromBytes :: ByteString -> Either Error Address Source #
Import exact bytes. Byron, reward and reserved headers return
UnsupportedAddressType. Empty input or incorrect exact lengths return
InvalidShelleyAddress. Pointer components must be minimally encoded, fit
32 bits and consume the full input. All four-bit network tags are retained.
toBytes :: Address -> ByteString Source #
Serialize exact header and credential bytes: 57 bytes for base addresses, 29 for enterprise addresses, and 32–44 for pointer addresses.
fromText :: Text -> Either Error Address Source #
Parse lowercase or all-uppercase Bech32. Mixed case, non-ASCII, empty,
overlong (more than 120 characters), or mismatched network/form prefixes
return InvalidShelleyAddressText. Malformed encoding or checksum returns
InvalidShelleyAddressText; unsupported headers return UnsupportedAddressType;
incorrect exact lengths return InvalidShelleyAddress.