@@ -4,7 +4,7 @@ |
||
4 | 4 | namespace Appino\Blockchain\Interfaces; |
5 | 5 | |
6 | 6 | |
7 | -abstract class Operation{ |
|
7 | +abstract class Operation { |
|
8 | 8 | |
9 | 9 | const SPEND = 'SPEND'; |
10 | 10 | const RECEIVE = 'RECEIVE'; |
@@ -4,7 +4,7 @@ |
||
4 | 4 | namespace Appino\Blockchain\Interfaces; |
5 | 5 | |
6 | 6 | |
7 | -abstract class Notification{ |
|
7 | +abstract class Notification { |
|
8 | 8 | |
9 | 9 | const KEEP = 'KEEP'; |
10 | 10 | const DELETE = 'DELETE'; |
@@ -5,5 +5,5 @@ |
||
5 | 5 | */ |
6 | 6 | return [ |
7 | 7 | 'api_code'=>env('blockchain_api_code'), |
8 | - 'base_url'=>env('blockchain_base_url','http://localhost:3000/') |
|
8 | + 'base_url'=>env('blockchain_base_url', 'http://localhost:3000/') |
|
9 | 9 | ]; |
@@ -56,7 +56,7 @@ |
||
56 | 56 | $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'blockchain'); |
57 | 57 | |
58 | 58 | // Register the main class to use with the facade |
59 | - $this->app->singleton('blockchain', function () { |
|
59 | + $this->app->singleton('blockchain', function() { |
|
60 | 60 | $config = app('config')->get('blockchain'); |
61 | 61 | return (new Blockchain($config)); |
62 | 62 | }); |
@@ -5,12 +5,12 @@ discard block |
||
5 | 5 | use Appino\Blockchain\Exception\ParameterError; |
6 | 6 | use Appino\Blockchain\Objects\WalletResponse; |
7 | 7 | |
8 | -class Create{ |
|
8 | +class Create { |
|
9 | 9 | |
10 | 10 | protected $blockchain; |
11 | 11 | const URL = '/api/v2/create'; |
12 | 12 | |
13 | - public function __construct(Blockchain $blockchain){ |
|
13 | + public function __construct(Blockchain $blockchain) { |
|
14 | 14 | $this->blockchain = $blockchain; |
15 | 15 | } |
16 | 16 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @return WalletResponse |
24 | 24 | * @throws ParameterError |
25 | 25 | */ |
26 | - public function create($password, $email=null, $label=null) { |
|
26 | + public function create($password, $email = null, $label = null) { |
|
27 | 27 | $response = $this->doCreate($password, null, $email, $label); |
28 | 28 | return new WalletResponse($response); |
29 | 29 | } |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * @return WalletResponse |
39 | 39 | * @throws ParameterError |
40 | 40 | */ |
41 | - public function createWithKey($password, $privKey, $email=null, $label=null) { |
|
42 | - if(!isset($privKey) || is_null($privKey)) |
|
41 | + public function createWithKey($password, $privKey, $email = null, $label = null) { |
|
42 | + if (!isset($privKey) || is_null($privKey)) |
|
43 | 43 | throw new ParameterError("Private Key required."); |
44 | 44 | |
45 | 45 | return new WalletResponse($this->doCreate($password, $privKey, $email, $label)); |
@@ -55,22 +55,22 @@ discard block |
||
55 | 55 | * @return array |
56 | 56 | * @throws ParameterError |
57 | 57 | */ |
58 | - protected function doCreate($password, $priv = null, $label = null, $email = null){ |
|
59 | - if(!isset($password) || empty($password)) |
|
58 | + protected function doCreate($password, $priv = null, $label = null, $email = null) { |
|
59 | + if (!isset($password) || empty($password)) |
|
60 | 60 | throw new ParameterError("Password required."); |
61 | 61 | |
62 | 62 | $params = array( |
63 | 63 | 'password'=>$password, |
64 | 64 | 'hd'=>true |
65 | 65 | ); |
66 | - if(!is_null($priv)) |
|
66 | + if (!is_null($priv)) |
|
67 | 67 | $params['priv'] = $priv; |
68 | - if(!is_null($email)) |
|
68 | + if (!is_null($email)) |
|
69 | 69 | $params['email'] = $email; |
70 | - if(!is_null($label)) |
|
70 | + if (!is_null($label)) |
|
71 | 71 | $params['label'] = $label; |
72 | 72 | |
73 | - return $this->blockchain->Request(Blockchain::POST,self::URL,$params); |
|
73 | + return $this->blockchain->Request(Blockchain::POST, self::URL, $params); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | use Appino\Blockchain\Exception\ParameterError; |
13 | 13 | use Appino\Blockchain\Objects\WalletAddress; |
14 | 14 | |
15 | -class Wallet{ |
|
15 | +class Wallet { |
|
16 | 16 | |
17 | 17 | protected $blockchain; |
18 | 18 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * Wallet constructor. |
30 | 30 | * @param Blockchain $blockchain |
31 | 31 | */ |
32 | - public function __construct(Blockchain $blockchain){ |
|
32 | + public function __construct(Blockchain $blockchain) { |
|
33 | 33 | $this->blockchain = $blockchain; |
34 | 34 | } |
35 | 35 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param $resource |
40 | 40 | * @return string |
41 | 41 | */ |
42 | - private function URL($resource){ |
|
42 | + private function URL($resource) { |
|
43 | 43 | return 'merchant/'.$this->identifier.'/'.$resource; |
44 | 44 | } |
45 | 45 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param string $guid |
50 | 50 | * @param string $password |
51 | 51 | */ |
52 | - public function credentials($guid, $password){ |
|
52 | + public function credentials($guid, $password) { |
|
53 | 53 | $this->identifier = $guid; |
54 | 54 | $this->password = $password; |
55 | 55 | return $this; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @throws CredentialsError |
62 | 62 | */ |
63 | 63 | private function _checkCredentials() { |
64 | - if(is_null($this->identifier) || is_null($this->password)) { |
|
64 | + if (is_null($this->identifier) || is_null($this->password)) { |
|
65 | 65 | throw new CredentialsError('Please enter wallet credentials.'); |
66 | 66 | } |
67 | 67 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param array $extras |
73 | 73 | * @return array |
74 | 74 | */ |
75 | - private function reqParams($extras=array()) { |
|
75 | + private function reqParams($extras = array()) { |
|
76 | 76 | $ret = array('password'=>$this->password); |
77 | 77 | return array_merge($ret, $extras); |
78 | 78 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @throws CredentialsError |
85 | 85 | */ |
86 | 86 | |
87 | - private function call($resource, $params=array()) { |
|
87 | + private function call($resource, $params = array()) { |
|
88 | 88 | $this->_checkCredentials(); |
89 | 89 | return $this->blockchain->Request('POST', $this->URL($resource), $this->reqParams($params)); |
90 | 90 | } |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | * @return WalletAddress |
96 | 96 | */ |
97 | 97 | |
98 | - public function CreateAddress($label = null){ |
|
98 | + public function CreateAddress($label = null) { |
|
99 | 99 | $params = array(); |
100 | - if(!is_null($label)) |
|
100 | + if (!is_null($label)) |
|
101 | 101 | $params = ['label'=>$label]; |
102 | - $response = $this->call('accounts/create',$params); |
|
102 | + $response = $this->call('accounts/create', $params); |
|
103 | 103 | return new WalletAddress($response); |
104 | 104 | } |
105 | 105 | |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * @return int in satoshi |
111 | 111 | */ |
112 | 112 | |
113 | - public function Balance(){ |
|
114 | - $response = $this->call('balance',$this->reqParams()); |
|
113 | + public function Balance() { |
|
114 | + $response = $this->call('balance', $this->reqParams()); |
|
115 | 115 | return $response['balance']; |
116 | 116 | } |
117 | 117 | |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @return int in satoshi |
123 | 123 | */ |
124 | 124 | |
125 | - public function AddressBallance($param){ |
|
126 | - $response = $this->call('accounts/'.$param.'/balance',$this->reqParams()); |
|
125 | + public function AddressBallance($param) { |
|
126 | + $response = $this->call('accounts/'.$param.'/balance', $this->reqParams()); |
|
127 | 127 | return $response['balance']; |
128 | 128 | } |
129 | 129 | |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | */ |
134 | 134 | |
135 | 135 | public function ActiveAddresses() { |
136 | - $addresses = $this->call('accounts',$this->reqParams()); |
|
136 | + $addresses = $this->call('accounts', $this->reqParams()); |
|
137 | 137 | $response = array(); |
138 | - if(!empty($addresses)) |
|
139 | - foreach ($addresses as $address){ |
|
138 | + if (!empty($addresses)) |
|
139 | + foreach ($addresses as $address) { |
|
140 | 140 | $response[] = new AccountResponse($address); |
141 | 141 | } |
142 | 142 | return $response; |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | * @return string[] xpub address |
149 | 149 | */ |
150 | 150 | |
151 | - public function XpubList(){ |
|
152 | - $response = $this->call('accounts/xpubs',$this->reqParams()); |
|
151 | + public function XpubList() { |
|
152 | + $response = $this->call('accounts/xpubs', $this->reqParams()); |
|
153 | 153 | return $response; |
154 | 154 | } |
155 | 155 | |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @return AccountResponse |
161 | 161 | */ |
162 | 162 | |
163 | - public function SingleAddress($param){ |
|
164 | - $response = $this->call('accounts/'.$param,$this->reqParams()); |
|
163 | + public function SingleAddress($param) { |
|
164 | + $response = $this->call('accounts/'.$param, $this->reqParams()); |
|
165 | 165 | return new AccountResponse($response); |
166 | 166 | } |
167 | 167 | |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | * @return string |
173 | 173 | */ |
174 | 174 | |
175 | - public function ReceivingAddress($param){ |
|
176 | - $response = $this->call('accounts/'.$param.'/receiveAddress',$this->reqParams()); |
|
175 | + public function ReceivingAddress($param) { |
|
176 | + $response = $this->call('accounts/'.$param.'/receiveAddress', $this->reqParams()); |
|
177 | 177 | return $response['address']; |
178 | 178 | } |
179 | 179 | |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * @return AccountResponse |
185 | 185 | */ |
186 | 186 | |
187 | - public function ArchiveAddress($param){ |
|
188 | - $response = $this->call('accounts/'.$param.'/archive',$this->reqParams()); |
|
187 | + public function ArchiveAddress($param) { |
|
188 | + $response = $this->call('accounts/'.$param.'/archive', $this->reqParams()); |
|
189 | 189 | return new AccountResponse($response); |
190 | 190 | } |
191 | 191 | |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | * @return AccountResponse |
197 | 197 | */ |
198 | 198 | |
199 | - public function UnArchiveAddress($param){ |
|
200 | - $response = $this->call('accounts/'.$param.'/unarchive',$this->reqParams()); |
|
199 | + public function UnArchiveAddress($param) { |
|
200 | + $response = $this->call('accounts/'.$param.'/unarchive', $this->reqParams()); |
|
201 | 201 | return new AccountResponse($response); |
202 | 202 | } |
203 | 203 | |
@@ -213,21 +213,21 @@ discard block |
||
213 | 213 | * @throws ParameterError |
214 | 214 | */ |
215 | 215 | |
216 | - public function SendPayment($to, $amount, $from=null, $fee=null, $fee_per_byte=null){ |
|
217 | - if(!isset($amount)) |
|
216 | + public function SendPayment($to, $amount, $from = null, $fee = null, $fee_per_byte = null) { |
|
217 | + if (!isset($amount)) |
|
218 | 218 | throw new ParameterError("Amount required."); |
219 | 219 | |
220 | 220 | $params = array( |
221 | 221 | 'to'=>$to, |
222 | 222 | 'amount'=>$amount |
223 | 223 | ); |
224 | - if(!is_null($from)) |
|
224 | + if (!is_null($from)) |
|
225 | 225 | $params['from'] = $from; |
226 | - if(!is_null($fee)) |
|
226 | + if (!is_null($fee)) |
|
227 | 227 | $params['fee'] = $fee; |
228 | - if(!is_null($fee_per_byte)) |
|
228 | + if (!is_null($fee_per_byte)) |
|
229 | 229 | $params['fee_per_byte'] = $fee_per_byte; |
230 | - $response = $this->call('payment',$params); |
|
230 | + $response = $this->call('payment', $params); |
|
231 | 231 | return new PaymentResponse($response); |
232 | 232 | } |
233 | 233 | |
@@ -240,17 +240,17 @@ discard block |
||
240 | 240 | * @param integer|null $fee_per_byte must be in satoshi |
241 | 241 | */ |
242 | 242 | |
243 | - public function SendManyPayment($recipients, $from=null, $fee=null, $fee_per_byte = null){ |
|
243 | + public function SendManyPayment($recipients, $from = null, $fee = null, $fee_per_byte = null) { |
|
244 | 244 | $params = array( |
245 | 245 | 'recipients'=>json_encode($recipients) |
246 | 246 | ); |
247 | - if(!is_null($from)) |
|
247 | + if (!is_null($from)) |
|
248 | 248 | $params['from'] = $from; |
249 | - if(!is_null($fee)) |
|
249 | + if (!is_null($fee)) |
|
250 | 250 | $params['fee'] = $fee; |
251 | - if(!is_null($fee_per_byte)) |
|
251 | + if (!is_null($fee_per_byte)) |
|
252 | 252 | $params['fee_per_byte'] = $fee_per_byte; |
253 | - $response = $this->call('sendmany',$params); |
|
253 | + $response = $this->call('sendmany', $params); |
|
254 | 254 | return new PaymentResponse($response); |
255 | 255 | } |
256 | 256 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | namespace Appino\Blockchain\Objects; |
5 | 5 | |
6 | 6 | |
7 | -class PaymentResponse{ |
|
7 | +class PaymentResponse { |
|
8 | 8 | /** |
9 | 9 | * @var array of string |
10 | 10 | */ |
@@ -35,24 +35,24 @@ discard block |
||
35 | 35 | * @param $params array |
36 | 36 | */ |
37 | 37 | |
38 | - public function __construct($params){ |
|
39 | - if(is_null($params)) |
|
38 | + public function __construct($params) { |
|
39 | + if (is_null($params)) |
|
40 | 40 | return; |
41 | - $this->to = data_get($params,'to'); |
|
42 | - $this->from = data_get($params,'from'); |
|
43 | - $this->amount = data_get($params,'amount'); |
|
44 | - $this->fee = data_get($params,'fee'); |
|
45 | - $this->txid = data_get($params,'txid'); |
|
46 | - $this->success = data_get($params,'success'); |
|
41 | + $this->to = data_get($params, 'to'); |
|
42 | + $this->from = data_get($params, 'from'); |
|
43 | + $this->amount = data_get($params, 'amount'); |
|
44 | + $this->fee = data_get($params, 'fee'); |
|
45 | + $this->txid = data_get($params, 'txid'); |
|
46 | + $this->success = data_get($params, 'success'); |
|
47 | 47 | } |
48 | 48 | |
49 | - public function __toString(){ |
|
49 | + public function __toString() { |
|
50 | 50 | $class_vars = get_class_vars(get_class($this)); |
51 | 51 | $response = []; |
52 | - foreach ($class_vars as $key => $value){ |
|
52 | + foreach ($class_vars as $key => $value) { |
|
53 | 53 | $response[$key] = $this->{$key}; |
54 | 54 | } |
55 | - return json_encode($response, JSON_THROW_ON_ERROR) .""; |
|
55 | + return json_encode($response, JSON_THROW_ON_ERROR).""; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | namespace Appino\Blockchain\Objects; |
5 | 5 | |
6 | 6 | |
7 | -class BalanceCallback{ |
|
7 | +class BalanceCallback { |
|
8 | 8 | |
9 | 9 | public $transaction_hash; |
10 | 10 | public $address; |
@@ -16,21 +16,21 @@ discard block |
||
16 | 16 | * @param $params |
17 | 17 | */ |
18 | 18 | |
19 | - public function __construct($params){ |
|
20 | - if(is_null($params)) |
|
19 | + public function __construct($params) { |
|
20 | + if (is_null($params)) |
|
21 | 21 | return; |
22 | - foreach ($params as $key => $value){ |
|
22 | + foreach ($params as $key => $value) { |
|
23 | 23 | $this->{$key} = $value; |
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
27 | - public function __toString(){ |
|
27 | + public function __toString() { |
|
28 | 28 | $class_vars = get_class_vars(get_class($this)); |
29 | 29 | $response = []; |
30 | - foreach ($class_vars as $key => $value){ |
|
30 | + foreach ($class_vars as $key => $value) { |
|
31 | 31 | $response[$key] = $this->{$key}; |
32 | 32 | } |
33 | - return json_encode($response, JSON_THROW_ON_ERROR) .""; |
|
33 | + return json_encode($response, JSON_THROW_ON_ERROR).""; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Appino\Blockchain\Objects\Cache; |
6 | 6 | |
7 | -class WalletAddress{ |
|
7 | +class WalletAddress { |
|
8 | 8 | /** |
9 | 9 | * @var string |
10 | 10 | */ |
@@ -35,25 +35,25 @@ discard block |
||
35 | 35 | * @param $params array|object |
36 | 36 | */ |
37 | 37 | |
38 | - public function __construct($params){ |
|
38 | + public function __construct($params) { |
|
39 | 39 | //echo Json::encode($params); |
40 | - if(is_null($params)) |
|
40 | + if (is_null($params)) |
|
41 | 41 | return; |
42 | - $this->label = data_get($params,'label'); |
|
43 | - $this->archived = data_get($params,'archived'); |
|
44 | - $this->xpriv = data_get($params,'xpriv'); |
|
45 | - $this->xpub = data_get($params,'xpub'); |
|
46 | - $this->addresslabels = data_get($params,'addresslabels',array()); |
|
47 | - $this->cahce = new Cache(data_get($params,'cache')); |
|
42 | + $this->label = data_get($params, 'label'); |
|
43 | + $this->archived = data_get($params, 'archived'); |
|
44 | + $this->xpriv = data_get($params, 'xpriv'); |
|
45 | + $this->xpub = data_get($params, 'xpub'); |
|
46 | + $this->addresslabels = data_get($params, 'addresslabels', array()); |
|
47 | + $this->cahce = new Cache(data_get($params, 'cache')); |
|
48 | 48 | } |
49 | 49 | |
50 | - public function __toString(){ |
|
50 | + public function __toString() { |
|
51 | 51 | $class_vars = get_class_vars(get_class($this)); |
52 | 52 | $response = []; |
53 | - foreach ($class_vars as $key => $value){ |
|
53 | + foreach ($class_vars as $key => $value) { |
|
54 | 54 | $response[$key] = $this->{$key}; |
55 | 55 | } |
56 | - return json_encode($response, JSON_THROW_ON_ERROR) .""; |
|
56 | + return json_encode($response, JSON_THROW_ON_ERROR).""; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | } |