pub fn withdraw_nonce_account(
nonce_address: &Address,
authorized_address: &Address,
to_address: &Address,
lamports: u64,
) -> Instructionbincode only.Expand description
Withdraw lamports from a durable transaction nonce account.
This function produces an Instruction which must be submitted in a
Transaction or invoked to take effect, containing a serialized
SystemInstruction::WithdrawNonceAccount.
Withdrawing the entire balance of a nonce account will cause the runtime to destroy it upon successful completion of the transaction.
Otherwise, nonce accounts must maintain a balance greater than or equal to the minimum required for rent exemption. If the result of this instruction would leave the nonce account with a balance less than required for rent exemption, but also greater than zero, then the transaction will fail.
This constructor creates a SystemInstruction::WithdrawNonceAccount
instruction.
§Required signers
The authorized_address signer must sign the transaction.
§Examples
use solana_rpc_client::rpc_client::RpcClient;
use solana_address::Address;
use solana_sdk::{
signature::{Keypair, Signer},
transaction::Transaction,
};
use solana_system_interface::instruction;
use anyhow::Result;
fn submit_withdraw_nonce_account_tx(
client: &RpcClient,
nonce_account_address: &Address,
authorized_account: &Keypair,
) -> Result<()> {
let nonce_balance = client.get_balance(nonce_account_address)?;
let instr = instruction::withdraw_nonce_account(
nonce_account_address,
&authorized_account.pubkey(),
&authorized_account.pubkey(),
nonce_balance,
);
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(())
}