fix minimum rent error and lamports conversion

This commit is contained in:
thesn10
2026-05-23 21:58:41 +02:00
parent f86d893ce2
commit d7d57ca7a4
6 changed files with 37 additions and 3 deletions

View File

@@ -16,4 +16,6 @@ pub enum EscrowError {
DisputeTimeoutNotReached,
#[msg("Vault balance is insufficient for the requested escrow amount")]
InsufficientVaultBalance,
#[msg("Amount must be at least rent-exempt minimum for the vault (~890880 lamports)")]
AmountBelowRentMinimum,
}

View File

@@ -1,5 +1,6 @@
use anchor_lang::prelude::*;
use crate::state::{EscrowAccount, EscrowState};
use crate::EscrowError;
#[derive(Accounts)]
#[instruction(amount: u64, dispute_resolver: Option<Pubkey>, escrow_id: u64)]
@@ -36,6 +37,9 @@ pub fn handler(
dispute_resolver: Option<Pubkey>,
escrow_id: u64,
) -> Result<()> {
let rent_min = Rent::get()?.minimum_balance(0);
require!(amount >= rent_min, EscrowError::AmountBelowRentMinimum);
let escrow = &mut ctx.accounts.escrow_account;
escrow.seller = ctx.accounts.seller.key();
escrow.buyer = ctx.accounts.buyer.key();