| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cometa.Transaction.Body
Description
Transaction bodies with typed semantic fields and exact imported identity.
Construct a minimal body, update its typed fields, then retain EncodedBody
for hashing or signing. Reassembling semantic fields deliberately produces a
fresh encoding and can change a transaction identifier.
minimal = body [] [] 0
Synopsis
- data Body = Body {
- bodyFields :: !Fields
- bodyFee :: !Word64
- bodyUpdate :: !(Maybe UpdateProposal)
- bodyCollateral :: !(Maybe [Input])
- bodyCollateralReturn :: !(Maybe Output)
- bodyTotalCollateral :: !(Maybe Word64)
- bodySubTransactions :: !(Maybe [SubTransaction])
- bodyStartingAccountBalanceIntervals :: !(Maybe (Entries RewardAddress BalanceInterval))
- body :: [Input] -> [Output] -> Word64 -> Body
- fee :: Body -> Word64
- setFee :: Word64 -> Body -> Body
- setFeeEncoded :: Word64 -> EncodedBody -> EncodedBody
- encodeCbor :: Body -> Either Error ByteString
- encodeCborWith :: SetEncoding -> Body -> Either Error ByteString
- data SetField
- setEncoding :: SetField -> EncodedBody -> Maybe SetEncoding
- inputsAreTagged :: EncodedBody -> Bool
- withSetEncoding :: SetField -> SetEncoding -> EncodedBody -> EncodedBody
- data EncodedBody
- decodeCbor :: ByteString -> Either Error EncodedBody
- fromBody :: Body -> Either Error EncodedBody
- toBody :: EncodedBody -> Body
- toCbor :: EncodedBody -> ByteString
- hash :: EncodedBody -> IO (Either Error TransactionId)
Documentation
Semantic transaction-body data. Equality includes field presence, list order, and exact encodings of embedded hash-bearing data. It does not compare the imported containing-body encoding. No ledger-state validation is implied.
Constructors
| Body | |
Fields
| |
body :: [Input] -> [Output] -> Word64 -> Body Source #
Assemble required references, ordered outputs and fee with optional fields absent. Empty input/output lists are representable but may fail ledger rules.
setFee :: Word64 -> Body -> Body Source #
Set a fee in lovelace. Other semantic fields remain independent. Construct
a fresh EncodedBody before signing this edited body.
setFeeEncoded :: Word64 -> EncodedBody -> EncodedBody Source #
Edit only a validated body's fee, retaining exact nested field bytes. An unchanged fee returns the exact original body. A changed fee uses a fresh definite outer map in numeric key order; other fields keep their original encodings, including imported historical empty collections. The input snapshot remains independent. Any signatures over the previous identifier need renewal.
encodeCbor :: Body -> Either Error ByteString Source #
Encode a fresh definite map in numeric field order, using shortest numbers
and tag 258 on sets. Present empty or duplicate guards return
InvalidTransactionField. Embedded inline data and subtransactions retain exact
identity. Importing an existing signed body should use toCbor instead.
encodeCborWith :: SetEncoding -> Body -> Either Error ByteString Source #
Encode fresh body fields with the requested set tags. Embedded values keep their own encoding choices. Protocol validity is the caller's responsibility.
Set-valued fields in this body schema. Outputs and maps are not sets.
Constructors
| Inputs | Spending inputs. |
| Certificates | Stake and governance certificates. |
| Guards | Required signer or guard credentials. |
| ReferenceInputs | Reference inputs. |
| Proposals | Governance proposals. |
| CollateralInputs | Collateral inputs. |
| SubTransactions | Included subtransactions; their internal encodings are unchanged. |
Instances
| Bounded SetField Source # | |
| Enum SetField Source # | |
Defined in Cometa.Transaction.Body | |
| Show SetField Source # | |
| Eq SetField Source # | |
| Ord SetField Source # | |
Defined in Cometa.Transaction.Body | |
setEncoding :: SetField -> EncodedBody -> Maybe SetEncoding Source #
Observe one field's set tag. An absent optional field returns Nothing.
inputsAreTagged :: EncodedBody -> Bool Source #
Whether the encoded spending-input collection carries set tag 258.
Other tagged collections do not affect this result; an absent input field
returns False. This observes the exact body snapshot without re-encoding.
withSetEncoding :: SetField -> SetEncoding -> EncodedBody -> EncodedBody Source #
Change one present field's set tag. Absence and an unchanged tag preserve the exact original body. A change rebuilds the outer map in numeric key order, retaining all other field bytes and the selected array's contents. It can change the body hash: signatures over the previous body must be renewed.
data EncodedBody Source #
Exact transaction-body bytes paired with semantic data. Equality compares bytes, so alternative integer widths, tags and map order remain distinguishable.
Instances
| Show EncodedBody Source # | |
Defined in Cometa.Transaction.Body Methods showsPrec :: Int -> EncodedBody -> ShowS # show :: EncodedBody -> String # showList :: [EncodedBody] -> ShowS # | |
| Eq EncodedBody Source # | |
Defined in Cometa.Transaction.Body | |
decodeCbor :: ByteString -> Either Error EncodedBody Source #
Decode all pinned native body fields, including typed Dijkstra fields 23-27. Unknown keys, repeated keys, missing inputsoutputsfee, malformed nested data, and trailing bytes return a structured error. Definite and indefinite maps, nonminimal numbers and optional set tags retain their original byte identity.
fromBody :: Body -> Either Error EncodedBody Source #
Validate fresh assembly and pair semantic data with its encoding. Present
empty guards or repeated guard credentials return InvalidTransactionField.
toBody :: EncodedBody -> Body Source #
Inspect semantic fields without changing the original body bytes.
toCbor :: EncodedBody -> ByteString Source #
Exact imported or freshly encoded ledger transaction-body bytes.
hash :: EncodedBody -> IO (Either Error TransactionId) Source #
Hash the exact body bytes with native BLAKE2b-256. This operation does not
normalize or rebuild the body. Native failures remain NativeError.