cardano-rpc
Safe HaskellNone
LanguageHaskell2010

Cardano.Rpc.Server.Internal.UtxoRpc.Predicate

Synopsis

UTxO predicates

matchesUtxoPredicate :: IsCardanoEra era => Proto UtxoPredicate -> TxOut CtxUTxO era -> Bool Source #

Check if a UTxO entry matches a UtxoPredicate. All present fields are combined with AND logic.

matchesAnyUtxoPattern :: IsCardanoEra era => Proto AnyUtxoPattern -> TxOut CtxUTxO era -> Bool Source #

Check if a UTxO entry matches an AnyUtxoPattern. Delegates to the Cardano-specific TxOutputPattern if present.

matchesTxOutputPattern :: IsCardanoEra era => Proto TxOutputPattern -> TxOut CtxUTxO era -> Bool Source #

Check if a tx output matches a TxOutputPattern. Address and asset filters are combined with AND; absent fields are vacuously true.

matchesAddressPattern :: IsCardanoEra era => Proto AddressPattern -> AddressInEra era -> Bool Source #

Check if an address matches an AddressPattern. All present fields (exact, payment, delegation) must match (AND logic). Byron addresses only support exact matching; payment/delegation filters reject them.

matchesAssetPattern :: Proto AssetPattern -> Value -> Bool Source #

Check if a Value contains a native asset matching an AssetPattern. Ada entries are always skipped; zero-quantity entries do not match.

exactAddressPredicate :: IsCardanoEra era => AddressInEra era -> Proto UtxoPredicate Source #

A UtxoPredicate matching UTxOs at the exact address.

extractAddressesFromPredicate :: Proto UtxoPredicate -> Maybe (Set AddressAny) Source #

Try to extract a set of exact addresses from the predicate for use with QueryUTxOByAddress. Returns Just if the optimization is applicable, Nothing otherwise.

predicateLeaves :: Proto UtxoPredicate -> [Proto AnyUtxoPattern] Source #

Every match leaf in the predicate tree, duplicates included, descending through not, allOf and anyOf. Lazy, so a caller can stop after N leaves.

data CompiledUtxoPredicate Source #

A UtxoPredicate compiled into a per-address lookup table; see compileUtxoPredicate.

compileUtxoPredicate :: Proto UtxoPredicate -> Maybe CompiledUtxoPredicate Source #

Compile a predicate once into a per-address lookup table: matching a UTxO then costs one map lookup, not a walk over every address term. Same acceptance rule as extractAddressesFromPredicate.

compiledPredicateAddresses :: CompiledUtxoPredicate -> Set AddressAny Source #

The exact addresses a compiled predicate names, for QueryUTxOByAddress.

matchesCompiledPredicate :: IsCardanoEra era => CompiledUtxoPredicate -> TxOut CtxUTxO era -> Bool Source #

Match a UTxO entry against a predicate already compiled by compileUtxoPredicate.

Transaction predicates

matchesTxPredicate :: Proto TxPredicate -> Proto Tx -> Bool Source #

Check if a tx matches a TxPredicate. All present fields are combined with AND logic.

matchesAnyChainTxPattern :: Proto AnyChainTxPattern -> Proto Tx -> Bool Source #

Check if a tx matches an AnyChainTxPattern. Delegates to the Cardano-specific TxPattern if present.

matchesTxPattern :: Proto TxPattern -> Proto Tx -> Bool Source #

Check if a tx matches a TxPattern. All present fields are combined with AND logic; absent fields are vacuously true.

consumes and the input side of has_address/moves_asset rely on as_output, which the mempool tx conversion never populates (resolving it needs a UTxO lookup outside the pure conversion) - these fields never fire on real mempool traffic today, only in tests that build fixtures with as_output set.

matchesAddressPatternBytes :: Proto AddressPattern -> ByteString -> Bool Source #

Check if raw address bytes match an AddressPattern. Mirrors matchesAddressPattern, but for proto-native tx data where addresses are opaque bytes rather than parsed AddressInEra values: the bytes are parsed via deserialiseFromRawBytes first. Unparseable bytes and Byron addresses only support exact matching, same as matchesAddressPattern.

matchesAssetPatternProto :: (Integer -> Bool) -> Proto AssetPattern -> [Proto Multiasset] -> Bool Source #

Check if a policy/asset-name pattern matches any asset entry across a list of Multiasset bundles. quantityMatches selects which quantities count, since moves_asset and mints_asset apply different sign checks. A BigInt that fails to decode is treated as no match.

Certificate matching

matchesCertificatePattern :: Proto CertificatePattern -> Proto Certificate -> Bool Source #

Check if a certificate matches a CertificatePattern. The five discriminated branches (stake registration/deregistration/delegation, pool registration/retirement) only match the identically-shaped certificate - the newer Conway certificate families (reg/unreg/vote-deleg, DRep, committee) are only reachable through the three "any_*" wildcards below, which scan every certificate variant that carries the relevant credential.

data CertificateCredentials Source #

Credentials a certificate is about, classified once per oneof variant. Exhaustive match, no wildcard: a new certificate variant in the proto is a compile error here, not a silently unmatched cert.

certificateStakeCredentials :: Proto Certificate -> [Proto StakeCredential] Source #

Every stake-shaped credential embedded in a certificate; see certificateCredentials.

certificatePoolKeyHashes :: Proto Certificate -> [ByteString] Source #

Every pool key hash embedded in a certificate; see certificateCredentials.

certificateDRepBytes :: Proto Certificate -> [ByteString] Source #

Every DRep, identified by key/script hash, embedded in a certificate; see certificateCredentials.

Credential serialisation

credentialBytes :: Proto StakeCredential -> ByteString Source #

The bare key/script hash bytes of a credential, regardless of which it is.

serialisePaymentCredential :: PaymentCredential -> ByteString Source #

Serialise a PaymentCredential to raw bytes (the key or script hash).

serialiseStakeCredential :: StakeCredential -> ByteString Source #

Serialise a StakeCredential to raw bytes (the key or script hash).