Complex classes like Wallet often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Wallet, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 29 | abstract class Wallet implements WalletInterface { |
||
| 30 | |||
| 31 | const WALLET_VERSION_V1 = 'v1'; |
||
| 32 | const WALLET_VERSION_V2 = 'v2'; |
||
| 33 | const WALLET_VERSION_V3 = 'v3'; |
||
| 34 | |||
| 35 | const CHAIN_BTC_DEFAULT = 0; |
||
| 36 | const CHAIN_BCC_DEFAULT = 1; |
||
| 37 | const CHAIN_BTC_SEGWIT = 2; |
||
| 38 | |||
| 39 | const BASE_FEE = 10000; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * development / debug setting |
||
| 43 | * when getting a new derivation from the API, |
||
| 44 | * will verify address / redeeemScript with the values the API provides |
||
| 45 | */ |
||
| 46 | const VERIFY_NEW_DERIVATION = true; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @var BlocktrailSDKInterface |
||
| 50 | */ |
||
| 51 | protected $sdk; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @var string |
||
| 55 | */ |
||
| 56 | protected $identifier; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * BIP32 master primary private key (m/) |
||
| 60 | * |
||
| 61 | * @var BIP32Key |
||
| 62 | */ |
||
| 63 | protected $primaryPrivateKey; |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @var BIP32Key[] |
||
| 67 | */ |
||
| 68 | protected $primaryPublicKeys; |
||
| 69 | |||
| 70 | /** |
||
| 71 | * BIP32 master backup public key (M/) |
||
| 72 | |||
| 73 | * @var BIP32Key |
||
| 74 | */ |
||
| 75 | protected $backupPublicKey; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * map of blocktrail BIP32 public keys |
||
| 79 | * keyed by key index |
||
| 80 | * path should be `M / key_index'` |
||
| 81 | * |
||
| 82 | * @var BIP32Key[] |
||
| 83 | */ |
||
| 84 | protected $blocktrailPublicKeys; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * the 'Blocktrail Key Index' that is used for new addresses |
||
| 88 | * |
||
| 89 | * @var int |
||
| 90 | */ |
||
| 91 | protected $keyIndex; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * 'bitcoin' |
||
| 95 | * |
||
| 96 | * @var string |
||
| 97 | */ |
||
| 98 | protected $network; |
||
| 99 | |||
| 100 | /** |
||
| 101 | * testnet yes / no |
||
| 102 | * |
||
| 103 | * @var bool |
||
| 104 | */ |
||
| 105 | protected $testnet; |
||
| 106 | |||
| 107 | /** |
||
| 108 | * cache of public keys, by path |
||
| 109 | * |
||
| 110 | * @var BIP32Key[] |
||
| 111 | */ |
||
| 112 | protected $pubKeys = []; |
||
| 113 | |||
| 114 | /** |
||
| 115 | * cache of address / redeemScript, by path |
||
| 116 | * |
||
| 117 | * @var string[][] [[address, redeemScript)], ] |
||
| 118 | */ |
||
| 119 | protected $derivations = []; |
||
| 120 | |||
| 121 | /** |
||
| 122 | * reverse cache of paths by address |
||
| 123 | * |
||
| 124 | * @var string[] |
||
| 125 | */ |
||
| 126 | protected $derivationsByAddress = []; |
||
| 127 | |||
| 128 | /** |
||
| 129 | * @var WalletPath |
||
| 130 | */ |
||
| 131 | protected $walletPath; |
||
| 132 | |||
| 133 | protected $checksum; |
||
| 134 | |||
| 135 | protected $locked = true; |
||
| 136 | |||
| 137 | protected $optimalFeePerKB; |
||
| 138 | protected $lowPriorityFeePerKB; |
||
| 139 | protected $feePerKBAge; |
||
| 140 | protected $allowedSignModes = [SignInfo::MODE_DONTSIGN, SignInfo::MODE_SIGN]; |
||
| 141 | |||
| 142 | /** |
||
| 143 | * @param BlocktrailSDKInterface $sdk SDK instance used to do requests |
||
| 144 | * @param string $identifier identifier of the wallet |
||
| 145 | * @param BIP32Key[] $primaryPublicKeys |
||
| 146 | * @param BIP32Key $backupPublicKey should be BIP32 master public key M/ |
||
| 147 | * @param BIP32Key[] $blocktrailPublicKeys |
||
| 148 | * @param int $keyIndex |
||
| 149 | * @param string $network |
||
| 150 | * @param bool $testnet |
||
| 151 | * @param bool $segwit |
||
| 152 | * @param string $checksum |
||
| 153 | * @throws BlocktrailSDKException |
||
| 154 | */ |
||
| 155 | 18 | public function __construct(BlocktrailSDKInterface $sdk, $identifier, array $primaryPublicKeys, $backupPublicKey, array $blocktrailPublicKeys, $keyIndex, $network, $testnet, $segwit, $checksum) { |
|
| 156 | 18 | $this->sdk = $sdk; |
|
| 157 | |||
| 158 | 18 | $this->identifier = $identifier; |
|
| 159 | 18 | $this->backupPublicKey = BlocktrailSDK::normalizeBIP32Key($backupPublicKey); |
|
| 160 | 18 | $this->primaryPublicKeys = BlocktrailSDK::normalizeBIP32KeyArray($primaryPublicKeys); |
|
| 161 | ; |
||
| 162 | 18 | $this->blocktrailPublicKeys = BlocktrailSDK::normalizeBIP32KeyArray($blocktrailPublicKeys); |
|
| 163 | |||
| 164 | 18 | $this->network = $network; |
|
| 165 | 18 | $this->testnet = $testnet; |
|
| 166 | 18 | $this->keyIndex = $keyIndex; |
|
| 167 | 18 | $this->checksum = $checksum; |
|
| 168 | |||
| 169 | 18 | if ($network === "bitcoin") { |
|
| 170 | 18 | if ($segwit) { |
|
| 171 | 2 | $chainIdx = self::CHAIN_BTC_SEGWIT; |
|
| 172 | } else { |
||
| 173 | 18 | $chainIdx = self::CHAIN_BTC_DEFAULT; |
|
| 174 | } |
||
| 175 | } else { |
||
| 176 | if ($segwit && $network === "bitcoincash") { |
||
| 177 | throw new BlocktrailSDKException("Received segwit flag for bitcoincash - abort"); |
||
| 178 | } |
||
| 179 | $chainIdx = self::CHAIN_BCC_DEFAULT; |
||
| 180 | } |
||
| 181 | |||
| 182 | 18 | $this->walletPath = WalletPath::create($this->keyIndex, $chainIdx); |
|
| 183 | 18 | } |
|
| 184 | |||
| 185 | /** |
||
| 186 | * Returns the current chain index, usually |
||
| 187 | * indicating what type of scripts to derive. |
||
| 188 | * @return int |
||
| 189 | */ |
||
| 190 | 3 | public function getChainIndex() { |
|
| 193 | |||
| 194 | /** |
||
| 195 | * @return bool |
||
| 196 | */ |
||
| 197 | 3 | public function isSegwit() { |
|
| 200 | |||
| 201 | /** |
||
| 202 | * return the wallet identifier |
||
| 203 | * |
||
| 204 | * @return string |
||
| 205 | */ |
||
| 206 | 10 | public function getIdentifier() { |
|
| 209 | |||
| 210 | /** |
||
| 211 | * return list of Blocktrail co-sign extended public keys |
||
| 212 | * |
||
| 213 | * @return array[] [ [xpub, path] ] |
||
| 214 | */ |
||
| 215 | 5 | public function getBlocktrailPublicKeys() { |
|
| 220 | |||
| 221 | /** |
||
| 222 | * check if wallet is locked |
||
| 223 | * |
||
| 224 | * @return bool |
||
| 225 | */ |
||
| 226 | 10 | public function isLocked() { |
|
| 229 | |||
| 230 | /** |
||
| 231 | * upgrade wallet to different blocktrail cosign key |
||
| 232 | * |
||
| 233 | * @param $keyIndex |
||
| 234 | * @return bool |
||
| 235 | * @throws \Exception |
||
| 236 | */ |
||
| 237 | 5 | public function upgradeKeyIndex($keyIndex) { |
|
| 266 | |||
| 267 | /** |
||
| 268 | * get a new BIP32 derivation for the next (unused) address |
||
| 269 | * by requesting it from the API |
||
| 270 | * |
||
| 271 | * @return string |
||
| 272 | * @throws \Exception |
||
| 273 | */ |
||
| 274 | 13 | protected function getNewDerivation() { |
|
| 304 | |||
| 305 | /** |
||
| 306 | * @param string|BIP32Path $path |
||
| 307 | * @return BIP32Key|false |
||
| 308 | * @throws \Exception |
||
| 309 | * |
||
| 310 | * @TODO: hmm? |
||
| 311 | */ |
||
| 312 | 14 | protected function getParentPublicKey($path) { |
|
| 329 | |||
| 330 | /** |
||
| 331 | * get address for the specified path |
||
| 332 | * |
||
| 333 | * @param string|BIP32Path $path |
||
| 334 | * @return string |
||
| 335 | */ |
||
| 336 | 13 | public function getAddressByPath($path) { |
|
| 347 | |||
| 348 | /** |
||
| 349 | * @param string $path |
||
| 350 | * @return WalletScript |
||
| 351 | */ |
||
| 352 | 14 | public function getWalletScriptByPath($path) { |
|
| 364 | |||
| 365 | /** |
||
| 366 | * get address and redeemScript for specified path |
||
| 367 | * |
||
| 368 | * @param string $path |
||
| 369 | * @return array[string, ScriptInterface, ScriptInterface|null] [address, redeemScript, witnessScript] |
||
| 370 | */ |
||
| 371 | 14 | public function getRedeemScriptByPath($path) { |
|
| 378 | |||
| 379 | /** |
||
| 380 | * @param BIP32Key $key |
||
| 381 | * @param string|BIP32Path $path |
||
| 382 | * @return string |
||
| 383 | */ |
||
| 384 | protected function getAddressFromKey(BIP32Key $key, $path) { |
||
| 387 | |||
| 388 | /** |
||
| 389 | * @param BIP32Key $key |
||
| 390 | * @param string|BIP32Path $path |
||
| 391 | * @return WalletScript |
||
| 392 | * @throws \Exception |
||
| 393 | */ |
||
| 394 | 14 | protected function getWalletScriptFromKey(BIP32Key $key, $path) { |
|
| 418 | |||
| 419 | /** |
||
| 420 | * get the path (and redeemScript) to specified address |
||
| 421 | * |
||
| 422 | * @param string $address |
||
| 423 | * @return array |
||
| 424 | */ |
||
| 425 | public function getPathForAddress($address) { |
||
| 428 | |||
| 429 | /** |
||
| 430 | * @param string|BIP32Path $path |
||
| 431 | * @return BIP32Key |
||
| 432 | * @throws \Exception |
||
| 433 | */ |
||
| 434 | 14 | public function getBlocktrailPublicKey($path) { |
|
| 445 | |||
| 446 | /** |
||
| 447 | * generate a new derived key and return the new path and address for it |
||
| 448 | * |
||
| 449 | * @return string[] [path, address] |
||
| 450 | */ |
||
| 451 | 13 | public function getNewAddressPair() { |
|
| 457 | |||
| 458 | /** |
||
| 459 | * generate a new derived private key and return the new address for it |
||
| 460 | * |
||
| 461 | * @return string |
||
| 462 | */ |
||
| 463 | 10 | public function getNewAddress() { |
|
| 466 | |||
| 467 | /** |
||
| 468 | * get the balance for the wallet |
||
| 469 | * |
||
| 470 | * @return int[] [confirmed, unconfirmed] |
||
| 471 | */ |
||
| 472 | 9 | public function getBalance() { |
|
| 477 | |||
| 478 | /** |
||
| 479 | * do wallet discovery (slow) |
||
| 480 | * |
||
| 481 | * @param int $gap the gap setting to use for discovery |
||
| 482 | * @return int[] [confirmed, unconfirmed] |
||
| 483 | */ |
||
| 484 | 2 | public function doDiscovery($gap = 200) { |
|
| 489 | |||
| 490 | /** |
||
| 491 | * create, sign and send a transaction |
||
| 492 | * |
||
| 493 | * @param array $outputs [address => value, ] or [[address, value], ] or [['address' => address, 'value' => value], ] coins to send |
||
| 494 | * value should be INT |
||
| 495 | * @param string $changeAddress change address to use (autogenerated if NULL) |
||
| 496 | * @param bool $allowZeroConf |
||
| 497 | * @param bool $randomizeChangeIdx randomize the location of the change (for increased privacy / anonimity) |
||
| 498 | * @param string $feeStrategy |
||
| 499 | * @param null|int $forceFee set a fixed fee instead of automatically calculating the correct fee, not recommended! |
||
| 500 | * @return string the txid / transaction hash |
||
| 501 | * @throws \Exception |
||
| 502 | */ |
||
| 503 | 9 | public function pay(array $outputs, $changeAddress = null, $allowZeroConf = false, $randomizeChangeIdx = true, $feeStrategy = self::FEE_STRATEGY_OPTIMAL, $forceFee = null) { |
|
| 525 | |||
| 526 | /** |
||
| 527 | * determine max spendable from wallet after fees |
||
| 528 | * |
||
| 529 | * @param bool $allowZeroConf |
||
| 530 | * @param string $feeStrategy |
||
| 531 | * @param null|int $forceFee set a fixed fee instead of automatically calculating the correct fee, not recommended! |
||
| 532 | * @param int $outputCnt |
||
| 533 | * @return string |
||
| 534 | * @throws BlocktrailSDKException |
||
| 535 | */ |
||
| 536 | public function getMaxSpendable($allowZeroConf = false, $feeStrategy = self::FEE_STRATEGY_OPTIMAL, $forceFee = null, $outputCnt = 1) { |
||
| 539 | |||
| 540 | /** |
||
| 541 | * parse outputs into normalized struct |
||
| 542 | * |
||
| 543 | * @param array $outputs [address => value, ] or [[address, value], ] or [['address' => address, 'value' => value], ] |
||
| 544 | * @return array [['address' => address, 'value' => value], ] |
||
| 545 | */ |
||
| 546 | 10 | public static function normalizeOutputsStruct(array $outputs) { |
|
| 574 | |||
| 575 | /** |
||
| 576 | * 'fund' the txBuilder with UTXOs (modified in place) |
||
| 577 | * |
||
| 578 | * @param TransactionBuilder $txBuilder |
||
| 579 | * @param bool|true $lockUTXOs |
||
| 580 | * @param bool|false $allowZeroConf |
||
| 581 | * @param null|int $forceFee |
||
| 582 | * @return TransactionBuilder |
||
| 583 | */ |
||
| 584 | 11 | public function coinSelectionForTxBuilder(TransactionBuilder $txBuilder, $lockUTXOs = true, $allowZeroConf = false, $forceFee = null) { |
|
| 612 | |||
| 613 | /** |
||
| 614 | * build inputs and outputs lists for TransactionBuilder |
||
| 615 | * |
||
| 616 | * @param TransactionBuilder $txBuilder |
||
| 617 | * @return [TransactionInterface, SignInfo[]] |
||
| 618 | * @throws \Exception |
||
| 619 | */ |
||
| 620 | 7 | public function buildTx(TransactionBuilder $txBuilder) { |
|
| 708 | |||
| 709 | 7 | public function determineFeeAndChange(TransactionBuilder $txBuilder, $optimalFeePerKB, $lowPriorityFeePerKB) { |
|
| 765 | |||
| 766 | /** |
||
| 767 | * create, sign and send transction based on TransactionBuilder |
||
| 768 | * |
||
| 769 | * @param TransactionBuilder $txBuilder |
||
| 770 | * @param bool $apiCheckFee let the API check if the fee is correct |
||
| 771 | * @return string |
||
| 772 | * @throws \Exception |
||
| 773 | */ |
||
| 774 | 4 | public function sendTx(TransactionBuilder $txBuilder, $apiCheckFee = true) { |
|
| 779 | |||
| 780 | /** |
||
| 781 | * !! INTERNAL METHOD, public for testing purposes !! |
||
| 782 | * create, sign and send transction based on inputs and outputs |
||
| 783 | * |
||
| 784 | * @param Transaction $tx |
||
| 785 | * @param SignInfo[] $signInfo |
||
| 786 | * @param bool $apiCheckFee let the API check if the fee is correct |
||
| 787 | * @return string |
||
| 788 | * @throws \Exception |
||
| 789 | * @internal |
||
| 790 | */ |
||
| 791 | 4 | public function _sendTx(Transaction $tx, array $signInfo, $apiCheckFee = true) { |
|
| 813 | |||
| 814 | /** |
||
| 815 | * only supports estimating fee for 2of3 multsig UTXOs and P2PKH/P2SH outputs |
||
| 816 | * |
||
| 817 | * @todo: mark this as deprecated, insist on the utxo's or qualified scripts. |
||
| 818 | * @param int $utxoCnt number of unspent inputs in transaction |
||
| 819 | * @param int $outputCnt number of outputs in transaction |
||
| 820 | * @return float |
||
| 821 | * @access public reminder that people might use this! |
||
| 822 | */ |
||
| 823 | 1 | public static function estimateFee($utxoCnt, $outputCnt) { |
|
| 828 | |||
| 829 | /** |
||
| 830 | * @param int $size size in bytes |
||
| 831 | * @return int fee in satoshi |
||
| 832 | */ |
||
| 833 | 5 | public static function baseFeeForSize($size) { |
|
| 838 | |||
| 839 | /** |
||
| 840 | * @todo: variable varint |
||
| 841 | * @param int $txinSize |
||
| 842 | * @param int $txoutSize |
||
| 843 | * @return float |
||
| 844 | */ |
||
| 845 | 9 | public static function estimateSize($txinSize, $txoutSize) { |
|
| 848 | |||
| 849 | /** |
||
| 850 | * only supports estimating size for P2PKH/P2SH outputs |
||
| 851 | * |
||
| 852 | * @param int $outputCnt number of outputs in transaction |
||
| 853 | * @return float |
||
| 854 | */ |
||
| 855 | 2 | public static function estimateSizeOutputs($outputCnt) { |
|
| 858 | |||
| 859 | /** |
||
| 860 | * only supports estimating size for 2of3 multsig UTXOs |
||
| 861 | * |
||
| 862 | * @param int $utxoCnt number of unspent inputs in transaction |
||
| 863 | * @return float |
||
| 864 | */ |
||
| 865 | 3 | public static function estimateSizeUTXOs($utxoCnt) { |
|
| 901 | |||
| 902 | /** |
||
| 903 | * determine how much fee is required based on the inputs and outputs |
||
| 904 | * this is an estimation, not a proper 100% correct calculation |
||
| 905 | * |
||
| 906 | * @param UTXO[] $utxos |
||
| 907 | * @param array[] $outputs |
||
| 908 | * @param $feeStrategy |
||
| 909 | * @param $optimalFeePerKB |
||
| 910 | * @param $lowPriorityFeePerKB |
||
| 911 | * @return int |
||
| 912 | * @throws BlocktrailSDKException |
||
| 913 | */ |
||
| 914 | 7 | protected function determineFee($utxos, $outputs, $feeStrategy, $optimalFeePerKB, $lowPriorityFeePerKB) { |
|
| 932 | |||
| 933 | /** |
||
| 934 | * determine how much change is left over based on the inputs and outputs and the fee |
||
| 935 | * |
||
| 936 | * @param UTXO[] $utxos |
||
| 937 | * @param array[] $outputs |
||
| 938 | * @param int $fee |
||
| 939 | * @return int |
||
| 940 | */ |
||
| 941 | 7 | protected function determineChange($utxos, $outputs, $fee) { |
|
| 949 | |||
| 950 | /** |
||
| 951 | * sign a raw transaction with the private keys that we have |
||
| 952 | * |
||
| 953 | * @param Transaction $tx |
||
| 954 | * @param SignInfo[] $signInfo |
||
| 955 | * @return TransactionInterface |
||
| 956 | * @throws \Exception |
||
| 957 | */ |
||
| 958 | 4 | protected function signTransaction(Transaction $tx, array $signInfo) { |
|
| 959 | 4 | $signer = new Signer($tx, Bitcoin::getEcAdapter()); |
|
| 960 | |||
| 961 | 4 | assert(Util::all(function ($signInfo) { |
|
| 962 | 4 | return $signInfo instanceof SignInfo; |
|
| 963 | 4 | }, $signInfo), '$signInfo should be SignInfo[]'); |
|
| 964 | |||
| 965 | 4 | $sigHash = SigHash::ALL; |
|
| 966 | 4 | if ($this->network === "bitcoincash") { |
|
| 967 | $sigHash |= SigHash::BITCOINCASH; |
||
| 968 | $signer->redeemBitcoinCash(true); |
||
| 969 | } |
||
| 970 | |||
| 971 | 4 | foreach ($signInfo as $idx => $info) { |
|
| 972 | 4 | if ($info->mode === SignInfo::MODE_SIGN) { |
|
| 973 | // required SignInfo: path, redeemScript|witnessScript, output |
||
| 974 | 4 | $path = BIP32Path::path($info->path)->privatePath(); |
|
| 975 | 4 | $key = $this->primaryPrivateKey->buildKey($path)->key()->getPrivateKey(); |
|
| 976 | 4 | $signData = new SignData(); |
|
| 977 | 4 | if ($info->redeemScript) { |
|
| 978 | 4 | $signData->p2sh($info->redeemScript); |
|
| 979 | } |
||
| 980 | 4 | if ($info->witnessScript) { |
|
| 981 | 1 | $signData->p2wsh($info->witnessScript); |
|
| 982 | } |
||
| 983 | 4 | $input = $signer->input($idx, $info->output, $signData); |
|
| 984 | 4 | $input->sign($key, $sigHash); |
|
| 985 | } |
||
| 986 | } |
||
| 987 | |||
| 988 | 4 | return $signer->get(); |
|
| 989 | } |
||
| 990 | |||
| 991 | /** |
||
| 992 | * send the transaction using the API |
||
| 993 | * |
||
| 994 | * @param string|array $signed |
||
| 995 | * @param string[] $paths |
||
| 996 | * @param bool $checkFee |
||
| 997 | * @return string the complete raw transaction |
||
| 998 | * @throws \Exception |
||
| 999 | */ |
||
| 1000 | 4 | protected function sendTransaction($signed, $paths, $checkFee = false) { |
|
| 1003 | |||
| 1004 | /** |
||
| 1005 | * @param \array[] $outputs |
||
| 1006 | * @param bool $lockUTXO |
||
| 1007 | * @param bool $allowZeroConf |
||
| 1008 | * @param int|null|string $feeStrategy |
||
| 1009 | * @param null $forceFee |
||
| 1010 | * @return array |
||
| 1011 | */ |
||
| 1012 | 11 | public function coinSelection($outputs, $lockUTXO = true, $allowZeroConf = false, $feeStrategy = self::FEE_STRATEGY_OPTIMAL, $forceFee = null) { |
|
| 1021 | |||
| 1022 | 7 | public function getOptimalFeePerKB() { |
|
| 1029 | |||
| 1030 | 7 | public function getLowPriorityFeePerKB() { |
|
| 1037 | |||
| 1038 | 3 | public function updateFeePerKB() { |
|
| 1046 | |||
| 1047 | /** |
||
| 1048 | * delete the wallet |
||
| 1049 | * |
||
| 1050 | * @param bool $force ignore warnings (such as non-zero balance) |
||
| 1051 | * @return mixed |
||
| 1052 | * @throws \Exception |
||
| 1053 | */ |
||
| 1054 | 10 | public function deleteWallet($force = false) { |
|
| 1062 | |||
| 1063 | /** |
||
| 1064 | * create checksum to verify ownership of the master primary key |
||
| 1065 | * |
||
| 1066 | * @return string[] [address, signature] |
||
| 1067 | */ |
||
| 1068 | 10 | protected function createChecksumVerificationSignature() { |
|
| 1079 | |||
| 1080 | /** |
||
| 1081 | * setup a webhook for our wallet |
||
| 1082 | * |
||
| 1083 | * @param string $url URL to receive webhook events |
||
| 1084 | * @param string $identifier identifier for the webhook, defaults to WALLET-{$this->identifier} |
||
| 1085 | * @return array |
||
| 1086 | */ |
||
| 1087 | 1 | public function setupWebhook($url, $identifier = null) { |
|
| 1091 | |||
| 1092 | /** |
||
| 1093 | * @param string $identifier identifier for the webhook, defaults to WALLET-{$this->identifier} |
||
| 1094 | * @return mixed |
||
| 1095 | */ |
||
| 1096 | 1 | public function deleteWebhook($identifier = null) { |
|
| 1100 | |||
| 1101 | /** |
||
| 1102 | * lock a specific unspent output |
||
| 1103 | * |
||
| 1104 | * @param $txHash |
||
| 1105 | * @param $txIdx |
||
| 1106 | * @param int $ttl |
||
| 1107 | * @return bool |
||
| 1108 | */ |
||
| 1109 | public function lockUTXO($txHash, $txIdx, $ttl = 3) { |
||
| 1112 | |||
| 1113 | /** |
||
| 1114 | * unlock a specific unspent output |
||
| 1115 | * |
||
| 1116 | * @param $txHash |
||
| 1117 | * @param $txIdx |
||
| 1118 | * @return bool |
||
| 1119 | */ |
||
| 1120 | public function unlockUTXO($txHash, $txIdx) { |
||
| 1123 | |||
| 1124 | /** |
||
| 1125 | * get all transactions for the wallet (paginated) |
||
| 1126 | * |
||
| 1127 | * @param integer $page pagination: page number |
||
| 1128 | * @param integer $limit pagination: records per page (max 500) |
||
| 1129 | * @param string $sortDir pagination: sort direction (asc|desc) |
||
| 1130 | * @return array associative array containing the response |
||
| 1131 | */ |
||
| 1132 | 1 | public function transactions($page = 1, $limit = 20, $sortDir = 'asc') { |
|
| 1135 | |||
| 1136 | /** |
||
| 1137 | * get all addresses for the wallet (paginated) |
||
| 1138 | * |
||
| 1139 | * @param integer $page pagination: page number |
||
| 1140 | * @param integer $limit pagination: records per page (max 500) |
||
| 1141 | * @param string $sortDir pagination: sort direction (asc|desc) |
||
| 1142 | * @return array associative array containing the response |
||
| 1143 | */ |
||
| 1144 | 1 | public function addresses($page = 1, $limit = 20, $sortDir = 'asc') { |
|
| 1147 | |||
| 1148 | /** |
||
| 1149 | * get all UTXOs for the wallet (paginated) |
||
| 1150 | * |
||
| 1151 | * @param integer $page pagination: page number |
||
| 1152 | * @param integer $limit pagination: records per page (max 500) |
||
| 1153 | * @param string $sortDir pagination: sort direction (asc|desc) |
||
| 1154 | * @param boolean $zeroconf include zero confirmation transactions |
||
| 1155 | * @return array associative array containing the response |
||
| 1156 | */ |
||
| 1157 | 1 | public function utxos($page = 1, $limit = 20, $sortDir = 'asc', $zeroconf = true) { |
|
| 1160 | } |
||
| 1161 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.