Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data TxSizeLinear = TxSizeLinear ! Lovelace ! Rational
- txSizeLinearMinValue :: TxSizeLinear -> Lovelace
- calculateTxSizeLinear :: TxSizeLinear -> Natural -> Either LovelaceError Lovelace
- data TxFeePolicy = TxFeePolicyTxSizeLinear ! TxSizeLinear
- data NetworkMagic
- makeNetworkMagic :: AProtocolMagic a -> NetworkMagic
-
newtype
MerkleRoot
a =
MerkleRoot
{
- getMerkleRoot :: Hash Raw
-
data
MerkleTree
a
- = MerkleEmpty
- | MerkleTree ! Word32 !( MerkleNode a)
- mtRoot :: MerkleTree a -> MerkleRoot a
- mkMerkleTree :: ToCBOR a => [a] -> MerkleTree a
- mkMerkleTreeDecoded :: [ Annotated a ByteString ] -> MerkleTree a
-
data
MerkleNode
a
- = MerkleBranch !( MerkleRoot a) !( MerkleNode a) !( MerkleNode a)
- | MerkleLeaf !( MerkleRoot a) a
- mkBranch :: MerkleNode a -> MerkleNode a -> MerkleNode a
- mkLeaf :: forall a. ToCBOR a => a -> MerkleNode a
- mkLeafDecoded :: Annotated a ByteString -> MerkleNode a
- data LovelacePortion
- rationalToLovelacePortion :: Rational -> LovelacePortion
- lovelacePortionToRational :: LovelacePortion -> Rational
- data Lovelace
- data LovelaceError
- maxLovelaceVal :: Word64
- mkLovelace :: Word64 -> Either LovelaceError Lovelace
- mkKnownLovelace :: forall n. ( KnownNat n, n <= 45000000000000000) => Lovelace
- lovelaceF :: Format r ( Lovelace -> r)
- unsafeGetLovelace :: Lovelace -> Word64
- lovelaceToInteger :: Lovelace -> Integer
- integerToLovelace :: Integer -> Either LovelaceError Lovelace
- sumLovelace :: ( Foldable t, Functor t) => t Lovelace -> Either LovelaceError Lovelace
- addLovelace :: Lovelace -> Lovelace -> Either LovelaceError Lovelace
- subLovelace :: Lovelace -> Lovelace -> Either LovelaceError Lovelace
- scaleLovelace :: Integral b => Lovelace -> b -> Either LovelaceError Lovelace
- scaleLovelaceRational :: Lovelace -> Rational -> Lovelace
- scaleLovelaceRationalUp :: Lovelace -> Rational -> Lovelace
- divLovelace :: Integral b => Lovelace -> b -> Either LovelaceError Lovelace
- modLovelace :: Integral b => Lovelace -> b -> Either LovelaceError Lovelace
- newtype KeyHash = KeyHash { }
- hashKey :: VerificationKey -> KeyHash
- data CompactAddress
- toCompactAddress :: Address -> CompactAddress
- fromCompactAddress :: CompactAddress -> Address
- unsafeGetCompactAddress :: CompactAddress -> ShortByteString
- newtype ChainDifficulty = ChainDifficulty { }
- dropChainDifficulty :: Dropper s
- encodeKnownCborDataItem :: ToCBOR a => a -> Encoding
- encodeUnknownCborDataItem :: LByteString -> Encoding
- knownCborDataItemSizeExpr :: Size -> Size
- unknownCborDataItemSizeExpr :: Size -> Size
- decodeKnownCborDataItem :: FromCBOR a => Decoder s a
- decodeUnknownCborDataItem :: Decoder s ByteString
- encodeCrcProtected :: ToCBOR a => a -> Encoding
- encodedCrcProtectedSizeExpr :: forall a. ToCBOR a => ( forall t. ToCBOR t => Proxy t -> Size ) -> Proxy a -> Size
- decodeCrcProtected :: forall s a. FromCBOR a => Decoder s a
- newtype BlockCount = BlockCount { }
- newtype UnparsedFields = UnparsedFields ( Map Word8 ByteString )
-
data
Attributes
h =
Attributes
{
- attrData :: !h
- attrRemain :: ! UnparsedFields
- attributesAreKnown :: Attributes a -> Bool
- unknownAttributesLength :: Attributes a -> Int
- toCBORAttributes :: forall t. [( Word8 , t -> ByteString )] -> Attributes t -> Encoding
- fromCBORAttributes :: forall t s. t -> ( Word8 -> ByteString -> t -> Decoder s ( Maybe t)) -> Decoder s ( Attributes t)
- mkAttributes :: h -> Attributes h
- dropAttributes :: Dropper s
- dropEmptyAttributes :: Dropper s
- type AddressHash = AbstractHash Blake2b_224
- addressHash :: ToCBOR a => a -> AddressHash a
- unsafeAddressHash :: ToCBOR a => a -> AddressHash b
-
data
Address
=
Address
{
- addrRoot :: !( AddressHash Address' )
- addrAttributes :: !( Attributes AddrAttributes )
- addrType :: ! AddrType
-
newtype
Address'
=
Address'
{
- unAddress' :: ( AddrType , AddrSpendingData , Attributes AddrAttributes )
- addressF :: Format r ( Address -> r)
- addressDetailedF :: Format r ( Address -> r)
- fromCBORTextAddress :: Text -> Either DecoderError Address
- checkAddrSpendingData :: AddrSpendingData -> Address -> Bool
- checkVerKeyAddress :: VerificationKey -> Address -> Bool
- checkRedeemAddress :: RedeemVerificationKey -> Address -> Bool
- addrToBase58 :: Address -> ByteString
- toCBORAddr :: Address -> Encoding
- toCBORAddrCRC32 :: Address -> Encoding
- decodeAddressBase58 :: Text -> Either DecoderError Address
- encodeAddressBase58 :: Address -> Text
- addrAttributesUnwrapped :: Address -> AddrAttributes
- addrNetworkMagic :: Address -> NetworkMagic
- isRedeemAddress :: Address -> Bool
- makeAddress :: AddrSpendingData -> AddrAttributes -> Address
- makeVerKeyAddress :: NetworkMagic -> VerificationKey -> Address
- makeVerKeyHdwAddress :: NetworkMagic -> HDAddressPayload -> VerificationKey -> Address
- makeRedeemAddress :: NetworkMagic -> RedeemVerificationKey -> Address
- data AddrSpendingData
- data AddrType
- addrSpendingDataToType :: AddrSpendingData -> AddrType
-
data
AddrAttributes
=
AddrAttributes
{
- aaVKDerivationPath :: !( Maybe HDAddressPayload )
- aaNetworkMagic :: ! NetworkMagic
- newtype HDAddressPayload = HDAddressPayload { }
Documentation
data TxSizeLinear Source #
A linear equation on the transaction size. Represents the
s -> a + b*s
function where
s
is the transaction size in bytes,
a
and
b
are
constant coefficients.
Instances
data TxFeePolicy Source #
Transaction fee policy represents a formula to compute the minimal allowed Fee for a transaction. Transactions with lesser fees won't be accepted. The Minimal fee may depend on the properties of a transaction (for example, its Size in bytes), so the policy can't be represented simply as a number.
Recall that a transaction fee is the difference between the sum of its
Inputs and the sum of its outputs. The transaction is accepted when
minimal_fee(tx) <= fee(tx)
, where
minimal_fee
is the function defined
By the policy.
The policy can change during the lifetime of the blockchain (using the Update mechanism). At the moment we have just one policy type (a linear Equation on the transaction size), but in the future other policies may Be added. To make this future-proof, we also have an "unknown" policy used By older node versions (the ones that haven't updated yet).
Instances
data NetworkMagic Source #
Instances
MerkleRoot
newtype MerkleRoot a Source #
Data type for root of Merkle tree
MerkleRoot | |
|
Instances
MerkleTree
data MerkleTree a Source #
MerkleEmpty | |
MerkleTree ! Word32 !( MerkleNode a) |
Instances
mtRoot :: MerkleTree a -> MerkleRoot a Source #
Returns root of Merkle tree
mkMerkleTree :: ToCBOR a => [a] -> MerkleTree a Source #
Smart constructor for
MerkleTree
mkMerkleTreeDecoded :: [ Annotated a ByteString ] -> MerkleTree a Source #
Reconstruct a
MerkleTree
from a decoded list of items
MerkleNode
data MerkleNode a Source #
MerkleBranch !( MerkleRoot a) !( MerkleNode a) !( MerkleNode a) |
MerkleBranch mRoot mLeft mRight |
MerkleLeaf !( MerkleRoot a) a |
MerkleLeaf mRoot mVal |
Instances
mkBranch :: MerkleNode a -> MerkleNode a -> MerkleNode a Source #
mkLeaf :: forall a. ToCBOR a => a -> MerkleNode a Source #
mkLeafDecoded :: Annotated a ByteString -> MerkleNode a Source #
data LovelacePortion Source #
LovelacePortion
is a legacy Byron type that we keep only for
compatibility. It was originally intended to represent a fraction of stake
in the system. It is used only for the thresholds used in the update system
rules, most of which are now themselves unused. The remaining case is no
longer interpreted as a fraction of all stake, but as a fraction of the
number of genesis keys.
It has enormous precision, due to the fact that it was originally intended to represent a fraction of all stake and can cover the precision of all the Lovelace in the system.
It is represented as a rational nominator with a fixed implicit denominator
of 1e15. So the nominator must be in the range
[0..1e15]
. This is also the
representation used on-chain (in update proposals) and in the JSON
genesis file.
It is interpreted as a
Rational
via the provided conversion functions.
Instances
rationalToLovelacePortion :: Rational -> LovelacePortion Source #
Make a
LovelacePortion
from a
Rational
which must be in the range
[0..1]
.
lovelacePortionToRational :: LovelacePortion -> Rational Source #
Turn a
LovelacePortion
into a
Rational
in the range
[0..1]
.
Lovelace
Lovelace is the least possible unit of currency
Instances
data LovelaceError Source #
LovelaceOverflow Word64 | |
LovelaceTooLarge Integer | |
LovelaceTooSmall Integer | |
LovelaceUnderflow Word64 Word64 |
Instances
maxLovelaceVal :: Word64 Source #
Maximal possible value of
Lovelace
Constructors
mkLovelace :: Word64 -> Either LovelaceError Lovelace Source #
Constructor for
Lovelace
returning
LovelaceError
when
c
exceeds
maxLovelaceVal
mkKnownLovelace :: forall n. ( KnownNat n, n <= 45000000000000000) => Lovelace Source #
Construct a
Lovelace
from a
KnownNat
, known to be less than
maxLovelaceVal
Formatting
Conversions
unsafeGetLovelace :: Lovelace -> Word64 Source #
Unwraps
Lovelace
. It's called “unsafe” so that people wouldn't use it
willy-nilly if they want to sum lovelace or something. It's actually safe.
lovelaceToInteger :: Lovelace -> Integer Source #
Arithmetic operations
sumLovelace :: ( Foldable t, Functor t) => t Lovelace -> Either LovelaceError Lovelace Source #
Compute sum of all lovelace in container. Result is
Integer
as a
protection against possible overflow.
addLovelace :: Lovelace -> Lovelace -> Either LovelaceError Lovelace Source #
Addition of lovelace, returning
LovelaceError
in case of overflow
subLovelace :: Lovelace -> Lovelace -> Either LovelaceError Lovelace Source #
Subtraction of lovelace, returning
LovelaceError
on underflow
scaleLovelace :: Integral b => Lovelace -> b -> Either LovelaceError Lovelace Source #
Scale a
Lovelace
by an
Integral
factor, returning
LovelaceError
when
the result is too large
scaleLovelaceRational :: Lovelace -> Rational -> Lovelace Source #
Scale a
Lovelace
by a rational factor, rounding down.
scaleLovelaceRationalUp :: Lovelace -> Rational -> Lovelace Source #
Scale a
Lovelace
by a rational factor, rounding up.
divLovelace :: Integral b => Lovelace -> b -> Either LovelaceError Lovelace Source #
modLovelace :: Integral b => Lovelace -> b -> Either LovelaceError Lovelace Source #
A
KeyHash
refers to a
VerificationKey
Instances
Eq KeyHash Source # | |
Ord KeyHash Source # | |
Defined in Cardano.Chain.Common.KeyHash |
|
Show KeyHash Source # | |
NFData KeyHash Source # | |
Defined in Cardano.Chain.Common.KeyHash |
|
ToCBOR KeyHash Source # | |
FromCBOR KeyHash Source # | |
HeapWords KeyHash Source # | |
Buildable KeyHash Source # | |
NoThunks KeyHash Source # | |
Monad m => ToObjectKey m KeyHash Source # | |
Defined in Cardano.Chain.Common.KeyHash toObjectKey :: KeyHash -> m JSString Source # |
|
MonadError SchemaError m => FromObjectKey m KeyHash Source # | |
Defined in Cardano.Chain.Common.KeyHash |
hashKey :: VerificationKey -> KeyHash Source #
data CompactAddress Source #
A compact in-memory representation for an
Address
.
Convert using
toCompactAddress
and
fromCompactAddress
.
Instances
newtype ChainDifficulty Source #
Chain difficulty represents necessary effort to generate a chain. In the simplest case it can be number of blocks in chain.
Instances
CBOR in CBOR
These utilities are is used in the Byron-era chain encodings in cases where there are extensible parts of the encoding. In thse cases we have to be able to handle unknown extensions and thus decode values where we do not know the concrete type.
To solve this, the serialised representation uses nested CBOR-in-CBOR https://tools.ietf.org/html/rfc7049#section-2.4.4.1 . The nesting means that the size is known without having to decode the body in those cases where we cannot decode the body.
The functions in this module handle the encoding and decoding for the cases of the known and unknown types.
encodeKnownCborDataItem :: ToCBOR a => a -> Encoding Source #
This is an alias for
encodeNestedCbor
.
This function is used to handle the case of a known type, but compatible
with the encoding used by
encodeUnknownCborDataItem
.
encodeUnknownCborDataItem :: LByteString -> Encoding Source #
This is an alias for
encodeNestedCborBytes
, so all its details apply.
This function is used to handle the case of an unknown type, so it takes an opaque blob that is the representation of the value of the unknown type.
knownCborDataItemSizeExpr :: Size -> Size Source #
decodeKnownCborDataItem :: FromCBOR a => Decoder s a Source #
This is an alias for
decodeNestedCbor
.
This function is used to handle the case of a known type, but compatible
with the encoding used by
decodeUnknownCborDataItem
.
decodeUnknownCborDataItem :: Decoder s ByteString Source #
This is an alias for
decodeNestedCborBytes
, so all its details apply.
This function is used to handle the case of an unknown type, so it returns an opaque blob that is the representation of the value of the unknown type.
Cyclic redundancy check
The Byron era address format includes a CRC to help resist accidental corruption. These functions deal with encoding and decoding the format that is used.
encodeCrcProtected :: ToCBOR a => a -> Encoding Source #
Encodes a value of type
a
, protecting it from accidental corruption by
protecting it with a CRC.
encodedCrcProtectedSizeExpr :: forall a. ToCBOR a => ( forall t. ToCBOR t => Proxy t -> Size ) -> Proxy a -> Size Source #
decodeCrcProtected :: forall s a. FromCBOR a => Decoder s a Source #
Decodes a CBOR blob into a value of type
a
, checking the serialised CRC
corresponds to the computed one
newtype BlockCount Source #
Instances
newtype UnparsedFields Source #
Representation of unparsed fields in Attributes. Newtype wrapper is used for clear backward compatibility between previous representation (which was just a single ByteString) during transition from Store to CBOR.
Instances
data Attributes h Source #
Convenient wrapper for the datatype to represent it (in binary format) as k-v map
Attributes | |
|
Instances
attributesAreKnown :: Attributes a -> Bool Source #
Check whether all data from
Attributes
is known, i. e. was successfully
parsed into some structured data
unknownAttributesLength :: Attributes a -> Int Source #
toCBORAttributes :: forall t. [( Word8 , t -> ByteString )] -> Attributes t -> Encoding Source #
fromCBORAttributes :: forall t s. t -> ( Word8 -> ByteString -> t -> Decoder s ( Maybe t)) -> Decoder s ( Attributes t) Source #
mkAttributes :: h -> Attributes h Source #
dropAttributes :: Dropper s Source #
dropEmptyAttributes :: Dropper s Source #
Drop `Attributes ()` making sure that the
UnparsedFields
are empty
type AddressHash = AbstractHash Blake2b_224 Source #
Hash used to identify address.
addressHash :: ToCBOR a => a -> AddressHash a Source #
unsafeAddressHash :: ToCBOR a => a -> AddressHash b Source #
Address
is where you can send Lovelace
Address | |
|
Instances
Hash of this data is stored in
Address
. This type exists mostly
for internal usage.
Instances
Eq Address' Source # | |
Show Address' Source # | |
Generic Address' Source # | |
ToCBOR Address' Source # | |
FromCBOR Address' Source # | |
type Rep Address' Source # | |
Defined in Cardano.Chain.Common.Address
type
Rep
Address'
=
D1
('
MetaData
"Address'" "Cardano.Chain.Common.Address" "cardano-ledger-byron-0.1.0.0-1U5kXR8zMRrE7QjCz70XVD" '
True
) (
C1
('
MetaCons
"Address'" '
PrefixI
'
True
) (
S1
('
MetaSel
('
Just
"unAddress'") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
(
AddrType
,
AddrSpendingData
,
Attributes
AddrAttributes
))))
|
Formatting
fromCBORTextAddress :: Text -> Either DecoderError Address Source #
Deprecated: Use decodeAddressBase58 instead
A function which decodes base58-encoded
Address
Spending data checks
checkAddrSpendingData :: AddrSpendingData -> Address -> Bool Source #
Check whether given
AddrSpendingData
corresponds to given
Address
checkVerKeyAddress :: VerificationKey -> Address -> Bool Source #
Check if given
Address
is created from given
VerificationKey
checkRedeemAddress :: RedeemVerificationKey -> Address -> Bool Source #
Check if given
Address
is created from given
RedeemVerificationKey
Encoding/Decoding
addrToBase58 :: Address -> ByteString Source #
toCBORAddr :: Address -> Encoding Source #
toCBORAddrCRC32 :: Address -> Encoding Source #
decodeAddressBase58 :: Text -> Either DecoderError Address Source #
Decode an address from Base58 encoded Text.
encodeAddressBase58 :: Address -> Text Source #
Encode an address to Text. `decodeAddressBase58 (encodeAddressBase58 x) === Right x`
Utilities
addrAttributesUnwrapped :: Address -> AddrAttributes Source #
Get
AddrAttributes
from
Address
addrNetworkMagic :: Address -> NetworkMagic Source #
Get
NetworkMagic
from
Address
Pattern-matching helpers
Construction
makeAddress :: AddrSpendingData -> AddrAttributes -> Address Source #
Make an
Address
from spending data and attributes.
makeVerKeyAddress :: NetworkMagic -> VerificationKey -> Address Source #
A function for making an address from
VerificationKey
:: NetworkMagic | |
-> HDAddressPayload |
Derivation path |
-> VerificationKey | |
-> Address |
A function for making an HDW address
makeRedeemAddress :: NetworkMagic -> RedeemVerificationKey -> Address Source #
A function for making an address from
RedeemVerificationKey
data AddrSpendingData Source #
Data which is bound to an address and must be revealed in order to spend lovelace belonging to this address.
VerKeyASD ! VerificationKey |
Funds can be spent by revealing a
|
RedeemASD ! RedeemVerificationKey |
Funds can be spent by revealing a
|
Instances
Type of an address. It corresponds to constructors of
AddrSpendingData
.
It's separated, because
Address
doesn't store
AddrSpendingData
, but we
want to know its type.
Instances
addrSpendingDataToType :: AddrSpendingData -> AddrType Source #
Convert
AddrSpendingData
to the corresponding
AddrType
data AddrAttributes Source #
Additional information stored along with address. It's intended
to be put into
Attributes
data type to make it extensible with
softfork.
Instances
newtype HDAddressPayload Source #
HDAddressPayload is a specific address attribute that was used by the Cardano wallet at mainnet launch, prior to moving to a BIP-44 style scheme.
It consisted of
- serialiazed and encrypted using HDPassphrase derivation path from the root key to given descendant key (using ChaChaPoly1305 algorithm)
- cryptographic tag
It is still distinguished as an attribute, but not used by the ledger, because the attributes size limits treat this attribute specially.