Skip to content

Commit 1316124

Browse files
committed
Do not permit token accounts to be closed when the withheld amount is non-zero
1 parent 10559ae commit 1316124

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

token/program-2022/src/extension/confidential_transfer/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ impl ConfidentialTransferAccount {
108108
pub fn closable(&self) -> ProgramResult {
109109
if self.pending_balance == pod::ElGamalCiphertext::zeroed()
110110
&& self.available_balance == pod::ElGamalCiphertext::zeroed()
111+
&& self.withheld_amount == pod::ElGamalCiphertext::zeroed()
111112
{
112113
Ok(())
113114
} else {

token/program-2022/src/extension/confidential_transfer/processor.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ fn process_empty_account(
236236
}
237237

238238
ct_token_account.available_balance = pod::ElGamalCiphertext::zeroed();
239+
240+
if ct_token_account.withheld_amount != pod::ElGamalCiphertext::zeroed() {
241+
msg!("Withheld amount is not zero");
242+
return Err(ProgramError::InvalidAccountData);
243+
}
239244
ct_token_account.closable()?;
240245

241246
Ok(())

0 commit comments

Comments
 (0)