@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | /** |
| 108 | 108 | * normalize network string |
| 109 | 109 | * |
| 110 | - * @param $network |
|
| 110 | + * @param string $network |
|
| 111 | 111 | * @param $testnet |
| 112 | 112 | * @return array |
| 113 | 113 | * @throws \Exception |
@@ -764,6 +764,11 @@ discard block |
||
| 764 | 764 | ]; |
| 765 | 765 | } |
| 766 | 766 | |
| 767 | + /** |
|
| 768 | + * @param integer $bits |
|
| 769 | + * |
|
| 770 | + * @return string |
|
| 771 | + */ |
|
| 767 | 772 | public function randomBits($bits) { |
| 768 | 773 | return $this->randomBytes($bits / 8); |
| 769 | 774 | } |
@@ -1092,7 +1097,7 @@ discard block |
||
| 1092 | 1097 | * create wallet using the API |
| 1093 | 1098 | * |
| 1094 | 1099 | * @param string $identifier the wallet identifier to create |
| 1095 | - * @param array $primaryPublicKey BIP32 extended public key - [key, path] |
|
| 1100 | + * @param string[] $primaryPublicKey BIP32 extended public key - [key, path] |
|
| 1096 | 1101 | * @param array $backupPublicKey BIP32 extended public key - [backup key, path "M"] |
| 1097 | 1102 | * @param string $primaryMnemonic mnemonic to store |
| 1098 | 1103 | * @param string $checksum checksum to store |
@@ -1120,10 +1125,10 @@ discard block |
||
| 1120 | 1125 | * |
| 1121 | 1126 | * @param string $identifier the wallet identifier to create |
| 1122 | 1127 | * @param array $primaryPublicKey BIP32 extended public key - [key, path] |
| 1123 | - * @param array $backupPublicKey BIP32 extended public key - [backup key, path "M"] |
|
| 1124 | - * @param $encryptedPrimarySeed |
|
| 1125 | - * @param $encryptedSecret |
|
| 1126 | - * @param $recoverySecret |
|
| 1128 | + * @param string[] $backupPublicKey BIP32 extended public key - [backup key, path "M"] |
|
| 1129 | + * @param string|false $encryptedPrimarySeed |
|
| 1130 | + * @param string|false $encryptedSecret |
|
| 1131 | + * @param string|false $recoverySecret |
|
| 1127 | 1132 | * @param string $checksum checksum to store |
| 1128 | 1133 | * @param int $keyIndex account that we expect to use |
| 1129 | 1134 | * @param bool $segwit opt in to segwit |
@@ -1153,9 +1158,9 @@ discard block |
||
| 1153 | 1158 | * |
| 1154 | 1159 | * @param string $identifier the wallet identifier to create |
| 1155 | 1160 | * @param array $primaryPublicKey BIP32 extended public key - [key, path] |
| 1156 | - * @param array $backupPublicKey BIP32 extended public key - [backup key, path "M"] |
|
| 1157 | - * @param $encryptedPrimarySeed |
|
| 1158 | - * @param $encryptedSecret |
|
| 1161 | + * @param string[] $backupPublicKey BIP32 extended public key - [backup key, path "M"] |
|
| 1162 | + * @param string|false $encryptedPrimarySeed |
|
| 1163 | + * @param string|false $encryptedSecret |
|
| 1159 | 1164 | * @param $recoverySecret |
| 1160 | 1165 | * @param string $checksum checksum to store |
| 1161 | 1166 | * @param int $keyIndex account that we expect to use |
@@ -1889,7 +1894,7 @@ discard block |
||
| 1889 | 1894 | * convert a Satoshi value to a BTC value |
| 1890 | 1895 | * |
| 1891 | 1896 | * @param int $satoshi |
| 1892 | - * @return float |
|
| 1897 | + * @return string |
|
| 1893 | 1898 | */ |
| 1894 | 1899 | public static function toBTC($satoshi) { |
| 1895 | 1900 | return bcdiv((int)(string)$satoshi, 100000000, 8); |
@@ -1919,7 +1924,7 @@ discard block |
||
| 1919 | 1924 | * convert a BTC value to a Satoshi value |
| 1920 | 1925 | * |
| 1921 | 1926 | * @param float $btc |
| 1922 | - * @return string |
|
| 1927 | + * @return integer |
|
| 1923 | 1928 | */ |
| 1924 | 1929 | public static function toSatoshi($btc) { |
| 1925 | 1930 | return (int)self::toSatoshiString($btc); |
@@ -1980,6 +1985,9 @@ discard block |
||
| 1980 | 1985 | } |
| 1981 | 1986 | } |
| 1982 | 1987 | |
| 1988 | + /** |
|
| 1989 | + * @param BIP32Key[] $keys |
|
| 1990 | + */ |
|
| 1983 | 1991 | public static function normalizeBIP32KeyArray($keys) { |
| 1984 | 1992 | return Util::arrayMapWithIndex(function ($idx, $key) { |
| 1985 | 1993 | return [$idx, self::normalizeBIP32Key($key)]; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $btccomEndpoint = getenv('BLOCKTRAIL_SDK_BTCCOM_API_ENDPOINT'); |
| 92 | 92 | if (!$btccomEndpoint) { |
| 93 | - $btccomEndpoint = "https://" . ($this->network === "bitcoincash" ? "bch-chain" : "chain") . ".api.btc.com"; |
|
| 93 | + $btccomEndpoint = "https://".($this->network === "bitcoincash" ? "bch-chain" : "chain").".api.btc.com"; |
|
| 94 | 94 | } |
| 95 | 95 | $btccomEndpoint = "{$btccomEndpoint}/v3/"; |
| 96 | 96 | |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | } else { |
| 669 | 669 | // create new primary seed |
| 670 | 670 | /** @var HierarchicalKey $primaryPrivateKey */ |
| 671 | - list($primaryMnemonic, , $primaryPrivateKey) = $this->newV1PrimarySeed($options['passphrase']); |
|
| 671 | + list($primaryMnemonic,, $primaryPrivateKey) = $this->newV1PrimarySeed($options['passphrase']); |
|
| 672 | 672 | if ($storePrimaryMnemonic !== false) { |
| 673 | 673 | $storePrimaryMnemonic = true; |
| 674 | 674 | } |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | $backupPublicKey = null; |
| 708 | 708 | if (!isset($options['backup_mnemonic']) && !isset($options['backup_public_key'])) { |
| 709 | 709 | /** @var HierarchicalKey $backupPrivateKey */ |
| 710 | - list($backupMnemonic, , ) = $this->newV1BackupSeed(); |
|
| 710 | + list($backupMnemonic,,) = $this->newV1BackupSeed(); |
|
| 711 | 711 | } else if (isset($options['backup_mnemonic'])) { |
| 712 | 712 | $backupMnemonic = $options['backup_mnemonic']; |
| 713 | 713 | } elseif (isset($options['backup_public_key'])) { |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | ); |
| 741 | 741 | |
| 742 | 742 | // received the blocktrail public keys |
| 743 | - $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) { |
|
| 743 | + $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) { |
|
| 744 | 744 | return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])]; |
| 745 | 745 | }, $data['blocktrail_public_keys']); |
| 746 | 746 | |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | ); |
| 860 | 860 | |
| 861 | 861 | // received the blocktrail public keys |
| 862 | - $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) { |
|
| 862 | + $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) { |
|
| 863 | 863 | return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])]; |
| 864 | 864 | }, $data['blocktrail_public_keys']); |
| 865 | 865 | |
@@ -894,7 +894,7 @@ discard block |
||
| 894 | 894 | 'backup_seed' => $backupSeed ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer($backupSeed)) : null, |
| 895 | 895 | 'recovery_encrypted_secret' => $recoveryEncryptedSecret ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer(base64_decode($recoveryEncryptedSecret))) : null, |
| 896 | 896 | 'encrypted_secret' => $encryptedSecret ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer(base64_decode($encryptedSecret))) : null, |
| 897 | - 'blocktrail_public_keys' => Util::arrayMapWithIndex(function ($keyIndex, BIP32Key $pubKey) { |
|
| 897 | + 'blocktrail_public_keys' => Util::arrayMapWithIndex(function($keyIndex, BIP32Key $pubKey) { |
|
| 898 | 898 | return [$keyIndex, $pubKey->tuple()]; |
| 899 | 899 | }, $blocktrailPublicKeys), |
| 900 | 900 | ], |
@@ -998,7 +998,7 @@ discard block |
||
| 998 | 998 | ); |
| 999 | 999 | |
| 1000 | 1000 | // received the blocktrail public keys |
| 1001 | - $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) { |
|
| 1001 | + $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) { |
|
| 1002 | 1002 | return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])]; |
| 1003 | 1003 | }, $data['blocktrail_public_keys']); |
| 1004 | 1004 | |
@@ -1033,7 +1033,7 @@ discard block |
||
| 1033 | 1033 | 'backup_seed' => $backupSeed ? MnemonicFactory::bip39()->entropyToMnemonic($backupSeed) : null, |
| 1034 | 1034 | 'recovery_encrypted_secret' => $recoveryEncryptedSecret ? EncryptionMnemonic::encode($recoveryEncryptedSecret) : null, |
| 1035 | 1035 | 'encrypted_secret' => $encryptedSecret ? EncryptionMnemonic::encode($encryptedSecret) : null, |
| 1036 | - 'blocktrail_public_keys' => Util::arrayMapWithIndex(function ($keyIndex, BIP32Key $pubKey) { |
|
| 1036 | + 'blocktrail_public_keys' => Util::arrayMapWithIndex(function($keyIndex, BIP32Key $pubKey) { |
|
| 1037 | 1037 | return [$keyIndex, $pubKey->tuple()]; |
| 1038 | 1038 | }, $blocktrailPublicKeys), |
| 1039 | 1039 | ] |
@@ -1282,10 +1282,7 @@ discard block |
||
| 1282 | 1282 | } |
| 1283 | 1283 | |
| 1284 | 1284 | $identifier = $options['identifier']; |
| 1285 | - $readonly = isset($options['readonly']) ? $options['readonly'] : |
|
| 1286 | - (isset($options['readOnly']) ? $options['readOnly'] : |
|
| 1287 | - (isset($options['read-only']) ? $options['read-only'] : |
|
| 1288 | - false)); |
|
| 1285 | + $readonly = isset($options['readonly']) ? $options['readonly'] : (isset($options['readOnly']) ? $options['readOnly'] : (isset($options['read-only']) ? $options['read-only'] : false)); |
|
| 1289 | 1286 | |
| 1290 | 1287 | // get the wallet data from the server |
| 1291 | 1288 | $data = $this->getWallet($identifier); |
@@ -1986,7 +1983,7 @@ discard block |
||
| 1986 | 1983 | */ |
| 1987 | 1984 | public static function sortMultisigKeys(array $pubKeys) { |
| 1988 | 1985 | $result = array_values($pubKeys); |
| 1989 | - usort($result, function (PublicKeyInterface $a, PublicKeyInterface $b) { |
|
| 1986 | + usort($result, function(PublicKeyInterface $a, PublicKeyInterface $b) { |
|
| 1990 | 1987 | $av = $a->getHex(); |
| 1991 | 1988 | $bv = $b->getHex(); |
| 1992 | 1989 | return $av == $bv ? 0 : $av > $bv ? 1 : -1; |
@@ -2012,7 +2009,7 @@ discard block |
||
| 2012 | 2009 | } |
| 2013 | 2010 | |
| 2014 | 2011 | public static function normalizeBIP32KeyArray($keys) { |
| 2015 | - return Util::arrayMapWithIndex(function ($idx, $key) { |
|
| 2012 | + return Util::arrayMapWithIndex(function($idx, $key) { |
|
| 2016 | 2013 | return [$idx, self::normalizeBIP32Key($key)]; |
| 2017 | 2014 | }, $keys); |
| 2018 | 2015 | } |
@@ -15,6 +15,7 @@ discard block |
||
| 15 | 15 | * @param bool $debug |
| 16 | 16 | * |
| 17 | 17 | * @codeCoverageIgnore |
| 18 | + * @return void |
|
| 18 | 19 | */ |
| 19 | 20 | public function setCurlDebugging($debug = true); |
| 20 | 21 | |
@@ -24,6 +25,7 @@ discard block |
||
| 24 | 25 | * @param bool $verboseErrors |
| 25 | 26 | * |
| 26 | 27 | * @codeCoverageIgnore |
| 28 | + * @return void |
|
| 27 | 29 | */ |
| 28 | 30 | public function setVerboseErrors($verboseErrors = true); |
| 29 | 31 | |
@@ -33,6 +35,7 @@ discard block |
||
| 33 | 35 | * @param bool $value |
| 34 | 36 | * |
| 35 | 37 | * @codeCoverageIgnore |
| 38 | + * @return void |
|
| 36 | 39 | */ |
| 37 | 40 | public function setCurlDefaultOption($key, $value); |
| 38 | 41 | |
@@ -328,7 +331,7 @@ discard block |
||
| 328 | 331 | * |
| 329 | 332 | * @param string $identifier the wallet identifier to be upgraded |
| 330 | 333 | * @param int $keyIndex the new account to use |
| 331 | - * @param array $primaryPublicKey BIP32 extended public key - [key, path] |
|
| 334 | + * @param string[] $primaryPublicKey BIP32 extended public key - [key, path] |
|
| 332 | 335 | * @return mixed |
| 333 | 336 | */ |
| 334 | 337 | public function upgradeKeyIndex($identifier, $keyIndex, $primaryPublicKey); |
@@ -423,7 +426,7 @@ discard block |
||
| 423 | 426 | * |
| 424 | 427 | * @param string $identifier the identifier of the wallet |
| 425 | 428 | * @param string|array $rawTransaction raw hex of the transaction (should be partially signed) |
| 426 | - * @param array $paths list of the paths that were used for the UTXO |
|
| 429 | + * @param string[] $paths list of the paths that were used for the UTXO |
|
| 427 | 430 | * @param bool $checkFee let the server verify the fee after signing |
| 428 | 431 | * @param null $twoFactorToken |
| 429 | 432 | * @return string the complete raw transaction |
@@ -495,22 +498,22 @@ discard block |
||
| 495 | 498 | /** |
| 496 | 499 | * lock a specific unspent output |
| 497 | 500 | * |
| 498 | - * @param $identifier |
|
| 501 | + * @param string $identifier |
|
| 499 | 502 | * @param $txHash |
| 500 | 503 | * @param $txIdx |
| 501 | 504 | * @param int $ttl |
| 502 | 505 | * @return |
| 503 | - */ |
|
| 506 | + boolean |
|
| 504 | 507 | public function lockWalletUTXO($identifier, $txHash, $txIdx, $ttl = 3); |
| 505 | 508 | |
| 506 | 509 | /** |
| 507 | 510 | * unlock a specific unspent output |
| 508 | 511 | * |
| 509 | - * @param $identifier |
|
| 512 | + * @param string $identifier |
|
| 510 | 513 | * @param $txHash |
| 511 | 514 | * @param $txIdx |
| 512 | 515 | * @return |
| 513 | - */ |
|
| 516 | + boolean |
|
| 514 | 517 | public function unlockWalletUTXO($identifier, $txHash, $txIdx); |
| 515 | 518 | |
| 516 | 519 | /** |
@@ -639,5 +642,8 @@ discard block |
||
| 639 | 642 | */ |
| 640 | 643 | public static function sortMultisigKeys(array $pubKeys); |
| 641 | 644 | |
| 645 | + /** |
|
| 646 | + * @return void |
|
| 647 | + */ |
|
| 642 | 648 | public function shuffle($arr); |
| 643 | 649 | } |
@@ -8,7 +8,6 @@ |
||
| 8 | 8 | use Blocktrail\SDK\Address\AddressReaderBase; |
| 9 | 9 | use Blocktrail\SDK\Bitcoin\BIP32Key; |
| 10 | 10 | use Blocktrail\SDK\Exceptions\BlocktrailSDKException; |
| 11 | -use Blocktrail\SDK\Exceptions\WalletDecryptException; |
|
| 12 | 11 | use Btccom\JustEncrypt\Encryption; |
| 13 | 12 | use Btccom\JustEncrypt\EncryptionMnemonic; |
| 14 | 13 | |