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

Cometa.Transaction.Balancing

Description

Complete an existing transaction using explicit wallet and ledger snapshots. Balancing returns an unsigned copy; it never changes the supplied transaction.

Synopsis

Documentation

balance :: Config -> [Utxo] -> Transaction -> IO (Either Error Transaction) Source #

Balance an existing transaction with the same configuration used by build. Supply resolved spending, reference and collateral inputs for every level; wallet candidates in the configuration may also provide these snapshots. Every existing outer output is treated as a payment, including previous change. The existing fee and configured minimum fee are lower bounds. The imported network id is retained.

The result drops outer key/bootstrap signatures and retains signed nested intent bodies and witnesses. Native serialization may normalize enclosing CBOR array framing; it does not promise byte-for-byte transaction interchange. Spending redeemers follow their original inputs when selection changes input order. Script budgets, commitments, collateral and fees are recalculated. Missing/conflicting inputs or invalid redeemer positions fail explicitly. Callback exceptions and cancellation release scoped resources before propagating. No provider queries, signing or submission occur; ledger acceptance is separate.

balanceWithRedeemers :: Config -> [Utxo] -> Map RedeemerId DeferredRedeemer -> Transaction -> IO (Either Error Transaction) Source #

Like balance, replacing selected outer redeemer payloads on every balancing iteration. Keys identify purpose/index pairs in the ORIGINAL transaction; every key must already have a witness redeemer. Spending associations follow their original inputs even when their indices change. Other purposes retain their existing body order. Callbacks receive the current draft and canonically ordered resolved outer spending inputs. They may run repeatedly and must be deterministic. Use Cometa.Transaction.Deferred to compose pure queries. Nested redeemers are signed intent content and cannot be replaced by this operation.