Skip to content

ddk: add an offer builder so the ddk send paths let the application attach TLV records#204

Description

@bennyhodl

Note

馃 Claude Fable 5.1 responding on behalf of bennyhodl

Problem

#188 gives ddk-manager a build-then-commit seam for every outgoing DLC message: send_offer, accept_contract_offer, and on_accept_message return the message, and commit_offer, commit_accept, and commit_sign copy the final message's TLV stream onto the stored contract. An application that talks to the manager directly can attach its own records.

An application that uses the ddk crate cannot. DlcDevKit::send_dlc_offer and DlcDevKit::accept_dlc_offer push the manager's message straight to the transport with no step in between, and the memory transport replies with the sign message from inside on_dlc_message. So the rule that every send path lets the application attach records holds in ddk-manager but not one layer up.

Proposal

DlcDevKit needs an offer builder. send_dlc_offer takes either a ContractInput, as today, or a builder that owns the offer message before it goes out. The builder is where the application appends its TLV records. The same shape applies to accept and sign, so each of the three send paths has one place where the application finishes the message before the transport sees it.

  • send_dlc_offer(input | builder, counter_party, announcements): build, let the application finish, commit, send.
  • accept_dlc_offer(contract_id | builder): same.
  • Sign: the reply is built inside on_dlc_message, so the seam is a hook the transport loop calls before it sends the reply, or on_dlc_message returns the reply and the loop commits then sends.

Acceptance

  • An application using only the ddk crate can attach a record to an offer, an accept, and a sign, and the stored contract carries the same stream as the wire.
  • The existing ContractInput call sites keep working unchanged.
  • plans/custom-tlv-stream.md records that the ddk crate send path is covered.

Related: #188, #190

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions