Skip to content

Commit a062853

Browse files
committed
fix(cardano-blockchain-types): check required keys
Signed-off-by: bkioshn <[email protected]>
1 parent 7a27ec0 commit a062853

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

rust/cardano-blockchain-types/src/cip36/key_registration.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,19 @@ impl Decode<'_, ()> for Cip36KeyRegistration {
134134
}
135135
}
136136
}
137-
Ok(cip36_key_registration)
137+
138+
// Check if all the required keys are present.
139+
if found_keys.contains(&(Cip36KeyRegistrationKeys::VotingKey as u16))
140+
&& found_keys.contains(&(Cip36KeyRegistrationKeys::StakePk as u16))
141+
&& found_keys.contains(&(Cip36KeyRegistrationKeys::PaymentAddr as u16))
142+
&& found_keys.contains(&(Cip36KeyRegistrationKeys::Nonce as u16))
143+
{
144+
Ok(cip36_key_registration)
145+
} else {
146+
Err(decode::Error::message(
147+
"Missing required key in CIP36 Key Registration",
148+
))
149+
}
138150
}
139151
}
140152

0 commit comments

Comments
 (0)