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

@@ -5,21 +5,19 @@
/* BOLT #2:
*
* 1. `OP_DUP` `OP_HASH160` `20` 20-bytes `OP_EQUALVERIFY` `OP_CHECKSIG`
* (pay to pubkey hash), OR
* 2. `OP_HASH160` `20` 20-bytes `OP_EQUAL` (pay to script hash), OR
* 3. `OP_0` `20` 20-bytes (version 0 pay to witness pubkey hash), OR
* 4. `OP_0` `32` 32-bytes (version 0 pay to witness script hash), OR
* 5. if (and only if) `option_shutdown_anysegwit` is negotiated:
* 1. `OP_0` `20` 20-bytes (version 0 pay to witness pubkey hash), OR
* 2. `OP_0` `32` 32-bytes (version 0 pay to witness script hash), OR
* 3. if (and only if) `option_shutdown_anysegwit` is negotiated:
* * `OP_1` through `OP_16` inclusive, followed by a single push of 2 to 40 bytes
* (witness program versions 1 through 16)
*
* A receiving node:
*...
* - if the `scriptpubkey` is not in one of the above forms:
* - SHOULD fail the connection.
* - SHOULD send a `warning`
*/
bool valid_shutdown_scriptpubkey(const u8 *scriptpubkey,
bool anysegwit);
bool anysegwit,
bool anchors);
#endif /* LIGHTNING_COMMON_SHUTDOWN_SCRIPTPUBKEY_H */