Skip to content

fix: add backward compat for DlcOffer without protocol_version#238

Merged
matthewjablack merged 1 commit into
masterfrom
fix/backward-compat-dlcoffer-protocol-version
Jun 27, 2026
Merged

fix: add backward compat for DlcOffer without protocol_version#238
matthewjablack merged 1 commit into
masterfrom
fix/backward-compat-dlcoffer-protocol-version

Conversation

@matthewjablack

Copy link
Copy Markdown
Contributor

Summary

Re-introduces backward compatibility for deserializing old-format DlcOffer messages that lack the protocol_version field (pre-dlcspecs PR #163).

The previous heuristic (removed in #237) incorrectly required contract_flags === 0, which broke when contract_flags is 0x01 (refund-to-accepter). This version only checks whether the first 4 bytes are a plausible protocol_version (1-10), matching the Rust implementation in dlcdevkit PR #165.

Changes

  • Peek first 4 bytes after type as u32 — if 1-10, treat as new format with protocol_version; otherwise treat as old format (default protocolVersion = 1)
  • contract_flags is read unconditionally in both paths, supporting any value including 0x01

All 419 existing tests pass, including cross-language compatibility tests against Rust-DLC test vectors.

Re-introduces the heuristic for detecting old-format DlcOffer messages
that lack the protocol_version field (pre-dlcspecs PR #163).

The previous heuristic (removed in #237) incorrectly required
contract_flags === 0, which broke when contract_flags is 0x01
(refund-to-accepter). This version only checks whether the first 4 bytes
are a plausible protocol_version (1-10), matching the Rust
implementation in dlcdevkit.
@matthewjablack matthewjablack merged commit b2f38bf into master Jun 27, 2026
2 checks passed
@matthewjablack matthewjablack deleted the fix/backward-compat-dlcoffer-protocol-version branch June 27, 2026 11:44
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