I am getting a privilege escalation error (Hw5dRzdcUNHahscRYr1AtsS3t6KXoxyHiGaeShjF7Wq3's signer privilege escalated
) when I try to change the authority of an SPL.
Hw5dRzdcUNHahscRYr1AtsS3t6KXoxyHiGaeShjF7Wq3
is the address of the escrow_signer in the code below.
I can confirm the SPL token account is owned by the PDA, as I changed its authority in another transaction.
token::set_authority(
ctx.accounts.into(),
AuthorityType::AccountOwner,
Some(ctx.accounts.escrow_signer.key()),
)?;
pub fn terminate_escrow (ctx: Context<Terminate>) -> ProgramResult {
let seeds = &[
ctx.accounts.escrow_signer.key.as_ref(),
&[ctx.accounts.escrow_account.nonce],
];
let cpi_accounts = SetAuthority {
account_or_mint: ctx.accounts
.initializer_lp_token_account
.to_account_info()
.clone(),
current_authority: ctx.accounts.escrow_signer.clone(),
};
let cpi_program = ctx.accounts.token_program.clone();
token::set_authority(
CpiContext::new(cpi_program, cpi_accounts)
.with_signer(&[&seeds[..]]),
AuthorityType::AccountOwner,
Some(ctx.accounts.initializer.key()),
)?;
}
#[derive(Accounts)]
pub struct Terminate<'info> {
...
#[account(
seeds = [escrow_account.to_account_info().key.as_ref()],
bump = escrow_account.nonce,
)]
pub escrow_signer: AccountInfo<'info>,
}
Here is how I am creating the PDA address:
const [_escrowSigner, _nonce] = await anchor.web3.PublicKey.findProgramAddress(
[escrowAccount.publicKey.toBuffer()],
program.programId
);
Thanks for helping.