/ src / BitcoindClient.php
BitcoindClient.php
 1  <?php
 2  
 3  namespace BitcoindRPC;
 4  
 5  use BitcoindRPC\Wallet\Wallet;
 6  use BitcoindRPC\Blockchain\Blockchain;
 7  use BitcoindRPC\Mining\Mining;
 8  use BitcoindRPC\Network\Network;
 9  use BitcoindRPC\RawTransactions\RawTransactions;
10  use BitcoindRPC\Util\Util;
11  use BitcoindRPC\Generating\Generating;
12  use BitcoindRPC\Control\Control;
13  
14  class BitcoindClient
15  {
16      private RpcClient $rpcClient;
17      private Wallet $wallet;
18      private Blockchain $blockchain;
19      private Mining $mining;
20      private Network $network;
21      private RawTransactions $rawTransactions;
22      private Util $util;
23      private Generating $generating;
24      private Control $control;
25  
26      public function __construct(array $config = [])
27      {
28          $this->rpcClient = new RpcClient($config);
29          $this->initializeComponents();
30      }
31  
32      private function initializeComponents(): void
33      {
34          $this->wallet = new Wallet($this->rpcClient);
35          $this->blockchain = new Blockchain($this->rpcClient);
36          $this->mining = new Mining($this->rpcClient);
37          $this->network = new Network($this->rpcClient);
38          $this->rawTransactions = new RawTransactions($this->rpcClient);
39          $this->util = new Util($this->rpcClient);
40          $this->generating = new Generating($this->rpcClient);
41          $this->control = new Control($this->rpcClient);
42      }
43  
44      public function wallet(): Wallet
45      {
46          return $this->wallet;
47      }
48  
49      public function blockchain(): Blockchain
50      {
51          return $this->blockchain;
52      }
53  
54      public function mining(): Mining
55      {
56          return $this->mining;
57      }
58  
59      public function network(): Network
60      {
61          return $this->network;
62      }
63  
64      public function rawTransactions(): RawTransactions
65      {
66          return $this->rawTransactions;
67      }
68  
69      public function util(): Util
70      {
71          return $this->util;
72      }
73  
74      public function generating(): Generating
75      {
76          return $this->generating;
77      }
78  
79      public function control(): Control
80      {
81          return $this->control;
82      }
83  
84      public function getRpcClient(): RpcClient
85      {
86          return $this->rpcClient;
87      }
88  }