@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | $inputFile = $argv[1]; |
| 13 | -$percentage = min(100, max(0, (int) $argv[2])); |
|
| 13 | +$percentage = min(100, max(0, (int)$argv[2])); |
|
| 14 | 14 | |
| 15 | 15 | if (!file_exists($inputFile)) { |
| 16 | 16 | throw new InvalidArgumentException('Invalid input file provided'); |
@@ -26,10 +26,10 @@ discard block |
||
| 26 | 26 | $checkedElements = 0; |
| 27 | 27 | |
| 28 | 28 | $excludes = [ |
| 29 | - "/^Blocktrail\\\\SDK\\\\Console/", // just wrappers and a pain in the ass to test |
|
| 30 | - "/Compiler\\.php/", // just a tool and copy paste from Composer |
|
| 31 | - "/BackupGenerator\\.php/", // tmp excluding, it's rather hard to test the whole process |
|
| 32 | - "/WalletSweeper\\.php/", // because we're running it's test without coverage (because xdebug is REALLY slow) |
|
| 29 | + "/^Blocktrail\\\\SDK\\\\Console/", // just wrappers and a pain in the ass to test |
|
| 30 | + "/Compiler\\.php/", // just a tool and copy paste from Composer |
|
| 31 | + "/BackupGenerator\\.php/", // tmp excluding, it's rather hard to test the whole process |
|
| 32 | + "/WalletSweeper\\.php/", // because we're running it's test without coverage (because xdebug is REALLY slow) |
|
| 33 | 33 | ]; |
| 34 | 34 | |
| 35 | 35 | foreach ($xml->xpath("//package") as $package) { |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | foreach ($xml->xpath("//project/file/metrics") as $metric) { |
| 85 | - $totalElements += (int) $metric['elements']; |
|
| 86 | - $checkedElements += (int) $metric['coveredelements']; |
|
| 85 | + $totalElements += (int)$metric['elements']; |
|
| 86 | + $checkedElements += (int)$metric['coveredelements']; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | var_dump($totalElements); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | public function insert($insert, $offset) { |
| 25 | 25 | $path = $this->path; |
| 26 | 26 | |
| 27 | - array_splice($path, $offset+1, 0, [$insert]); |
|
| 27 | + array_splice($path, $offset + 1, 0, [$insert]); |
|
| 28 | 28 | |
| 29 | 29 | return new static($path); |
| 30 | 30 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * @return string |
| 206 | 206 | */ |
| 207 | 207 | public function getLast() { |
| 208 | - return $this->path[count($this->path)-1]; |
|
| 208 | + return $this->path[count($this->path) - 1]; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -1097,7 +1097,6 @@ |
||
| 1097 | 1097 | |
| 1098 | 1098 | /** |
| 1099 | 1099 | * convert a Satoshi value to a BTC value and return it as a string |
| 1100 | - |
|
| 1101 | 1100 | * @param int $satoshi |
| 1102 | 1101 | * @return string |
| 1103 | 1102 | */ |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | * @return array[] array containing the response |
| 324 | 324 | */ |
| 325 | 325 | public function transactions($txhashes) { |
| 326 | - $response = $this->client->get("transactions/" . implode(",", $txhashes)); |
|
| 326 | + $response = $this->client->get("transactions/".implode(",", $txhashes)); |
|
| 327 | 327 | return self::jsonDecode($response->body(), true); |
| 328 | 328 | } |
| 329 | 329 | |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | } else { |
| 591 | 591 | // create new primary seed |
| 592 | 592 | /** @var HierarchicalKey $primaryPrivateKey */ |
| 593 | - list($primaryMnemonic, , $primaryPrivateKey) = $this->newPrimarySeed($options['passphrase']); |
|
| 593 | + list($primaryMnemonic,, $primaryPrivateKey) = $this->newPrimarySeed($options['passphrase']); |
|
| 594 | 594 | if ($storePrimaryMnemonic !== false) { |
| 595 | 595 | $storePrimaryMnemonic = true; |
| 596 | 596 | } |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | $backupPublicKey = null; |
| 630 | 630 | if (!isset($options['backup_mnemonic']) && !isset($options['backup_public_key'])) { |
| 631 | 631 | /** @var HierarchicalKey $backupPrivateKey */ |
| 632 | - list($backupMnemonic, , ) = $this->newBackupSeed(); |
|
| 632 | + list($backupMnemonic,,) = $this->newBackupSeed(); |
|
| 633 | 633 | } else if (isset($options['backup_mnemonic'])) { |
| 634 | 634 | $backupMnemonic = $options['backup_mnemonic']; |
| 635 | 635 | } elseif (isset($options['backup_public_key'])) { |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | $data = $this->storeNewWalletV1($options['identifier'], $primaryPublicKey->tuple(), $backupPublicKey->tuple(), $primaryMnemonic, $checksum, $options['key_index']); |
| 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 | |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | ); |
| 772 | 772 | |
| 773 | 773 | // received the blocktrail public keys |
| 774 | - $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) { |
|
| 774 | + $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) { |
|
| 775 | 775 | return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])]; |
| 776 | 776 | }, $data['blocktrail_public_keys']); |
| 777 | 777 | |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | 'backup_seed' => $backupSeed ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer($backupSeed)) : null, |
| 805 | 805 | 'recovery_encrypted_secret' => $recoveryEncryptedSecret ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer(base64_decode($recoveryEncryptedSecret))) : null, |
| 806 | 806 | 'encrypted_secret' => $encryptedSecret ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer(base64_decode($encryptedSecret))) : null, |
| 807 | - 'blocktrail_public_keys' => Util::arrayMapWithIndex(function ($keyIndex, BIP32Key $pubKey) { |
|
| 807 | + 'blocktrail_public_keys' => Util::arrayMapWithIndex(function($keyIndex, BIP32Key $pubKey) { |
|
| 808 | 808 | return [$keyIndex, $pubKey->tuple()]; |
| 809 | 809 | }, $blocktrailPublicKeys), |
| 810 | 810 | ], |
@@ -909,7 +909,7 @@ discard block |
||
| 909 | 909 | ); |
| 910 | 910 | |
| 911 | 911 | // received the blocktrail public keys |
| 912 | - $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) { |
|
| 912 | + $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) { |
|
| 913 | 913 | return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])]; |
| 914 | 914 | }, $data['blocktrail_public_keys']); |
| 915 | 915 | |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | 'backup_seed' => $backupSeed ? MnemonicFactory::bip39()->entropyToMnemonic($backupSeed) : null, |
| 943 | 943 | 'recovery_encrypted_secret' => $recoveryEncryptedSecret ? EncryptionMnemonic::encode($recoveryEncryptedSecret) : null, |
| 944 | 944 | 'encrypted_secret' => $encryptedSecret ? EncryptionMnemonic::encode($encryptedSecret) : null, |
| 945 | - 'blocktrail_public_keys' => Util::arrayMapWithIndex(function ($keyIndex, BIP32Key $pubKey) { |
|
| 945 | + 'blocktrail_public_keys' => Util::arrayMapWithIndex(function($keyIndex, BIP32Key $pubKey) { |
|
| 946 | 946 | return [$keyIndex, $pubKey->tuple()]; |
| 947 | 947 | }, $blocktrailPublicKeys), |
| 948 | 948 | ] |
@@ -1104,10 +1104,7 @@ discard block |
||
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | 1106 | $identifier = $options['identifier']; |
| 1107 | - $readonly = isset($options['readonly']) ? $options['readonly'] : |
|
| 1108 | - (isset($options['readOnly']) ? $options['readOnly'] : |
|
| 1109 | - (isset($options['read-only']) ? $options['read-only'] : |
|
| 1110 | - false)); |
|
| 1107 | + $readonly = isset($options['readonly']) ? $options['readonly'] : (isset($options['readOnly']) ? $options['readOnly'] : (isset($options['read-only']) ? $options['read-only'] : false)); |
|
| 1111 | 1108 | |
| 1112 | 1109 | // get the wallet data from the server |
| 1113 | 1110 | $data = $this->getWallet($identifier); |
@@ -1752,7 +1749,7 @@ discard block |
||
| 1752 | 1749 | */ |
| 1753 | 1750 | public static function sortMultisigKeys(array $pubKeys) { |
| 1754 | 1751 | $result = array_values($pubKeys); |
| 1755 | - usort($result, function (PublicKeyInterface $a, PublicKeyInterface $b) { |
|
| 1752 | + usort($result, function(PublicKeyInterface $a, PublicKeyInterface $b) { |
|
| 1756 | 1753 | $av = $a->getHex(); |
| 1757 | 1754 | $bv = $b->getHex(); |
| 1758 | 1755 | return $av == $bv ? 0 : $av > $bv ? 1 : -1; |
@@ -1778,7 +1775,7 @@ discard block |
||
| 1778 | 1775 | } |
| 1779 | 1776 | |
| 1780 | 1777 | public static function normalizeBIP32KeyArray($keys) { |
| 1781 | - return Util::arrayMapWithIndex(function ($idx, $key) { |
|
| 1778 | + return Util::arrayMapWithIndex(function($idx, $key) { |
|
| 1782 | 1779 | return [$idx, self::normalizeBIP32Key($key)]; |
| 1783 | 1780 | }, $keys); |
| 1784 | 1781 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | /** |
| 75 | 75 | * normalize network string |
| 76 | 76 | * |
| 77 | - * @param $network |
|
| 77 | + * @param string $network |
|
| 78 | 78 | * @param $testnet |
| 79 | 79 | * @return array |
| 80 | 80 | * @throws \Exception |
@@ -662,6 +662,11 @@ discard block |
||
| 662 | 662 | ]; |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | + /** |
|
| 666 | + * @param integer $bits |
|
| 667 | + * |
|
| 668 | + * @return string |
|
| 669 | + */ |
|
| 665 | 670 | public static function randomBits($bits) { |
| 666 | 671 | return self::randomBytes($bits / 8); |
| 667 | 672 | } |
@@ -956,7 +961,7 @@ discard block |
||
| 956 | 961 | * create wallet using the API |
| 957 | 962 | * |
| 958 | 963 | * @param string $identifier the wallet identifier to create |
| 959 | - * @param array $primaryPublicKey BIP32 extended public key - [key, path] |
|
| 964 | + * @param string[] $primaryPublicKey BIP32 extended public key - [key, path] |
|
| 960 | 965 | * @param string $backupPublicKey plain public key |
| 961 | 966 | * @param string $primaryMnemonic mnemonic to store |
| 962 | 967 | * @param string $checksum checksum to store |
@@ -983,9 +988,9 @@ discard block |
||
| 983 | 988 | * @param string $identifier the wallet identifier to create |
| 984 | 989 | * @param array $primaryPublicKey BIP32 extended public key - [key, path] |
| 985 | 990 | * @param string $backupPublicKey plain public key |
| 986 | - * @param $encryptedPrimarySeed |
|
| 987 | - * @param $encryptedSecret |
|
| 988 | - * @param $recoverySecret |
|
| 991 | + * @param string|false $encryptedPrimarySeed |
|
| 992 | + * @param string|false $encryptedSecret |
|
| 993 | + * @param string|false $recoverySecret |
|
| 989 | 994 | * @param string $checksum checksum to store |
| 990 | 995 | * @param int $keyIndex account that we expect to use |
| 991 | 996 | * @return mixed |
@@ -1014,8 +1019,8 @@ discard block |
||
| 1014 | 1019 | * @param string $identifier the wallet identifier to create |
| 1015 | 1020 | * @param array $primaryPublicKey BIP32 extended public key - [key, path] |
| 1016 | 1021 | * @param string $backupPublicKey plain public key |
| 1017 | - * @param $encryptedPrimarySeed |
|
| 1018 | - * @param $encryptedSecret |
|
| 1022 | + * @param string|false $encryptedPrimarySeed |
|
| 1023 | + * @param string|false $encryptedSecret |
|
| 1019 | 1024 | * @param $recoverySecret |
| 1020 | 1025 | * @param string $checksum checksum to store |
| 1021 | 1026 | * @param int $keyIndex account that we expect to use |
@@ -1681,7 +1686,7 @@ discard block |
||
| 1681 | 1686 | * convert a Satoshi value to a BTC value |
| 1682 | 1687 | * |
| 1683 | 1688 | * @param int $satoshi |
| 1684 | - * @return float |
|
| 1689 | + * @return string |
|
| 1685 | 1690 | */ |
| 1686 | 1691 | public static function toBTC($satoshi) { |
| 1687 | 1692 | return bcdiv((int)(string)$satoshi, 100000000, 8); |
@@ -1711,7 +1716,7 @@ discard block |
||
| 1711 | 1716 | * convert a BTC value to a Satoshi value |
| 1712 | 1717 | * |
| 1713 | 1718 | * @param float $btc |
| 1714 | - * @return string |
|
| 1719 | + * @return integer |
|
| 1715 | 1720 | */ |
| 1716 | 1721 | public static function toSatoshi($btc) { |
| 1717 | 1722 | return (int)self::toSatoshiString($btc); |
@@ -1720,7 +1725,7 @@ discard block |
||
| 1720 | 1725 | /** |
| 1721 | 1726 | * json_decode helper that throws exceptions when it fails to decode |
| 1722 | 1727 | * |
| 1723 | - * @param $json |
|
| 1728 | + * @param string $json |
|
| 1724 | 1729 | * @param bool $assoc |
| 1725 | 1730 | * @return mixed |
| 1726 | 1731 | * @throws \Exception |
@@ -1772,6 +1777,9 @@ discard block |
||
| 1772 | 1777 | } |
| 1773 | 1778 | } |
| 1774 | 1779 | |
| 1780 | + /** |
|
| 1781 | + * @param BIP32Key[] $keys |
|
| 1782 | + */ |
|
| 1775 | 1783 | public static function normalizeBIP32KeyArray($keys) { |
| 1776 | 1784 | return Util::arrayMapWithIndex(function ($idx, $key) { |
| 1777 | 1785 | return [$idx, self::normalizeBIP32Key($key)]; |
@@ -55,7 +55,6 @@ |
||
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * BIP32 master backup public key (M/) |
| 58 | - |
|
| 59 | 58 | * @var BIP32Key |
| 60 | 59 | */ |
| 61 | 60 | protected $backupPublicKey; |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
| 262 | - * @param string|BIP32Path $path |
|
| 262 | + * @param BIP32Path $path |
|
| 263 | 263 | * @return BIP32Key|false |
| 264 | 264 | * @throws \Exception |
| 265 | 265 | * |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | /** |
| 287 | 287 | * get address for the specified path |
| 288 | 288 | * |
| 289 | - * @param string|BIP32Path $path |
|
| 289 | + * @param string $path |
|
| 290 | 290 | * @return string |
| 291 | 291 | */ |
| 292 | 292 | public function getAddressByPath($path) { |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
| 363 | - * @param string|BIP32Path $path |
|
| 363 | + * @param BIP32Path $path |
|
| 364 | 364 | * @return BIP32Key |
| 365 | 365 | * @throws \Exception |
| 366 | 366 | */ |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | * 'fund' the txBuilder with UTXOs (modified in place) |
| 509 | 509 | * |
| 510 | 510 | * @param TransactionBuilder $txBuilder |
| 511 | - * @param bool|true $lockUTXOs |
|
| 511 | + * @param boolean $lockUTXOs |
|
| 512 | 512 | * @param bool|false $allowZeroConf |
| 513 | 513 | * @param null|int $forceFee |
| 514 | 514 | * @return TransactionBuilder |
@@ -629,6 +629,10 @@ discard block |
||
| 629 | 629 | return [$txb->get(), $signInfo]; |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | + /** |
|
| 633 | + * @param integer $optimalFeePerKB |
|
| 634 | + * @param integer $lowPriorityFeePerKB |
|
| 635 | + */ |
|
| 632 | 636 | public function determineFeeAndChange(TransactionBuilder $txBuilder, $optimalFeePerKB, $lowPriorityFeePerKB) { |
| 633 | 637 | $send = $txBuilder->getOutputs(); |
| 634 | 638 | $utxos = $txBuilder->getUtxos(); |
@@ -736,7 +740,7 @@ discard block |
||
| 736 | 740 | * |
| 737 | 741 | * @param int $utxoCnt number of unspent inputs in transaction |
| 738 | 742 | * @param int $outputCnt number of outputs in transaction |
| 739 | - * @return float |
|
| 743 | + * @return integer |
|
| 740 | 744 | * @access public reminder that people might use this! |
| 741 | 745 | */ |
| 742 | 746 | public static function estimateFee($utxoCnt, $outputCnt) { |
@@ -758,7 +762,7 @@ discard block |
||
| 758 | 762 | /** |
| 759 | 763 | * @param int $txinSize |
| 760 | 764 | * @param int $txoutSize |
| 761 | - * @return float |
|
| 765 | + * @return integer |
|
| 762 | 766 | */ |
| 763 | 767 | public static function estimateSize($txinSize, $txoutSize) { |
| 764 | 768 | return 4 + 4 + $txinSize + 4 + $txoutSize + 4; // version + txinVarInt + txin + txoutVarInt + txout + locktime |
@@ -768,7 +772,7 @@ discard block |
||
| 768 | 772 | * only supports estimating size for P2PKH/P2SH outputs |
| 769 | 773 | * |
| 770 | 774 | * @param int $outputCnt number of outputs in transaction |
| 771 | - * @return float |
|
| 775 | + * @return integer |
|
| 772 | 776 | */ |
| 773 | 777 | public static function estimateSizeOutputs($outputCnt) { |
| 774 | 778 | return ($outputCnt * 34); |
@@ -822,7 +826,7 @@ discard block |
||
| 822 | 826 | * |
| 823 | 827 | * @param UTXO[] $utxos |
| 824 | 828 | * @param array[] $outputs |
| 825 | - * @param $feeStrategy |
|
| 829 | + * @param string $feeStrategy |
|
| 826 | 830 | * @param $optimalFeePerKB |
| 827 | 831 | * @param $lowPriorityFeePerKB |
| 828 | 832 | * @return int |
@@ -921,8 +925,8 @@ discard block |
||
| 921 | 925 | * @param \array[] $outputs |
| 922 | 926 | * @param bool $lockUTXO |
| 923 | 927 | * @param bool $allowZeroConf |
| 924 | - * @param int|null|string $feeStrategy |
|
| 925 | - * @param null $forceFee |
|
| 928 | + * @param string $feeStrategy |
|
| 929 | + * @param null|integer $forceFee |
|
| 926 | 930 | * @return array |
| 927 | 931 | */ |
| 928 | 932 | public function coinSelection($outputs, $lockUTXO = true, $allowZeroConf = false, $feeStrategy = self::FEE_STRATEGY_OPTIMAL, $forceFee = null) { |
@@ -16,7 +16,6 @@ |
||
| 16 | 16 | use BitWasp\Bitcoin\Transaction\SignatureHash\SigHash; |
| 17 | 17 | use BitWasp\Bitcoin\Transaction\Transaction; |
| 18 | 18 | use BitWasp\Bitcoin\Transaction\TransactionInterface; |
| 19 | -use BitWasp\Bitcoin\Transaction\TransactionOutput; |
|
| 20 | 19 | use BitWasp\Buffertools\Buffer; |
| 21 | 20 | use Blocktrail\SDK\Bitcoin\BIP32Key; |
| 22 | 21 | use Blocktrail\SDK\Bitcoin\BIP32Path; |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * @return array[] [ [xpub, path] ] |
| 177 | 177 | */ |
| 178 | 178 | public function getBlocktrailPublicKeys() { |
| 179 | - return array_map(function (BIP32Key $key) { |
|
| 179 | + return array_map(function(BIP32Key $key) { |
|
| 180 | 180 | return $key->tuple(); |
| 181 | 181 | }, $this->blocktrailPublicKeys); |
| 182 | 182 | } |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | public function getAddressByPath($path) { |
| 296 | 296 | $path = (string)BIP32Path::path($path)->privatePath(); |
| 297 | 297 | if (!isset($this->derivations[$path])) { |
| 298 | - list($address, ) = $this->getRedeemScriptByPath($path); |
|
| 298 | + list($address,) = $this->getRedeemScriptByPath($path); |
|
| 299 | 299 | |
| 300 | 300 | $this->derivations[$path] = $address; |
| 301 | 301 | $this->derivationsByAddress[$address] = $path; |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | $signInfo[] = $utxo->getSignInfo(); |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | - $utxoSum = array_sum(array_map(function (UTXO $utxo) { |
|
| 598 | + $utxoSum = array_sum(array_map(function(UTXO $utxo) { |
|
| 599 | 599 | return $utxo->value; |
| 600 | 600 | }, $utxos)); |
| 601 | 601 | if ($utxoSum < array_sum(array_column($send, 'value'))) { |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | throw new \Exception("Wallet needs to be unlocked to pay"); |
| 729 | 729 | } |
| 730 | 730 | |
| 731 | - assert(Util::all(function ($signInfo) { |
|
| 731 | + assert(Util::all(function($signInfo) { |
|
| 732 | 732 | return $signInfo instanceof SignInfo; |
| 733 | 733 | }, $signInfo), '$signInfo should be SignInfo[]'); |
| 734 | 734 | |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | $signed = $this->signTransaction($tx, $signInfo); |
| 737 | 737 | |
| 738 | 738 | // send the transaction |
| 739 | - return $this->sendTransaction($signed->getHex(), array_map(function (SignInfo $r) { |
|
| 739 | + return $this->sendTransaction($signed->getHex(), array_map(function(SignInfo $r) { |
|
| 740 | 740 | return $r->path; |
| 741 | 741 | }, $signInfo), $apiCheckFee); |
| 742 | 742 | } |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | public static function estimateSizeUTXOs($utxoCnt) { |
| 794 | 794 | $txinSize = 0; |
| 795 | 795 | |
| 796 | - for ($i=0; $i<$utxoCnt; $i++) { |
|
| 796 | + for ($i = 0; $i < $utxoCnt; $i++) { |
|
| 797 | 797 | // @TODO: proper size calculation, we only do multisig right now so it's hardcoded and then we guess the size ... |
| 798 | 798 | $multisig = "2of3"; |
| 799 | 799 | |
@@ -879,7 +879,7 @@ discard block |
||
| 879 | 879 | * @return int |
| 880 | 880 | */ |
| 881 | 881 | protected function determineChange($utxos, $outputs, $fee) { |
| 882 | - $inputsTotal = array_sum(array_map(function (UTXO $utxo) { |
|
| 882 | + $inputsTotal = array_sum(array_map(function(UTXO $utxo) { |
|
| 883 | 883 | return $utxo->value; |
| 884 | 884 | }, $utxos)); |
| 885 | 885 | $outputsTotal = array_sum(array_column($outputs, 'value')); |
@@ -898,7 +898,7 @@ discard block |
||
| 898 | 898 | protected function signTransaction(Transaction $tx, array $signInfo) { |
| 899 | 899 | $signer = new Signer($tx, Bitcoin::getEcAdapter()); |
| 900 | 900 | |
| 901 | - assert(Util::all(function ($signInfo) { |
|
| 901 | + assert(Util::all(function($signInfo) { |
|
| 902 | 902 | return $signInfo instanceof SignInfo; |
| 903 | 903 | }, $signInfo), '$signInfo should be SignInfo[]'); |
| 904 | 904 | |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | protected static function BIP32Path(array $path) { |
| 34 | - return BIP32Path::path(array_values(array_filter($path, function ($v) { |
|
| 34 | + return BIP32Path::path(array_values(array_filter($path, function($v) { |
|
| 35 | 35 | return $v !== null; |
| 36 | 36 | }))); |
| 37 | 37 | } |
@@ -68,6 +68,11 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | protected $verboseErrors = false; |
| 70 | 70 | |
| 71 | + /** |
|
| 72 | + * @param string $apiVersion |
|
| 73 | + * @param string $apiKey |
|
| 74 | + * @param string $apiSecret |
|
| 75 | + */ |
|
| 71 | 76 | public function __construct($apiEndpoint, $apiVersion, $apiKey, $apiSecret) { |
| 72 | 77 | $this->apiEndpoint = $apiEndpoint; |
| 73 | 78 | $this->apiVersion = $apiVersion; |
@@ -210,6 +215,10 @@ discard block |
||
| 210 | 215 | } |
| 211 | 216 | |
| 212 | 217 | private static $replaceQuery = ['=' => '%3D', '&' => '%26']; |
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * @param string $key |
|
| 221 | + */ |
|
| 213 | 222 | public static function hasQueryValue(Uri $uri, $key) { |
| 214 | 223 | $current = $uri->getQuery(); |
| 215 | 224 | $key = strtr($key, self::$replaceQuery); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | 'handler' => $handler, |
| 102 | 102 | 'base_uri' => $this->apiEndpoint, |
| 103 | 103 | 'headers' => array( |
| 104 | - 'User-Agent' => Blocktrail::SDK_USER_AGENT . '/' . Blocktrail::SDK_VERSION |
|
| 104 | + 'User-Agent' => Blocktrail::SDK_USER_AGENT.'/'.Blocktrail::SDK_VERSION |
|
| 105 | 105 | ), |
| 106 | 106 | 'http_errors' => false, |
| 107 | 107 | 'connect_timeout' => 3, |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | $contentMD5Mode = !is_null($body) ? 'body' : 'url'; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - $request = new Request($method, $this->apiEndpoint . $endpointUrl); |
|
| 249 | + $request = new Request($method, $this->apiEndpoint.$endpointUrl); |
|
| 250 | 250 | $uri = $request->getUri(); |
| 251 | 251 | |
| 252 | 252 | if ($queryString) { |
@@ -341,9 +341,9 @@ discard block |
||
| 341 | 341 | throw new ObjectNotFound($this->verboseErrors ? $body : Blocktrail::EXCEPTION_OBJECT_NOT_FOUND, $httpResponseCode); |
| 342 | 342 | } |
| 343 | 343 | } elseif ($httpResponseCode == 500) { |
| 344 | - throw new GenericServerError(Blocktrail::EXCEPTION_GENERIC_SERVER_ERROR . "\nServer Response: " . $body, $httpResponseCode); |
|
| 344 | + throw new GenericServerError(Blocktrail::EXCEPTION_GENERIC_SERVER_ERROR."\nServer Response: ".$body, $httpResponseCode); |
|
| 345 | 345 | } else { |
| 346 | - throw new GenericHTTPError(Blocktrail::EXCEPTION_GENERIC_HTTP_ERROR . "\nServer Response: " . $body, $httpResponseCode); |
|
| 346 | + throw new GenericHTTPError(Blocktrail::EXCEPTION_GENERIC_HTTP_ERROR."\nServer Response: ".$body, $httpResponseCode); |
|
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | |
@@ -185,6 +185,9 @@ |
||
| 185 | 185 | return $extraInfo; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | + /** |
|
| 189 | + * @param string $file |
|
| 190 | + */ |
|
| 188 | 191 | public static function renderTemplate($file, $vars) { |
| 189 | 192 | if (is_array($vars) && !empty($vars)) { |
| 190 | 193 | extract($vars); |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | define('DOMPDF_ENABLE_AUTOLOAD', false); |
| 55 | 55 | |
| 56 | 56 | //try the different possible locations for the config file, depending on if the sdk is included as a dependency or is the main project itself |
| 57 | - (@include_once __DIR__ . '/../../../dompdf/dompdf/dompdf_config.inc.php') || @include_once __DIR__ . '/../vendor/dompdf/dompdf/dompdf_config.inc.php'; |
|
| 57 | + (@include_once __DIR__.'/../../../dompdf/dompdf/dompdf_config.inc.php') || @include_once __DIR__.'/../vendor/dompdf/dompdf/dompdf_config.inc.php'; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | //set the fonts path |
| 61 | - $this->fontsPath = dirname(__FILE__) . '/../resources/fonts'; |
|
| 61 | + $this->fontsPath = dirname(__FILE__).'/../resources/fonts'; |
|
| 62 | 62 | |
| 63 | 63 | $this->identifier = $identifier; |
| 64 | 64 | $this->backupInfo = $backupInfo; |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $qrCode = new QrCode(); |
| 81 | 81 | $qrCode |
| 82 | 82 | ->setText($key->key()) |
| 83 | - ->setSize(self::QR_CODE_SIZE-20) |
|
| 83 | + ->setSize(self::QR_CODE_SIZE - 20) |
|
| 84 | 84 | ->setPadding(10) |
| 85 | 85 | ->setErrorCorrection('high') |
| 86 | 86 | ->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0)) |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $passwordEncryptedSecret = $this->backupInfo['encrypted_secret']; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $html = self::renderTemplate(__DIR__ . "/../resources/templates/recovery_sheet.html.php", [ |
|
| 124 | + $html = self::renderTemplate(__DIR__."/../resources/templates/recovery_sheet.html.php", [ |
|
| 125 | 125 | 'identifier' => $this->identifier, |
| 126 | 126 | 'totalPubKeys' => $totalPubKeys, |
| 127 | 127 | 'pubKeysHtml' => $pubKeysHtml, |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Blocktrail\SDK\Bitcoin; |
| 4 | 4 | |
| 5 | -use BitWasp\Bitcoin\Crypto\EcAdapter\Impl\PhpEcc\Key\PublicKey; |
|
| 6 | 5 | use BitWasp\Bitcoin\Crypto\EcAdapter\Key\PublicKeyInterface; |
| 7 | 6 | use BitWasp\Bitcoin\Key\Deterministic\HierarchicalKey; |
| 8 | 7 | |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | /** |
| 116 | 116 | * normalize network string |
| 117 | 117 | * |
| 118 | - * @param $network |
|
| 119 | - * @param $testnet |
|
| 118 | + * @param string $network |
|
| 119 | + * @param boolean $testnet |
|
| 120 | 120 | * @return array |
| 121 | 121 | * @throws \Exception |
| 122 | 122 | */ |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | /** |
| 147 | 147 | * generate multisig address for given path |
| 148 | 148 | * |
| 149 | - * @param string|BIP32Path $path |
|
| 149 | + * @param string $path |
|
| 150 | 150 | * @return array[string, ScriptInterface] [address, redeemScript] |
| 151 | 151 | * @throws \Exception |
| 152 | 152 | */ |
@@ -165,8 +165,8 @@ discard block |
||
| 165 | 165 | /** |
| 166 | 166 | * create a batch of multisig addresses |
| 167 | 167 | * |
| 168 | - * @param $start |
|
| 169 | - * @param $count |
|
| 168 | + * @param integer $start |
|
| 169 | + * @param integer $count |
|
| 170 | 170 | * @param $keyIndex |
| 171 | 171 | * @return array |
| 172 | 172 | */ |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | /** |
| 196 | 196 | * gets the blocktrail pub key for the given path from the stored array of pub keys |
| 197 | 197 | * |
| 198 | - * @param string|BIP32Path $path |
|
| 198 | + * @param BIP32Path $path |
|
| 199 | 199 | * @return BIP32Key |
| 200 | 200 | * @throws \Exception |
| 201 | 201 | */ |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | /** |
| 315 | - * @param $destinationAddress |
|
| 315 | + * @param string $destinationAddress |
|
| 316 | 316 | * @return TransactionInterface |
| 317 | 317 | */ |
| 318 | 318 | protected function createTransaction($destinationAddress) { |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | for ($i = 0; $i < $count; $i++) { |
| 180 | 180 | //create a path subsequent address |
| 181 | - $path = (string)WalletPath::create($keyIndex, $_chain = 0, $start+$i)->path()->publicPath(); |
|
| 181 | + $path = (string)WalletPath::create($keyIndex, $_chain = 0, $start + $i)->path()->publicPath(); |
|
| 182 | 182 | list($address, $redeem) = $this->createAddress($path); |
| 183 | 183 | $addresses[$address] = array( |
| 184 | 184 | //'address' => $address, |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $totalUTXOs = 0; |
| 227 | 227 | $totalAddressesGenerated = 0; |
| 228 | 228 | |
| 229 | - $addressUTXOs = array(); //addresses and their utxos, paths and redeem scripts |
|
| 229 | + $addressUTXOs = array(); //addresses and their utxos, paths and redeem scripts |
|
| 230 | 230 | |
| 231 | 231 | //for each blocktrail pub key, do fund discovery on batches of addresses |
| 232 | 232 | foreach ($this->blocktrailPublicKeys as $keyIndex => $blocktrailPubKey) { |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | $addressUTXOs[$address]['utxos'][] = $utxo; |
| 264 | - $totalUTXOs ++; |
|
| 264 | + $totalUTXOs++; |
|
| 265 | 265 | |
| 266 | 266 | //add up the total utxo value for all addresses |
| 267 | 267 | $totalBalance += $utxo['value']; |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | $signer->redeemBitcoinCash(true); |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - assert(Util::all(function ($signInfo) { |
|
| 378 | + assert(Util::all(function($signInfo) { |
|
| 379 | 379 | return $signInfo instanceof SignInfo; |
| 380 | 380 | }, $signInfo), '$signInfo should be SignInfo[]'); |
| 381 | 381 | |