swaps: trivial rename WITNESS_TEMPLATE_REVERSE_SWAP
What changed, and why it matters
This commit is a simple variable rename from WITNESS_TEMPLATE_REVERSE_SWAP to WITNESS_TEMPLATE_SWAP, plus a comment update explaining the historical naming. The actual swap script logic, structure, and values are unchanged. There is no security issue here.
No action needed. This is a non-security refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch renames a constant and updates all references in _check_swap_scriptcode() and _construct_swap_scriptcode(). The witness template contents (opcodes, pushdata, structure) are identical before and after. The comment clarifies that the same script template is now used for all swaps, not just reverse swaps. No functional or security-relevant change is introduced.
Changed components
electrum/submarine_swaps.pyInspect captured patch +4 / −3
diff --git a/electrum/submarine_swaps.py b/electrum/submarine_swaps.py
index cef15fd..f0e84c5 100644
--- a/electrum/submarine_swaps.py
+++ b/electrum/submarine_swaps.py
@@ -77,7 +77,8 @@ assert MAX_LOCKTIME_DELTA < MIN_FINAL_CLTV_DELTA_FOR_CLIENT
# different length which would still allow for claiming the onchain
# coins but the invoice couldn't be settled
-WITNESS_TEMPLATE_REVERSE_SWAP = [
+# Unified witness-script for all swaps. Historically with Boltz-backend, this was the reverse-swap script.
+WITNESS_TEMPLATE_SWAP = [
opcodes.OP_SIZE,
OPPushDataGeneric(None), # idx 1. length of preimage
opcodes.OP_EQUAL,
@@ -108,7 +109,7 @@ def _check_swap_scriptcode(
) -> None:
assert (refund_pubkey is not None) or (claim_pubkey is not None), "at least one pubkey must be set"
parsed_script = [x for x in script_GetOp(redeem_script)]
- if not match_script_against_template(redeem_script, WITNESS_TEMPLATE_REVERSE_SWAP):
+ if not match_script_against_template(redeem_script, WITNESS_TEMPLATE_SWAP):
raise Exception("rswap check failed: scriptcode does not match template")
if script_to_p2wsh(redeem_script) != lockup_address:
raise Exception("rswap check failed: inconsistent scriptcode and address")
@@ -143,7 +144,7 @@ def _construct_swap_scriptcode(
assert isinstance(refund_pubkey, bytes) and len(refund_pubkey) == 33
assert isinstance(claim_pubkey, bytes) and len(claim_pubkey) == 33
return construct_script(
- WITNESS_TEMPLATE_REVERSE_SWAP,
+ WITNESS_TEMPLATE_SWAP,
values={1: 32, 5: ripemd(payment_hash), 7: claim_pubkey, 10: locktime, 13: refund_pubkey}
)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.