mirror of
https://github.com/ElementsProject/lightning.git
synced 2026-08-13 12:32:55 +02:00
New subdaemon implementing the BOLT2 simple close protocol, replacing `lightning_closingd` when `option_simple_close` is negotiated: - Each peer independently sends `closing_complete` with their fee proposal; - The other side signs it and sends `closing_sig`; - Both sides broadcast two conflicting closing transactions and whichever confirms first wins. Key protocol details: - Closer pays the fee and closee receives their exact channel balance; - TLV variants selected per BOLT2: `closer_output_only`, `closer_and_closee_outputs`, `closee_output_only`; - Sequence 0xFFFFFFFD enables RBF via re-sending `closing_complete`; - Script mismatch on `closee_scriptpubkey` warns and fails to reconnect; common/shutdown_scriptpubkey.h/c: removed `static` from `is_valid_op_return` so it can be used in `simpleclosed.c`
39 lines
1.5 KiB
C
39 lines
1.5 KiB
C
#ifndef LIGHTNING_COMMON_SHUTDOWN_SCRIPTPUBKEY_H
|
|
#define LIGHTNING_COMMON_SHUTDOWN_SCRIPTPUBKEY_H
|
|
#include "config.h"
|
|
#include <ccan/short_types/short_types.h>
|
|
|
|
/* BOLT #2:
|
|
*
|
|
* 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)
|
|
* 4. if (and only if) `option_simple_close` is negotiated:
|
|
* * `OP_RETURN` followed by one of:
|
|
* * `6` to `75` inclusive followed by exactly that many bytes
|
|
* * `76` followed by `76` to `80` followed by exactly that many bytes
|
|
*
|
|
* A receiving node:
|
|
*...
|
|
* - if the `scriptpubkey` is not in one of the above forms:
|
|
* - SHOULD send a `warning`
|
|
*/
|
|
|
|
/* We still allow them to specify an old-style P2PKH or P2SH (though we
|
|
* never will send such a thing!) if they're not using anchors. */
|
|
/* BOLT #2:
|
|
* 4. if (and only if) `option_simple_close` is negotiated:
|
|
* * `OP_RETURN` followed by one of:
|
|
* * `6` to `75` inclusive followed by exactly that many bytes
|
|
* * `76` followed by `76` to `80` followed by exactly that many bytes
|
|
*/
|
|
bool is_valid_op_return(const u8 *scriptpubkey, size_t scriptpubkey_len);
|
|
|
|
bool valid_shutdown_scriptpubkey(const u8 *scriptpubkey,
|
|
bool anysegwit,
|
|
bool allow_oldstyle,
|
|
bool option_simple_close);
|
|
|
|
#endif /* LIGHTNING_COMMON_SHUTDOWN_SCRIPTPUBKEY_H */
|