Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- serialiseAddr ∷ Addr → ByteString
- data Addr
- addrPtrNormalize ∷ Addr → Addr
- newtype BootstrapAddress = BootstrapAddress {}
- bootstrapAddressAttrsSize ∷ BootstrapAddress → Int
- isBootstrapRedeemer ∷ BootstrapAddress → Bool
- getNetwork ∷ Addr → Network
- data RewardAccount = RewardAccount {
- raNetwork ∷ !Network
- raCredential ∷ !(Credential 'Staking)
- rewardAccountCredentialL ∷ Lens' RewardAccount (Credential 'Staking)
- rewardAccountNetworkL ∷ Lens' RewardAccount Network
- serialiseRewardAccount ∷ RewardAccount → ByteString
- deserialiseRewardAccount ∷ ByteString → Maybe RewardAccount
- bootstrapKeyHash ∷ BootstrapAddress → KeyHash 'Payment
- putAddr ∷ Addr → Put
- putCredential ∷ Credential kr → Put
- putPtr ∷ Ptr → Put
- putRewardAccount ∷ RewardAccount → Put
- putVariableLengthWord64 ∷ Word64 → Put
- newtype Word7 = Word7 Word8
- toWord7 ∷ Word8 → Word7
- fromBoostrapCompactAddress ∷ CompactAddress → CompactAddr
- compactAddr ∷ Addr → CompactAddr
- decompactAddr ∷ HasCallStack ⇒ CompactAddr → Addr
- data CompactAddr
- unCompactAddr ∷ CompactAddr → ShortByteString
- isPayCredScriptCompactAddr ∷ CompactAddr → Bool
- isBootstrapCompactAddr ∷ CompactAddr → Bool
- decodeAddr ∷ ∀ m. MonadFail m ⇒ ByteString → m Addr
- decodeAddrEither ∷ ByteString → Either String Addr
- decodeAddrStateT ∷ (MonadFail m, AddressBuffer b) ⇒ b → StateT Int m Addr
- decodeAddrStateLenientT ∷ (MonadFail m, AddressBuffer b) ⇒ Bool → Bool → b → StateT Int m Addr
- fromCborAddr ∷ Decoder s Addr
- fromCborBothAddr ∷ Decoder s (Addr, CompactAddr)
- fromCborCompactAddr ∷ Decoder s CompactAddr
- fromCborBackwardsBothAddr ∷ Decoder s (Addr, CompactAddr)
- decodeRewardAccount ∷ ∀ b m. (AddressBuffer b, MonadFail m) ⇒ b → m RewardAccount
- fromCborRewardAccount ∷ Decoder s RewardAccount
- newtype Withdrawals = Withdrawals {}
Documentation
serialiseAddr ∷ Addr → ByteString Source #
Serialise an address to the external format.
An address for UTxO.
Contents of Addr data type are intentionally left as lazy, otherwise operating on compact form of an address will result in redundant work.
Instances
addrPtrNormalize ∷ Addr → Addr Source #
This function is implemented solely for the purpose of translating garbage pointers
into knowingly invalid ones. Any pointer that contains a SlotNo, TxIx or CertIx that
is too large to fit into Word32, Word16 and Word16 respectively, will have all of its
values set to 0 using normalizePtr
.
There are two reasons why we can safely do that at the Babbage/Conway era boundary:
- Invalid pointers are no longer allowed in transactions starting with Babbage era
- There are only a handful of
Ptr
s on mainnet that are invalid.
Once the transition is complete and we are officially in Conway era, this translation logic can be removed in favor of a fixed deserializer that does the same thing for all eras prior to Babbage.
newtype BootstrapAddress Source #
Instances
bootstrapAddressAttrsSize ∷ BootstrapAddress → Int Source #
The size of the extra attributes in a bootstrap (ie Byron) address. Used to help enforce that people do not post huge ones on the chain.
isBootstrapRedeemer ∷ BootstrapAddress → Bool Source #
Return True if a given address is a redeemer address from the Byron Era
getNetwork ∷ Addr → Network Source #
Lookup a Network Id for an Address
data RewardAccount Source #
An account based address for rewards
Instances
serialiseRewardAccount ∷ RewardAccount → ByteString Source #
Serialise a reward account to the external format.
deserialiseRewardAccount ∷ ByteString → Maybe RewardAccount Source #
Deserialise a reward account from the external format. This will fail if the input data is not in the right format (or if there is trailing data).
putCredential ∷ Credential kr → Put Source #
Compact Address
fromBoostrapCompactAddress ∷ CompactAddress → CompactAddr Source #
Convert Byron's comapct address into CompactAddr
. This is just an efficient type cast.
data CompactAddr Source #
Instances
unCompactAddr ∷ CompactAddr → ShortByteString Source #
Unwrap the compact address and get to the address' binary representation.
isPayCredScriptCompactAddr ∷ CompactAddr → Bool Source #
Efficiently check whether compacted adddress is an address with a credential that is a payment script.
isBootstrapCompactAddr ∷ CompactAddr → Bool Source #
Efficiently check whether compated adddress is a Byron address.
decodeAddr ∷ ∀ m. MonadFail m ⇒ ByteString → m Addr Source #
Strict decoder for an address from a ByteString
. This will not let you decode some
of the buggy addresses that have been placed on chain. This decoder is intended for
addresses that are to be placed on chian today.
decodeAddrEither ∷ ByteString → Either String Addr Source #
Same as decodeAddr
, but produces an Either
result
decodeAddrStateT ∷ (MonadFail m, AddressBuffer b) ⇒ b → StateT Int m Addr Source #
Just like decodeAddrStateLenientT
, but enforces the address to be well-formed.
decodeAddrStateLenientT Source #
∷ (MonadFail m, AddressBuffer b) | |
⇒ Bool | Enable lenient decoding for Ptrs, i.e. indicate whether junk can follow a Ptr. This is necessary for backwards compatibility only. Setting this argument to True is only needed for backwards compatibility. |
→ Bool | Indicate whether decoder should not enforce the full input to be consumed or not, i.e. allow garbage at the end or not. Setting this argument to True is only needed for backwards compatibility. |
→ b | |
→ StateT Int m Addr |
This is the most general decoder for a Cardano address. This function is not meant to
be used directly, but it is exported for convenice. decodeAddr
and other should be
used instead.
While decoding an Addr the header (the first byte in the buffer) is expected to be in a certain format. Here are the meaning of all the bits:
@@@
┏━━━━━━━━━━━━━━━━┳━┯━┯━┯━┯━┯━┯━┯━┓ ┃ Byron Address ┃1┊0┊0┊0┊0┊0┊1┊0┃ ┣━━━━━━━━━━━━━━━━╋━┿━┿━┿━┿━┿━┿━┿━┫ ┃Shelley Address ┃0┊x┊x┊x┊0┊0┊0┊x┃ ┗━━━━━━━━━━━━━━━━╋━┿━┿━┿━┿━┿━┿━┿━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃0┊0┊0┊0┊0┊0┊0┊0┃ Testnet PaymentKey StakingKey ┃ ┃0┊0┊0┊0┊0┊0┊0┊1┃ Mainnet PaymentKey StakingKey ┃ ┃0┊0┊0┊1┊0┊0┊0┊0┃ Testnet PaymentScript StakingKey ┃ ┃0┊0┊0┊1┊0┊0┊0┊1┃ Mainnet PaymentScript StakingKey ┃ ┃0┊0┊1┊0┊0┊0┊0┊0┃ Testnet PaymentKey StakingScript ┃ ┃0┊0┊1┊0┊0┊0┊0┊1┃ Mainnet PaymentKey StakingScript ┃ ┃0┊0┊1┊1┊0┊0┊0┊0┃ Testnet PaymentScript StakingScript ┃ ┃0┊0┊1┊1┊0┊0┊0┊1┃ Mainnet PaymentScript StakingScript ┃ ┃0┊1┊0┊0┊0┊0┊0┊0┃ Testnet PaymentKey StakingPtr ┃ ┃0┊1┊0┊0┊0┊0┊0┊1┃ Mainnet PaymentKey StakingPtr ┃ ┃0┊1┊0┊1┊0┊0┊0┊0┃ Testnet PaymentScript StakingPtr ┃ ┃0┊1┊0┊1┊0┊0┊0┊1┃ Mainnet PaymentScript StakingPtr ┃ ┃0┊1┊1┊0┊0┊0┊0┊0┃ Testnet PaymentKey StakingNull ┃ ┃0┊1┊1┊0┊0┊0┊0┊1┃ Mainnet PaymentKey StakingNull ┃ ┃0┊1┊1┊1┊0┊0┊0┊0┃ Testnet PaymentScript StakingNull ┃ ┃0┊1┊1┊1┊0┊0┊0┊1┃ Mainnet PaymentScript StakingNull ┃ ┗━┷━┷━┷━┷━┷━┷━┷━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ `Is Mainnet Address `Payment Credential is a Script `Staking Credential is a Script / No Staking Credential `Not a Base Address @@@
fromCborBothAddr ∷ Decoder s (Addr, CompactAddr) Source #
This is the decoder for an address that returns both the actual Addr
and the bytes,
that it was encoded as.
fromCborCompactAddr ∷ Decoder s CompactAddr Source #
Returns the actual bytes that represent an addres, while ensuring that they can
be decoded in any era as an Addr
when need be.
fromCborBackwardsBothAddr ∷ Decoder s (Addr, CompactAddr) Source #
Prior to Babbage era we did not check if a binary blob representing an address was fully consumed, so unfortunately we must preserve this behavior. However, we do not need to preserve the unconsumed bytes in memory, therefore we can to drop the garbage after we successfully decoded the malformed address. We also need to allow bogus pointer address to be deserializeable prior to Babbage era.
decodeRewardAccount ∷ ∀ b m. (AddressBuffer b, MonadFail m) ⇒ b → m RewardAccount Source #
newtype Withdrawals Source #
This is called wdrl
in the spec.