@@ -1212,6 +1212,9 @@ static void handle_peer_wants_to_close(struct subd *dualopend,
1212
1212
struct lightningd * ld = dualopend -> ld ;
1213
1213
struct channel * channel = dualopend -> channel ;
1214
1214
char * errmsg ;
1215
+ bool anysegwit = feature_negotiated (ld -> our_features ,
1216
+ channel -> peer -> their_features ,
1217
+ OPT_SHUTDOWN_ANYSEGWIT );
1215
1218
1216
1219
/* We shouldn't get this message while we're waiting to finish */
1217
1220
if (channel_unsaved (channel )) {
@@ -1237,20 +1240,13 @@ static void handle_peer_wants_to_close(struct subd *dualopend,
1237
1240
channel -> shutdown_scriptpubkey [REMOTE ] = scriptpubkey ;
1238
1241
1239
1242
/* 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)
1246
1243
*
1247
1244
* A receiving node:
1248
1245
*...
1249
1246
* - if the `scriptpubkey` is not in one of the above forms:
1250
1247
* - SHOULD fail the connection.
1251
1248
*/
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 )) {
1254
1250
channel_fail_permanent (channel ,
1255
1251
REASON_PROTOCOL ,
1256
1252
"Bad shutdown scriptpubkey %s" ,
0 commit comments