Skip to content

Commit

Permalink
Add lock height and kernel features checks
Browse files Browse the repository at this point in the history
Helps to ensure the wallet doesn't end up with non spendable inputs
preventing the ability to spend transactions.
  • Loading branch information
brianp committed Oct 10, 2023
1 parent 38dc014 commit 30c1565
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions base_layer/wallet/src/output_manager_service/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
10 changes: 10 additions & 0 deletions base_layer/wallet/src/output_manager_service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;

Expand Down

0 comments on commit 30c1565

Please sign in to comment.