cometa-0.1.0.0: Idiomatic Haskell bindings to cardano-c
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cometa.Transaction

Description

Transactions retain exact body, witnesses and outer framing. Decoding does not verify signatures, script execution, auxiliary-data hashes or ledger rules. Witness updates preserve the bytes used for the transaction ID. A changed body removes outer verification-key and bootstrap signatures; embedded transaction witnesses remain part of their own unchanged bodies.

import qualified Cometa.Transaction as Tx

reload bytes = Tx.encodeCbor $ Tx.decodeCbor bytes
Synopsis

Documentation

data Transaction Source #

An immutable transaction. Equality compares exact encoded representation, including nonminimal encodings and definite versus indefinite framing. Show is diagnostic; use encodeCbor for storage.

Instances

Instances details
Show Transaction Source # 
Instance details

Defined in Cometa.Transaction

Eq Transaction Source # 
Instance details

Defined in Cometa.Transaction

data Frame Source #

Outer transaction field order. These layouts describe representation, not validity in a particular ledger era.

Constructors

Historical

[body,witnesses,auxiliary-data-or-null]; script validity is true.

Mempool

[body,witnesses,script-validity,auxiliary-data-or-null].

Block

[body,witnesses,auxiliary-data-or-null,script-validity].

Instances

Instances details
Show Frame Source # 
Instance details

Defined in Cometa.Transaction

Methods

showsPrec :: Int -> Frame -> ShowS #

show :: Frame -> String #

showList :: [Frame] -> ShowS #

Eq Frame Source # 
Instance details

Defined in Cometa.Transaction

Methods

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

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

Ord Frame Source # 
Instance details

Defined in Cometa.Transaction

Methods

compare :: Frame -> Frame -> Ordering #

(<) :: Frame -> Frame -> Bool #

(<=) :: Frame -> Frame -> Bool #

(>) :: Frame -> Frame -> Bool #

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

max :: Frame -> Frame -> Frame #

min :: Frame -> Frame -> Frame #

fromBody :: EncodedBody -> Transaction Source #

Assemble an unsigned transaction with a definite four-field mempool frame, true script validity, empty witnesses and absent auxiliary data. This does not balance the body or assert ledger validity.

assemble :: EncodedBody -> EncodedWitnesses -> Maybe EncodedAuxiliaryData -> Transaction Source #

Assemble a fresh definite mempool frame with true script validity. The body, witness set and optional auxiliary data retain their supplied exact bytes. This does not check signatures or the body's auxiliary-data commitment.

decodeCbor :: ByteString -> Either Error Transaction Source #

Decode exactly one historical, mempool or block frame, accepting definite and indefinite arrays. Preserve every byte. Malformed, trailing, unsupported or duplicate-field encodings return a structured error. No native resources or secret keys are acquired.

encodeCbor :: Transaction -> ByteString Source #

Exact transaction encoding. Updates retain unchanged component bytes and the original outer array header and ending, including indefinite framing.

body :: Transaction -> EncodedBody Source #

Body with its exact identity-bearing encoding.

witnesses :: Transaction -> EncodedWitnesses Source #

Outer witness set with its exact encoding.

frame :: Transaction -> Frame Source #

Original outer field order.

scriptValidity :: Transaction -> Bool Source #

Claimed script validity. Historical frames implicitly claim true.

auxiliaryData :: Transaction -> Maybe EncodedAuxiliaryData Source #

Optional auxiliary data, preserving its original encoding.

hasScriptData :: Transaction -> Bool Source #

Whether the outer witness set contains at least one datum or redeemer. Script bytes alone do not count, and nested transactions are inspected independently. This does not run or validate a script.

transactionId :: Transaction -> IO (Either Error TransactionId) Source #

BLAKE2b-256 of the exact body bytes, independent of witnesses and framing. Native hashing failures return NativeError.

setBody :: EncodedBody -> Transaction -> Transaction Source #

Replace the body. A semantically equal body is an exact no-op, retaining existing signatures and encodings. A changed body uses the supplied encoding and removes only the outer verification-key and bootstrap witnesses. Scripts, datums, redeemers, auxiliary data and nested transaction witnesses are retained. The caller must recheck fees, auxiliary-data commitments and ledger validity.

setBodySetEncoding :: SetField -> SetEncoding -> Transaction -> Transaction Source #

Change a present body's collection tag, retaining unrelated field bytes. An encoding change removes outer key/bootstrap signatures even when the body has the same semantic values. Absent fields and unchanged tags are exact no-ops. Recheck fees and protocol encoding requirements before signing again.

setFee :: Word64 -> Transaction -> Transaction Source #

Change the fee in lovelace, removing outer key signatures when it changes. An unchanged fee preserves the complete original transaction.

setScriptValidity :: Bool -> Transaction -> Transaction Source #

Change claimed script validity without changing the body hash or witnesses. A same-value update is an exact no-op. Historical frames cannot encode false: setting false promotes them to mempool order, retaining definite/indefinite framing and every component byte. Other frames retain their original order.

setAuxiliaryData :: Maybe EncodedAuxiliaryData -> Transaction -> Transaction Source #

Replace auxiliary data without changing the body or its key signatures. This does not update the body's auxiliary-data commitment: supply a matching body separately using setBody. Equal auxiliary bytes are an exact no-op.

setWitnesses :: EncodedWitnesses -> Transaction -> Transaction Source #

Replace the outer witness set without changing the body, its hash or any framing bytes. An equal witness value preserves the original encoding.

addWitnesses :: EncodedWitnesses -> Transaction -> Either Error Transaction Source #

Merge partial witnesses into the outer set. Conflicting signatures for the same verification key fail. Unchanged body and nested witness bytes remain exact; no signature verification or script evaluation occurs.