From 578f07540744d924f9d8f4907a22c20638a82cd9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 30 Jan 2023 16:35:03 +1030 Subject: [PATCH] wallet: remove unused TX_ANNOTATION type in transaction_annotations table. We only ever use this table for output and input transactions: indeed, my node doesn't have any annotation types 0. Signed-off-by: Rusty Russell --- common/wallet.h | 4 +--- wallet/wallet.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/common/wallet.h b/common/wallet.h index aaeb4fe85..5b14b3def 100644 --- a/common/wallet.h +++ b/common/wallet.h @@ -21,10 +21,8 @@ enum wallet_tx_type { TX_CHANNEL_CHEAT = 1024, }; -/* What part of a transaction are we annotating? The entire transaction, an - * input or an output. */ +/* What part of a transaction are we annotating? An input or an output. */ enum wallet_tx_annotation_type { - TX_ANNOTATION = 0, OUTPUT_ANNOTATION = 1, INPUT_ANNOTATION = 2, }; diff --git a/wallet/wallet.c b/wallet/wallet.c index 2822732f1..1424dfc3b 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -4863,14 +4863,17 @@ struct wallet_transaction *wallet_transactions_get(struct wallet *w, const tal_t struct tx_annotation *ann; /* Select annotation from array to fill in. */ - if (loc == OUTPUT_ANNOTATION) + switch (loc) { + case OUTPUT_ANNOTATION: ann = &cur->output_annotations[idx]; - else if (loc == INPUT_ANNOTATION) + goto got_ann; + case INPUT_ANNOTATION: ann = &cur->input_annotations[idx]; - else - fatal("Transaction annotations are only available for inputs and outputs. Value %d", loc); + goto got_ann; + } + fatal("Transaction annotations are only available for inputs and outputs. Value %d", loc); - /* cppcheck-suppress uninitvar - false positive on fatal() above */ + got_ann: ann->type = db_col_int(stmt, "annotation_type"); if (!db_col_is_null(stmt, "c.scid")) db_col_scid(stmt, "c.scid", &ann->channel);