shutdown: don't allow shutdown to p2pkh or p2sh addresses for anchor outputs.

This doesn't have an effect now (except in experimental mode), but it
will when we support anchors.  So we deprecate the use of those in the
close command too.

For experimental mode we have to avoid using p2pkh; adapt that test.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Deprecated: JSON-RPC: `shutdown` no longer allows p2pkh or p2sh addresses.
This commit is contained in:
Rusty Russell
2022-03-31 19:40:50 +10:30
parent 7491af5495
commit 9f06a59e3c
10 changed files with 57 additions and 22 deletions

View File

@@ -1289,6 +1289,12 @@ static void handle_peer_wants_to_close(struct subd *dualopend,
bool anysegwit = feature_negotiated(ld->our_features,
channel->peer->their_features,
OPT_SHUTDOWN_ANYSEGWIT);
bool anchors = feature_negotiated(ld->our_features,
channel->peer->their_features,
OPT_ANCHOR_OUTPUTS)
|| feature_negotiated(ld->our_features,
channel->peer->their_features,
OPT_ANCHORS_ZERO_FEE_HTLC_TX);
/* We shouldn't get this message while we're waiting to finish */
if (channel_unsaved(channel)) {
@@ -1320,7 +1326,7 @@ static void handle_peer_wants_to_close(struct subd *dualopend,
* - if the `scriptpubkey` is not in one of the above forms:
* - SHOULD fail the connection.
*/
if (!valid_shutdown_scriptpubkey(scriptpubkey, anysegwit)) {
if (!valid_shutdown_scriptpubkey(scriptpubkey, anysegwit, anchors)) {
channel_fail_permanent(channel,
REASON_PROTOCOL,
"Bad shutdown scriptpubkey %s",