Skip to content

Commit

Permalink
db_col_tx: report txn hex if transaction pulled is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs authored and rustyrussell committed May 29, 2023
1 parent c029de7 commit 2918bbb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions db/bindings.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,20 @@ struct bitcoin_tx *db_col_tx(const tal_t *ctx, struct db_stmt *stmt, const char
size_t col = db_query_colnum(stmt, colname);
const u8 *src = db_column_blob(stmt, col);
size_t len = db_column_bytes(stmt, col);
struct bitcoin_tx *tx;
bool is_null;

db_column_null_warn(stmt, colname, col);
return pull_bitcoin_tx(ctx, &src, &len);
is_null = db_column_null_warn(stmt, colname, col);
tx = pull_bitcoin_tx(ctx, &src, &len);

if (is_null || tx) return tx;

/* Column wasn't null, but we couldn't retrieve a valid wally_tx! */
u8 *tx_dup = tal_dup_arr(stmt, u8, src, len, 0);

db_fatal("db_col_tx: Invalid bitcoin transaction bytes retrieved: %s",
tal_hex(stmt, tx_dup));
return NULL;
}

struct wally_psbt *db_col_psbt(const tal_t *ctx, struct db_stmt *stmt, const char *colname)
Expand Down

0 comments on commit 2918bbb

Please sign in to comment.