From 894a46e8e3bcee3dc1230ab7bfc756dbac407062 Mon Sep 17 00:00:00 2001 From: niftynei Date: Thu, 21 May 2020 16:32:53 -0500 Subject: [PATCH] psbt: populate last commitment transaction's input info at db when re-populating a channel's data from the database, since we don't store the psbt data (with input scripts + amounts), we need to re-populate it. the right solution is to patch the psbt into the database; for now we 'monkey-patch' it in. --- wallet/wallet.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wallet/wallet.c b/wallet/wallet.c index 7842f92fa..70eed9499 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -1,6 +1,7 @@ #include "invoices.h" #include "wallet.h" +#include #include #include #include @@ -1075,6 +1076,20 @@ static struct channel *wallet_stmt2channel(struct wallet *w, struct db_stmt *stm db_column_int(stmt, 44), db_column_arr(tmpctx, stmt, 45, u8), db_column_int(stmt, 46)); + + /* as a final step, we go ahead and populate the utxo + * for the last_tx with the funding amount */ + /* FIXME: input index for funding will not always be zero! */ + if (chan->last_tx) { + const u8 * funding_wscript = + bitcoin_redeem_2of2(tmpctx, + &chan->local_funding_pubkey, + &chan->channel_info.remote_fundingkey); + psbt_input_set_prev_utxo_wscript(chan->last_tx->psbt, + 0, funding_wscript, + chan->funding); + } + return chan; }