Check coin address when updating account
This will fix #506 and ensures valid addresses are added when updating the account.
This commit is contained in:
parent
35d1f5fa92
commit
c6a4df2975
@ -30,6 +30,9 @@ class Base {
|
||||
public function setToken($token) {
|
||||
$this->token = $token;
|
||||
}
|
||||
public function setBitcoin($bitcoin) {
|
||||
$this->bitcoin = $bitcoin;
|
||||
}
|
||||
public function setTokenType($tokentype) {
|
||||
$this->tokentype = $tokentype;
|
||||
}
|
||||
|
||||
@ -23,7 +23,10 @@ class User {
|
||||
$this->mail = $mail;
|
||||
}
|
||||
public function setToken($token) {
|
||||
$this->token= $token;
|
||||
$this->token = $token;
|
||||
}
|
||||
public function setBitcoin($bitcoin) {
|
||||
$this->bitcoin = $bitcoin;
|
||||
}
|
||||
private function setErrorMessage($msg) {
|
||||
$this->sError = $msg;
|
||||
@ -317,6 +320,21 @@ class User {
|
||||
$this->setErrorMessage('Invalid email address');
|
||||
return false;
|
||||
}
|
||||
if ($this->bitcoin->can_connect() === true && !empty($address)) {
|
||||
try {
|
||||
$aStatus = $this->bitcoin->validateaddress($address);
|
||||
if (!$aStatus['isvalid']) {
|
||||
$this->setErrorMessage('Invalid coin address');
|
||||
return false;
|
||||
}
|
||||
} catch (BitcoinClientException $e) {
|
||||
$this->setErrorMessage('Unable to verify coin address');
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->setErrorMessage('Unable to connect to RPC server for coin address validation');
|
||||
return false;
|
||||
}
|
||||
// Number sanitizer, just in case we fall through above
|
||||
$threshold = min($this->config['ap_threshold']['max'], max(0, floatval($threshold)));
|
||||
$donate = min(100, max(0, floatval($donate)));
|
||||
@ -646,3 +664,4 @@ class User {
|
||||
$user = new User($debug, $mysqli, SALT, $config);
|
||||
$user->setMail($mail);
|
||||
$user->setToken($oToken);
|
||||
$user->setBitcoin($bitcoin);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user