Skip to content

Commit

Permalink
update secure pda example
Browse files Browse the repository at this point in the history
  • Loading branch information
nheingit committed Jul 12, 2022
1 parent 2b70674 commit 4a8e9d3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions programs/8-pda-sharing/secure/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ pub mod pda_sharing_secure {
ctx.accounts.pool.withdraw_destination.as_ref(),
&[ctx.accounts.pool.bump],
];
let (address, expected_bump) = Pubkey::find_program_address(seeds, ctx.program_id);
if address != ctx.accounts.pool.key() {
return Err(ProgramError::InvalidArgument);
}
if expected_bump != ctx.accounts.pool.bump {
return Err(ProgramError::InvalidArgument);
}
token::transfer(ctx.accounts.transfer_ctx().with_signer(&[seeds]), amount)
}
}
Expand Down

0 comments on commit 4a8e9d3

Please sign in to comment.