Repository navigation
ddk: take per-outcome payout script overrides as an input to the stateless API - #223
Closed
matthewjablack wants to merge 1 commit into
Closed
matthewjablack wants to merge 1 commit into
matthewjablack wants to merge 1 commit into
Conversation
…eless API A CET pays the offering and accepting parties and nobody else. A loan settled by a DLC needs an outcome that pays a third party, the liquidator, in the lender's place. Every stateless entry point rebuilds the CETs and signs or verifies in the same call, so an application has nowhere to patch them itself. Each operation that touches CETs now takes an optional map of enum outcome to script. For a named outcome the accepting party's output pays that script instead. DDK does not define how the map travels between the parties; the application owns that, for example as a TLV record on the offer.
Owner
|
Note 🤖 Claude Opus 5.5 responding on behalf of bennyhodl Replaced by #224. We went with the TLV record (type 65005) instead of a parameter on the stateless API, so the manager and the stateless module read the overrides from the same offer, and both build the same CETs in one shared builder. Overrides can name an enum outcome or a numeric range, and a manager only accepts an offer carrying the record if the application allows the type ( |
Contributor
Author
|
Superseded by #224. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative to #222, after Benny's point that the application owns TLV parsing. DDK doesn't define a record here and never reads one from a message. It takes the overrides as a plain input.
A CET pays the offerer or the accepter and nobody else. A loan settled by a DLC needs an outcome that pays whoever liquidated the position on the EVM side, in the lender's place. Every stateless entry point rebuilds the CETs inside
context_from_messagesand signs or verifies in the same call, so an application that parses its own TLV still has nowhere to put the result. That's the part DDK has to own.PayoutScriptOverridesis aHashMap<String, ScriptBuf>keyed by enum outcome. For a named outcome, the output that would have paid the accepter'spayout_spkpays that script instead. Amounts come from the descriptor, so a liquidation outcome is written asoffer = 0, accept = total. The accepter is the lender in a loan and a liquidator is paid in the lender's place, so the lender liquidating itself is the normal accepter payout with nothing to override.It's an
Option<&PayoutScriptOverrides>on every operation that touches CET bytes:create_dlc_transactions,create_signed_dlc_transactions,sign_acceptand the spliced and raw witness variants,finalize_signand its variants,sign_cet,create_cet_adaptor_signaturesandverify_cet_adaptor_signatures, and a field onAcceptOfferParams.sign_refund,create_funding_psbt,compute_contract_idandcreate_dlc_splice_inputonly use the funding or refund transaction and are unchanged. Both parties have to pass the same map to every call on a contract, since adaptor signatures commit to the CET bytes. How the map travels is the application's problem, a TLV record on the offer in our case.The rewrite runs in
build_contextafter every CET is built and before anything is signed. An outcome no enum descriptor has, or an empty script, is rejected. Numerical descriptors are skipped. The accepter's output is found by script, so offer and accept payout scripts have to differ, which every real contract already does.This is a breaking signature change on the 2.0 rc. I went with one parameter rather than
_with_overridesvariants because the API already has spliced and raw witness variants and a third axis would get silly. Most of the diff isNoneat call sites in tests and examples.Tests cover the rewrite through
create_dlc_transactions, an unknown outcome rejected, an empty script rejected, and adaptor signatures made with the overrides verifying with them and failing without. Workspace lib tests green, clippy and fmt clean on ddk. I didn't run the bitcoind backed stateless integration tests. The 1.x manager path is not touched here; dlcd-rs on 1.1.2 would still need #222 or a move to the stateless API.