Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- serialiseAddr ∷ Addr c → ByteString
- data Addr c
- = Addr Network (PaymentCredential c) (StakeReference c)
- | AddrBootstrap (BootstrapAddress c)
- addrPtrNormalize ∷ Addr c → Addr c
- newtype BootstrapAddress c = BootstrapAddress {}
- bootstrapAddressAttrsSize ∷ BootstrapAddress c → Int
- isBootstrapRedeemer ∷ BootstrapAddress c → Bool
- getNetwork ∷ Addr c → Network
- data RewardAccount c = RewardAccount {
- raNetwork ∷ !Network
- raCredential ∷ !(Credential 'Staking c)
- rewardAccountCredentialL ∷ Lens' (RewardAccount c) (Credential 'Staking c)
- rewardAccountNetworkL ∷ Lens' (RewardAccount c) Network
- serialiseRewardAccount ∷ RewardAccount c → ByteString
- deserialiseRewardAccount ∷ Crypto c ⇒ ByteString → Maybe (RewardAccount c)
- bootstrapKeyHash ∷ ∀ c. Crypto c ⇒ BootstrapAddress c → KeyHash 'Payment c
- putAddr ∷ Addr c → Put
- putCredential ∷ Credential kr c → Put
- putPtr ∷ Ptr → Put
- putRewardAccount ∷ RewardAccount c → Put
- putVariableLengthWord64 ∷ Word64 → Put
- newtype Word7 = Word7 Word8
- toWord7 ∷ Word8 → Word7
- fromBoostrapCompactAddress ∷ CompactAddress → CompactAddr c
- compactAddr ∷ Addr c → CompactAddr c
- decompactAddr ∷ ∀ c. (HasCallStack, Crypto c) ⇒ CompactAddr c → Addr c
- data CompactAddr c
- unCompactAddr ∷ CompactAddr c → ShortByteString
- isPayCredScriptCompactAddr ∷ CompactAddr c → Bool
- isBootstrapCompactAddr ∷ CompactAddr c → Bool
- decodeAddr ∷ ∀ c m. (Crypto c, MonadFail m) ⇒ ByteString → m (Addr c)
- decodeAddrEither ∷ ∀ c. Crypto c ⇒ ByteString → Either String (Addr c)
- decodeAddrStateT ∷ (Crypto c, MonadFail m, AddressBuffer b) ⇒ b → StateT Int m (Addr c)
- decodeAddrStateLenientT ∷ (Crypto c, MonadFail m, AddressBuffer b) ⇒ Bool → Bool → b → StateT Int m (Addr c)
- fromCborAddr ∷ ∀ c s. Crypto c ⇒ Decoder s (Addr c)
- fromCborBothAddr ∷ ∀ c s. Crypto c ⇒ Decoder s (Addr c, CompactAddr c)
- fromCborCompactAddr ∷ ∀ c s. Crypto c ⇒ Decoder s (CompactAddr c)
- fromCborBackwardsBothAddr ∷ ∀ c s. Crypto c ⇒ Decoder s (Addr c, CompactAddr c)
- decodeRewardAccount ∷ ∀ c b m. (Crypto c, AddressBuffer b, MonadFail m) ⇒ b → m (RewardAccount c)
- fromCborRewardAccount ∷ ∀ c s. Crypto c ⇒ Decoder s (RewardAccount c)
- newtype Withdrawals c = Withdrawals {
- unWithdrawals ∷ Map (RewardAccount c) Coin
Documentation
serialiseAddr ∷ Addr c → 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 c → Addr c 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 c Source #
Instances
bootstrapAddressAttrsSize ∷ BootstrapAddress c → 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 c → Bool Source #
Return True if a given address is a redeemer address from the Byron Era
getNetwork ∷ Addr c → Network Source #
Lookup a Network Id for an Address
data RewardAccount c Source #
An account based address for rewards
RewardAccount | |
|
Instances
rewardAccountCredentialL ∷ Lens' (RewardAccount c) (Credential 'Staking c) Source #
serialiseRewardAccount ∷ RewardAccount c → ByteString Source #
Serialise a reward account to the external format.
deserialiseRewardAccount ∷ Crypto c ⇒ ByteString → Maybe (RewardAccount c) 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).
bootstrapKeyHash ∷ ∀ c. Crypto c ⇒ BootstrapAddress c → KeyHash 'Payment c Source #
putCredential ∷ Credential kr c → Put Source #
putRewardAccount ∷ RewardAccount c → Put Source #
Compact Address
fromBoostrapCompactAddress ∷ CompactAddress → CompactAddr c Source #
Convert Byron's comapct address into CompactAddr
. This is just an efficient type cast.
compactAddr ∷ Addr c → CompactAddr c Source #
decompactAddr ∷ ∀ c. (HasCallStack, Crypto c) ⇒ CompactAddr c → Addr c Source #
data CompactAddr c Source #
Instances
unCompactAddr ∷ CompactAddr c → ShortByteString Source #
Unwrap the compact address and get to the address' binary representation.
isPayCredScriptCompactAddr ∷ CompactAddr c → Bool Source #
Efficiently check whether compacted adddress is an address with a credential that is a payment script.
isBootstrapCompactAddr ∷ CompactAddr c → Bool Source #
Efficiently check whether compated adddress is a Byron address.
decodeAddr ∷ ∀ c m. (Crypto c, MonadFail m) ⇒ ByteString → m (Addr c) 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 ∷ ∀ c. Crypto c ⇒ ByteString → Either String (Addr c) Source #
Same as decodeAddr
, but produces an Either
result
decodeAddrStateT ∷ (Crypto c, MonadFail m, AddressBuffer b) ⇒ b → StateT Int m (Addr c) Source #
Just like decodeAddrStateLenientT
, but enforces the address to be well-formed.
decodeAddrStateLenientT Source #
∷ (Crypto c, 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 c) |
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 ∷ ∀ c s. Crypto c ⇒ Decoder s (Addr c, CompactAddr c) Source #
This is the decoder for an address that returns both the actual Addr
and the bytes,
that it was encoded as.
fromCborCompactAddr ∷ ∀ c s. Crypto c ⇒ Decoder s (CompactAddr c) 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 ∷ ∀ c s. Crypto c ⇒ Decoder s (Addr c, CompactAddr c) 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 ∷ ∀ c b m. (Crypto c, AddressBuffer b, MonadFail m) ⇒ b → m (RewardAccount c) Source #
fromCborRewardAccount ∷ ∀ c s. Crypto c ⇒ Decoder s (RewardAccount c) Source #
newtype Withdrawals c Source #
This is called wdrl
in the spec.