hydra
hydra copied to clipboard
Revise `POST /commit` endpoint interface
Discussed in https://github.com/input-output-hk/hydra/discussions/1337
Why
Currently POST /commit endpoint accepts utxos with witnesses as request payload and supports spending from script addresses. However, it does not provide any means to tweak transaction context, making it impractical for many real-world cases that often involve checking transaction validity range, required signers, etc. as part of the validator logic.
What
-
The
/commitendpoint can accept a "Blueprint"Tx(CBOR-encoded) + aUTxO(as JSON) to resolve inputs for higher configurability-
This transactions is used by the hydra-node as as starting point to
draftCommitTx -
Anything that does not conflict with the requirements of a valid head commit transaction should be kept. For example:
- A Hydra
commitTxdoes not need to have some specific validity range, so any lower or upper bound is also present on the resulting commit tx draft - Any inputs, already present are also present on the resulting commit tx draft
- A Hydra
-
The drafted commit tx is balanced (
hydra-nodeestimates and pays fees) and signed by the--cardano-signing-key(as before)
-
-
Tests covering a transaction with additional required signers and lower/upper validity set which assert that the resulting
commitTxhas the same things present as the blueprint has. -
The existing
UTxOWithWitnessesis still supported as a request body on/commit -
API reference and documentation is updated (explain how to use this with
cardano-clias an example)
How
- New signature of
draftCommitTx :: HeadId -> UTxOType tx -> tx -> m tx(roughly) commitTxbasically starts with theTxBodyinstead ofemptyTxBody- The
UTxOWithWitnessesis implemented in terms of the now more capabletx-baseddraftCommitTxby building the blueprint transaction from theUTxOWithWitnesses - Support both request types by making the request a sum-type, e.g.
data DraftCommitTxRequest
= SimpleCommitRequest {utxoToCommit :: UTxO' TxOutWithWitness}
| FullCommitRequest {blueprintTx :: Tx}
TBD
- Mix CBOR and JSON on the request body?