当我尝试更改SPL的权限时,我得到了一个权限提升错误(Hw5dRzdcUNHahscRYr1AtsS3t6KXoxyHiGaeShjF7Wq3's signer privilege escalated)。在以下代码中,Hw5dRzdcUNHahscRYr1AtsS3t6KXoxyHiGaeShjF7Wq3是escrow_signer的地址。
我可以确认SPL令牌帐户归PDA所有,因为我在另一项交易中更改了它的权限。
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>,
}下面是我创建PDA地址的方法:
const [_escrowSigner, _nonce] = await anchor.web3.PublicKey.findProgramAddress(
[escrowAccount.publicKey.toBuffer()],
program.programId
);谢谢你的帮助。
发布于 2021-10-13 21:56:43
你的种子应该是:
let seeds = &[
ctx.accounts.escrow_account.key.as_ref(),
&[ctx.accounts.escrow_account.nonce],
];而不是签名者?
我想知道它们是不是被错误地传递了,所以escrow_signer实际上是escrow_account,它没有签署这条指令,这可以解释这个错误。
https://stackoverflow.com/questions/69480093
复制相似问题