Skip to content

ddk: own the BIP-329 contract label text in contract::labels - #226

Open
bennyhodl wants to merge 1 commit into
masterfrom
benny/225-bip329-labels
Open

bennyhodl wants to merge 1 commit into
masterfrom
benny/225-bip329-labels

Conversation

@bennyhodl

Copy link
Copy Markdown
Owner

Summary

Item 9 of #225. DDK's wallet sync writes DLC funding <id>, the funding outpoint label and DLC close <id>: <outcomes> inline, and the Lygos wallet writes the same strings on its own. ddk::contract::labels now owns that text, so every DDK wallet's BIP-329 export reads the same. It builds without the manager feature.

Changes

  • Add contract::labels:
    • funding_labels(contract_id, outpoint) -> FundingLabels returns the transaction label and the output label, each paired with the txid or outpoint it belongs on.
    • close_label(contract_id, outcomes) -> String.
    • Both return plain strings and use no bip329 types, so a stateless wallet wraps them in its own record type.
  • wallet/command.rs uses the module for the funding labels and the close label. spendable: Some(false) stays with the BIP-329 record it belongs to.
  • The text is unchanged. One test pins it, including outcomes that join to an empty string.

Not changed

  • Lygos also writes DLC refund <id> and DLC cancel <temp id>. DDK has no refund or cancel label today; a refund close is written as DLC close <id>. Adding them would change exports on purpose, so it's left for a separate decision.

Testing

  • cargo test -p ddk --lib: 81 passed, including the new label_text_is_stable and the existing label tests.
  • cargo test -p ddk --test enumeration -- --ignored: the end-to-end flow writes the funding, outpoint and close labels and round-trips the JSONL export.
  • cargo fmt --check, cargo clippy -- -D warnings and cargo check -p ddk --no-default-features pass.
  • Reviewed by GPT-6 Astra. It found one regression: a single empty outcome gained a trailing : . That is fixed, and the test covers it.

The wallet wrote "DLC funding <id>", the funding outpoint label, and
"DLC close <id>: <outcomes>" inline in its sync, and stateless wallets
(Lygos) wrote the same strings on their own. contract::labels now owns
the text so every DDK wallet's export reads the same. It returns plain
strings with their txid/outpoint, so it needs no bip329 types and
compiles without the manager feature. The wallet's sync uses it; the
text is unchanged and a test pins it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant