From 26d291583b04ce13e0a1aa5d87283f0617f0afd7 Mon Sep 17 00:00:00 2001 From: Lucas Buzzo Date: Mon, 16 Apr 2018 21:16:08 -0300 Subject: [PATCH] First attempt to add support to BTC >= 0.16 --- include/classes/bitcoin.class.php | 4 +++- include/classes/bitcoinwrapper.class.php | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) mode change 100644 => 100755 include/classes/bitcoin.class.php mode change 100644 => 100755 include/classes/bitcoinwrapper.class.php diff --git a/include/classes/bitcoin.class.php b/include/classes/bitcoin.class.php old mode 100644 new mode 100755 index 03e63e6f..7d4582ef --- a/include/classes/bitcoin.class.php +++ b/include/classes/bitcoin.class.php @@ -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(); } diff --git a/include/classes/bitcoinwrapper.class.php b/include/classes/bitcoinwrapper.class.php old mode 100644 new mode 100755 index 16232e4d..63729002 --- a/include/classes/bitcoinwrapper.class.php +++ b/include/classes/bitcoinwrapper.class.php @@ -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;