Skip to content

Commit e975ea7

Browse files
committed
Tx validation: check count of auths
1 parent e731e38 commit e975ea7

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

lib/authorization.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@ pub fn get_address(verifying_key: &VerifyingKey) -> Address {
105105
pub fn verify_authorized_transaction(
106106
transaction: &AuthorizedTransaction,
107107
) -> Result<(), Error> {
108+
let verifications_required = &transaction.transaction.inputs.len();
109+
match transaction
110+
.authorizations
111+
.len()
112+
.cmp(verifications_required)
113+
{
114+
std::cmp::Ordering::Less => return Err(Error::NotEnoughAuthorizations),
115+
std::cmp::Ordering::Equal => (),
116+
std::cmp::Ordering::Greater => {
117+
return Err(Error::TooManyAuthorizations);
118+
}
119+
}
108120
let tx_bytes_canonical = borsh::to_vec(&transaction.transaction)?;
109121
let messages: Vec<_> = std::iter::repeat_n(
110122
tx_bytes_canonical.as_slice(),

0 commit comments

Comments
 (0)