pub fn authorize_nonce_account(
    nonce_pubkey: &Pubkey,
    authorized_pubkey: &Pubkey,
    new_authority: &Pubkey
) -> Instruction
Expand description

Change the authority of a durable transaction nonce account.

This function produces an Instruction which must be submitted in a Transaction or invoked to take effect.

This constructor creates a SystemInstruction::AuthorizeNonceAccount instruction.

Required signers

The authorized_pubkey signer must sign the transaction.

Examples

use safecoin_client::rpc_client::RpcClient;
use solana_sdk::{
    pubkey::Pubkey,
    signature::{Keypair, Signer},
    system_instruction,
    transaction::Transaction,
};
use anyhow::Result;

fn authorize_nonce_account_tx(
    client: &RpcClient,
    nonce_account_pubkey: &Pubkey,
    authorized_account: &Keypair,
    new_authority_pubkey: &Pubkey,
) -> Result<()> {

    let instr = system_instruction::authorize_nonce_account(
        &nonce_account_pubkey,
        &authorized_account.pubkey(),
        &new_authority_pubkey,
    );

    let mut tx = Transaction::new_with_payer(&[instr], Some(&authorized_account.pubkey()));

    let blockhash = client.get_latest_blockhash()?;
    tx.try_sign(&[authorized_account], blockhash)?;

    client.send_and_confirm_transaction(&tx)?;

    Ok(())
}