From 3c98bec693404c0db6ffb5367e616d20d3fb2456 Mon Sep 17 00:00:00 2001 From: niftynei Date: Fri, 11 Sep 2020 15:33:41 -0500 Subject: [PATCH] db: add helper for db_col_psbt We had db_bind_psbt; this is the missing symmetric response to that --- wallet/db.c | 10 +++++++--- wallet/db.h | 2 ++ wallet/db_postgres_sqlgen.c | 2 +- wallet/db_sqlite3_sqlgen.c | 2 +- wallet/statements_gettextgen.po | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/wallet/db.c b/wallet/db.c index 0382ee1aa..65a1cf2fe 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -1647,12 +1647,16 @@ struct bitcoin_tx *db_column_tx(const tal_t *ctx, struct db_stmt *stmt, int col) return pull_bitcoin_tx(ctx, &src, &len); } -struct bitcoin_tx *db_column_psbt_to_tx(const tal_t *ctx, struct db_stmt *stmt, int col) +struct wally_psbt *db_column_psbt(const tal_t *ctx, struct db_stmt *stmt, int col) { - struct wally_psbt *psbt; const u8 *src = db_column_blob(stmt, col); size_t len = db_column_bytes(stmt, col); - psbt = psbt_from_bytes(ctx, src, len); + return psbt_from_bytes(ctx, src, len); +} + +struct bitcoin_tx *db_column_psbt_to_tx(const tal_t *ctx, struct db_stmt *stmt, int col) +{ + struct wally_psbt *psbt = db_column_psbt(ctx, stmt, col); if (!psbt) return NULL; return bitcoin_tx_with_psbt(ctx, psbt); diff --git a/wallet/db.h b/wallet/db.h index 36a7eb2a2..dadc02f26 100644 --- a/wallet/db.h +++ b/wallet/db.h @@ -24,6 +24,7 @@ struct onionreply; struct db_stmt; struct db; struct wally_psbt; +struct wally_tx; /** * Macro to annotate a named SQL query. @@ -162,6 +163,7 @@ bool db_column_signature(struct db_stmt *stmt, int col, secp256k1_ecdsa_signature *sig); struct timeabs db_column_timeabs(struct db_stmt *stmt, int col); struct bitcoin_tx *db_column_tx(const tal_t *ctx, struct db_stmt *stmt, int col); +struct wally_psbt *db_column_psbt(const tal_t *ctx, struct db_stmt *stmt, int col); struct bitcoin_tx *db_column_psbt_to_tx(const tal_t *ctx, struct db_stmt *stmt, int col); struct onionreply *db_column_onionreply(const tal_t *ctx, diff --git a/wallet/db_postgres_sqlgen.c b/wallet/db_postgres_sqlgen.c index bfc35e536..56372b64b 100644 --- a/wallet/db_postgres_sqlgen.c +++ b/wallet/db_postgres_sqlgen.c @@ -1654,4 +1654,4 @@ struct db_query db_postgres_queries[] = { #endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */ -// SHA256STAMP:b58d5903df88487b84515e511c1cd98e5fb15f86cf9676e3125ab56a27c27877 +// SHA256STAMP:e395834264c88a46c76e9e19347340507d615ad7902ddb5e179f253db7dc55e7 diff --git a/wallet/db_sqlite3_sqlgen.c b/wallet/db_sqlite3_sqlgen.c index 4b7d3f2d7..714f26d4e 100644 --- a/wallet/db_sqlite3_sqlgen.c +++ b/wallet/db_sqlite3_sqlgen.c @@ -1654,4 +1654,4 @@ struct db_query db_sqlite3_queries[] = { #endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */ -// SHA256STAMP:b58d5903df88487b84515e511c1cd98e5fb15f86cf9676e3125ab56a27c27877 +// SHA256STAMP:e395834264c88a46c76e9e19347340507d615ad7902ddb5e179f253db7dc55e7 diff --git a/wallet/statements_gettextgen.po b/wallet/statements_gettextgen.po index aa8c9c38c..8a5f9126b 100644 --- a/wallet/statements_gettextgen.po +++ b/wallet/statements_gettextgen.po @@ -1089,4 +1089,4 @@ msgstr "" #: wallet/test/run-wallet.c:1359 msgid "INSERT INTO channels (id) VALUES (1);" msgstr "" -# SHA256STAMP:b5142a6c1570a9fdf0745214134e54ff79e3d91408a91a1555cdb0a546fb0c7b +# SHA256STAMP:06772e06eea0d31f3172982d9a4fac7326f8ce39868ff405fd4e7babe923f17c