Skip to content

Commit dcea66d

Browse files
committed
update secure pda example
1 parent 75be44a commit dcea66d

File tree

1 file changed

+7
-0
lines changed
  • programs/8-pda-sharing/secure/src

1 file changed

+7
-0
lines changed

programs/8-pda-sharing/secure/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ pub mod pda_sharing_secure {
1313
ctx.accounts.pool.withdraw_destination.as_ref(),
1414
&[ctx.accounts.pool.bump],
1515
];
16+
let (address, expected_bump) = Pubkey::find_program_address(seeds, ctx.program_id);
17+
if address != ctx.accounts.pool.key() {
18+
return Err(ProgramError::InvalidArgument);
19+
}
20+
if expected_bump != ctx.accounts.pool.bump {
21+
return Err(ProgramError::InvalidArgument);
22+
}
1623
token::transfer(ctx.accounts.transfer_ctx().with_signer(&[seeds]), amount)
1724
}
1825
}

0 commit comments

Comments
 (0)