From 0519cd42562ed50ce99b075c3980a004d5fea4ea Mon Sep 17 00:00:00 2001 From: Dusty Daemon Date: Mon, 22 Jan 2024 17:47:35 -0500 Subject: [PATCH] interactive_tx: Add tx_abort support We add checks for tx_abort and pass them back up to be handled. --- common/interactivetx.c | 14 ++++++++------ common/interactivetx.h | 5 ++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/common/interactivetx.c b/common/interactivetx.c index 5b7a772d65fa..8bb8b12e39f8 100644 --- a/common/interactivetx.c +++ b/common/interactivetx.c @@ -128,8 +128,7 @@ static u8 *read_next_msg(const tal_t *ctx, desc = is_peer_warning(msg, msg); if (desc) { status_info("They sent %s", desc); - tal_free(msg); - continue; + return tal_free(msg); } /* In theory, we're in the middle of an open/RBF/splice, but @@ -142,9 +141,8 @@ static u8 *read_next_msg(const tal_t *ctx, case WIRE_TX_ADD_OUTPUT: case WIRE_TX_REMOVE_OUTPUT: case WIRE_TX_COMPLETE: - return msg; case WIRE_TX_ABORT: - /* TODO */ + return msg; case WIRE_TX_SIGNATURES: case WIRE_CHANNEL_READY: case WIRE_TX_INIT_RBF: @@ -345,13 +343,16 @@ bool interactivetx_has_changes(struct interactivetx_context *ictx, char *process_interactivetx_updates(const tal_t *ctx, struct interactivetx_context *ictx, - bool *received_tx_complete) + bool *received_tx_complete, + u8 **abort_msg) { bool we_complete = false, they_complete = false; u8 *msg; char *error = NULL; struct wally_psbt *next_psbt; + *abort_msg = NULL; + if (received_tx_complete) they_complete = *received_tx_complete; @@ -696,7 +697,8 @@ char *process_interactivetx_updates(const tal_t *ctx, *received_tx_complete = true; break; case WIRE_TX_ABORT: - /* Todo */ + *abort_msg = msg; + return NULL; case WIRE_INIT: case WIRE_ERROR: case WIRE_WARNING: diff --git a/common/interactivetx.h b/common/interactivetx.h index a63d01896dd9..d2233f4df463 100644 --- a/common/interactivetx.h +++ b/common/interactivetx.h @@ -77,10 +77,13 @@ struct interactivetx_context *new_interactivetx_context(const tal_t *ctx, * out -> true means the last message from the peer was 'tx_complete'. * * Returns NULL on success or a description of the error on failure. + * + * If `tx_abort` is received, NULL is returned and `abort_msg` will be set to */ char *process_interactivetx_updates(const tal_t *ctx, struct interactivetx_context *ictx, - bool *received_tx_complete); + bool *received_tx_complete, + u8 **abort_msg); /* If the given ictx would cause `process_interactivetx_updates to send tx * changes when called. Returns true if an error occurs