From 1f87226722b12750424ab2f4861fe0475a67dfd6 Mon Sep 17 00:00:00 2001 From: Brian Pearce Date: Wed, 11 Oct 2023 15:03:07 +0200 Subject: [PATCH] fix: add lock height and kernel features checks on default transactions (#5836) Description --- It helps to ensure the wallet doesn't end up with non-spendable inputs preventing the ability to submit transactions. Motivation and Context --- Closes: #5796 How Has This Been Tested? --- What process can a PR reviewer use to test or verify this change? --- Double-check the spelling. Breaking Changes --- - [x] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [ ] Other - Please specify --- base_layer/wallet/src/output_manager_service/error.rs | 4 ++++ .../wallet/src/output_manager_service/service.rs | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/base_layer/wallet/src/output_manager_service/error.rs b/base_layer/wallet/src/output_manager_service/error.rs index 6339302ecc..0f0f31332b 100644 --- a/base_layer/wallet/src/output_manager_service/error.rs +++ b/base_layer/wallet/src/output_manager_service/error.rs @@ -120,6 +120,10 @@ pub enum OutputManagerError { InvalidCovenant, #[error("Unsupported Output Features")] InvalidOutputFeatures, + #[error("Unsupported Kernel Features")] + InvalidKernelFeatures, + #[error("Unsupported Lock Height")] + InvalidLockHeight, #[error("Tari script error: {0}")] ScriptError(#[from] ScriptError), #[error("Master secret key does not match persisted key manager state")] diff --git a/base_layer/wallet/src/output_manager_service/service.rs b/base_layer/wallet/src/output_manager_service/service.rs index 4949b07c24..c84c75750e 100644 --- a/base_layer/wallet/src/output_manager_service/service.rs +++ b/base_layer/wallet/src/output_manager_service/service.rs @@ -699,6 +699,16 @@ where return Err(OutputManagerError::InvalidOutputFeatures); } + // Confirm lock height is 0 + if single_round_sender_data.metadata.lock_height != 0 { + return Err(OutputManagerError::InvalidLockHeight); + } + + // Confirm kernel features + if single_round_sender_data.metadata.kernel_features != KernelFeatures::default() { + return Err(OutputManagerError::InvalidKernelFeatures); + } + let (spending_key_id, _, script_key_id, script_public_key) = self.resources.key_manager.get_next_spend_and_script_key_ids().await?;