Skip to content

Commit 91a08e3

Browse files
committed
lightningd: respect anysegwit on dual-funding opens too.
Instead of open-coding, use the helper. Signed-off-by: Rusty Russell <[email protected]>
1 parent 9a363c6 commit 91a08e3

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

lightningd/dual_open_control.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,9 @@ static void handle_peer_wants_to_close(struct subd *dualopend,
12121212
struct lightningd *ld = dualopend->ld;
12131213
struct channel *channel = dualopend->channel;
12141214
char *errmsg;
1215+
bool anysegwit = feature_negotiated(ld->our_features,
1216+
channel->peer->their_features,
1217+
OPT_SHUTDOWN_ANYSEGWIT);
12151218

12161219
/* We shouldn't get this message while we're waiting to finish */
12171220
if (channel_unsaved(channel)) {
@@ -1237,20 +1240,13 @@ static void handle_peer_wants_to_close(struct subd *dualopend,
12371240
channel->shutdown_scriptpubkey[REMOTE] = scriptpubkey;
12381241

12391242
/* BOLT #2:
1240-
*
1241-
* 1. `OP_DUP` `OP_HASH160` `20` 20-bytes `OP_EQUALVERIFY` `OP_CHECKSIG`
1242-
* (pay to pubkey hash), OR
1243-
* 2. `OP_HASH160` `20` 20-bytes `OP_EQUAL` (pay to script hash), OR
1244-
* 3. `OP_0` `20` 20-bytes (version 0 pay to witness pubkey hash), OR
1245-
* 4. `OP_0` `32` 32-bytes (version 0 pay to witness script hash)
12461243
*
12471244
* A receiving node:
12481245
*...
12491246
* - if the `scriptpubkey` is not in one of the above forms:
12501247
* - SHOULD fail the connection.
12511248
*/
1252-
if (!is_p2pkh(scriptpubkey, NULL) && !is_p2sh(scriptpubkey, NULL)
1253-
&& !is_p2wpkh(scriptpubkey, NULL) && !is_p2wsh(scriptpubkey, NULL)) {
1249+
if (!valid_shutdown_scriptpubkey(scriptpubkey, anysegwit)) {
12541250
channel_fail_permanent(channel,
12551251
REASON_PROTOCOL,
12561252
"Bad shutdown scriptpubkey %s",

0 commit comments

Comments
 (0)