From 1266ce29bfb7963c87789f3ce564e8455fc7a111 Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 5 Dec 2023 02:02:38 +0200 Subject: [PATCH] add getBalance method --- src/Client.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Client.php b/src/Client.php index 1186144..d9b14cb 100644 --- a/src/Client.php +++ b/src/Client.php @@ -127,6 +127,30 @@ class Client return null; } + public function getBalance(): ?float + { + $this->_id++; + + $this->_prepare( + '', + 'POST', + [ + 'method' => 'getbalance', + 'params' => [], + 'id' => $this->_id + ] + ); + + $response = $this->_execute(); + + if (isset($response['result']) && is_float($response['result'])) + { + return $response['result']; + } + + return null; + } + public function getBlockHash( int $block ): ?string