From ddae604f3d3969b27b3bc4e6d65e54dd7f6740e8 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 30 Sep 2019 22:25:00 +0200 Subject: [PATCH] wallet: Move tx annotation for deposits into the wallet We have split the iteration over the txs and the output in different functions, so pushing the annotation down, while keeping the transaction addition atop. This showcases the need to not have the txid reference the transactions.id in the DB: we annotate in a function that doesn't have the tx index context, but only add the TX after we have finished extracting. --- lightningd/chaintopology.c | 2 -- wallet/wallet.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lightningd/chaintopology.c b/lightningd/chaintopology.c index e163e6736..78f3a3b75 100644 --- a/lightningd/chaintopology.c +++ b/lightningd/chaintopology.c @@ -92,8 +92,6 @@ static void filter_block_txs(struct chain_topology *topo, struct block *b) tx, &b->height, &owned); wallet_transaction_add(topo->ld->wallet, tx, b->height, i); - wallet_transaction_annotate(topo->ld->wallet, &txid, - TX_WALLET_DEPOSIT, 0); } /* We did spends first, in case that tells us to watch tx. */ diff --git a/wallet/wallet.c b/wallet/wallet.c index 00959e05b..6e5ac83c3 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -1577,6 +1577,8 @@ int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx, type_to_string(tmpctx, struct amount_sat, total), type_to_string(tmpctx, struct amount_sat, &utxo->amount)); + + wallet_annotate_txout(w, &utxo->txid, output, TX_WALLET_DEPOSIT, 0); tal_free(utxo); num_utxos++; }