Completed
Pull Request — master (#110)
by Ruben de
75:02 queued 05:01
created
src/BlocktrailSDK.php 3 patches
Doc Comments   +19 added lines, -11 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     /**
111 111
      * normalize network string
112 112
      *
113
-     * @param $network
113
+     * @param string $network
114 114
      * @param $testnet
115 115
      * @return array
116 116
      * @throws \Exception
@@ -746,6 +746,11 @@  discard block
 block discarded – undo
746 746
         ];
747 747
     }
748 748
 
749
+    /**
750
+     * @param integer $bits
751
+     *
752
+     * @return string
753
+     */
749 754
     public static function randomBits($bits) {
750 755
         return self::randomBytes($bits / 8);
751 756
     }
@@ -1048,7 +1053,7 @@  discard block
 block discarded – undo
1048 1053
      * create wallet using the API
1049 1054
      *
1050 1055
      * @param string    $identifier             the wallet identifier to create
1051
-     * @param array     $primaryPublicKey       BIP32 extended public key - [key, path]
1056
+     * @param string[]     $primaryPublicKey       BIP32 extended public key - [key, path]
1052 1057
      * @param array     $backupPublicKey        BIP32 extended public key - [backup key, path "M"]
1053 1058
      * @param string    $primaryMnemonic        mnemonic to store
1054 1059
      * @param string    $checksum               checksum to store
@@ -1076,10 +1081,10 @@  discard block
 block discarded – undo
1076 1081
      *
1077 1082
      * @param string $identifier       the wallet identifier to create
1078 1083
      * @param array  $primaryPublicKey BIP32 extended public key - [key, path]
1079
-     * @param array  $backupPublicKey  BIP32 extended public key - [backup key, path "M"]
1080
-     * @param        $encryptedPrimarySeed
1081
-     * @param        $encryptedSecret
1082
-     * @param        $recoverySecret
1084
+     * @param string[]  $backupPublicKey  BIP32 extended public key - [backup key, path "M"]
1085
+     * @param        string|false $encryptedPrimarySeed
1086
+     * @param        string|false $encryptedSecret
1087
+     * @param        string|false $recoverySecret
1083 1088
      * @param string $checksum         checksum to store
1084 1089
      * @param int    $keyIndex         account that we expect to use
1085 1090
      * @param bool   $segwit           opt in to segwit
@@ -1109,9 +1114,9 @@  discard block
 block discarded – undo
1109 1114
      *
1110 1115
      * @param string $identifier       the wallet identifier to create
1111 1116
      * @param array  $primaryPublicKey BIP32 extended public key - [key, path]
1112
-     * @param array  $backupPublicKey  BIP32 extended public key - [backup key, path "M"]
1113
-     * @param        $encryptedPrimarySeed
1114
-     * @param        $encryptedSecret
1117
+     * @param string[]  $backupPublicKey  BIP32 extended public key - [backup key, path "M"]
1118
+     * @param        string|false $encryptedPrimarySeed
1119
+     * @param        string|false $encryptedSecret
1115 1120
      * @param        $recoverySecret
1116 1121
      * @param string $checksum         checksum to store
1117 1122
      * @param int    $keyIndex         account that we expect to use
@@ -1843,7 +1848,7 @@  discard block
 block discarded – undo
1843 1848
      * convert a Satoshi value to a BTC value
1844 1849
      *
1845 1850
      * @param int       $satoshi
1846
-     * @return float
1851
+     * @return string
1847 1852
      */
1848 1853
     public static function toBTC($satoshi) {
1849 1854
         return bcdiv((int)(string)$satoshi, 100000000, 8);
@@ -1873,7 +1878,7 @@  discard block
 block discarded – undo
1873 1878
      * convert a BTC value to a Satoshi value
1874 1879
      *
1875 1880
      * @param float     $btc
1876
-     * @return string
1881
+     * @return integer
1877 1882
      */
1878 1883
     public static function toSatoshi($btc) {
1879 1884
         return (int)self::toSatoshiString($btc);
@@ -1934,6 +1939,9 @@  discard block
 block discarded – undo
1934 1939
         }
1935 1940
     }
1936 1941
 
1942
+    /**
1943
+     * @param BIP32Key[] $keys
1944
+     */
1937 1945
     public static function normalizeBIP32KeyArray($keys) {
1938 1946
         return Util::arrayMapWithIndex(function ($idx, $key) {
1939 1947
             return [$idx, self::normalizeBIP32Key($key)];
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,6 @@
 block discarded – undo
23 23
 use Blocktrail\SDK\Address\BitcoinAddressReader;
24 24
 use Blocktrail\SDK\Address\BitcoinCashAddressReader;
25 25
 use Blocktrail\SDK\Address\CashAddress;
26
-use Blocktrail\SDK\Backend\BlocktrailConverter;
27 26
 use Blocktrail\SDK\Backend\BtccomConverter;
28 27
 use Blocktrail\SDK\Backend\ConverterInterface;
29 28
 use Blocktrail\SDK\Bitcoin\BIP32Key;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -13 removed lines patch added patch discarded remove patch
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
             } else {
646 646
                 // create new primary seed
647 647
                 /** @var HierarchicalKey $primaryPrivateKey */
648
-                list($primaryMnemonic, , $primaryPrivateKey) = $this->newPrimarySeed($options['passphrase']);
648
+                list($primaryMnemonic,, $primaryPrivateKey) = $this->newPrimarySeed($options['passphrase']);
649 649
                 if ($storePrimaryMnemonic !== false) {
650 650
                     $storePrimaryMnemonic = true;
651 651
                 }
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
         $backupPublicKey = null;
685 685
         if (!isset($options['backup_mnemonic']) && !isset($options['backup_public_key'])) {
686 686
             /** @var HierarchicalKey $backupPrivateKey */
687
-            list($backupMnemonic, , ) = $this->newBackupSeed();
687
+            list($backupMnemonic,,) = $this->newBackupSeed();
688 688
         } else if (isset($options['backup_mnemonic'])) {
689 689
             $backupMnemonic = $options['backup_mnemonic'];
690 690
         } elseif (isset($options['backup_public_key'])) {
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
         );
718 718
 
719 719
         // received the blocktrail public keys
720
-        $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) {
720
+        $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) {
721 721
             return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])];
722 722
         }, $data['blocktrail_public_keys']);
