Skip to content

Commit

Permalink
interactive_tx: Add tx_abort support
Browse files Browse the repository at this point in the history
We add checks for tx_abort and pass them back up to be handled.
  • Loading branch information
ddustin authored and cdecker committed Feb 11, 2024
1 parent bee4654 commit 0519cd4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
14 changes: 8 additions & 6 deletions common/interactivetx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion common/interactivetx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0519cd4

Please sign in to comment.