@@ -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; |
@@ -262,7 +262,7 @@ |
||
| 262 | 262 | * generate image file of backup details, ready to |
| 263 | 263 | * |
| 264 | 264 | * @param null $filename filename to save image as (optional - if ommited raw image stream is outputted instead) |
| 265 | - * @return bool |
|
| 265 | + * @return null|boolean |
|
| 266 | 266 | */ |
| 267 | 267 | public function generateImg($filename = null) { |
| 268 | 268 | //create blocktrail pub key QR codes if not already done |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $this->primaryMnemonic = $primaryMnemonic; |
| 74 | 74 | $this->backupMnemonic = $backupMnemonic; |
| 75 | 75 | |
| 76 | - $this->blocktrailPublicKeys = array_map(function ($key) { |
|
| 76 | + $this->blocktrailPublicKeys = array_map(function($key) { |
|
| 77 | 77 | return BIP32Key::create($key); // M/9999' or M/0' or M/1' |
| 78 | 78 | }, $blocktrailPublicKeys); |
| 79 | 79 | } |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | $qrCode = new QrCode(); |
| 88 | 88 | $qrCode |
| 89 | 89 | ->setText($key->key()) |
| 90 | - ->setSize(self::QR_CODE_SIZE-20) |
|
| 90 | + ->setSize(self::QR_CODE_SIZE - 20) |
|
| 91 | 91 | ->setPadding(10) |
| 92 | 92 | ->setErrorCorrection('high') |
| 93 | 93 | ->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0)) |
| 94 | 94 | ->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0)) |
| 95 | - ->setLabel("KeyIndex: ".$keyIndex." Path: ".$key->path()) |
|
| 95 | + ->setLabel("KeyIndex: " . $keyIndex . " Path: " . $key->path()) |
|
| 96 | 96 | ->setLabelFontSize(10) |
| 97 | 97 | ; |
| 98 | 98 | $this->blocktrailPubKeyQRs[] = array( |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | } |
| 272 | 272 | //create the image canvas - use the count of blocktrail pub keys to augment appropriately |
| 273 | 273 | $totalPubKeys = count($this->blocktrailPubKeyQRs); |
| 274 | - $increaseCanvas = ceil($totalPubKeys/4) * (self::QR_CODE_SIZE + 30); |
|
| 274 | + $increaseCanvas = ceil($totalPubKeys / 4) * (self::QR_CODE_SIZE + 30); |
|
| 275 | 275 | $image = imagecreatetruecolor(1024, 600 + $increaseCanvas); |
| 276 | 276 | |
| 277 | 277 | //create colours |
@@ -315,11 +315,11 @@ discard block |
||
| 315 | 315 | //3. Bloctrail pub key QR codes |
| 316 | 316 | $backupContent[] = array('font-size' => 12, 'line-height' => 30, 'text' => ''); |
| 317 | 317 | $backupContent[] = array('font-size' => 14, 'line-height' => 20, 'text' => 'Blocktrail Public Keys'); |
| 318 | - $backupContent[] = array('font-size' => 10, 'line-height' => 24, 'text' => $totalPubKeys.' in total'); |
|
| 318 | + $backupContent[] = array('font-size' => 10, 'line-height' => 24, 'text' => $totalPubKeys . ' in total'); |
|
| 319 | 319 | |
| 320 | 320 | |
| 321 | 321 | //Merge all the text content together and print to image |
| 322 | - $font = $this->fontsPath.'/OpenSans-Regular.ttf'; |
|
| 322 | + $font = $this->fontsPath . '/OpenSans-Regular.ttf'; |
|
| 323 | 323 | $content = array_merge($introContent, $backupContent); |
| 324 | 324 | $leftMargin = 15; |
| 325 | 325 | $topMargin = 25; |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | $xPos = $leftMargin; |
| 335 | 335 | $i = 0; |
| 336 | 336 | foreach ($this->blocktrailPubKeyQRs as $btPubKey) { |
| 337 | - imagecopy($image, $btPubKey['qrImg'], $xPos, $yPos, 0, 0, self::QR_CODE_SIZE, self::QR_CODE_SIZE+20); |
|
| 337 | + imagecopy($image, $btPubKey['qrImg'], $xPos, $yPos, 0, 0, self::QR_CODE_SIZE, self::QR_CODE_SIZE + 20); |
|
| 338 | 338 | |
| 339 | 339 | //increment to help decide when to start a new row |
| 340 | 340 | $i++; |
@@ -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; |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | /** |
| 76 | 76 | * get tuple of the key and path, the way BitcoinLib likes it |
| 77 | 77 | * |
| 78 | - * @return array [key, path] |
|
| 78 | + * @return string[] [key, path] |
|
| 79 | 79 | */ |
| 80 | 80 | public function tuple() { |
| 81 | 81 | return [$this->key, (string)$this->path]; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | /** |
| 92 | 92 | * build child key |
| 93 | 93 | * |
| 94 | - * @param string|BIP32Path $path |
|
| 94 | + * @param BIP32Path $path |
|
| 95 | 95 | * @return BIP32Key |
| 96 | 96 | * @throws \Exception |
| 97 | 97 | */ |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * normalize network string |
| 60 | 60 | * |
| 61 | 61 | * @param $network |
| 62 | - * @param $testnet |
|
| 62 | + * @param boolean $testnet |
|
| 63 | 63 | * @return array |
| 64 | 64 | * @throws \Exception |
| 65 | 65 | */ |
@@ -1089,7 +1089,7 @@ discard block |
||
| 1089 | 1089 | * convert a Satoshi value to a BTC value |
| 1090 | 1090 | * |
| 1091 | 1091 | * @param int $satoshi |
| 1092 | - * @return float |
|
| 1092 | + * @return string |
|
| 1093 | 1093 | */ |
| 1094 | 1094 | public static function toBTC($satoshi) { |
| 1095 | 1095 | return bcdiv((int)(string)$satoshi, 100000000, 8); |
@@ -1119,7 +1119,7 @@ discard block |
||
| 1119 | 1119 | * convert a BTC value to a Satoshi value |
| 1120 | 1120 | * |
| 1121 | 1121 | * @param float $btc |
| 1122 | - * @return string |
|
| 1122 | + * @return integer |
|
| 1123 | 1123 | */ |
| 1124 | 1124 | public static function toSatoshi($btc) { |
| 1125 | 1125 | return (int)self::toSatoshiString($btc); |
@@ -1128,7 +1128,7 @@ discard block |
||
| 1128 | 1128 | /** |
| 1129 | 1129 | * json_decode helper that throws exceptions when it fails to decode |
| 1130 | 1130 | * |
| 1131 | - * @param $json |
|
| 1131 | + * @param string $json |
|
| 1132 | 1132 | * @param bool $assoc |
| 1133 | 1133 | * @return mixed |
| 1134 | 1134 | * @throws \Exception |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * @return array associative array containing the response |
| 299 | 299 | */ |
| 300 | 300 | public function getWebhook($identifier) { |
| 301 | - $response = $this->client->get("webhook/".$identifier); |
|
| 301 | + $response = $this->client->get("webhook/" . $identifier); |
|
| 302 | 302 | return self::jsonDecode($response->body(), true); |
| 303 | 303 | } |
| 304 | 304 | |
@@ -648,10 +648,7 @@ discard block |
||
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | $identifier = $options['identifier']; |
| 651 | - $readonly = isset($options['readonly']) ? $options['readonly'] : |
|
| 652 | - (isset($options['readOnly']) ? $options['readOnly'] : |
|
| 653 | - (isset($options['read-only']) ? $options['read-only'] : |
|
| 654 | - false)); |
|
| 651 | + $readonly = isset($options['readonly']) ? $options['readonly'] : (isset($options['readOnly']) ? $options['readOnly'] : (isset($options['read-only']) ? $options['read-only'] : false)); |
|
| 655 | 652 | |
| 656 | 653 | // get the wallet data from the server |
| 657 | 654 | $data = $this->getWallet($identifier); |
@@ -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 | |
@@ -371,7 +379,7 @@ discard block |
||
| 371 | 379 | * |
| 372 | 380 | * @param string $identifier the identifier of the wallet |
| 373 | 381 | * @param string $rawTransaction raw hex of the transaction (should be partially signed) |
| 374 | - * @param array $paths list of the paths that were used for the UTXO |
|
| 382 | + * @param string[] $paths list of the paths that were used for the UTXO |
|
| 375 | 383 | * @param bool $checkFee let the server verify the fee after signing |
| 376 | 384 | * @return string the complete raw transaction |
| 377 | 385 | * @throws \Exception |
@@ -443,22 +451,22 @@ discard block |
||
| 443 | 451 | /** |
| 444 | 452 | * lock a specific unspent output |
| 445 | 453 | * |
| 446 | - * @param $identifier |
|
| 454 | + * @param string $identifier |
|
| 447 | 455 | * @param $txHash |
| 448 | 456 | * @param $txIdx |
| 449 | 457 | * @param int $ttl |
| 450 | 458 | * @return |
| 451 | - */ |
|
| 459 | + boolean |
|
| 452 | 460 | public function lockWalletUTXO($identifier, $txHash, $txIdx, $ttl = 3); |
| 453 | 461 | |
| 454 | 462 | /** |
| 455 | 463 | * unlock a specific unspent output |
| 456 | 464 | * |
| 457 | - * @param $identifier |
|
| 465 | + * @param string $identifier |
|
| 458 | 466 | * @param $txHash |
| 459 | 467 | * @param $txIdx |
| 460 | 468 | * @return |
| 461 | - */ |
|
| 469 | + boolean |
|
| 462 | 470 | public function unlockWalletUTXO($identifier, $txHash, $txIdx); |
| 463 | 471 | |
| 464 | 472 | /** |
@@ -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; |
@@ -44,6 +44,11 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | protected $verboseErrors = false; |
| 46 | 46 | |
| 47 | + /** |
|
| 48 | + * @param string $apiVersion |
|
| 49 | + * @param string $apiKey |
|
| 50 | + * @param string $apiSecret |
|
| 51 | + */ |
|
| 47 | 52 | public function __construct($apiEndpoint, $apiVersion, $apiKey, $apiSecret) { |
| 48 | 53 | $this->guzzle = new Guzzle(array( |
| 49 | 54 | 'base_url' => $apiEndpoint, |
@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use GuzzleHttp\Client as Guzzle; |
| 6 | 6 | use GuzzleHttp\Message\RequestInterface; |
| 7 | 7 | use GuzzleHttp\Message\ResponseInterface; |
| 8 | -use GuzzleHttp\Post\PostBodyInterface; |
|
| 9 | 8 | use GuzzleHttp\Query; |
| 10 | 9 | use GuzzleHttp\Stream\Stream; |
| 11 | 10 | use HttpSignatures\Context; |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @param $options ['primary_private_key' => key] OR ['passphrase' => pass] |
| 193 | 193 | * @param callable $fn |
| 194 | - * @return bool |
|
| 194 | + * @return boolean|null |
|
| 195 | 195 | * @throws \Exception |
| 196 | 196 | */ |
| 197 | 197 | public function unlock($options, callable $fn = null) { |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | /** |
| 333 | - * @param string|BIP32Path $path |
|
| 333 | + * @param BIP32Path $path |
|
| 334 | 334 | * @return BIP32Key|false |
| 335 | 335 | * @throws \Exception |
| 336 | 336 | * |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | /** |
| 358 | 358 | * get address for the specified path |
| 359 | 359 | * |
| 360 | - * @param string|BIP32Path $path |
|
| 360 | + * @param string $path |
|
| 361 | 361 | * @return string |
| 362 | 362 | */ |
| 363 | 363 | public function getAddressByPath($path) { |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | |
| 394 | 394 | /** |
| 395 | 395 | * @param BIP32Key $key |
| 396 | - * @param string|BIP32Path $path |
|
| 396 | + * @param BIP32Path $path |
|
| 397 | 397 | * @return string |
| 398 | 398 | */ |
| 399 | 399 | protected function getAddressFromKey(BIP32Key $key, $path) { |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | /** |
| 437 | - * @param string|BIP32Path $path |
|
| 437 | + * @param BIP32Path $path |
|
| 438 | 438 | * @return BIP32Key |
| 439 | 439 | * @throws \Exception |
| 440 | 440 | */ |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | * 'fund' the txBuilder with UTXOs (modified in place) |
| 569 | 569 | * |
| 570 | 570 | * @param TransactionBuilder $txBuilder |
| 571 | - * @param bool|true $lockUTXOs |
|
| 571 | + * @param boolean $lockUTXOs |
|
| 572 | 572 | * @param bool|false $allowZeroConf |
| 573 | 573 | * @param null|int $forceFee |
| 574 | 574 | * @return TransactionBuilder |
@@ -682,6 +682,9 @@ discard block |
||
| 682 | 682 | return [$inputs, $send]; |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | + /** |
|
| 686 | + * @param integer $optimalFeePerKB |
|
| 687 | + */ |
|
| 685 | 688 | public function determineFeeAndChange(TransactionBuilder $txBuilder, $optimalFeePerKB) { |
| 686 | 689 | $send = $txBuilder->getOutputs(); |
| 687 | 690 | $utxos = $txBuilder->getUtxos(); |
@@ -794,7 +797,7 @@ discard block |
||
| 794 | 797 | * |
| 795 | 798 | * @param int $utxoCnt number of unspent inputs in transaction |
| 796 | 799 | * @param int $outputCnt number of outputs in transaction |
| 797 | - * @return float |
|
| 800 | + * @return integer |
|
| 798 | 801 | * @access public reminder that people might use this! |
| 799 | 802 | */ |
| 800 | 803 | public static function estimateFee($utxoCnt, $outputCnt) { |
@@ -816,7 +819,7 @@ discard block |
||
| 816 | 819 | /** |
| 817 | 820 | * @param int $txinSize |
| 818 | 821 | * @param int $txoutSize |
| 819 | - * @return float |
|
| 822 | + * @return integer |
|
| 820 | 823 | */ |
| 821 | 824 | public static function estimateSize($txinSize, $txoutSize) { |
| 822 | 825 | return 4 + 4 + $txinSize + 4 + $txoutSize + 4; // version + txinVarInt + txin + txoutVarInt + txout + locktime |
@@ -826,7 +829,7 @@ discard block |
||
| 826 | 829 | * only supports estimating size for P2PKH/P2SH outputs |
| 827 | 830 | * |
| 828 | 831 | * @param int $outputCnt number of outputs in transaction |
| 829 | - * @return float |
|
| 832 | + * @return integer |
|
| 830 | 833 | */ |
| 831 | 834 | public static function estimateSizeOutputs($outputCnt) { |
| 832 | 835 | return ($outputCnt * 34); |
@@ -880,7 +883,7 @@ discard block |
||
| 880 | 883 | * |
| 881 | 884 | * @param UTXO[] $utxos |
| 882 | 885 | * @param array[] $outputs |
| 883 | - * @param $feeStrategy |
|
| 886 | + * @param string $feeStrategy |
|
| 884 | 887 | * @param $optimalFeePerKB |
| 885 | 888 | * @return int |
| 886 | 889 | * @throws BlocktrailSDKException |
@@ -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; |
@@ -142,10 +142,10 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | $this->primaryMnemonic = $primaryMnemonic; |
| 144 | 144 | $this->backupPublicKey = BIP32Key::create($backupPublicKey); |
| 145 | - $this->primaryPublicKeys = array_map(function ($key) { |
|
| 145 | + $this->primaryPublicKeys = array_map(function($key) { |
|
| 146 | 146 | return BIP32Key::create($key); |
| 147 | 147 | }, $primaryPublicKeys); |
| 148 | - $this->blocktrailPublicKeys = array_map(function ($key) { |
|
| 148 | + $this->blocktrailPublicKeys = array_map(function($key) { |
|
| 149 | 149 | return BIP32Key::create($key); |
| 150 | 150 | }, $blocktrailPublicKeys); |
| 151 | 151 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @return array[] [ [xpub, path] ] |
| 182 | 182 | */ |
| 183 | 183 | public function getBlocktrailPublicKeys() { |
| 184 | - return array_map(function (BIP32Key $key) { |
|
| 184 | + return array_map(function(BIP32Key $key) { |
|
| 185 | 185 | return $key->tuple(); |
| 186 | 186 | }, $this->blocktrailPublicKeys); |
| 187 | 187 | } |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | public function getAddressByPath($path) { |
| 364 | 364 | $path = (string)BIP32Path::path($path)->privatePath(); |
| 365 | 365 | if (!isset($this->derivations[$path])) { |
| 366 | - list($address, ) = $this->getRedeemScriptByPath($path); |
|
| 366 | + list($address,) = $this->getRedeemScriptByPath($path); |
|
| 367 | 367 | |
| 368 | 368 | $this->derivations[$path] = $address; |
| 369 | 369 | $this->derivationsByAddress[$address] = $path; |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | } |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | - if (array_sum(array_map(function (UTXO $utxo) { return $utxo->value; }, $utxos)) < array_sum(array_column($send, 'value'))) { |
|
| 644 | + if (array_sum(array_map(function(UTXO $utxo) { return $utxo->value; }, $utxos)) < array_sum(array_column($send, 'value'))) { |
|
| 645 | 645 | throw new \Exception("Atempting to spend more than sum of UTXOs"); |
| 646 | 646 | } |
| 647 | 647 | |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | // create raw transaction |
| 664 | - $inputs = array_map(function (UTXO $utxo) { |
|
| 664 | + $inputs = array_map(function(UTXO $utxo) { |
|
| 665 | 665 | return [ |
| 666 | 666 | 'txid' => $utxo->hash, |
| 667 | 667 | 'vout' => (int)$utxo->index, |
@@ -841,7 +841,7 @@ discard block |
||
| 841 | 841 | public static function estimateSizeUTXOs($utxoCnt) { |
| 842 | 842 | $txinSize = 0; |
| 843 | 843 | |
| 844 | - for ($i=0; $i<$utxoCnt; $i++) { |
|
| 844 | + for ($i = 0; $i < $utxoCnt; $i++) { |
|
| 845 | 845 | // @TODO: proper size calculation, we only do multisig right now so it's hardcoded and then we guess the size ... |
| 846 | 846 | $multisig = "2of3"; |
| 847 | 847 | |
@@ -918,7 +918,7 @@ discard block |
||
| 918 | 918 | * @return int |
| 919 | 919 | */ |
| 920 | 920 | protected function determineChange($utxos, $outputs, $fee) { |
| 921 | - $inputsTotal = array_sum(array_map(function (UTXO $utxo) { |
|
| 921 | + $inputsTotal = array_sum(array_map(function(UTXO $utxo) { |
|
| 922 | 922 | return $utxo->value; |
| 923 | 923 | }, $utxos)); |
| 924 | 924 | $outputsTotal = array_sum(array_column($outputs, 'value')); |
@@ -962,7 +962,7 @@ discard block |
||
| 962 | 962 | } |
| 963 | 963 | } |
| 964 | 964 | |
| 965 | - BIP32::bip32_keys_to_wallet($wallet, array_map(function (BIP32Key $key) { |
|
| 965 | + BIP32::bip32_keys_to_wallet($wallet, array_map(function(BIP32Key $key) { |
|
| 966 | 966 | return $key->tuple(); |
| 967 | 967 | }, $keys)); |
| 968 | 968 | RawTransaction::redeem_scripts_to_wallet($wallet, $redeemScripts); |
@@ -24,6 +24,7 @@ discard block |
||
| 24 | 24 | * @param string $network |
| 25 | 25 | * @param bool $testnet |
| 26 | 26 | * @param string $checksum |
| 27 | + * @return void |
|
| 27 | 28 | */ |
| 28 | 29 | public function __construct(BlocktrailSDKInterface $sdk, $identifier, $primaryMnemonic, $primaryPublicKey, $backupPublicKey, $blocktrailPublicKeys, $keyIndex, $network, $testnet, $checksum); |
| 29 | 30 | |
@@ -92,7 +93,7 @@ discard block |
||
| 92 | 93 | * get address and redeemScript for specified path |
| 93 | 94 | * |
| 94 | 95 | * @param string $path |
| 95 | - * @return array[string, string] [address, redeemScript] |
|
| 96 | + * @return string[] string] [address, redeemScript] |
|
| 96 | 97 | */ |
| 97 | 98 | public function getRedeemScriptByPath($path); |
| 98 | 99 | |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | /** |
| 121 | 121 | * normalize network string |
| 122 | 122 | * |
| 123 | - * @param $network |
|
| 124 | - * @param $testnet |
|
| 123 | + * @param string $network |
|
| 124 | + * @param boolean $testnet |
|
| 125 | 125 | * @return array |
| 126 | 126 | * @throws \Exception |
| 127 | 127 | */ |
@@ -151,8 +151,8 @@ discard block |
||
| 151 | 151 | /** |
| 152 | 152 | * generate multisig address for given path |
| 153 | 153 | * |
| 154 | - * @param $path |
|
| 155 | - * @return array |
|
| 154 | + * @param string $path |
|
| 155 | + * @return string[] |
|
| 156 | 156 | * @throws \Exception |
| 157 | 157 | */ |
| 158 | 158 | protected function createAddress($path) { |
@@ -175,8 +175,8 @@ discard block |
||
| 175 | 175 | /** |
| 176 | 176 | * create a batch of multisig addresses |
| 177 | 177 | * |
| 178 | - * @param $start |
|
| 179 | - * @param $count |
|
| 178 | + * @param integer $start |
|
| 179 | + * @param integer $count |
|
| 180 | 180 | * @param $keyIndex |
| 181 | 181 | * @return array |
| 182 | 182 | */ |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | /** |
| 206 | 206 | * gets the blocktrail pub key for the given path from the stored array of pub keys |
| 207 | 207 | * |
| 208 | - * @param string|BIP32Path $path |
|
| 208 | + * @param BIP32Path $path |
|
| 209 | 209 | * @return BIP32Key |
| 210 | 210 | * @throws \Exception |
| 211 | 211 | */ |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | /** |
| 316 | 316 | * create a signed transaction sending all the found outputs to the given address |
| 317 | 317 | * |
| 318 | - * @param $destinationAddress |
|
| 318 | + * @param string $destinationAddress |
|
| 319 | 319 | * @return array |
| 320 | 320 | * @throws \Exception |
| 321 | 321 | */ |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | /** |
| 370 | 370 | * signs a raw transaction |
| 371 | 371 | * |
| 372 | - * @param $rawTransaction |
|
| 372 | + * @param string $rawTransaction |
|
| 373 | 373 | * @param $inputs |
| 374 | 374 | * @return array |
| 375 | 375 | */ |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | for ($i = 0; $i < $count; $i++) { |
| 187 | 187 | //create a path subsequent address |
| 188 | - $path = (string)WalletPath::create($keyIndex, $_chain = 0, $start+$i)->path()->publicPath(); |
|
| 188 | + $path = (string)WalletPath::create($keyIndex, $_chain = 0, $start + $i)->path()->publicPath(); |
|
| 189 | 189 | list($address, $redeem) = $this->createAddress($path); |
| 190 | 190 | $addresses[$address] = array( |
| 191 | 191 | //'address' => $address, |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | $totalUTXOs = 0; |
| 233 | 233 | $totalAddressesGenerated = 0; |
| 234 | 234 | |
| 235 | - $addressUTXOs = array(); //addresses and their utxos, paths and redeem scripts |
|
| 235 | + $addressUTXOs = array(); //addresses and their utxos, paths and redeem scripts |
|
| 236 | 236 | |
| 237 | 237 | //for each blocktrail pub key, do fund discovery on batches of addresses |
| 238 | 238 | foreach ($this->blocktrailPublicKeys as $keyIndex => $blocktrailPubKey) { |
@@ -260,12 +260,12 @@ discard block |
||
| 260 | 260 | $totalUTXOs += count($outputs); |
| 261 | 261 | |
| 262 | 262 | //add up the total utxo value for all addresses |
| 263 | - $totalBalance = array_reduce($outputs, function ($carry, $output) { |
|
| 263 | + $totalBalance = array_reduce($outputs, function($carry, $output) { |
|
| 264 | 264 | return $carry += $output['value']; |
| 265 | 265 | }, $totalBalance); |
| 266 | 266 | |
| 267 | 267 | if ($this->debug) { |
| 268 | - echo "\nfound ".count($outputs)." unspent outputs in address $address"; |
|
| 268 | + echo "\nfound " . count($outputs) . " unspent outputs in address $address"; |
|
| 269 | 269 | } |
| 270 | 270 | } |
| 271 | 271 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | foreach ($this->sweepData['utxos'] as $address => $data) { |
| 330 | 330 | $inputs = array_merge( |
| 331 | 331 | $inputs, |
| 332 | - array_map(function ($utxo) use ($address, $data) { |
|
| 332 | + array_map(function($utxo) use ($address, $data) { |
|
| 333 | 333 | return [ |
| 334 | 334 | 'txid' => $utxo['hash'], |
| 335 | 335 | 'vout' => $utxo['index'], |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | //add the keys and redeem scripts to a wallet to sign the transaction with |
| 390 | - BIP32::bip32_keys_to_wallet($wallet, array_map(function (BIP32Key $key) { |
|
| 390 | + BIP32::bip32_keys_to_wallet($wallet, array_map(function(BIP32Key $key) { |
|
| 391 | 391 | return $key->tuple(); |
| 392 | 392 | }, $keys)); |
| 393 | 393 | RawTransaction::redeem_scripts_to_wallet($wallet, $redeemScripts); |