| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
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
- data Transaction
- data Frame
- = Historical
- | Mempool
- | Block
- fromBody :: EncodedBody -> Transaction
- assemble :: EncodedBody -> EncodedWitnesses -> Maybe EncodedAuxiliaryData -> Transaction
- decodeCbor :: ByteString -> Either Error Transaction
- encodeCbor :: Transaction -> ByteString
- body :: Transaction -> EncodedBody
- witnesses :: Transaction -> EncodedWitnesses
- frame :: Transaction -> Frame
- scriptValidity :: Transaction -> Bool
- auxiliaryData :: Transaction -> Maybe EncodedAuxiliaryData
- hasScriptData :: Transaction -> Bool
- transactionId :: Transaction -> IO (Either Error TransactionId)
- setBody :: EncodedBody -> Transaction -> Transaction
- setBodySetEncoding :: SetField -> SetEncoding -> Transaction -> Transaction
- setFee :: Word64 -> Transaction -> Transaction
- setScriptValidity :: Bool -> Transaction -> Transaction
- setAuxiliaryData :: Maybe EncodedAuxiliaryData -> Transaction -> Transaction
- setWitnesses :: EncodedWitnesses -> Transaction -> Transaction
- addWitnesses :: EncodedWitnesses -> Transaction -> Either Error Transaction
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
| Show Transaction Source # | |
Defined in Cometa.Transaction Methods showsPrec :: Int -> Transaction -> ShowS # show :: Transaction -> String # showList :: [Transaction] -> ShowS # | |
| Eq Transaction Source # | |
Defined in Cometa.Transaction | |
Outer transaction field order. These layouts describe representation, not validity in a particular ledger era.
Constructors
| Historical |
|
| Mempool |
|
| Block |
|
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.