lightningd: only allow closing to native segwit

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: JSON-RPC: `close` `destination` no longer allows p2pkh or p2sh addresses (deprecated v0.11.0)
This commit is contained in:
Rusty Russell
2022-12-12 16:36:04 +10:30
parent ae48c7b78d
commit 66bde4bd9f
6 changed files with 11 additions and 8 deletions

View File

@@ -315,7 +315,7 @@ static void peer_got_shutdown(struct channel *channel, const u8 *msg)
* - if the `scriptpubkey` is not in one of the above forms:
* - SHOULD send a `warning`.
*/
if (!valid_shutdown_scriptpubkey(scriptpubkey, anysegwit, anchors)) {
if (!valid_shutdown_scriptpubkey(scriptpubkey, anysegwit, !anchors)) {
u8 *warning = towire_warningfmt(NULL,
&channel->cid,
"Bad shutdown scriptpubkey %s",

View File

@@ -724,11 +724,11 @@ static struct command_result *json_close(struct command *cmd,
channel->peer->their_features,
OPT_SHUTDOWN_ANYSEGWIT);
if (!valid_shutdown_scriptpubkey(channel->shutdown_scriptpubkey[LOCAL],
anysegwit, !deprecated_apis)) {
anysegwit, false)) {
/* Explicit check for future segwits. */
if (!anysegwit &&
valid_shutdown_scriptpubkey(channel->shutdown_scriptpubkey
[LOCAL], true, !deprecated_apis)) {
[LOCAL], true, false)) {
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"Peer does not allow v1+ shutdown addresses");
}

View File

@@ -1364,7 +1364,7 @@ static void handle_peer_wants_to_close(struct subd *dualopend,
* - if the `scriptpubkey` is not in one of the above forms:
* - SHOULD send a `warning`
*/
if (!valid_shutdown_scriptpubkey(scriptpubkey, anysegwit, anchors)) {
if (!valid_shutdown_scriptpubkey(scriptpubkey, anysegwit, !anchors)) {
u8 *warning = towire_warningfmt(NULL,
&channel->cid,
"Bad shutdown scriptpubkey %s",