dlc: rename funding_script_pubkey to funding_witness_script - #180
Merged
Conversation
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.
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.
Summary
DlcTransactions.funding_script_pubkeyholds 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 tofunding_witness_scriptso the name says what the field holds, and the compiler makes each caller notice the change.Changes
DlcTransactions.funding_script_pubkeytofunding_witness_scriptand update all 148 references across the workspace (ddk-dlc,ddk-manager,ddk,ddk-messagestests,ddk-trie), including the function parameters and local variables that carried the same misleading name.DlcTransactions::funding_script_pubkey(), which returns the P2WSH-wrapped script pubkey that appears in the fund output, for callers that want the output script.#[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.funding_spk=log labels incontract_updater.rstofunding_witness_script=— they print the witness script.ddk-dlcREADME 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 fromscript_code()), theinput_script_pubkeyparameters incontract_updater.rs, and thescript_pubkeyparameters indlc/src/util.rs. None of these crosses the FFI boundary.This is a breaking API change for
ddk-dlcconsumers (ddk-ffi,ddk-ts,ddk-rn); the bindings must rename the field when they bump.Testing
cargo check --all-featurescargo clippy --all-targets --all-features(no new warnings)cargo fmt --checkcargo 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)