diff --git a/public/include/admin_checks.php b/public/include/admin_checks.php index dad3070e..f29c67d4 100644 --- a/public/include/admin_checks.php +++ b/public/include/admin_checks.php @@ -65,17 +65,19 @@ if (@$_SESSION['USERDATA']['is_admin'] && $user->isAdmin(@$_SESSION['USERDATA'][ if ($bitcoin->can_connect() !== true) { $error[] = "Unable to connect to coin daemon using provided credentials"; } - } catch (Exception $e) { - } - // if coldwallet is not empty, check if the address is valid -> error - if (!empty($config['coldwallet']['address'])) { - try { - if ($bitcoin->can_connect() == true) { + else { + // validate that the wallet service is not in test mode + if ($bitcoin->is_testnet() == true) { + $error[] = "The coin daemon service is running as a testnet. Check the TESTNET setting in your coin daemon config and make sure the correct port is set in the MPOS config."; + } + + // if coldwallet is not empty, check if the address is valid -> error + if (!empty($config['coldwallet']['address'])) { if (!$bitcoin->validateaddress($config['coldwallet']['address'])) $error[] = "Your cold wallet address is SET and INVALID"; } - } catch (Exception $e) { } + } catch (Exception $e) { } // if database connection fails -> error $db_connect = new mysqli($config['db']['host'], $config['db']['user'], $config['db']['pass'], $config['db']['name'], $config['db']['port']); diff --git a/public/include/classes/bitcoin.class.php b/public/include/classes/bitcoin.class.php index 11e82f70..03e63e6f 100644 --- a/public/include/classes/bitcoin.class.php +++ b/public/include/classes/bitcoin.class.php @@ -308,4 +308,16 @@ class BitcoinClient extends jsonRPCClient { } return true; } + + public function is_testnet() { + try { + $r = parent::getinfo(); + if ($r['testnet']) { + return true; + } + } catch (Exception $e) { + return false; + } + return false; + } }