723 723
 
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
         );
840 840
 
841 841
         // received the blocktrail public keys
842
-        $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) {
842
+        $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) {
843 843
             return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])];
844 844
         }, $data['blocktrail_public_keys']);
845 845
 
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
                 'backup_seed' => $backupSeed ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer($backupSeed)) : null,
875 875
                 'recovery_encrypted_secret' => $recoveryEncryptedSecret ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer(base64_decode($recoveryEncryptedSecret))) : null,
876 876
                 'encrypted_secret' => $encryptedSecret ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer(base64_decode($encryptedSecret))) : null,
877
-                'blocktrail_public_keys' => Util::arrayMapWithIndex(function ($keyIndex, BIP32Key $pubKey) {
877
+                'blocktrail_public_keys' => Util::arrayMapWithIndex(function($keyIndex, BIP32Key $pubKey) {
878 878
                     return [$keyIndex, $pubKey->tuple()];
879 879
                 }, $blocktrailPublicKeys),
880 880
             ],
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
         );
982 982
 
983 983
         // received the blocktrail public keys
984
-        $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) {
984
+        $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) {
985 985
             return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])];
986 986
         }, $data['blocktrail_public_keys']);
987 987
 
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
                 'backup_seed'               => $backupSeed ? MnemonicFactory::bip39()->entropyToMnemonic($backupSeed) : null,
1017 1017
                 'recovery_encrypted_secret' => $recoveryEncryptedSecret ? EncryptionMnemonic::encode($recoveryEncryptedSecret) : null,
1018 1018
                 'encrypted_secret'          => $encryptedSecret ? EncryptionMnemonic::encode($encryptedSecret) : null,
1019
-                'blocktrail_public_keys'    => Util::arrayMapWithIndex(function ($keyIndex, BIP32Key $pubKey) {
1019
+                'blocktrail_public_keys'    => Util::arrayMapWithIndex(function($keyIndex, BIP32Key $pubKey) {
1020 1020
                     return [$keyIndex, $pubKey->tuple()];
1021 1021
                 }, $blocktrailPublicKeys),
1022 1022
             ]
@@ -1210,10 +1210,7 @@  discard block
 block discarded – undo
1210 1210
         }
1211 1211
 
1212 1212
         $identifier = $options['identifier'];
