@@ -1,6 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -use BitWasp\BitcoinLib\RawTransaction; |
|
| 4 | 3 | use Blocktrail\SDK\Blocktrail; |
| 5 | 4 | use Blocktrail\SDK\BlocktrailSDK; |
| 6 | 5 | use Blocktrail\SDK\Connection\Exceptions\ObjectNotFound; |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | use Blocktrail\SDK\BlocktrailSDK; |
| 4 | 4 | |
| 5 | -require_once __DIR__ . "/../vendor/autoload.php"; |
|
| 5 | +require_once __DIR__."/../vendor/autoload.php"; |
|
| 6 | 6 | |
| 7 | 7 | /* |
| 8 | 8 | This simple example shows how to get the payload when your webhook is called. |
@@ -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 | /** |
@@ -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) { |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * @return array[] [ [xpub, path] ] |
| 174 | 174 | */ |
| 175 | 175 | public function getBlocktrailPublicKeys() { |
| 176 | - return array_map(function (BIP32Key $key) { |
|
| 176 | + return array_map(function(BIP32Key $key) { |
|
| 177 | 177 | return $key->tuple(); |
| 178 | 178 | }, $this->blocktrailPublicKeys); |
| 179 | 179 | } |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | public function getAddressByPath($path) { |
| 293 | 293 | $path = (string)BIP32Path::path($path)->privatePath(); |
| 294 | 294 | if (!isset($this->derivations[$path])) { |
| 295 | - list($address, ) = $this->getRedeemScriptByPath($path); |
|
| 295 | + list($address,) = $this->getRedeemScriptByPath($path); |
|
| 296 | 296 | |
| 297 | 297 | $this->derivations[$path] = $address; |
| 298 | 298 | $this->derivationsByAddress[$address] = $path; |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | if (array_sum(array_map( |
| 587 | - function (UTXO $utxo) { return $utxo->value; }, |
|
| 587 | + function(UTXO $utxo) { return $utxo->value; }, |
|
| 588 | 588 | $utxos |
| 589 | 589 | )) < array_sum(array_column($send, 'value'))) { |
| 590 | 590 | throw new \Exception("Atempting to spend more than sum of UTXOs"); |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | throw new \Exception("Wallet needs to be unlocked to pay"); |
| 717 | 717 | } |
| 718 | 718 | |
| 719 | - assert(Util::all(function ($signInfo) { |
|
| 719 | + assert(Util::all(function($signInfo) { |
|
| 720 | 720 | return $signInfo instanceof SignInfo; |
| 721 | 721 | }, $signInfo), '$signInfo should be SignInfo[]'); |
| 722 | 722 | |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | $signed = $this->signTransaction($tx, $signInfo); |
| 725 | 725 | |
| 726 | 726 | // send the transaction |
| 727 | - $finished = $this->sendTransaction($signed->getHex(), array_map(function (SignInfo $r) { |
|
| 727 | + $finished = $this->sendTransaction($signed->getHex(), array_map(function(SignInfo $r) { |
|
| 728 | 728 | return $r->path; |
| 729 | 729 | }, $signInfo), $apiCheckFee); |
| 730 | 730 | |
@@ -783,7 +783,7 @@ discard block |
||
| 783 | 783 | public static function estimateSizeUTXOs($utxoCnt) { |
| 784 | 784 | $txinSize = 0; |
| 785 | 785 | |
| 786 | - for ($i=0; $i<$utxoCnt; $i++) { |
|
| 786 | + for ($i = 0; $i < $utxoCnt; $i++) { |
|
| 787 | 787 | // @TODO: proper size calculation, we only do multisig right now so it's hardcoded and then we guess the size ... |
| 788 | 788 | $multisig = "2of3"; |
| 789 | 789 | |
@@ -868,7 +868,7 @@ discard block |
||
| 868 | 868 | * @return int |
| 869 | 869 | */ |
| 870 | 870 | protected function determineChange($utxos, $outputs, $fee) { |
| 871 | - $inputsTotal = array_sum(array_map(function (UTXO $utxo) { |
|
| 871 | + $inputsTotal = array_sum(array_map(function(UTXO $utxo) { |
|
| 872 | 872 | return $utxo->value; |
| 873 | 873 | }, $utxos)); |
| 874 | 874 | $outputsTotal = array_sum(array_column($outputs, 'value')); |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | protected function signTransaction(Transaction $tx, array $signInfo) { |
| 888 | 888 | $signer = new Signer($tx, Bitcoin::getEcAdapter()); |
| 889 | 889 | |
| 890 | - assert(Util::all(function ($signInfo) { |
|
| 890 | + assert(Util::all(function($signInfo) { |
|
| 891 | 891 | return $signInfo instanceof SignInfo; |
| 892 | 892 | }, $signInfo), '$signInfo should be SignInfo[]'); |
| 893 | 893 | |
@@ -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 | } |
@@ -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; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * normalize network string |
| 77 | 77 | * |
| 78 | 78 | * @param $network |
| 79 | - * @param $testnet |
|
| 79 | + * @param boolean $testnet |
|
| 80 | 80 | * @return array |
| 81 | 81 | * @throws \Exception |
| 82 | 82 | */ |
@@ -671,6 +671,11 @@ discard block |
||
| 671 | 671 | ]; |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | + /** |
|
| 675 | + * @param integer $bits |
|
| 676 | + * |
|
| 677 | + * @return string |
|
| 678 | + */ |
|
| 674 | 679 | public static function randomBits($bits) { |
| 675 | 680 | return self::randomBytes($bits / 8); |
| 676 | 681 | } |
@@ -941,7 +946,7 @@ discard block |
||
| 941 | 946 | * create wallet using the API |
| 942 | 947 | * |
| 943 | 948 | * @param string $identifier the wallet identifier to create |
| 944 | - * @param array $primaryPublicKey BIP32 extended public key - [key, path] |
|
| 949 | + * @param string[] $primaryPublicKey BIP32 extended public key - [key, path] |
|
| 945 | 950 | * @param string $backupPublicKey plain public key |
| 946 | 951 | * @param string $primaryMnemonic mnemonic to store |
| 947 | 952 | * @param string $checksum checksum to store |
@@ -968,9 +973,9 @@ discard block |
||
| 968 | 973 | * @param string $identifier the wallet identifier to create |
| 969 | 974 | * @param array $primaryPublicKey BIP32 extended public key - [key, path] |
| 970 | 975 | * @param string $backupPublicKey plain public key |
| 971 | - * @param $encryptedPrimarySeed |
|
| 972 | - * @param $encryptedSecret |
|
| 973 | - * @param $recoverySecret |
|
| 976 | + * @param string|false $encryptedPrimarySeed |
|
| 977 | + * @param string|false $encryptedSecret |
|
| 978 | + * @param string|false $recoverySecret |
|
| 974 | 979 | * @param string $checksum checksum to store |
| 975 | 980 | * @param int $keyIndex account that we expect to use |
| 976 | 981 | * @return mixed |
@@ -999,8 +1004,8 @@ discard block |
||
| 999 | 1004 | * @param string $identifier the wallet identifier to create |
| 1000 | 1005 | * @param array $primaryPublicKey BIP32 extended public key - [key, path] |
| 1001 | 1006 | * @param string $backupPublicKey plain public key |
| 1002 | - * @param $encryptedPrimarySeed |
|
| 1003 | - * @param $encryptedSecret |
|
| 1007 | + * @param string|false $encryptedPrimarySeed |
|
| 1008 | + * @param string|false $encryptedSecret |
|
| 1004 | 1009 | * @param $recoverySecret |
| 1005 | 1010 | * @param string $checksum checksum to store |
| 1006 | 1011 | * @param int $keyIndex account that we expect to use |
@@ -1648,7 +1653,7 @@ discard block |
||
| 1648 | 1653 | * convert a Satoshi value to a BTC value |
| 1649 | 1654 | * |
| 1650 | 1655 | * @param int $satoshi |
| 1651 | - * @return float |
|
| 1656 | + * @return string |
|
| 1652 | 1657 | */ |
| 1653 | 1658 | public static function toBTC($satoshi) { |
| 1654 | 1659 | return bcdiv((int)(string)$satoshi, 100000000, 8); |
@@ -1678,7 +1683,7 @@ discard block |
||
| 1678 | 1683 | * convert a BTC value to a Satoshi value |
| 1679 | 1684 | * |
| 1680 | 1685 | * @param float $btc |
| 1681 | - * @return string |
|
| 1686 | + * @return integer |
|
| 1682 | 1687 | */ |
| 1683 | 1688 | public static function toSatoshi($btc) { |
| 1684 | 1689 | return (int)self::toSatoshiString($btc); |
@@ -1687,7 +1692,7 @@ discard block |
||
| 1687 | 1692 | /** |
| 1688 | 1693 | * json_decode helper that throws exceptions when it fails to decode |
| 1689 | 1694 | * |
| 1690 | - * @param $json |
|
| 1695 | + * @param string $json |
|
| 1691 | 1696 | * @param bool $assoc |
| 1692 | 1697 | * @return mixed |
| 1693 | 1698 | * @throws \Exception |
@@ -1739,6 +1744,9 @@ discard block |
||
| 1739 | 1744 | } |
| 1740 | 1745 | } |
| 1741 | 1746 | |
| 1747 | + /** |
|
| 1748 | + * @param BIP32Key[] $keys |
|
| 1749 | + */ |
|
| 1742 | 1750 | public static function normalizeBIP32KeyArray($keys) { |
| 1743 | 1751 | return Util::arrayMapWithIndex(function ($idx, $key) { |
| 1744 | 1752 | return [$idx, self::normalizeBIP32Key($key)]; |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | } else { |
| 579 | 579 | // create new primary seed |
| 580 | 580 | /** @var HierarchicalKey $primaryPrivateKey */ |
| 581 | - list($primaryMnemonic, , $primaryPrivateKey) = $this->newPrimarySeed($options['passphrase']); |
|
| 581 | + list($primaryMnemonic,, $primaryPrivateKey) = $this->newPrimarySeed($options['passphrase']); |
|
| 582 | 582 | if ($storePrimaryMnemonic !== false) { |
| 583 | 583 | $storePrimaryMnemonic = true; |
| 584 | 584 | } |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | $backupPublicKey = null; |
| 618 | 618 | if (!isset($options['backup_mnemonic']) && !isset($options['backup_public_key'])) { |
| 619 | 619 | /** @var HierarchicalKey $backupPrivateKey */ |
| 620 | - list($backupMnemonic, , ) = $this->newBackupSeed(); |
|
| 620 | + list($backupMnemonic,,) = $this->newBackupSeed(); |
|
| 621 | 621 | } else if (isset($options['backup_mnemonic'])) { |
| 622 | 622 | $backupMnemonic = $options['backup_mnemonic']; |
| 623 | 623 | } elseif (isset($options['backup_public_key'])) { |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | $data = $this->storeNewWalletV1($options['identifier'], $primaryPublicKey->tuple(), $backupPublicKey->tuple(), $primaryMnemonic, $checksum, $options['key_index']); |
| 642 | 642 | |
| 643 | 643 | // received the blocktrail public keys |
| 644 | - $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) { |
|
| 644 | + $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) { |
|
| 645 | 645 | return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])]; |
| 646 | 646 | }, $data['blocktrail_public_keys']); |
| 647 | 647 | |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | ); |
| 760 | 760 | |
| 761 | 761 | // received the blocktrail public keys |
| 762 | - $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) { |
|
| 762 | + $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) { |
|
| 763 | 763 | return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])]; |
| 764 | 764 | }, $data['blocktrail_public_keys']); |
| 765 | 765 | |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | 'backup_seed' => $backupSeed ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer($backupSeed)) : null, |
| 793 | 793 | 'recovery_encrypted_secret' => $recoveryEncryptedSecret ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer(base64_decode($recoveryEncryptedSecret))) : null, |
| 794 | 794 | 'encrypted_secret' => $encryptedSecret ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer(base64_decode($encryptedSecret))) : null, |
| 795 | - 'blocktrail_public_keys' => Util::arrayMapWithIndex(function ($keyIndex, BIP32Key $pubKey) { |
|
| 795 | + 'blocktrail_public_keys' => Util::arrayMapWithIndex(function($keyIndex, BIP32Key $pubKey) { |
|
| 796 | 796 | return [$keyIndex, $pubKey->tuple()]; |
| 797 | 797 | }, $blocktrailPublicKeys), |
| 798 | 798 | ], |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | ); |
| 898 | 898 | |
| 899 | 899 | // received the blocktrail public keys |
| 900 | - $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) { |
|
| 900 | + $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) { |
|
| 901 | 901 | return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])]; |
| 902 | 902 | }, $data['blocktrail_public_keys']); |
| 903 | 903 | |
@@ -930,7 +930,7 @@ discard block |
||
| 930 | 930 | 'backup_seed' => $backupSeed ? MnemonicFactory::bip39()->entropyToMnemonic($backupSeed) : null, |
| 931 | 931 | 'recovery_encrypted_secret' => $recoveryEncryptedSecret ? Mnemonic::encode($recoveryEncryptedSecret) : null, |
| 932 | 932 | 'encrypted_secret' => $encryptedSecret ? Mnemonic::encode($encryptedSecret) : null, |
| 933 | - 'blocktrail_public_keys' => Util::arrayMapWithIndex(function ($keyIndex, BIP32Key $pubKey) { |
|
| 933 | + 'blocktrail_public_keys' => Util::arrayMapWithIndex(function($keyIndex, BIP32Key $pubKey) { |
|
| 934 | 934 | return [$keyIndex, $pubKey->tuple()]; |
| 935 | 935 | }, $blocktrailPublicKeys), |
| 936 | 936 | ] |
@@ -1066,10 +1066,7 @@ discard block |
||
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | 1068 | $identifier = $options['identifier']; |
| 1069 | - $readonly = isset($options['readonly']) ? $options['readonly'] : |
|
| 1070 | - (isset($options['readOnly']) ? $options['readOnly'] : |
|
| 1071 | - (isset($options['read-only']) ? $options['read-only'] : |
|
| 1072 | - false)); |
|
| 1069 | + $readonly = isset($options['readonly']) ? $options['readonly'] : (isset($options['readOnly']) ? $options['readOnly'] : (isset($options['read-only']) ? $options['read-only'] : false)); |
|
| 1073 | 1070 | |
| 1074 | 1071 | // get the wallet data from the server |
| 1075 | 1072 | $data = $this->getWallet($identifier); |
@@ -1714,7 +1711,7 @@ discard block |
||
| 1714 | 1711 | */ |
| 1715 | 1712 | public static function sortMultisigKeys(array $pubKeys) { |
| 1716 | 1713 | $result = array_values($pubKeys); |
| 1717 | - usort($result, function (PublicKeyInterface $a, PublicKeyInterface $b) { |
|
| 1714 | + usort($result, function(PublicKeyInterface $a, PublicKeyInterface $b) { |
|
| 1718 | 1715 | $av = $a->getHex(); |
| 1719 | 1716 | $bv = $b->getHex(); |
| 1720 | 1717 | return $av == $bv ? 0 : $av > $bv ? 1 : -1; |
@@ -1740,7 +1737,7 @@ discard block |
||
| 1740 | 1737 | } |
| 1741 | 1738 | |
| 1742 | 1739 | public static function normalizeBIP32KeyArray($keys) { |
| 1743 | - return Util::arrayMapWithIndex(function ($idx, $key) { |
|
| 1740 | + return Util::arrayMapWithIndex(function($idx, $key) { |
|
| 1744 | 1741 | return [$idx, self::normalizeBIP32Key($key)]; |
| 1745 | 1742 | }, $keys); |
| 1746 | 1743 | } |
@@ -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; |
@@ -9,6 +9,11 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | interface BlocktrailSDKInterface { |
| 11 | 11 | |
| 12 | + /** |
|
| 13 | + * @param string $apiSecret |
|
| 14 | + * |
|
| 15 | + * @return void |
|
| 16 | + */ |
|
| 12 | 17 | public function __construct($apiKey, $apiSecret, $network = 'BTC', $testnet = false, $apiVersion = 'v1', $apiEndpoint = null); |
| 13 | 18 | |
| 14 | 19 | /** |
@@ -17,6 +22,7 @@ discard block |
||
| 17 | 22 | * @param bool $debug |
| 18 | 23 | * |
| 19 | 24 | * @codeCoverageIgnore |
| 25 | + * @return void |
|
| 20 | 26 | */ |
| 21 | 27 | public function setCurlDebugging($debug = true); |
| 22 | 28 | |
@@ -26,6 +32,7 @@ discard block |
||
| 26 | 32 | * @param bool $verboseErrors |
| 27 | 33 | * |
| 28 | 34 | * @codeCoverageIgnore |
| 35 | + * @return void |
|
| 29 | 36 | */ |
| 30 | 37 | public function setVerboseErrors($verboseErrors = true); |
| 31 | 38 | |
@@ -35,6 +42,7 @@ discard block |
||
| 35 | 42 | * @param bool $value |
| 36 | 43 | * |
| 37 | 44 | * @codeCoverageIgnore |
| 45 | + * @return void |
|
| 38 | 46 | */ |
| 39 | 47 | public function setCurlDefaultOption($key, $value); |
| 40 | 48 | |
@@ -304,7 +312,7 @@ discard block |
||
| 304 | 312 | * |
| 305 | 313 | * @param string $identifier the wallet identifier to be upgraded |
| 306 | 314 | * @param int $keyIndex the new account to use |
| 307 | - * @param array $primaryPublicKey BIP32 extended public key - [key, path] |
|
| 315 | + * @param string[] $primaryPublicKey BIP32 extended public key - [key, path] |
|
| 308 | 316 | * @return mixed |
| 309 | 317 | */ |
| 310 | 318 | public function upgradeKeyIndex($identifier, $keyIndex, $primaryPublicKey); |
@@ -408,7 +416,7 @@ discard block |
||
| 408 | 416 | * |
| 409 | 417 | * @param string $identifier the identifier of the wallet |
| 410 | 418 | * @param string $rawTransaction raw hex of the transaction (should be partially signed) |
| 411 | - * @param array $paths list of the paths that were used for the UTXO |
|
| 419 | + * @param string[] $paths list of the paths that were used for the UTXO |
|
| 412 | 420 | * @param bool $checkFee let the server verify the fee after signing |
| 413 | 421 | * @return string the complete raw transaction |
| 414 | 422 | * @throws \Exception |
@@ -436,7 +444,7 @@ discard block |
||
| 436 | 444 | * ] |
| 437 | 445 | * |
| 438 | 446 | * @param string $identifier the identifier of the wallet |
| 439 | - * @param array $outputs the outputs you want to create - array[address => satoshi-value] |
|
| 447 | + * @param \array[] $outputs the outputs you want to create - array[address => satoshi-value] |
|
| 440 | 448 | * @param bool $lockUTXO when TRUE the UTXOs selected will be locked for a few seconds |
| 441 | 449 | * so you have some time to spend them without race-conditions |
| 442 | 450 | * @param bool $allowZeroConf |
@@ -480,22 +488,22 @@ discard block |
||
| 480 | 488 | /** |
| 481 | 489 | * lock a specific unspent output |
| 482 | 490 | * |
| 483 | - * @param $identifier |
|
| 491 | + * @param string $identifier |
|
| 484 | 492 | * @param $txHash |
| 485 | 493 | * @param $txIdx |
| 486 | 494 | * @param int $ttl |
| 487 | 495 | * @return |
| 488 | - */ |
|
| 496 | + boolean |
|
| 489 | 497 | public function lockWalletUTXO($identifier, $txHash, $txIdx, $ttl = 3); |
| 490 | 498 | |
| 491 | 499 | /** |
| 492 | 500 | * unlock a specific unspent output |
| 493 | 501 | * |
| 494 | - * @param $identifier |
|
| 502 | + * @param string $identifier |
|
| 495 | 503 | * @param $txHash |
| 496 | 504 | * @param $txIdx |
| 497 | 505 | * @return |
| 498 | - */ |
|
| 506 | + boolean |
|
| 499 | 507 | public function unlockWalletUTXO($identifier, $txHash, $txIdx); |
| 500 | 508 | |
| 501 | 509 | /** |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | use Blocktrail\SDK\BlocktrailSDK; |
| 4 | 4 | |
| 5 | -require_once __DIR__ . "/../vendor/autoload.php"; |
|
| 5 | +require_once __DIR__."/../vendor/autoload.php"; |
|
| 6 | 6 | |
| 7 | 7 | /* |
| 8 | 8 | This simple example shows how to get the payload when your webhook is called. |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | use Blocktrail\SDK\BlocktrailSDK; |
| 4 | 4 | |
| 5 | -require_once __DIR__ . "/../vendor/autoload.php"; |
|
| 5 | +require_once __DIR__."/../vendor/autoload.php"; |
|
| 6 | 6 | |
| 7 | 7 | /* |
| 8 | 8 | This simple example shows how to get the payload when your webhook is called. |