|
23 | 23 | $bal2 = $coin->getbalance("*", 0); |
24 | 24 | $bal3 = abs($bal1 - $bal2); |
25 | 25 | $bal4 = abs("{$y['stake']}"); |
26 | | -if($primary!=""){ |
27 | | - $address = $primary; |
| 26 | + |
| 27 | +$showMainAddressChangedMessage = false; |
| 28 | +$oldAddress = $primary; |
| 29 | +$newAddress; |
| 30 | +// Fixes bug when the main address is set to an address not in the wallet ----------------------------------------------------- |
| 31 | +if($primary != ""){ |
| 32 | + $hasPrimary = false; |
| 33 | + $addresses = $coin->getaddressesbyaccount(""); |
| 34 | + |
| 35 | + foreach($addresses as $add){ |
| 36 | + if($add == $primary){ |
| 37 | + $hasPrimary = true; |
| 38 | + } |
| 39 | + } |
| 40 | + if ($hasPrimary) { |
| 41 | + $address = $primary; |
| 42 | + } else { |
| 43 | + |
| 44 | + $address = $coin->getaddressesbyaccount("")[0]; |
| 45 | + |
| 46 | + // Duplicated code from setPrimary, as we can't access the function ---------------- |
| 47 | + $primaryLocation = "/home/stakebox/UI/primary".$currentWallet."address.php"; |
| 48 | + // Open the file and erase the contents if any |
| 49 | + $fp = fopen($primaryLocation, "w"); |
| 50 | + // Write the data to the file |
| 51 | + // CODE INJECTION WARNING! |
| 52 | + fwrite($fp, "<?php\n\$primary='';\n?>"); |
| 53 | + // Close the file |
| 54 | + fclose($fp); |
| 55 | + $showMainAddressChangedMessage = true; |
| 56 | + $newAddress = $address; |
| 57 | + } |
28 | 58 | } |
29 | 59 | else{ |
30 | | - $address = $coin->getaddressesbyaccount("")[0]; |
| 60 | + $address = $coin->getaddressesbyaccount("")[0]; |
31 | 61 | } |
| 62 | +//------------------------------------------------------------- |
32 | 63 |
|
33 | 64 | if ($currentWallet == NavCoin){ |
34 | 65 | $stakinginfo = $coin->getstakinginfo(); |
|
48 | 79 | $fiatValue = number_format($fiatValue); |
49 | 80 | ?> |
50 | 81 | <div class="row"> |
| 82 | + <?php |
| 83 | + if ($showMainAddressChangedMessage == true) |
| 84 | + echo " |
| 85 | + <div class='col-lg-12'> |
| 86 | + <div class='alert alert-info'> |
| 87 | + <strong>Primary Address Updated:</strong>We detected your saved primary address was not owned by your wallet. It has been replaced with a valid address. |
| 88 | + <p><small>This can occur when you restore your wallet after manually setting the primary address.</small></p> |
| 89 | + <small> |
| 90 | + New Address: \"{$address}\" |
| 91 | + <br>Old Address: \"{$oldAddress}\" |
| 92 | + </small> |
| 93 | + </div> |
| 94 | + </div>"; |
| 95 | + |
| 96 | + ?> |
| 97 | + |
51 | 98 | <div class="col-lg-6"> |
52 | 99 | <h3>Available Balance: <font color='green'><?php echo number_format($bal1); ?></font> <?php echo $currentWallet; ?></h3> |
53 | 100 | <h4>Unavailable Due To Staking: <font color='red'><?php echo $bal4; ?></font> <?php echo $currentWallet; ?></h4> |
|
0 commit comments