1213
-        $readonly = isset($options['readonly']) ? $options['readonly'] :
1214
-                    (isset($options['readOnly']) ? $options['readOnly'] :
1215
-                        (isset($options['read-only']) ? $options['read-only'] :
1216
-                            false));
1213
+        $readonly = isset($options['readonly']) ? $options['readonly'] : (isset($options['readOnly']) ? $options['readOnly'] : (isset($options['read-only']) ? $options['read-only'] : false));
1217 1214
 
1218 1215
         // get the wallet data from the server
1219 1216
         $data = $this->getWallet($identifier);
@@ -1912,7 +1909,7 @@  discard block
 block discarded – undo
1912 1909
      */
1913 1910
     public static function sortMultisigKeys(array $pubKeys) {
1914 1911
         $result = array_values($pubKeys);
1915
-        usort($result, function (PublicKeyInterface $a, PublicKeyInterface $b) {
1912
+        usort($result, function(PublicKeyInterface $a, PublicKeyInterface $b) {
1916 1913
             $av = $a->getHex();
1917 1914
             $bv = $b->getHex();
1918 1915
             return $av == $bv ? 0 : $av > $bv ? 1 : -1;
@@ -1938,7 +1935,7 @@  discard block
 block discarded – undo
1938 1935
     }
1939 1936
 
1940 1937
     public static function normalizeBIP32KeyArray($keys) {
1941
-        return Util::arrayMapWithIndex(function ($idx, $key) {
1938
+        return Util::arrayMapWithIndex(function($idx, $key) {
1942 1939
             return [$idx, self::normalizeBIP32Key($key)];
1943 1940
         }, $keys);
1944 1941
     }
Please login to merge, or discard this patch.
src/Connection/RestClient.php 1 patch
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@
 block discarded – undo
29 29
     /**
30 30
      * GuzzleRestClient constructor.
31 31
      * @param $apiEndpoint
32
-     * @param $apiVersion
33
-     * @param $apiKey
34
-     * @param $apiSecret
32
+     * @param string $apiVersion
33
+     * @param string $apiKey
34
+     * @param string $apiSecret
35 35
      */
36 36
     public function __construct($apiEndpoint, $apiVersion, $apiKey, $apiSecret) {
37 37
         parent::__construct($apiEndpoint, $apiVersion, $apiKey, $apiSecret);
Please login to merge, or discard this patch.
src/Backend/BtccomConverter.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     }
33 33
 
34 34
     public function getUrlForTransactions($txIds) {
35
-        return "tx/" . implode(",", $txIds) . "?verbose=3";
35
+        return "tx/".implode(",", $txIds)."?verbose=3";
36 36
     }
37 37
 
38 38
     public function getUrlForBlockTransaction($blockHash) {
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
         }
228 228
 
229 229
         $data['total_input_value'] = $totalInputValue;
230
-        $data['total_output_value'] = array_reduce($tx['outputs'], function ($total, $output) {
230
+        $data['total_output_value'] = array_reduce($tx['outputs'], function($total, $output) {
231 231
             return $total + $output['value'];
232 232
         }, 0);
233 233
         $data['total_fee'] = $tx['fee'];
Please login to merge, or discard this patch.
src/Backend/BlocktrailConverter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
     }
19 19
 
20 20
     public function getUrlForTransactions($txIds) {
21
-        return "transactions/" . implode(",", $txIds);
21
+        return "transactions/".implode(",", $txIds);
22 22
     }
23 23
 
24 24
     public function getUrlForBlockTransaction($blockHash) {
Please login to merge, or discard this patch.
src/Services/BlocktrailUnspentOutputFinder.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
     protected $retryLimit;
12 12
     protected $sleepTime;
13 13
     protected $retries;
14
-    protected $paginationLimit = 50;   //max results to retrieve at a time
14
+    protected $paginationLimit = 50; //max results to retrieve at a time
15 15
 
16 16
     /**
17 17
      * @param        $apiKey
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         $this->retries = 0;
90 90
 
91 91
         //reduce the returned data into the values we're interested in
92
-        $result = array_map(function ($utxo) {
92
+        $result = array_map(function($utxo) {
93 93
             return array(
94 94
                 'hash'       => $utxo['hash'],
95 95
                 'index'      => $utxo['index'],
Please login to merge, or discard this patch.