common: implement op_return test.
Since we included the spec for it, this is a good time to implement it. I also asked chatgpt to write some unit tests. I had to mangle them a bit, but it probably saved me a few minutes. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1227,7 +1227,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, false)) {
|
||||
u8 *warning = towire_warningfmt(NULL,
|
||||
&channel->cid,
|
||||
"Bad shutdown scriptpubkey %s",
|
||||
|
||||
@@ -759,10 +759,10 @@ static struct command_result *json_close(struct command *cmd,
|
||||
/* In theory, this could happen if the peer had anysegwit when channel was
|
||||
* established, and doesn't now. Doesn't happen, and if it did we could
|
||||
* provide a new address manually. */
|
||||
if (!valid_shutdown_scriptpubkey(close_to_script, anysegwit, false)) {
|
||||
if (!valid_shutdown_scriptpubkey(close_to_script, anysegwit, false, false)) {
|
||||
/* Explicit check for future segwits. */
|
||||
if (!anysegwit &&
|
||||
valid_shutdown_scriptpubkey(close_to_script, true, false)) {
|
||||
valid_shutdown_scriptpubkey(close_to_script, true, false, false)) {
|
||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"Peer does not allow v1+ shutdown addresses");
|
||||
}
|
||||
|
||||
@@ -1588,7 +1588,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, false)) {
|
||||
u8 *warning = towire_warningfmt(NULL,
|
||||
&channel->cid,
|
||||
"Bad shutdown scriptpubkey %s",
|
||||
|
||||
Reference in New Issue
Block a user