I want to create an instruction where it is only possible to initialize a new PDA account if some parameter on another PDA account (same type) is fulfilled. So I was thinking that init_if_needed
would be the best option for such an use-case.
In the case that the old account does exist, would I still be able to match on the correct bump when using init_if_needed
- referring to old_acc
:
#[account(
init_if_needed
seeds = [seeds],
bump = acc.bump,
payer = payer
space = SPACE
)]
pub old_acc
#[account(
init
seeds = [seeds],
bump,
payer = payer
space = SPACE
)]
pub new_acc
In the normal init
i would just pass in "bump" without any assignment. Although not sure if I could still check for the correct bump if the account already exists.
So the question is how to account for the bumb in the case of account existence and non-existence