Merge pull request #508 from TheSerapher/issue-506

Check coin address when updating account
This commit is contained in:
Sebastian Grewe 2013-07-23 08:11:57 -07:00
commit 6a04666ec3
3 changed files with 24 additions and 1 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -12,6 +12,7 @@
<tr><td>Donation %: </td><td><input type="text" name="donatePercent" value="{nocache}{$smarty.request.donatePercent|default:$GLOBAL.userdata.donate_percent|escape}{nocache}" size="4"><font size="1"> [donation amount in percent (example: 0.5)]</font></td></tr>
<tr><td>Automatic Payout Threshold: </td><td valign="top"><input type="text" name="payoutThreshold" value="{$smarty.request.payoutThreshold|default:$GLOBAL.userdata.ap_threshold|escape}" size="5" maxlength="5"> <font size="1">[{$GLOBAL.config.ap_threshold.min}-{$GLOBAL.config.ap_threshold.max} {$GLOBAL.config.currency}. Set to '0' for no auto payout]</font></td></tr>
<tr><td>Anonymous Account <span id='tt'><img src='{$PATH}/images/questionmark.png' height='15px' width='15px' title='Will hide your username on the website for others. Only admins can still get your user information.'></span>:</td><td>
<input type="hidden" name="is_anonymous" value="0" />
<input type="checkbox" name="is_anonymous" value="1" id="is_anonymous" {if $GLOBAL.userdata.is_anonymous}checked{/if} />
<label for="is_anonymous"></label>
</td></tr>