<?php
// backend/api/get-deposit-history.php
header('Content-Type: application/json');
require_once '../config/db.php'; // Ensure path is correct

$wallet = $_GET['wallet'] ?? '';

if(empty($wallet)) {
    echo json_encode([]);
    exit;
}

// Fetch last 5 deposits for this wallet
$sql = "SELECT amount, tx_hash, status, created_at FROM deposits WHERE wallet = '$wallet' ORDER BY id DESC LIMIT 5";
$result = mysqli_query($conn, $sql);

$history = [];
while($row = mysqli_fetch_assoc($result)) {
    $history[] = $row;
}

echo json_encode($history);
?>