@@ -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,8 +16,8 @@ discard block |
||
| 16 | 16 | * @param $json |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | - public function __construct($json){ |
|
| 20 | - foreach ($json as $key => $value){ |
|
| 19 | + public function __construct($json) { |
|
| 20 | + foreach ($json as $key => $value) { |
|
| 21 | 21 | $this->{$key} = $value; |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -103,8 +103,8 @@ |
||
| 103 | 103 | */ |
| 104 | 104 | |
| 105 | 105 | public function DeleteBalanceNotification($id){ |
| 106 | - $response = json_decode($this->client->delete('balance_update/'.$id, ['query'=>$this->params]),true); |
|
| 107 | - return $response['deleted']; |
|
| 106 | + $response = json_decode($this->client->delete('balance_update/'.$id, ['query'=>$this->params]),true); |
|
| 107 | + return $response['deleted']; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -124,8 +124,9 @@ |
||
| 124 | 124 | 'onNotification' => $on, |
| 125 | 125 | 'confs' => $confs, |
| 126 | 126 | ]; |
| 127 | - if(!is_null($height)) |
|
| 128 | - $params['height'] = $height; |
|
| 127 | + if(!is_null($height)) { |
|
| 128 | + $params['height'] = $height; |
|
| 129 | + } |
|
| 129 | 130 | $params = array_merge($this->params, $params); |
| 130 | 131 | $response = json_decode($this->client->post('block_notification',['form_params'=>$params]),true); |
| 131 | 132 | return new NotificationResponse($response); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | use Appino\Blockchain\Objects\ReceiveResponse; |
| 13 | 13 | use GuzzleHttp\Client; |
| 14 | 14 | |
| 15 | -class Receive{ |
|
| 15 | +class Receive { |
|
| 16 | 16 | /** |
| 17 | 17 | * @var Blockchain |
| 18 | 18 | */ |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | * @param Blockchain $blockchain |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | - public function __construct($config){ |
|
| 32 | + public function __construct($config) { |
|
| 33 | 33 | $this->client = new Client(['base_uri'=>self::URL]); |
| 34 | 34 | $this->params = [ |
| 35 | - 'key'=>data_get('api_code',null) |
|
| 35 | + 'key'=>data_get('api_code', null) |
|
| 36 | 36 | ]; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -44,14 +44,14 @@ discard block |
||
| 44 | 44 | * @param int $gap_limit How many unused addresses are allowed. |
| 45 | 45 | * @return ReceiveResponse |
| 46 | 46 | */ |
| 47 | - public function Generate($xpub, $callback, $gap_limit = 20){ |
|
| 47 | + public function Generate($xpub, $callback, $gap_limit = 20) { |
|
| 48 | 48 | $params = [ |
| 49 | 49 | 'xpub' => $xpub, |
| 50 | 50 | 'callback' => $callback, |
| 51 | 51 | 'gap_limit' => $gap_limit |
| 52 | 52 | ]; |
| 53 | 53 | $params = array_merge($this->params, $params); |
| 54 | - $response = json_decode($this->client->get('',['query'=>$params]),true); |
|
| 54 | + $response = json_decode($this->client->get('', ['query'=>$params]), true); |
|
| 55 | 55 | return new ReceiveResponse($response); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | * @return integer |
| 63 | 63 | * @throws \GuzzleHttp\Exception\GuzzleException |
| 64 | 64 | */ |
| 65 | - public function AddressGap($xpub){ |
|
| 66 | - $params = array_merge(['xpub'=>$xpub],$this->params); |
|
| 67 | - $response = json_decode($this->client->get('checkgap',['query'=>$params]),true); |
|
| 65 | + public function AddressGap($xpub) { |
|
| 66 | + $params = array_merge(['xpub'=>$xpub], $this->params); |
|
| 67 | + $response = json_decode($this->client->get('checkgap', ['query'=>$params]), true); |
|
| 68 | 68 | return $response['gap']; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @return NotificationResponse |
| 82 | 82 | */ |
| 83 | 83 | |
| 84 | - public function BalanceNotification($address, $callback, $on = Notification::KEEP, $confs = 3, $op = Operation::ALL){ |
|
| 84 | + public function BalanceNotification($address, $callback, $on = Notification::KEEP, $confs = 3, $op = Operation::ALL) { |
|
| 85 | 85 | $params = [ |
| 86 | 86 | 'address' => $address, |
| 87 | 87 | 'callback' => $callback, |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | 'op' => $op |
| 91 | 91 | ]; |
| 92 | 92 | $params = array_merge($this->params, $params); |
| 93 | - $response = json_decode($this->client->post('balance_update',['form_params'=>$params]),true); |
|
| 93 | + $response = json_decode($this->client->post('balance_update', ['form_params'=>$params]), true); |
|
| 94 | 94 | return new NotificationResponse($response); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | * @throws \GuzzleHttp\Exception\GuzzleException |
| 103 | 103 | */ |
| 104 | 104 | |
| 105 | - public function DeleteBalanceNotification($id){ |
|
| 106 | - $response = json_decode($this->client->delete('balance_update/'.$id, ['query'=>$this->params]),true); |
|
| 105 | + public function DeleteBalanceNotification($id) { |
|
| 106 | + $response = json_decode($this->client->delete('balance_update/'.$id, ['query'=>$this->params]), true); |
|
| 107 | 107 | return $response['deleted']; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -118,16 +118,16 @@ discard block |
||
| 118 | 118 | * @throws \GuzzleHttp\Exception\GuzzleException |
| 119 | 119 | */ |
| 120 | 120 | |
| 121 | - public function BlockNotification($callback, $on = Notification::KEEP, $confs = 1, $height = null){ |
|
| 121 | + public function BlockNotification($callback, $on = Notification::KEEP, $confs = 1, $height = null) { |
|
| 122 | 122 | $params = [ |
| 123 | 123 | 'callback' => $callback, |
| 124 | 124 | 'onNotification' => $on, |
| 125 | 125 | 'confs' => $confs, |
| 126 | 126 | ]; |
| 127 | - if(!is_null($height)) |
|
| 127 | + if (!is_null($height)) |
|
| 128 | 128 | $params['height'] = $height; |
| 129 | 129 | $params = array_merge($this->params, $params); |
| 130 | - $response = json_decode($this->client->post('block_notification',['form_params'=>$params]),true); |
|
| 130 | + $response = json_decode($this->client->post('block_notification', ['form_params'=>$params]), true); |
|
| 131 | 131 | return new NotificationResponse($response); |
| 132 | 132 | } |
| 133 | 133 | |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | * @throws \GuzzleHttp\Exception\GuzzleException |
| 140 | 140 | */ |
| 141 | 141 | |
| 142 | - public function DeleteBlockNotification($id){ |
|
| 143 | - $response = json_decode($this->client->delete('block_notification/'.$id,['query'=>$this->params]),true); |
|
| 142 | + public function DeleteBlockNotification($id) { |
|
| 143 | + $response = json_decode($this->client->delete('block_notification/'.$id, ['query'=>$this->params]), true); |
|
| 144 | 144 | return $response['deleted']; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -152,11 +152,11 @@ discard block |
||
| 152 | 152 | * @throws \GuzzleHttp\Exception\GuzzleException |
| 153 | 153 | */ |
| 154 | 154 | |
| 155 | - public function CallbackLogs($callback){ |
|
| 156 | - $params = array_merge(['callback'=>$callback],$this->params); |
|
| 157 | - $logs = json_decode($this->client->get('callback_log',['query'=>$params]),true); |
|
| 155 | + public function CallbackLogs($callback) { |
|
| 156 | + $params = array_merge(['callback'=>$callback], $this->params); |
|
| 157 | + $logs = json_decode($this->client->get('callback_log', ['query'=>$params]), true); |
|
| 158 | 158 | $response = array(); |
| 159 | - foreach ($logs as $log){ |
|
| 159 | + foreach ($logs as $log) { |
|
| 160 | 160 | $response[] = new LogResponse($log); |
| 161 | 161 | } |
| 162 | 162 | return $response; |
@@ -5,12 +5,12 @@ discard block |
||
| 5 | 5 | use 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 | return new WalletResponse($this->doCreate($password, null, $email, $label)); |
| 28 | 28 | } |
| 29 | 29 | |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | * @return WalletResponse |
| 38 | 38 | * @throws ParameterError |
| 39 | 39 | */ |
| 40 | - public function createWithKey($password, $privKey, $email=null, $label=null) { |
|
| 41 | - if(!isset($privKey) || is_null($privKey)) |
|
| 40 | + public function createWithKey($password, $privKey, $email = null, $label = null) { |
|
| 41 | + if (!isset($privKey) || is_null($privKey)) |
|
| 42 | 42 | throw new ParameterError("Private Key required."); |
| 43 | 43 | |
| 44 | 44 | return new WalletResponse($this->doCreate($password, $privKey, $email, $label)); |
@@ -54,21 +54,21 @@ discard block |
||
| 54 | 54 | * @return array |
| 55 | 55 | * @throws ParameterError |
| 56 | 56 | */ |
| 57 | - protected function doCreate($password, $priv = null, $label = null, $email = null){ |
|
| 58 | - if(!isset($password) || is_null($password)) |
|
| 57 | + protected function doCreate($password, $priv = null, $label = null, $email = null) { |
|
| 58 | + if (!isset($password) || is_null($password)) |
|
| 59 | 59 | throw new ParameterError("Password required."); |
| 60 | 60 | |
| 61 | 61 | $params = array( |
| 62 | 62 | 'password'=>$password |
| 63 | 63 | ); |
| 64 | - if(!is_null($priv)) |
|
| 64 | + if (!is_null($priv)) |
|
| 65 | 65 | $params['priv'] = $priv; |
| 66 | - if(!is_null($email)) |
|
| 66 | + if (!is_null($email)) |
|
| 67 | 67 | $params['email'] = $email; |
| 68 | - if(!is_null($label)) |
|
| 68 | + if (!is_null($label)) |
|
| 69 | 69 | $params['label'] = $label; |
| 70 | 70 | |
| 71 | - return $this->blockchain->Request(Blockchain::POST,self::URL,$params); |
|
| 71 | + return $this->blockchain->Request(Blockchain::POST, self::URL, $params); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | } |
@@ -38,8 +38,9 @@ discard block |
||
| 38 | 38 | * @throws ParameterError |
| 39 | 39 | */ |
| 40 | 40 | public function createWithKey($password, $privKey, $email=null, $label=null) { |
| 41 | - if(!isset($privKey) || is_null($privKey)) |
|
| 42 | - throw new ParameterError("Private Key required."); |
|
| 41 | + if(!isset($privKey) || is_null($privKey)) { |
|
| 42 | + throw new ParameterError("Private Key required."); |
|
| 43 | + } |
|
| 43 | 44 | |
| 44 | 45 | return new WalletResponse($this->doCreate($password, $privKey, $email, $label)); |
| 45 | 46 | } |
@@ -55,18 +56,22 @@ discard block |
||
| 55 | 56 | * @throws ParameterError |
| 56 | 57 | */ |
| 57 | 58 | protected function doCreate($password, $priv = null, $label = null, $email = null){ |
| 58 | - if(!isset($password) || is_null($password)) |
|
| 59 | - throw new ParameterError("Password required."); |
|
| 59 | + if(!isset($password) || is_null($password)) { |
|
| 60 | + throw new ParameterError("Password required."); |
|
| 61 | + } |
|
| 60 | 62 | |
| 61 | 63 | $params = array( |
| 62 | 64 | 'password'=>$password |
| 63 | 65 | ); |
| 64 | - if(!is_null($priv)) |
|
| 65 | - $params['priv'] = $priv; |
|
| 66 | - if(!is_null($email)) |
|
| 67 | - $params['email'] = $email; |
|
| 68 | - if(!is_null($label)) |
|
| 69 | - $params['label'] = $label; |
|
| 66 | + if(!is_null($priv)) { |
|
| 67 | + $params['priv'] = $priv; |
|
| 68 | + } |
|
| 69 | + if(!is_null($email)) { |
|
| 70 | + $params['email'] = $email; |
|
| 71 | + } |
|
| 72 | + if(!is_null($label)) { |
|
| 73 | + $params['label'] = $label; |
|
| 74 | + } |
|
| 70 | 75 | |
| 71 | 76 | return $this->blockchain->Request(Blockchain::POST,self::URL,$params); |
| 72 | 77 | } |
@@ -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 | ]; |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | use GuzzleHttp\Client; |
| 9 | 9 | use GuzzleHttp\Exception\GuzzleException; |
| 10 | 10 | |
| 11 | -class Blockchain{ |
|
| 11 | +class Blockchain { |
|
| 12 | 12 | |
| 13 | 13 | protected $client; |
| 14 | 14 | protected $params; |
@@ -16,29 +16,29 @@ discard block |
||
| 16 | 16 | const GET = 'GET'; |
| 17 | 17 | const POST = 'POST'; |
| 18 | 18 | |
| 19 | - public function __construct($config){ |
|
| 20 | - $this->client = new Client(['base_uri'=>data_get($config,'base_uri')]); |
|
| 21 | - $this->params['api_code'] = data_get('api_code',null); |
|
| 19 | + public function __construct($config) { |
|
| 20 | + $this->client = new Client(['base_uri'=>data_get($config, 'base_uri')]); |
|
| 21 | + $this->params['api_code'] = data_get('api_code', null); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * @return Create |
| 26 | 26 | */ |
| 27 | - public function Create(){ |
|
| 27 | + public function Create() { |
|
| 28 | 28 | return new Create($this); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * @return Wallet |
| 33 | 33 | */ |
| 34 | - public function Wallet(){ |
|
| 34 | + public function Wallet() { |
|
| 35 | 35 | return new Wallet($this); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * @return Receive |
| 40 | 40 | */ |
| 41 | - public function Receive(){ |
|
| 41 | + public function Receive() { |
|
| 42 | 42 | return new Receive($this); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param $base_uri string Default : http://localhost:3000 |
| 47 | 47 | */ |
| 48 | 48 | |
| 49 | - public function newBaseUri($base_uri){ |
|
| 49 | + public function newBaseUri($base_uri) { |
|
| 50 | 50 | $this->client = new Client(['base_uri'=>$base_uri]); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @return array |
| 58 | 58 | */ |
| 59 | 59 | |
| 60 | - public function Request($method, $url, $params){ |
|
| 60 | + public function Request($method, $url, $params) { |
|
| 61 | 61 | $params = array_merge($this->params, $params); |
| 62 | 62 | $options = array( |
| 63 | 63 | 'form-params'=>$params, |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | ); |
| 68 | 68 | |
| 69 | 69 | try { |
| 70 | - return json_decode($this->client->request($method, $url, $options),true); |
|
| 70 | + return json_decode($this->client->request($method, $url, $options), true); |
|
| 71 | 71 | } catch (GuzzleException $e) { |
| 72 | 72 | //throw $e->getMessage(); |
| 73 | 73 | } |
@@ -4,16 +4,16 @@ |
||
| 4 | 4 | namespace Appino\Blockchain\Objects; |
| 5 | 5 | |
| 6 | 6 | |
| 7 | -class Cache{ |
|
| 7 | +class Cache { |
|
| 8 | 8 | |
| 9 | 9 | public $receiveAccount; |
| 10 | 10 | public $changeAccount; |
| 11 | 11 | |
| 12 | - public function __construct($params){ |
|
| 13 | - if(array_key_exists('receiveAccount',$params)) |
|
| 14 | - $this->receiveAccount = data_get($params,'receiveAccount'); |
|
| 15 | - if(array_key_exists('changeAccount',$params)) |
|
| 16 | - $this->changeAccount = new Cache(data_get($params,'changeAccount')); |
|
| 12 | + public function __construct($params) { |
|
| 13 | + if (array_key_exists('receiveAccount', $params)) |
|
| 14 | + $this->receiveAccount = data_get($params, 'receiveAccount'); |
|
| 15 | + if (array_key_exists('changeAccount', $params)) |
|
| 16 | + $this->changeAccount = new Cache(data_get($params, 'changeAccount')); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | } |
@@ -10,10 +10,12 @@ |
||
| 10 | 10 | public $changeAccount; |
| 11 | 11 | |
| 12 | 12 | public function __construct($params){ |
| 13 | - if(array_key_exists('receiveAccount',$params)) |
|
| 14 | - $this->receiveAccount = data_get($params,'receiveAccount'); |
|
| 15 | - if(array_key_exists('changeAccount',$params)) |
|
| 16 | - $this->changeAccount = new Cache(data_get($params,'changeAccount')); |
|
| 13 | + if(array_key_exists('receiveAccount',$params)) { |
|
| 14 | + $this->receiveAccount = data_get($params,'receiveAccount'); |
|
| 15 | + } |
|
| 16 | + if(array_key_exists('changeAccount',$params)) { |
|
| 17 | + $this->changeAccount = new Cache(data_get($params,'changeAccount')); |
|
| 18 | + } |
|
| 17 | 19 | } |
| 18 | 20 | |
| 19 | 21 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | use Blockchain\Exception\CredentialsError; |
| 12 | 12 | use Blockchain\Exception\ParameterError; |
| 13 | 13 | |
| 14 | -class Wallet{ |
|
| 14 | +class Wallet { |
|
| 15 | 15 | |
| 16 | 16 | protected $blockchain; |
| 17 | 17 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * Wallet constructor. |
| 29 | 29 | * @param Blockchain $blockchain |
| 30 | 30 | */ |
| 31 | - public function __construct(Blockchain $blockchain){ |
|
| 31 | + public function __construct(Blockchain $blockchain) { |
|
| 32 | 32 | $this->blockchain = $blockchain; |
| 33 | 33 | } |
| 34 | 34 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @param $resource |
| 39 | 39 | * @return string |
| 40 | 40 | */ |
| 41 | - private function URL($resource){ |
|
| 41 | + private function URL($resource) { |
|
| 42 | 42 | return 'merchant/'.$this->identifier.'/'.$resource; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param string $guid |
| 49 | 49 | * @param string $password |
| 50 | 50 | */ |
| 51 | - public function credentials($guid, $password){ |
|
| 51 | + public function credentials($guid, $password) { |
|
| 52 | 52 | $this->identifier = $guid; |
| 53 | 53 | $this->password = $password; |
| 54 | 54 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @throws CredentialsError |
| 60 | 60 | */ |
| 61 | 61 | private function _checkCredentials() { |
| 62 | - if(is_null($this->identifier) || is_null($this->password)) { |
|
| 62 | + if (is_null($this->identifier) || is_null($this->password)) { |
|
| 63 | 63 | throw new CredentialsError('Please enter wallet credentials.'); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @param array $extras |
| 71 | 71 | * @return array |
| 72 | 72 | */ |
| 73 | - private function reqParams($extras=array()) { |
|
| 73 | + private function reqParams($extras = array()) { |
|
| 74 | 74 | $ret = array('password'=>$this->password); |
| 75 | 75 | return array_merge($ret, $extras); |
| 76 | 76 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @throws CredentialsError |
| 83 | 83 | */ |
| 84 | 84 | |
| 85 | - private function call($resource, $params=array()) { |
|
| 85 | + private function call($resource, $params = array()) { |
|
| 86 | 86 | $this->_checkCredentials(); |
| 87 | 87 | return $this->blockchain->Request('post', $this->URL($resource), $this->reqParams($params)); |
| 88 | 88 | } |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | * @return AccountResponse |
| 94 | 94 | */ |
| 95 | 95 | |
| 96 | - public function CreateAddress($label = null){ |
|
| 97 | - if(!is_null($label)) |
|
| 96 | + public function CreateAddress($label = null) { |
|
| 97 | + if (!is_null($label)) |
|
| 98 | 98 | $params = ['label'=>$label]; |
| 99 | - $response = $this->call('accounts/create',$params); |
|
| 99 | + $response = $this->call('accounts/create', $params); |
|
| 100 | 100 | return new AccountResponse($response); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * @return int in satoshi |
| 108 | 108 | */ |
| 109 | 109 | |
| 110 | - public function Balance(){ |
|
| 110 | + public function Balance() { |
|
| 111 | 111 | $response = $this->call('balance'); |
| 112 | 112 | return $response['balance']; |
| 113 | 113 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @return int in satoshi |
| 120 | 120 | */ |
| 121 | 121 | |
| 122 | - public function AddressBallance($param){ |
|
| 122 | + public function AddressBallance($param) { |
|
| 123 | 123 | $response = $this->call('accounts/'.$param.'/balance'); |
| 124 | 124 | return $response['balance']; |
| 125 | 125 | } |
@@ -129,10 +129,10 @@ discard block |
||
| 129 | 129 | * @return array<AccountResponse> |
| 130 | 130 | */ |
| 131 | 131 | |
| 132 | - public function ActiveAddresses(){ |
|
| 132 | + public function ActiveAddresses() { |
|
| 133 | 133 | $addresses = $this->call('accounts'); |
| 134 | 134 | $response = array(); |
| 135 | - foreach ($addresses as $address){ |
|
| 135 | + foreach ($addresses as $address) { |
|
| 136 | 136 | $response[] = new AccountResponse($address); |
| 137 | 137 | } |
| 138 | 138 | return $response; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @return array<string> xpub address |
| 145 | 145 | */ |
| 146 | 146 | |
| 147 | - public function XpubList(){ |
|
| 147 | + public function XpubList() { |
|
| 148 | 148 | $response = $this->call('accounts/xpubs'); |
| 149 | 149 | return $response; |
| 150 | 150 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @return AccountResponse |
| 157 | 157 | */ |
| 158 | 158 | |
| 159 | - public function SingleAddress($param){ |
|
| 159 | + public function SingleAddress($param) { |
|
| 160 | 160 | $response = $this->call('accounts/'.$param); |
| 161 | 161 | return new AccountResponse($response); |
| 162 | 162 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @return string |
| 169 | 169 | */ |
| 170 | 170 | |
| 171 | - public function ReceivingAddress($param){ |
|
| 171 | + public function ReceivingAddress($param) { |
|
| 172 | 172 | $response = $this->call('accounts/'.$param.'/receiveAddress'); |
| 173 | 173 | return $response['address']; |
| 174 | 174 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @return AccountResponse |
| 181 | 181 | */ |
| 182 | 182 | |
| 183 | - public function ArchiveAddress($param){ |
|
| 183 | + public function ArchiveAddress($param) { |
|
| 184 | 184 | $response = $this->call('accounts/'.$param.'/archive'); |
| 185 | 185 | return new AccountResponse($response); |
| 186 | 186 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @return AccountResponse |
| 193 | 193 | */ |
| 194 | 194 | |
| 195 | - public function UnArchiveAddress($param){ |
|
| 195 | + public function UnArchiveAddress($param) { |
|
| 196 | 196 | $response = $this->call('accounts/'.$param.'/unarchive'); |
| 197 | 197 | return new AccountResponse($response); |
| 198 | 198 | } |
@@ -208,21 +208,21 @@ discard block |
||
| 208 | 208 | * @throws ParameterError |
| 209 | 209 | */ |
| 210 | 210 | |
| 211 | - public function SendPayment($to, $amount, $from=null, $fee=null, $fee_per_byte=null){ |
|
| 212 | - if(!isset($amount)) |
|
| 211 | + public function SendPayment($to, $amount, $from = null, $fee = null, $fee_per_byte = null) { |
|
| 212 | + if (!isset($amount)) |
|
| 213 | 213 | throw new ParameterError("Amount required."); |
| 214 | 214 | |
| 215 | 215 | $params = array( |
| 216 | 216 | 'to'=>$to, |
| 217 | 217 | 'amount'=>$amount |
| 218 | 218 | ); |
| 219 | - if(!is_null($from)) |
|
| 219 | + if (!is_null($from)) |
|
| 220 | 220 | $params['from'] = $from; |
| 221 | - if(!is_null($fee)) |
|
| 221 | + if (!is_null($fee)) |
|
| 222 | 222 | $params['fee'] = $fee; |
| 223 | - if(!is_null($fee_per_byte)) |
|
| 223 | + if (!is_null($fee_per_byte)) |
|
| 224 | 224 | $params['fee_per_byte'] = $fee_per_byte; |
| 225 | - $response = $this->call('payment',$params); |
|
| 225 | + $response = $this->call('payment', $params); |
|
| 226 | 226 | return new PaymentResponse($response); |
| 227 | 227 | } |
| 228 | 228 | |
@@ -235,17 +235,17 @@ discard block |
||
| 235 | 235 | * @param integer|null $fee_per_byte must be in satoshi |
| 236 | 236 | */ |
| 237 | 237 | |
| 238 | - public function SendManyPayment($recipients, $from=null, $fee=null, $fee_per_byte = null){ |
|
| 238 | + public function SendManyPayment($recipients, $from = null, $fee = null, $fee_per_byte = null) { |
|
| 239 | 239 | $params = array( |
| 240 | 240 | 'recipients'=>json_encode($recipients) |
| 241 | 241 | ); |
| 242 | - if(!is_null($from)) |
|
| 242 | + if (!is_null($from)) |
|
| 243 | 243 | $params['from'] = $from; |
| 244 | - if(!is_null($fee)) |
|
| 244 | + if (!is_null($fee)) |
|
| 245 | 245 | $params['fee'] = $fee; |
| 246 | - if(!is_null($fee_per_byte)) |
|
| 246 | + if (!is_null($fee_per_byte)) |
|
| 247 | 247 | $params['fee_per_byte'] = $fee_per_byte; |
| 248 | - $response = $this->call('sendmany',$params); |
|
| 248 | + $response = $this->call('sendmany', $params); |
|
| 249 | 249 | return new PaymentResponse($response); |
| 250 | 250 | } |
| 251 | 251 | |
@@ -94,8 +94,9 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | |
| 96 | 96 | public function CreateAddress($label = null){ |
| 97 | - if(!is_null($label)) |
|
| 98 | - $params = ['label'=>$label]; |
|
| 97 | + if(!is_null($label)) { |
|
| 98 | + $params = ['label'=>$label]; |
|
| 99 | + } |
|
| 99 | 100 | $response = $this->call('accounts/create',$params); |
| 100 | 101 | return new AccountResponse($response); |
| 101 | 102 | } |
@@ -209,19 +210,23 @@ discard block |
||
| 209 | 210 | */ |
| 210 | 211 | |
| 211 | 212 | public function SendPayment($to, $amount, $from=null, $fee=null, $fee_per_byte=null){ |
| 212 | - if(!isset($amount)) |
|
| 213 | - throw new ParameterError("Amount required."); |
|
| 213 | + if(!isset($amount)) { |
|
| 214 | + throw new ParameterError("Amount required."); |
|
| 215 | + } |
|
| 214 | 216 | |
| 215 | 217 | $params = array( |
| 216 | 218 | 'to'=>$to, |
| 217 | 219 | 'amount'=>$amount |
| 218 | 220 | ); |
| 219 | - if(!is_null($from)) |
|
| 220 | - $params['from'] = $from; |
|
| 221 | - if(!is_null($fee)) |
|
| 222 | - $params['fee'] = $fee; |
|
| 223 | - if(!is_null($fee_per_byte)) |
|
| 224 | - $params['fee_per_byte'] = $fee_per_byte; |
|
| 221 | + if(!is_null($from)) { |
|
| 222 | + $params['from'] = $from; |
|
| 223 | + } |
|
| 224 | + if(!is_null($fee)) { |
|
| 225 | + $params['fee'] = $fee; |
|
| 226 | + } |
|
| 227 | + if(!is_null($fee_per_byte)) { |
|
| 228 | + $params['fee_per_byte'] = $fee_per_byte; |
|
| 229 | + } |
|
| 225 | 230 | $response = $this->call('payment',$params); |
| 226 | 231 | return new PaymentResponse($response); |
| 227 | 232 | } |
@@ -239,12 +244,15 @@ discard block |
||
| 239 | 244 | $params = array( |
| 240 | 245 | 'recipients'=>json_encode($recipients) |
| 241 | 246 | ); |
| 242 | - if(!is_null($from)) |
|
| 243 | - $params['from'] = $from; |
|
| 244 | - if(!is_null($fee)) |
|
| 245 | - $params['fee'] = $fee; |
|
| 246 | - if(!is_null($fee_per_byte)) |
|
| 247 | - $params['fee_per_byte'] = $fee_per_byte; |
|
| 247 | + if(!is_null($from)) { |
|
| 248 | + $params['from'] = $from; |
|
| 249 | + } |
|
| 250 | + if(!is_null($fee)) { |
|
| 251 | + $params['fee'] = $fee; |
|
| 252 | + } |
|
| 253 | + if(!is_null($fee_per_byte)) { |
|
| 254 | + $params['fee_per_byte'] = $fee_per_byte; |
|
| 255 | + } |
|
| 248 | 256 | $response = $this->call('sendmany',$params); |
| 249 | 257 | return new PaymentResponse($response); |
| 250 | 258 | } |