PHP WebShell

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

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

<?php
// generate_sol_address.php
// SUPER SIMPLE stand-alone test page for generating a SOL (mainnet) address via BitGo Express.

// ================== CONFIG – EDIT THESE ==================
$BITGO_API_BASE_URL = 'http://127.0.0.1:3090';   // Your BitGo Express URL
$BITGO_ACCESS_TOKEN = 'v2x684ccb535d69ea3fdcdf8657164bba3796f71d61f5ec0a0065bc202e637cce24';
$DEFAULT_WALLET_ID  = '692f0411820d455d1117198bc8fef8cd'; // mainnet SOL wallet ID from BitGo
// ========================================================

$result       = null;
$errorMessage = null;
$httpCode     = null;

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Use wallet ID from form if provided, else fallback to default.
    $walletId = isset($_POST['wallet_id']) && $_POST['wallet_id'] !== ''
        ? trim($_POST['wallet_id'])
        : trim($DEFAULT_WALLET_ID);

    if ($walletId === '') {
        $errorMessage = 'Wallet ID is required. Set $DEFAULT_WALLET_ID at top of file or enter it in the form.';
    } else {
        $coin   = 'sol'; // mainnet only
        $base   = rtrim($BITGO_API_BASE_URL, '/');
        $url    = $base . '/api/v2/' . $coin . '/wallet/' . urlencode($walletId) . '/address';

        $ch = curl_init($url);

        $headers = [
            'Authorization: Bearer ' . $BITGO_ACCESS_TOKEN,
            'Content-Type: application/json',
        ];

        curl_setopt_array($ch, [
            CURLOPT_POST           => true,
            CURLOPT_HTTPHEADER     => $headers,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYPEER => false, // BitGo Express is typically HTTP on localhost
        ]);

        $responseBody = curl_exec($ch);
        $httpCode     = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        if ($responseBody === false) {
            $errorMessage = 'cURL error: ' . curl_error($ch);
        } else {
            $decoded = json_decode($responseBody, true);

            if ($httpCode >= 200 && $httpCode < 300) {
                $result = [
                    'raw'     => $responseBody,
                    'decoded' => $decoded,
                ];
            } else {
                $errorMessage = 'BitGo error (HTTP ' . $httpCode . '): ' . $responseBody;
            }
        }

        curl_close($ch);
    }
}
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Generate SOL Address (BitGo Mainnet Test)</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        body{
            font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
            background: #f5f7fb;
            margin: 0;
            padding: 0;
        }
        .page-wrap{
            max-width: 720px;
            margin: 40px auto;
            background: #ffffff;
            border-radius: 10px;
            box-shadow: 0 4px 16px rgba(0,0,0,.05);
            padding: 24px 28px 32px;
        }
        h1{
            margin-top: 0;
            margin-bottom: 8px;
            font-size: 20px;
        }
        .subtitle{
            margin: 0 0 20px;
            font-size: 13px;
            color: #666;
        }
        label{
            display: block;
            margin-bottom: 6px;
            font-size: 13px;
            font-weight: 600;
        }
        input[type="text"]{
            width: 100%;
            padding: 8px 10px;
            font-size: 14px;
            border-radius: 6px;
            border: 1px solid #ccd2e1;
            box-sizing: border-box;
        }
        .field-group{
            margin-bottom: 16px;
        }
        .btn{
            display: inline-block;
            border: none;
            background: #076289;
            color: #fff;
            padding: 10px 18px;
            border-radius: 6px;
            font-size: 14px;
            cursor: pointer;
        }
        .btn:hover{
            filter: brightness(0.95);
        }
        .alert{
            padding: 10px 12px;
            border-radius: 6px;
            margin-top: 16px;
            font-size: 13px;
        }
        .alert-error{
            background: #ffe6e6;
            border: 1px solid #e99;
            color: #a00;
        }
        .alert-success{
            background: #e6ffef;
            border: 1px solid #8ed9a8;
            color: #136b33;
        }
        .field-inline{
            font-size: 13px;
            margin-top: 6px;
        }
        .field-inline span{
            font-weight: 600;
        }
        pre{
            background: #0b1020;
            color: #e4e8ff;
            padding: 12px;
            border-radius: 6px;
            overflow-x: auto;
            font-size: 12px;
        }
    </style>
</head>
<body>
<div class="page-wrap">
    <h1>Generate SOL Address (Mainnet)</h1>
    <p class="subtitle">
        This stand-alone page calls BitGo Express (mainnet <strong>sol</strong>) to create a new receive address
        for your SOL wallet. Edit the config variables at the top of this file before using.
    </p>

    <form method="post">
        <div class="field-group">
            <label for="wallet_id">BitGo SOL Wallet ID</label>
            <input
                type="text"
                name="wallet_id"
                id="wallet_id"
                value="<?php
                    echo htmlspecialchars(
                        isset($_POST['wallet_id']) && $_POST['wallet_id'] !== ''
                            ? $_POST['wallet_id']
                            : $DEFAULT_WALLET_ID,
                        ENT_QUOTES,
                        'UTF-8'
                    );
                ?>"
                placeholder="Leave empty to use DEFAULT_WALLET_ID from top of file"
            >
        </div>
        <button type="submit" class="btn">Generate New Address</button>
    </form>

    <?php if ($errorMessage): ?>
        <div class="alert alert-error">
            <?php echo htmlspecialchars($errorMessage, ENT_QUOTES, 'UTF-8'); ?>
            <?php if ($httpCode !== null): ?>
                <br>HTTP code: <?php echo (int)$httpCode; ?>
            <?php endif; ?>
        </div>
    <?php endif; ?>

    <?php if ($result): ?>
        <?php
        $decoded = $result['decoded'];
        $address = isset($decoded['address']) ? $decoded['address'] : null;
        $id      = isset($decoded['id']) ? $decoded['id'] : null;
        $label   = isset($decoded['label']) ? $decoded['label'] : null;
        ?>
        <div class="alert alert-success">
            New SOL address generated successfully.
            <?php if ($address): ?>
                <div class="field-inline">
                    <span>Address:</span> <?php echo htmlspecialchars((string)$address, ENT_QUOTES, 'UTF-8'); ?>
                </div>
            <?php endif; ?>
            <?php if ($id): ?>
                <div class="field-inline">
                    <span>Address ID:</span> <?php echo htmlspecialchars((string)$id, ENT_QUOTES, 'UTF-8'); ?>
                </div>
            <?php endif; ?>
            <?php if ($label): ?>
                <div class="field-inline">
                    <span>Label:</span> <?php echo htmlspecialchars((string)$label, ENT_QUOTES, 'UTF-8'); ?>
                </div>
            <?php endif; ?>
        </div>

        <h3 style="margin-top: 20px; font-size: 14px;">Raw BitGo Response</h3>
        <pre><?php echo htmlspecialchars($result['raw'], ENT_QUOTES, 'UTF-8'); ?></pre>
    <?php endif; ?>
</div>
</body>
</html>

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


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