cardano-addresses-3.12.0: Library utilities for mnemonic generation and address derivation.
Safe HaskellNone
LanguageHaskell2010

Cardano.Address.Script

Synopsis

Script

data Script (elem :: Type) Source #

A Script type represents multi signature script. The script embodies conditions that need to be satisfied to make it valid.

Since: 3.0.0

Instances

Instances details
Eq elem => Eq (Script elem) Source # 
Instance details

Defined in Cardano.Address.Script

Methods

(==) :: Script elem -> Script elem -> Bool #

(/=) :: Script elem -> Script elem -> Bool #

Show elem => Show (Script elem) Source # 
Instance details

Defined in Cardano.Address.Script

Methods

showsPrec :: Int -> Script elem -> ShowS #

show :: Script elem -> String #

showList :: [Script elem] -> ShowS #

Generic (Script elem) Source # 
Instance details

Defined in Cardano.Address.Script

Associated Types

type Rep (Script elem) :: Type -> Type #

Methods

from :: Script elem -> Rep (Script elem) x #

to :: Rep (Script elem) x -> Script elem #

NFData elem => NFData (Script elem) Source # 
Instance details

Defined in Cardano.Address.Script

Methods

rnf :: Script elem -> () #

FromJSON (Script KeyHash) Source # 
Instance details

Defined in Cardano.Address.Script

Methods

parseJSON :: Value -> Parser (Script KeyHash)

parseJSONList :: Value -> Parser [Script KeyHash]

FromJSON (Script Cosigner) Source # 
Instance details

Defined in Cardano.Address.Script

Methods

parseJSON :: Value -> Parser (Script Cosigner)

parseJSONList :: Value -> Parser [Script Cosigner]

ToJSON elem => ToJSON (Script elem) Source # 
Instance details

Defined in Cardano.Address.Script

Methods

toJSON :: Script elem -> Value

toEncoding :: Script elem -> Encoding

toJSONList :: [Script elem] -> Value

toEncodingList :: [Script elem] -> Encoding

type Rep (Script elem) Source # 
Instance details

Defined in Cardano.Address.Script

serializeScript :: Script KeyHash -> ByteString Source #

This function realizes what cardano-node's `Api.serialiseToCBOR script` realizes This is basically doing the symbolically following: toCBOR [0,multisigScript]

Since: 3.0.0

foldScript :: (a -> b -> b) -> b -> Script a -> b Source #

Script folding

Since: 3.2.0

Script template

data ScriptTemplate Source #

Represents the script template that show the structure of the script and determines the expected place of verification keys corresponding to given cosigners.

Since: 3.2.0

Instances

Instances details
Eq ScriptTemplate Source # 
Instance details

Defined in Cardano.Address.Script

Show ScriptTemplate Source # 
Instance details

Defined in Cardano.Address.Script

Generic ScriptTemplate Source # 
Instance details

Defined in Cardano.Address.Script

Associated Types

type Rep ScriptTemplate :: Type -> Type #

NFData ScriptTemplate Source # 
Instance details

Defined in Cardano.Address.Script

Methods

rnf :: ScriptTemplate -> () #

FromJSON ScriptTemplate Source # 
Instance details

Defined in Cardano.Address.Script

Methods

parseJSON :: Value -> Parser ScriptTemplate

parseJSONList :: Value -> Parser [ScriptTemplate]

ToJSON ScriptTemplate Source # 
Instance details

Defined in Cardano.Address.Script

Methods

toJSON :: ScriptTemplate -> Value

toEncoding :: ScriptTemplate -> Encoding

toJSONList :: [ScriptTemplate] -> Value

toEncodingList :: [ScriptTemplate] -> Encoding

type Rep ScriptTemplate Source # 
Instance details

Defined in Cardano.Address.Script

