PHP WebShell
Текущая директория: /var/www/bitcardoApp/user/wallets
Просмотр файла: create_crypto_wallet.php
<?php
// BitGo API Configuration
define('BITGO_ACCESS_TOKEN', 'v2x0c9d24432b9db3e2d9a48e1adefd7bcc4680a47d28e3310bb19bab8e24e72b91');
define('BITGO_ENTERPRISE_ID', '6816dcc10aa7119c1ad94c489d0bd9fe');
define('BITGO_API_BASE_URL', 'http://127.0.0.1:3080/api/v2'); // testnet
// Database Configuration
define('DB_HOST', 'localhost');
define('DB_USER', 'bitcardo_wallet');
define('DB_PASS', 'Allowme@2050?');
define('DB_NAME', 'bitcardo_wallet');
// Establish procedural MySQLi connection
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
// Check connection
if (!$conn) {
die('Database connection failed: ' . mysqli_connect_error());
}
$userId = 1; // Example: change dynamically
$coin = 'tsol'; // 'tusdt' or any testnet coin
$walletId = '681d9bd654cc808ff22d420a96d31c33'; // your fixed wallet
$label = "Address for user_$userId";
$type = 'secondary';
// Step 1: Generate a new address via BitGo
$url = BITGO_API_BASE_URL . "/$coin/wallet/$walletId/address";
$data = ['label' => $label];
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . BITGO_ACCESS_TOKEN
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// Step 2: Process and insert into DB
if ($httpcode === 200) {
$result = json_decode($response, true);
$address = $result['address'];
// Insert into DB
$stmt = $conn->prepare("INSERT INTO wallets (user_id, wallet_id, address, coin, label, balance, type) VALUES (?, ?, ?, ?, ?, 0.00000, ?)");
$stmt->bind_param("isssss", $userId, $walletId, $address, $coin, $label, $type);
if ($stmt->execute()) {
echo "✅ Address generated and saved: $address";
} else {
echo "❌ DB Insert Error: " . $stmt->error;
}
$stmt->close();
} else {
echo "❌ BitGo API Error (HTTP $httpcode): $response";
}
Выполнить команду
Для локальной разработки. Не используйте в интернете!