First attempt to add support to BTC >= 0.16

This commit is contained in:
Lucas Buzzo 2018-04-16 21:16:08 -03:00
parent 8fa8d6c8de
commit 26d291583b
2 changed files with 9 additions and 2 deletions

4
include/classes/bitcoin.class.php Normal file → Executable file
View File

@ -284,13 +284,15 @@ class BitcoinClient extends jsonRPCClient {
* The check is done by calling the server's getinfo() method and checking
* for a fault.
*
* To turn code compatible with BTC >= 0.16, getmininginfo() method used instead of getinfo()
*
* @return mixed boolean TRUE if successful, or a fault string otherwise
* @access public
* @throws none
*/
public function can_connect() {
try {
$r = $this->getinfo();
$r = $this->getmininginfo();
} catch (Exception $e) {
return $e->getMessage();
}

7
include/classes/bitcoinwrapper.class.php Normal file → Executable file
View File

@ -24,13 +24,18 @@ class BitcoinWrapper extends BitcoinClient {
public function getinfo() {
$this->oDebug->append("STA " . __METHOD__, 4);
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
return $this->memcache->setCache(__FUNCTION__, parent::getinfo(), 30);
if (!(parent::getwalletinfo()['walletname']))
return $this->memcache->setCache(__FUNCTION__, parent::getinfo(), 30);
else
return $this->memcache->setCache(__FUNCTION__, parent::getnetworkinfo()+parent::getmininginfo()+parent::getwalletinfo(), 30);
}
public function getmininginfo() {
$this->oDebug->append("STA " . __METHOD__, 4);
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
return $this->memcache->setCache(__FUNCTION__, parent::getmininginfo(), 30);
}
public function getblockcount() {
$this->oDebug->append("STA " . __METHOD__, 4);
if ($data = $this->memcache->get(__FUNCTION__)) return $data;