type Rep ScriptTemplate = D1 ('MetaData "ScriptTemplate" "Cardano.Address.Script" "cardano-addresses-3.12.0-CXdZXYlvM2IBJZenPvTIY5" 'False) (C1 ('MetaCons "ScriptTemplate" 'PrefixI 'True) (S1 ('MetaSel ('Just "cosigners") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Cosigner XPub)) :*: S1 ('MetaSel ('Just "template") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Script Cosigner))))

newtype Cosigner Source #

Represents the cosigner of the script, ie., party that co-shares the script.

Since: 3.2.0

Constructors

Cosigner Word8 

Instances

Instances details
Eq Cosigner Source # 
Instance details

Defined in Cardano.Address.Script

Ord Cosigner Source # 
Instance details

Defined in Cardano.Address.Script

Show Cosigner Source # 
Instance details

Defined in Cardano.Address.Script

Generic Cosigner Source # 
Instance details

Defined in Cardano.Address.Script

Associated Types

type Rep Cosigner :: Type -> Type #

Methods

from :: Cosigner -> Rep Cosigner x #

to :: Rep Cosigner x -> Cosigner #

NFData Cosigner Source # 
Instance details

Defined in Cardano.Address.Script

Methods

rnf :: Cosigner -> () #

FromJSON Cosigner Source # 
Instance details

Defined in Cardano.Address.Script

Methods

parseJSON :: Value -> Parser Cosigner

parseJSONList :: Value -> Parser [Cosigner]

ToJSON Cosigner Source # 
Instance details

Defined in Cardano.Address.Script

Methods

toJSON :: Cosigner -> Value

toEncoding :: Cosigner -> Encoding

toJSONList :: [Cosigner] -> Value

toEncodingList :: [Cosigner] -> Encoding

Hashable Cosigner Source # 
Instance details

Defined in Cardano.Address.Script

FromJSON (Script Cosigner) Source # 
Instance details

Defined in Cardano.Address.Script

Methods

parseJSON :: Value -> Parser (Script Cosigner)

parseJSONList :: Value -> Parser [Script Cosigner]

type Rep Cosigner Source # 
Instance details

Defined in Cardano.Address.Script

type Rep Cosigner = D1 ('MetaData "Cosigner" "Cardano.Address.Script" "cardano-addresses-3.12.0-CXdZXYlvM2IBJZenPvTIY5" 'True) (C1 ('MetaCons "Cosigner" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word8)))

Validation

validateScript :: ValidationLevel -> Script KeyHash -> Either ErrValidateScript () Source #

Validate a Script, semantically

Since: 3.0.0

prettyErrValidateScript :: ErrValidateScript -> String Source #

Pretty-print a script validation error.

Since: 3.0.0

prettyErrValidateScriptTemplate :: ErrValidateScriptTemplate -> String Source #

Pretty-print a script template validation error.

Since: 3.2.0

Hashing

newtype ScriptHash Source #

A ScriptHash type represents script hash. The hash is expected to have size of 28-byte.

Since: 3.0.0

Constructors

ScriptHash 

Instances

Instances details
Eq ScriptHash Source # 
Instance details

Defined in Cardano.Address.Script

Ord ScriptHash Source # 
Instance details

Defined in Cardano.Address.Script

Show ScriptHash Source # 
Instance details

Defined in Cardano.Address.Script

Generic ScriptHash Source # 
Instance details

Defined in Cardano.Address.Script

Associated Types

type Rep ScriptHash :: Type -> Type #

NFData ScriptHash Source # 
Instance details

Defined in Cardano.Address.Script

Methods

rnf :: ScriptHash -> () #

type Rep ScriptHash Source # 
Instance details

Defined in Cardano.Address.Script

type Rep ScriptHash = D1 ('MetaData "ScriptHash" "Cardano.Address.Script" "cardano-addresses-3.12.0-CXdZXYlvM2IBJZenPvTIY5" 'True) (C1 ('MetaCons "ScriptHash" 'PrefixI 'True) (S1 ('MetaSel ('Just "unScriptHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

toScriptHash :: Script KeyHash -> ScriptHash Source #

Computes the hash of a given script, by first serializing it to CBOR.

Since: 3.0.0

scriptHashFromBytes :: ByteString -> Maybe ScriptHash Source #

Construct an ScriptHash from raw ByteString (28 bytes).

Since: 3.0.0

data KeyHash Source #

A KeyHash type represents verification key hash that participate in building multi-signature script. The hash is expected to have size of 28-byte.

Since: 3.0.0

Constructors

KeyHash 

Fields

Instances

Instances details
Eq KeyHash Source # 
Instance details

Defined in Cardano.Address.Script

Methods

(==) :: KeyHash -> KeyHash -> Bool #

(/=) :: KeyHash -> KeyHash -> Bool #

Ord KeyHash Source # 
Instance details

Defined in Cardano.Address.Script

Show KeyHash Source # 
Instance details

Defined in Cardano.Address.Script

Generic KeyHash Source # 
Instance details

Defined in Cardano.Address.Script

Associated Types

type Rep KeyHash :: Type -> Type #

Methods

from :: KeyHash -> Rep KeyHash x #

to :: Rep KeyHash x -> KeyHash #

NFData KeyHash Source # 
Instance details

Defined in Cardano.Address.Script

Methods

rnf :: KeyHash -> () #

ToJSON KeyHash Source # 
Instance details

Defined in Cardano.Address.Script

Methods

toJSON :: KeyHash -> Value

toEncoding :: KeyHash -> Encoding

toJSONList :: [KeyHash] -> Value

toEncodingList :: [KeyHash] -> Encoding

FromJSON (Script KeyHash) Source # 
Instance details

Defined in Cardano.Address.Script

Methods

parseJSON :: Value -> Parser (Script KeyHash)

parseJSONList :: Value -> Parser [Script KeyHash]

type Rep KeyHash Source # 
Instance details

Defined in Cardano.Address.Script

type Rep KeyHash = D1 ('MetaData "KeyHash" "Cardano.Address.Script" "cardano-addresses-3.12.0-CXdZXYlvM2IBJZenPvTIY5" 'False) (C1 ('MetaCons "KeyHash" 'PrefixI 'True) (S1 ('MetaSel ('Just "role") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 KeyRole) :*: S1 ('MetaSel ('Just "digest") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

keyHashFromBytes :: (KeyRole, ByteString) -> Maybe KeyHash Source #

Construct an KeyHash from raw ByteString (28 bytes).

Since: 3.0.0

keyHashFromText :: Text -> Either ErrKeyHashFromText KeyHash Source #

Construct a KeyHash from Text. It should be Bech32 encoded text with one of following hrp: - addr_shared_vkh - stake_shared_vkh - addr_vkh - stake_vkh - policy_vkh - addr_shared_vk - stake_shared_vk - addr_vk - stake_vk - addr_shared_xvk - stake_shared_xvk - addr_xvk - stake_xvk - policy_vk - policy_xvk Raw keys will be hashed on the fly, whereas hash that are directly provided will remain as such. If if hex is encountered Unknown policy key is assumed

Since: 3.1.0

keyHashToText :: KeyHash -> Text Source #

Encode a KeyHash to bech32 Text or hex is key role unknown.

Since: 3.0.0