inflights: save the whole psbt to the database

Otherwise we're missing info when we go to broadcast these and can't
properly sign the transaction to close it.

Found-by: @jasan
This commit is contained in:
niftynei
2021-05-19 19:15:12 -05:00
committed by Rusty Russell
parent 1d922bff1c
commit 4247ec3a05
7 changed files with 324 additions and 179 deletions

View File

@@ -1034,6 +1034,18 @@ struct db_query db_postgres_queries[] = {
.placeholders = 6,
.readonly = false,
},
{
.name = "SELECT c.id, p.node_id, c.fundingkey_remote, inflight.last_tx, inflight.last_sig, inflight.funding_satoshi, inflight.funding_tx_id FROM channels c LEFT OUTER JOIN peers p ON p.id = c.peer_id LEFT OUTER JOIN channel_funding_inflights inflight ON c.id = inflight.channel_id WHERE inflight.last_tx IS NOT NULL;",
.query = "SELECT c.id, p.node_id, c.fundingkey_remote, inflight.last_tx, inflight.last_sig, inflight.funding_satoshi, inflight.funding_tx_id FROM channels c LEFT OUTER JOIN peers p ON p.id = c.peer_id LEFT OUTER JOIN channel_funding_inflights inflight ON c.id = inflight.channel_id WHERE inflight.last_tx IS NOT NULL;",
.placeholders = 0,
.readonly = true,
},
{
.name = "UPDATE channel_funding_inflights SET last_tx = ? WHERE channel_id = ? AND funding_tx_id = ?;",
.query = "UPDATE channel_funding_inflights SET last_tx = $1 WHERE channel_id = $2 AND funding_tx_id = $3;",
.placeholders = 3,
.readonly = false,
},
{
.name = "SELECT c.id, p.node_id, c.last_tx, c.funding_satoshi, c.fundingkey_remote, c.last_sig FROM channels c LEFT OUTER JOIN peers p ON p.id = c.peer_id;",
.query = "SELECT c.id, p.node_id, c.last_tx, c.funding_satoshi, c.fundingkey_remote, c.last_sig FROM channels c LEFT OUTER JOIN peers p ON p.id = c.peer_id;",
@@ -1882,10 +1894,10 @@ struct db_query db_postgres_queries[] = {
},
};
#define DB_POSTGRES_QUERY_COUNT 312
#define DB_POSTGRES_QUERY_COUNT 314
#endif /* HAVE_POSTGRES */
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
// SHA256STAMP:78e8a75719f367a070874e2b4813b0b8ff3a74a51844c7e7a06b5f8cc18a414b
// SHA256STAMP:dbebcde72bd359ea7edaf5732c78549224c3b891e45f123696b4cfd60dd9037b