@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | if ($value <= Blocktrail::DUST) { |
| 105 | - throw new \Exception("Values should be more than dust (" . Blocktrail::DUST . ")"); |
|
| 105 | + throw new \Exception("Values should be more than dust (".Blocktrail::DUST.")"); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | $this->addOutput([ |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | if ($value <= Blocktrail::DUST) { |
| 153 | - throw new \Exception("Values should be more than dust (" . Blocktrail::DUST . ")"); |
|
| 153 | + throw new \Exception("Values should be more than dust (".Blocktrail::DUST.")"); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | if (!isset($this->outputs[$idx])) { |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * @return array |
| 197 | 197 | */ |
| 198 | 198 | public function getOutputs($json = false) { |
| 199 | - return array_map(function ($output) use ($json) { |
|
| 199 | + return array_map(function($output) use ($json) { |
|
| 200 | 200 | $result = $output; |
| 201 | 201 | |
| 202 | 202 | if ($json) { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * @param array $vectorSizes |
| 65 | - * @return int|mixed |
|
| 65 | + * @return integer |
|
| 66 | 66 | */ |
| 67 | 67 | public static function getLengthOfVector(array $vectorSizes) { |
| 68 | 68 | $vectorSize = self::getLengthOfVarInt(count($vectorSizes)); |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | - * @param array $stackSizes - array of integer size of a value (for scriptSig or witness) |
|
| 120 | + * @param integer[] $stackSizes - array of integer size of a value (for scriptSig or witness) |
|
| 121 | 121 | * @param bool $isWitness |
| 122 | 122 | * @param ScriptInterface $redeemScript |
| 123 | 123 | * @param ScriptInterface $witnessScript |
| 124 | - * @return array |
|
| 124 | + * @return integer[] |
|
| 125 | 125 | */ |
| 126 | 126 | public static function estimateSizeForStack(array $stackSizes, $isWitness, ScriptInterface $redeemScript = null, ScriptInterface $witnessScript = null) { |
| 127 | 127 | assert(($witnessScript === null) || $isWitness); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @param ScriptInterface|null $redeemScript |
| 169 | 169 | * @param ScriptInterface $witnessScript |
| 170 | 170 | * @param bool $isWitness |
| 171 | - * @return array |
|
| 171 | + * @return integer[] |
|
| 172 | 172 | */ |
| 173 | 173 | public static function estimateInputFromScripts(ScriptInterface $script, ScriptInterface $redeemScript = null, ScriptInterface $witnessScript = null, $isWitness) { |
| 174 | 174 | assert($witnessScript === null || $isWitness); |
@@ -22,7 +22,6 @@ |
||
| 22 | 22 | use BitWasp\Bitcoin\Transaction\TransactionInterface; |
| 23 | 23 | use BitWasp\Buffertools\Buffer; |
| 24 | 24 | use Blocktrail\SDK\Address\AddressReaderBase; |
| 25 | -use Blocktrail\SDK\Address\BitcoinCashAddressReader; |
|
| 26 | 25 | use Blocktrail\SDK\Address\CashAddress; |
| 27 | 26 | use Blocktrail\SDK\Bitcoin\BIP32Key; |
| 28 | 27 | use Blocktrail\SDK\Bitcoin\BIP32Path; |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | $this->addressReader = $addressReader; |
| 212 | - $this->isSegwit = (bool) $segwit; |
|
| 212 | + $this->isSegwit = (bool)$segwit; |
|
| 213 | 213 | $this->chainIndex = $chainIdx; |
| 214 | 214 | $this->changeIndex = $changeIdx; |
| 215 | 215 | } |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | * @return array[] [ [xpub, path] ] |
| 269 | 269 | */ |
| 270 | 270 | public function getBlocktrailPublicKeys() { |
| 271 | - return array_map(function (BIP32Key $key) { |
|
| 271 | + return array_map(function(BIP32Key $key) { |
|
| 272 | 272 | return $key->tuple(); |
| 273 | 273 | }, $this->blocktrailPublicKeys); |
| 274 | 274 | } |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | public function getAddressByPath($path) { |
| 418 | 418 | $path = (string)BIP32Path::path($path)->privatePath(); |
| 419 | 419 | if (!isset($this->derivations[$path])) { |
| 420 | - list($address, ) = $this->getRedeemScriptByPath($path); |
|
| 420 | + list($address,) = $this->getRedeemScriptByPath($path); |
|
| 421 | 421 | |
| 422 | 422 | $this->derivations[$path] = $address; |
| 423 | 423 | $this->derivationsByAddress[$address] = $path; |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | $signInfo[] = $utxo->getSignInfo(); |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | - $utxoSum = array_sum(array_map(function (UTXO $utxo) { |
|
| 764 | + $utxoSum = array_sum(array_map(function(UTXO $utxo) { |
|
| 765 | 765 | return $utxo->value; |
| 766 | 766 | }, $utxos)); |
| 767 | 767 | if ($utxoSum < array_sum(array_column($send, 'value'))) { |
@@ -895,7 +895,7 @@ discard block |
||
| 895 | 895 | throw new \Exception("Wallet needs to be unlocked to pay"); |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - assert(Util::all(function ($signInfo) { |
|
| 898 | + assert(Util::all(function($signInfo) { |
|
| 899 | 899 | return $signInfo instanceof SignInfo; |
| 900 | 900 | }, $signInfo), '$signInfo should be SignInfo[]'); |
| 901 | 901 | |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | ]; |
| 909 | 909 | |
| 910 | 910 | // send the transaction |
| 911 | - return $this->sendTransaction($txs, array_map(function (SignInfo $r) { |
|
| 911 | + return $this->sendTransaction($txs, array_map(function(SignInfo $r) { |
|
| 912 | 912 | return (string)$r->path; |
| 913 | 913 | }, $signInfo), $apiCheckFee); |
| 914 | 914 | } |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | public static function estimateSizeUTXOs($utxoCnt) { |
| 969 | 969 | $txinSize = 0; |
| 970 | 970 | |
| 971 | - for ($i=0; $i<$utxoCnt; $i++) { |
|
| 971 | + for ($i = 0; $i < $utxoCnt; $i++) { |
|
| 972 | 972 | // @TODO: proper size calculation, we only do multisig right now so it's hardcoded and then we guess the size ... |
| 973 | 973 | $multisig = "2of3"; |
| 974 | 974 | |
@@ -1046,7 +1046,7 @@ discard block |
||
| 1046 | 1046 | * @return int |
| 1047 | 1047 | */ |
| 1048 | 1048 | protected function determineChange($utxos, $outputs, $fee) { |
| 1049 | - $inputsTotal = array_sum(array_map(function (UTXO $utxo) { |
|
| 1049 | + $inputsTotal = array_sum(array_map(function(UTXO $utxo) { |
|
| 1050 | 1050 | return $utxo->value; |
| 1051 | 1051 | }, $utxos)); |
| 1052 | 1052 | $outputsTotal = array_sum(array_column($outputs, 'value')); |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | protected function signTransaction(Transaction $tx, array $signInfo) { |
| 1066 | 1066 | $signer = new Signer($tx, Bitcoin::getEcAdapter()); |
| 1067 | 1067 | |
| 1068 | - assert(Util::all(function ($signInfo) { |
|
| 1068 | + assert(Util::all(function($signInfo) { |
|
| 1069 | 1069 | return $signInfo instanceof SignInfo; |
| 1070 | 1070 | }, $signInfo), '$signInfo should be SignInfo[]'); |
| 1071 | 1071 | |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
| 387 | - * @param string|BIP32Path $path |
|
| 387 | + * @param BIP32Path $path |
|
| 388 | 388 | * @return BIP32Key|false |
| 389 | 389 | * @throws \Exception |
| 390 | 390 | * |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | /** |
| 412 | 412 | * get address for the specified path |
| 413 | 413 | * |
| 414 | - * @param string|BIP32Path $path |
|
| 414 | + * @param string $path |
|
| 415 | 415 | * @return string |
| 416 | 416 | */ |
| 417 | 417 | public function getAddressByPath($path) { |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
| 520 | - * @param string|BIP32Path $path |
|
| 520 | + * @param BIP32Path $path |
|
| 521 | 521 | * @return BIP32Key |
| 522 | 522 | * @throws \Exception |
| 523 | 523 | */ |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | * 'fund' the txBuilder with UTXOs (modified in place) |
| 678 | 678 | * |
| 679 | 679 | * @param TransactionBuilder $txBuilder |
| 680 | - * @param bool|true $lockUTXOs |
|
| 680 | + * @param boolean $lockUTXOs |
|
| 681 | 681 | * @param bool|false $allowZeroConf |
| 682 | 682 | * @param null|int $forceFee |
| 683 | 683 | * @return TransactionBuilder |
@@ -809,6 +809,10 @@ discard block |
||
| 809 | 809 | return [$txb->get(), $signInfo]; |
| 810 | 810 | } |
| 811 | 811 | |
| 812 | + /** |
|
| 813 | + * @param integer $optimalFeePerKB |
|
| 814 | + * @param integer $lowPriorityFeePerKB |
|
| 815 | + */ |
|
| 812 | 816 | public function determineFeeAndChange(TransactionBuilder $txBuilder, $highPriorityFeePerKB, $optimalFeePerKB, $lowPriorityFeePerKB) { |
| 813 | 817 | $send = (new OutputsNormalizer($this->addressReader))->normalize($txBuilder->getOutputs()); |
| 814 | 818 | $utxos = $txBuilder->getUtxos(); |
@@ -920,7 +924,7 @@ discard block |
||
| 920 | 924 | * @todo: mark this as deprecated, insist on the utxo's or qualified scripts. |
| 921 | 925 | * @param int $utxoCnt number of unspent inputs in transaction |
| 922 | 926 | * @param int $outputCnt number of outputs in transaction |
| 923 | - * @return float |
|
| 927 | + * @return integer |
|
| 924 | 928 | * @access public reminder that people might use this! |
| 925 | 929 | */ |
| 926 | 930 | public static function estimateFee($utxoCnt, $outputCnt) { |
@@ -944,7 +948,7 @@ discard block |
||
| 944 | 948 | * @todo: deprecate |
| 945 | 949 | * @param int $txinSize |
| 946 | 950 | * @param int $txoutSize |
| 947 | - * @return float |
|
| 951 | + * @return integer |
|
| 948 | 952 | */ |
| 949 | 953 | public static function estimateSize($txinSize, $txoutSize) { |
| 950 | 954 | return 4 + 4 + $txinSize + 4 + $txoutSize + 4; // version + txinVarInt + txin + txoutVarInt + txout + locktime |
@@ -954,7 +958,7 @@ discard block |
||
| 954 | 958 | * only supports estimating size for P2PKH/P2SH outputs |
| 955 | 959 | * |
| 956 | 960 | * @param int $outputCnt number of outputs in transaction |
| 957 | - * @return float |
|
| 961 | + * @return integer |
|
| 958 | 962 | */ |
| 959 | 963 | public static function estimateSizeOutputs($outputCnt) { |
| 960 | 964 | return ($outputCnt * 34); |
@@ -1009,7 +1013,7 @@ discard block |
||
| 1009 | 1013 | * |
| 1010 | 1014 | * @param UTXO[] $utxos |
| 1011 | 1015 | * @param array[] $outputs |
| 1012 | - * @param $feeStrategy |
|
| 1016 | + * @param string $feeStrategy |
|
| 1013 | 1017 | * @param $highPriorityFeePerKB |
| 1014 | 1018 | * @param $optimalFeePerKB |
| 1015 | 1019 | * @param $lowPriorityFeePerKB |
@@ -1113,8 +1117,8 @@ discard block |
||
| 1113 | 1117 | * @param \array[] $outputs |
| 1114 | 1118 | * @param bool $lockUTXO |
| 1115 | 1119 | * @param bool $allowZeroConf |
| 1116 | - * @param int|null|string $feeStrategy |
|
| 1117 | - * @param null $forceFee |
|
| 1120 | + * @param string $feeStrategy |
|
| 1121 | + * @param null|integer $forceFee |
|
| 1118 | 1122 | * @return array |
| 1119 | 1123 | */ |
| 1120 | 1124 | public function coinSelection($outputs, $lockUTXO = true, $allowZeroConf = false, $feeStrategy = self::FEE_STRATEGY_OPTIMAL, $forceFee = null) { |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | * @param bool $useNewCashAddress |
| 27 | 27 | */ |
| 28 | 28 | public function __construct($useNewCashAddress) { |
| 29 | - $this->useNewCashAddress = (bool) $useNewCashAddress; |
|
| 29 | + $this->useNewCashAddress = (bool)$useNewCashAddress; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $useNetwork = NetworkFactory::bitcoin(); |
| 101 | 101 | } |
| 102 | 102 | } else if ($network === "bitcoincash") { |
| 103 | - $useNetwork = new BitcoinCash((bool) $testnet); |
|
| 103 | + $useNetwork = new BitcoinCash((bool)$testnet); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | Bitcoin::setNetwork($useNetwork); |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | * @return array[] array containing the response |
| 315 | 315 | */ |
| 316 | 316 | public function transactions($txhashes) { |
| 317 | - $response = $this->client->get("transactions/" . implode(",", $txhashes)); |
|
| 317 | + $response = $this->client->get("transactions/".implode(",", $txhashes)); |
|
| 318 | 318 | return self::jsonDecode($response->body(), true); |
| 319 | 319 | } |
| 320 | 320 | |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | } else { |
| 582 | 582 | // create new primary seed |
| 583 | 583 | /** @var HierarchicalKey $primaryPrivateKey */ |
| 584 | - list($primaryMnemonic, , $primaryPrivateKey) = $this->newPrimarySeed($options['passphrase']); |
|
| 584 | + list($primaryMnemonic,, $primaryPrivateKey) = $this->newPrimarySeed($options['passphrase']); |
|
| 585 | 585 | if ($storePrimaryMnemonic !== false) { |
| 586 | 586 | $storePrimaryMnemonic = true; |
| 587 | 587 | } |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | $backupPublicKey = null; |
| 621 | 621 | if (!isset($options['backup_mnemonic']) && !isset($options['backup_public_key'])) { |
| 622 | 622 | /** @var HierarchicalKey $backupPrivateKey */ |
| 623 | - list($backupMnemonic, , ) = $this->newBackupSeed(); |
|
| 623 | + list($backupMnemonic,,) = $this->newBackupSeed(); |
|
| 624 | 624 | } else if (isset($options['backup_mnemonic'])) { |
| 625 | 625 | $backupMnemonic = $options['backup_mnemonic']; |
| 626 | 626 | } elseif (isset($options['backup_public_key'])) { |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | ); |
| 654 | 654 | |
| 655 | 655 | // received the blocktrail public keys |
| 656 | - $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) { |
|
| 656 | + $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) { |
|
| 657 | 657 | return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])]; |
| 658 | 658 | }, $data['blocktrail_public_keys']); |
| 659 | 659 | |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | ); |
| 776 | 776 | |
| 777 | 777 | // received the blocktrail public keys |
| 778 | - $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) { |
|
| 778 | + $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) { |
|
| 779 | 779 | return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])]; |
| 780 | 780 | }, $data['blocktrail_public_keys']); |
| 781 | 781 | |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | 'backup_seed' => $backupSeed ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer($backupSeed)) : null, |
| 811 | 811 | 'recovery_encrypted_secret' => $recoveryEncryptedSecret ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer(base64_decode($recoveryEncryptedSecret))) : null, |
| 812 | 812 | 'encrypted_secret' => $encryptedSecret ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer(base64_decode($encryptedSecret))) : null, |
| 813 | - 'blocktrail_public_keys' => Util::arrayMapWithIndex(function ($keyIndex, BIP32Key $pubKey) { |
|
| 813 | + 'blocktrail_public_keys' => Util::arrayMapWithIndex(function($keyIndex, BIP32Key $pubKey) { |
|
| 814 | 814 | return [$keyIndex, $pubKey->tuple()]; |
| 815 | 815 | }, $blocktrailPublicKeys), |
| 816 | 816 | ], |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | ); |
| 918 | 918 | |
| 919 | 919 | // received the blocktrail public keys |
| 920 | - $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) { |
|
| 920 | + $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) { |
|
| 921 | 921 | return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])]; |
| 922 | 922 | }, $data['blocktrail_public_keys']); |
| 923 | 923 | |
@@ -952,7 +952,7 @@ discard block |
||
| 952 | 952 | 'backup_seed' => $backupSeed ? MnemonicFactory::bip39()->entropyToMnemonic($backupSeed) : null, |
| 953 | 953 | 'recovery_encrypted_secret' => $recoveryEncryptedSecret ? EncryptionMnemonic::encode($recoveryEncryptedSecret) : null, |
| 954 | 954 | 'encrypted_secret' => $encryptedSecret ? EncryptionMnemonic::encode($encryptedSecret) : null, |
| 955 | - 'blocktrail_public_keys' => Util::arrayMapWithIndex(function ($keyIndex, BIP32Key $pubKey) { |
|
| 955 | + 'blocktrail_public_keys' => Util::arrayMapWithIndex(function($keyIndex, BIP32Key $pubKey) { |
|
| 956 | 956 | return [$keyIndex, $pubKey->tuple()]; |
| 957 | 957 | }, $blocktrailPublicKeys), |
| 958 | 958 | ] |
@@ -1146,10 +1146,7 @@ discard block |
||
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | 1148 | $identifier = $options['identifier']; |
| 1149 | - $readonly = isset($options['readonly']) ? $options['readonly'] : |
|
| 1150 | - (isset($options['readOnly']) ? $options['readOnly'] : |
|
| 1151 | - (isset($options['read-only']) ? $options['read-only'] : |
|
| 1152 | - false)); |
|
| 1149 | + $readonly = isset($options['readonly']) ? $options['readonly'] : (isset($options['readOnly']) ? $options['readOnly'] : (isset($options['read-only']) ? $options['read-only'] : false)); |
|
| 1153 | 1150 | |
| 1154 | 1151 | // get the wallet data from the server |
| 1155 | 1152 | $data = $this->getWallet($identifier); |
@@ -1837,7 +1834,7 @@ discard block |
||
| 1837 | 1834 | */ |
| 1838 | 1835 | public static function sortMultisigKeys(array $pubKeys) { |
| 1839 | 1836 | $result = array_values($pubKeys); |
| 1840 | - usort($result, function (PublicKeyInterface $a, PublicKeyInterface $b) { |
|
| 1837 | + usort($result, function(PublicKeyInterface $a, PublicKeyInterface $b) { |
|
| 1841 | 1838 | $av = $a->getHex(); |
| 1842 | 1839 | $bv = $b->getHex(); |
| 1843 | 1840 | return $av == $bv ? 0 : $av > $bv ? 1 : -1; |
@@ -1863,7 +1860,7 @@ discard block |
||
| 1863 | 1860 | } |
| 1864 | 1861 | |
| 1865 | 1862 | public static function normalizeBIP32KeyArray($keys) { |
| 1866 | - return Util::arrayMapWithIndex(function ($idx, $key) { |
|
| 1863 | + return Util::arrayMapWithIndex(function($idx, $key) { |
|
| 1867 | 1864 | return [$idx, self::normalizeBIP32Key($key)]; |
| 1868 | 1865 | }, $keys); |
| 1869 | 1866 | } |
@@ -53,6 +53,7 @@ |
||
| 53 | 53 | /** |
| 54 | 54 | * @param $address |
| 55 | 55 | * @param $value |
| 56 | + * @param NetworkInterface $network |
|
| 56 | 57 | * @return array |
| 57 | 58 | */ |
| 58 | 59 | private function parseAddressOutput($address, $value, $network) { |
@@ -123,7 +123,7 @@ |
||
| 123 | 123 | if (!$newOutput['value']) { |
| 124 | 124 | throw new BlocktrailSDKException("Values should be non zero"); |
| 125 | 125 | } else if ($newOutput['value'] < Blocktrail::DUST) { |
| 126 | - throw new BlocktrailSDKException("Values should be more than dust (" . Blocktrail::DUST . ")"); |
|
| 126 | + throw new BlocktrailSDKException("Values should be more than dust (".Blocktrail::DUST.")"); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | } |