PHP WebShell

Текущая директория: /var/www/bitcardoApp

Просмотр файла: bitgo_generate_address.php

<?php
/**
 * BitGo – Generate Deposit Address (Single File)
 *
 * HOW TO USE:
 * 1. Edit the CONFIG section below with your BitGo details.
 * 2. Upload this file to your server where PHP can run.
 * 3. Run from CLI:  php bitgo_generate_address.php
 * 4. Check the printed HTTP status and JSON response.
 */

/* =========================
 * CONFIG – EDIT THESE
 * ========================= */

// BitGo Express base URL (usually your local BitGo Express)
$bitgoBaseUrl = 'http://127.0.0.1:3090';  // e.g. http://127.0.0.1:3090

// Your BitGo access token
$bitgoAccessToken = 'v2x684ccb535d69ea3fdcdf8657164bba3796f71d61f5ec0a0065bc202e637cce24';

// Coin ticker – examples: 'eth', 'teth', 'btc', 'tbtc'
$coin = 'eth';

// Wallet ID for the wallet you want to generate an address for
// Get this from BitGo dashboard URL: https://app.bitgo.com/wallet/eth/main/YOUR_WALLET_ID/transactions
$walletId = '691615ed0d49bc94ea8e6e5770969d71';

/* =========================
 * DO NOT EDIT BELOW
 * ========================= */

if (empty($bitgoAccessToken) || empty($walletId)) {
    echo "ERROR: Please set \$bitgoAccessToken and \$walletId in this file.\n";
    exit(1);
}

$bitgoBaseUrl = rtrim($bitgoBaseUrl, '/');

// Endpoint: POST /api/v2/{coin}/wallet/{walletId}/address
$endpoint = $bitgoBaseUrl . '/api/v2/' . $coin . '/wallet/' . $walletId . '/address';

$payload = '{}';

echo "Calling BitGo...\n";
echo "  Endpoint: {$endpoint}\n";
echo "  Coin    : {$coin}\n\n";

$ch = curl_init($endpoint);
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST           => true,
    CURLOPT_HTTPHEADER     => [
        'Content-Type: application/json',
        'Authorization: Bearer ' . $bitgoAccessToken,
    ],
    CURLOPT_POSTFIELDS     => $payload,
    CURLOPT_TIMEOUT        => 30,
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$err      = curl_error($ch);

curl_close($ch);

if ($err) {
    echo "cURL ERROR: {$err}\n";
    exit(1);
}

echo "HTTP STATUS: {$httpCode}\n";
echo "RAW RESPONSE:\n{$response}\n\n";

// Try to pretty-print JSON
$data = json_decode($response, true);
if (json_last_error() === JSON_ERROR_NONE) {
    echo "DECODED JSON:\n";
    echo json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";

    if (isset($data['address'])) {
        echo "\nGenerated address: " . $data['address'] . "\n";
    }
} else {
    echo "WARNING: Response is not valid JSON or could not be decoded.\n";
}

Выполнить команду


Для локальной разработки. Не используйте в интернете!