From 7f8a8fae4a554686f50132394439616f33db80bf Mon Sep 17 00:00:00 2001 From: CanardMandarin Date: Sat, 19 Nov 2022 15:16:32 +0100 Subject: [PATCH] fix: add nonce check --- programs/multisig/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/programs/multisig/src/lib.rs b/programs/multisig/src/lib.rs index cdec868..8021021 100644 --- a/programs/multisig/src/lib.rs +++ b/programs/multisig/src/lib.rs @@ -36,6 +36,10 @@ pub mod coral_multisig { threshold: u64, nonce: u8, ) -> Result<()> { + let multisig_key = ctx.accounts.multisig.key(); + let seeds = &[multisig_key.as_ref(), &[nonce]]; + require!(Pubkey::create_program_address(&seeds[..], &ID).is_ok(), ErrorCode::InvalidNonce); + assert_unique_owners(&owners)?; require!( threshold > 0 && threshold <= owners.len() as u64, @@ -334,4 +338,6 @@ pub enum ErrorCode { InvalidThreshold, #[msg("Owners must be unique")] UniqueOwners, + #[msg("Invalid nonce.")] + InvalidNonce, }