53 lines
1.6 KiB
PHP
53 lines
1.6 KiB
PHP
<?php
|
||
// test_address_format.php
|
||
|
||
// Increase error reporting
|
||
error_reporting(E_ALL);
|
||
ini_set('display_errors', 1);
|
||
|
||
// --- Autoload dependencies ---
|
||
// This assumes the script is in the root directory of your project.
|
||
require_once __DIR__ . '/src/salvium_tipbot_wallet.php';
|
||
|
||
// --- Load Configuration ---
|
||
$configFile = __DIR__ . '/config.php';
|
||
if (!file_exists($configFile)) {
|
||
die("ERROR: config.php not found. Please copy config.sample.php to config.php and fill in your details.\n");
|
||
}
|
||
$config = require $configFile;
|
||
echo "✅ Config loaded successfully.\n";
|
||
|
||
// --- Instantiate Wallet ---
|
||
try {
|
||
$wallet = new Salvium\SalviumWallet(
|
||
$config['SALVIUM_RPC_HOST'],
|
||
$config['SALVIUM_RPC_PORT'],
|
||
$config['SALVIUM_RPC_USERNAME'],
|
||
$config['SALVIUM_RPC_PASSWORD']
|
||
);
|
||
echo "✅ Wallet class instantiated.\n";
|
||
} catch (Exception $e) {
|
||
die("ERROR: Could not instantiate the wallet class: " . $e->getMessage() . "\n");
|
||
}
|
||
|
||
// --- Call getNewSubaddress ---
|
||
echo "ℹ️ Calling getNewSubaddress()...\n";
|
||
$newAddress = $wallet->getNewSubaddress();
|
||
|
||
if (!$newAddress) {
|
||
die("❌ ERROR: The wallet RPC call failed. Check if your salvium-wallet-rpc is running and accessible.\n");
|
||
}
|
||
|
||
echo "✅ Received address: " . $newAddress . "\n";
|
||
|
||
// --- Validate the Address Format ---
|
||
$expectedPrefix = 'SC1';
|
||
if (str_starts_with($newAddress, $expectedPrefix)) {
|
||
echo "✅ SUCCESS: The new address starts with the correct 'SC1' prefix.\n";
|
||
} else {
|
||
echo "❌ FAILURE: The new address does not start with 'SC1'.\n";
|
||
echo " - Expected prefix: " . $expectedPrefix . "\n";
|
||
echo " - Actual prefix: " . substr($newAddress, 0, 3) . "\n";
|
||
}
|
||
?>
|