From 2590873ca9cbad414bede2da853d22df47a4b524 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 9 May 2024 12:34:12 +0300 Subject: [PATCH] fix connection init --- src/Model/Kevacoin.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Model/Kevacoin.php b/src/Model/Kevacoin.php index 636b869..cbd8ed4 100644 --- a/src/Model/Kevacoin.php +++ b/src/Model/Kevacoin.php @@ -18,21 +18,32 @@ class Kevacoin int $port, string $namespace ) { - // Connect wallet + // Init wallet connection $this->_client = new \Kevachat\Kevacoin\Client( $scheme, $host, $port, - $username, + $user, $password ); + // Check connection using balance request + if (!is_float($this->_client->getBalance())) + { + throw new \Exception( + _('could not connect kevacoin wallet!') + ); + } + // Check namespace given exists - if (!$this->_namespace = $this->_client->kevaFilter($namespace)) + if (is_null($this->_client->kevaFilter($namespace, '', 0, 0, 1))) { throw new \Exception( _('could not find requested namespace!') ); } + + // Init namespace + $this->_namespace = $namespace; } } \ No newline at end of file