db_col_tx: report txn hex if transaction pulled is invalid

This commit is contained in:
Greg Sanders
2023-05-26 13:23:21 -04:00
committed by Rusty Russell
parent c029de7d56
commit 2918bbbf36

View File

@@ -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); size_t col = db_query_colnum(stmt, colname);
const u8 *src = db_column_blob(stmt, col); const u8 *src = db_column_blob(stmt, col);
size_t len = db_column_bytes(stmt, col); size_t len = db_column_bytes(stmt, col);
struct bitcoin_tx *tx;
bool is_null;
db_column_null_warn(stmt, colname, col); is_null = db_column_null_warn(stmt, colname, col);
return pull_bitcoin_tx(ctx, &src, &len); 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) struct wally_psbt *db_col_psbt(const tal_t *ctx, struct db_stmt *stmt, const char *colname)