From 7de1b23fbe8f1a477db126a4d47014647e632a93 Mon Sep 17 00:00:00 2001 From: Philip Robinson Date: Wed, 26 Jan 2022 19:58:47 +0200 Subject: [PATCH] fix: fix attempting to validate faux transaction (#3758) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description --- Found a panic where the tx validation will try validate a faux transaction and then panic when it doesn’t have a kernel to display. Filtered out Imported transactions and fixed the unwrap to be handled gracefully. --- .../protocols/transaction_validation_protocol.rs | 2 +- base_layer/wallet/src/transaction_service/storage/sqlite_db.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/base_layer/wallet/src/transaction_service/protocols/transaction_validation_protocol.rs b/base_layer/wallet/src/transaction_service/protocols/transaction_validation_protocol.rs index abd9252264..f346cfb87a 100644 --- a/base_layer/wallet/src/transaction_service/protocols/transaction_validation_protocol.rs +++ b/base_layer/wallet/src/transaction_service/protocols/transaction_validation_protocol.rs @@ -252,7 +252,7 @@ where .kernels() .first() .map(|k| k.excess.to_hex()) - .unwrap(), + .unwrap_or_else(|| "{No Kernel found}".to_string()), self.operation_id ); self.update_transaction_as_unmined(last_mined_transaction.tx_id, &last_mined_transaction.status) diff --git a/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs b/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs index 7eff7dbedd..02798d3f3c 100644 --- a/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs +++ b/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs @@ -1049,6 +1049,7 @@ impl TransactionBackend for TransactionServiceSqliteDatabase { let acquire_lock = start.elapsed(); let tx = completed_transactions::table .filter(completed_transactions::mined_height.is_not_null()) + .filter(completed_transactions::mined_height.gt(0)) .order_by(completed_transactions::mined_height.desc()) .first::(&*conn) .optional()?;