Skip to content

Commit

Permalink
fix: add lock height and kernel features checks on default transactio…
Browse files Browse the repository at this point in the history
…ns (#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
  • Loading branch information
brianp authored Oct 11, 2023
1 parent dae7dd9 commit 1f87226
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 1f87226

Please sign in to comment.