Skip to content

dlc: rename funding_script_pubkey to funding_witness_script - #180

Merged
bennyhodl merged 1 commit into
masterfrom
funding-witness-script
Aug 15, 2026
Merged

dlc: rename funding_script_pubkey to funding_witness_script#180
bennyhodl merged 1 commit into
masterfrom
funding-witness-script

Conversation

@bennyhodl

Copy link
Copy Markdown
Owner

Summary

DlcTransactions.funding_script_pubkey holds the raw witness script of the fund output, not a script pubkey. A binding consumer used the value directly as a script pubkey and got incorrect results, because the correct script pubkey is the P2WSH wrapping of this value. This PR renames the field to funding_witness_script so the name says what the field holds, and the compiler makes each caller notice the change.

Changes

  • Rename DlcTransactions.funding_script_pubkey to funding_witness_script and update all 148 references across the workspace (ddk-dlc, ddk-manager, ddk, ddk-messages tests, ddk-trie), including the function parameters and local variables that carried the same misleading name.
  • Add DlcTransactions::funding_script_pubkey(), which returns the P2WSH-wrapped script pubkey that appears in the fund output, for callers that want the output script.
  • Add #[serde(alias = "funding_script_pubkey")] so JSON data serialized under the old field name still deserializes. The binary contract storage format is positional, so stored contracts are unaffected.
  • Rename the funding_spk= log labels in contract_updater.rs to funding_witness_script= — they print the witness script.
  • Correct the field doc comment and the ddk-dlc README example.

Every renamed reference was audited: each value originates from make_funding_redeemscript, and every consumer expects the raw witness script (BIP-143 sighash script code, witness-stack assembly, Address::p2wsh, or an explicit .to_p2wsh() call).

The audit found the same misnomer on internal-only identifiers that this PR leaves for a follow-up: SignedChannel.fund_script_pubkey, DlcChannelTransactions.buffer_script_pubkey (holds the buffer witness script from script_code()), the input_script_pubkey parameters in contract_updater.rs, and the script_pubkey parameters in dlc/src/util.rs. None of these crosses the FFI boundary.

This is a breaking API change for ddk-dlc consumers (ddk-ffi, ddk-ts, ddk-rn); the bindings must rename the field when they bump.

Testing

  • cargo check --all-features
  • cargo clippy --all-targets --all-features (no new warnings)
  • cargo fmt --check
  • cargo test -p ddk-dlc --all-features (17 passed), cargo test -p ddk-manager --lib --all-features (41 passed), cargo test -p ddk --lib (41 passed)

The field on DlcTransactions holds the raw witness script, not the
script pubkey of the fund output. The old name caused binding
consumers to use the value directly as a script pubkey. The new name
says what the field holds, and the compiler makes each caller notice
the change.

Add DlcTransactions::funding_script_pubkey() for callers that want
the P2WSH-wrapped script pubkey that appears in the fund output.
Keep a serde alias so data serialized under the old field name still
deserializes.
@bennyhodl
bennyhodl merged commit 7347cf5 into master Aug 15, 2026
134 checks passed
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