Since only the program(owner) of a PDA can modify it's data.
Do I have to validate a PDA passed to the program via seed and canonical bump?
Example: If I initialize a Group PDA...
#[derive(Accounts)]
#[instruction(id: String)]
pub struct InitGroup<'info> {
#[account(init, payer = group_leader, space = 8 + Group::INIT_SPACE,
seeds = [b"example_seed", group_leader.key().as_ref(), id.as_bytes()], bump )]
pub group: Account<'info, Group>,
#[account(mut)]
pub group_leader: Signer<'info>,
}
...
#[derive(Accounts)]
pub struct WithdrawFromGroup<'info> {
#[account(mut)] // <-- no validation ok?
pub group: Account<'info, Group>,
}
OR should I add PDA validation like:
#[account(
seeds = [b"example_seed", group_leader.key().as_ref(), id.as_bytes()], bump )]
pub group: Account<'info, Group>,
Validation requires extra function arguments... in some cases, I do not need those function arguments except for PDA validation...
Reference: