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 | * @var NetworkInterface |
||
| 102 | */ |
||
| 103 | protected $networkParams; |
||
| 104 | |||
| 105 | /** |
||
| 106 | * testnet yes / no |
||
| 107 | * |
||
| 108 | * @var bool |
||
| 109 | */ |
||
| 110 | protected $testnet; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * cache of public keys, by path |
||
| 114 | * |
||
| 115 | * @var BIP32Key[] |
||
| 116 | */ |
||
| 117 | protected $pubKeys = []; |
||
| 118 | |||
| 119 | /** |
||
| 120 | * cache of address / redeemScript, by path |
||
| 121 | * |
||
| 122 | * @var string[][] [[address, redeemScript)], ] |
||
| 123 | */ |
||
| 124 | protected $derivations = []; |
||
| 125 | |||
| 126 | /** |
||
| 127 | * reverse cache of paths by address |
||
| 128 | * |
||
| 129 | * @var string[] |
||
| 130 | */ |
||
| 131 | protected $derivationsByAddress = []; |
||
| 132 | |||
| 133 | protected $checksum; |
||
| 134 | |||
| 135 | /** |
||
| 136 | * @var bool |
||
| 137 | */ |
||
| 138 | protected $locked = true; |
||
| 139 | |||
| 140 | /** |
||
| 141 | * @var bool |
||
| 142 | */ |
||
| 143 | protected $isSegwit = false; |
||
| 144 | |||
| 145 | /** |
||
| 146 | * @var int |
||
| 147 | */ |
||
| 148 | protected $chainIndex; |
||
| 149 | |||
| 150 | /** |
||
| 151 | * @var int |
||
| 152 | */ |
||
| 153 | protected $changeIndex; |
||
| 154 | |||
| 155 | protected $optimalFeePerKB; |
||
| 156 | protected $lowPriorityFeePerKB; |
||
| 157 | protected $feePerKBAge; |
||
| 158 | protected $allowedSignModes = [SignInfo::MODE_DONTSIGN, SignInfo::MODE_SIGN]; |
||
| 159 | |||
| 160 | /** |
||
| 161 | * @param BlocktrailSDKInterface $sdk SDK instance used to do requests |
||
| 162 | * @param string $identifier identifier of the wallet |
||
| 163 | * @param BIP32Key[] $primaryPublicKeys |
||
| 164 | * @param BIP32Key $backupPublicKey should be BIP32 master public key M/ |
||
| 165 | * @param BIP32Key[] $blocktrailPublicKeys |
||
| 166 | * @param int $keyIndex |
||
| 167 | * @param bool $segwit |
||
| 168 | * @param string $checksum |
||
| 169 | * @throws BlocktrailSDKException |
||
| 170 | */ |
||
| 171 | 22 | public function __construct(BlocktrailSDKInterface $sdk, $identifier, array $primaryPublicKeys, $backupPublicKey, array $blocktrailPublicKeys, $keyIndex, $segwit, $checksum) { |
|
| 172 | 22 | $this->sdk = $sdk; |
|
| 173 | 22 | $this->networkParams = $sdk->getNetworkParams(); |
|
|
|
|||
| 174 | |||
| 175 | 22 | $this->identifier = $identifier; |
|
| 176 | 22 | $this->backupPublicKey = BlocktrailSDK::normalizeBIP32Key($backupPublicKey, $this->networkParams->getNetwork()); |
|
| 177 | 22 | $this->primaryPublicKeys = BlocktrailSDK::normalizeBIP32KeyArray($primaryPublicKeys, $this->networkParams->getNetwork()); |
|
| 178 | 22 | $this->blocktrailPublicKeys = BlocktrailSDK::normalizeBIP32KeyArray($blocktrailPublicKeys, $this->networkParams->getNetwork()); |
|
| 179 | |||
| 180 | 22 | $this->keyIndex = $keyIndex; |
|
| 181 | 22 | $this->checksum = $checksum; |
|
| 182 | |||
| 183 | 22 | if ($this->networkParams->isNetwork("bitcoin")) { |
|
| 184 | 22 | if ($segwit) { |
|
| 185 | 3 | $chainIdx = self::CHAIN_BTC_DEFAULT; |
|
| 186 | 3 | $changeIdx = self::CHAIN_BTC_SEGWIT; |
|
| 187 | } else { |
||
| 188 | 20 | $chainIdx = self::CHAIN_BTC_DEFAULT; |
|
| 189 | 22 | $changeIdx = self::CHAIN_BTC_DEFAULT; |
|
| 190 | } |
||
| 191 | } else { |
||
| 192 | if ($segwit && $this->networkParams->isNetwork("bitcoincash")) { |
||
| 193 | throw new BlocktrailSDKException("Received segwit flag for bitcoincash - abort"); |
||
| 194 | } |
||
| 195 | $chainIdx = self::CHAIN_BCC_DEFAULT; |
||
| 196 | $changeIdx = self::CHAIN_BCC_DEFAULT; |
||
| 197 | } |
||
| 198 | |||
| 199 | 22 | $this->isSegwit = (bool) $segwit; |
|
| 200 | 22 | $this->chainIndex = $chainIdx; |
|
| 201 | 22 | $this->changeIndex = $changeIdx; |
|
| 202 | 22 | } |
|
| 203 | |||
| 204 | /** |
||
| 205 | * @param int|null $chainIndex |
||
| 206 | * @return WalletPath |
||
| 207 | * @throws BlocktrailSDKException |
||
| 208 | */ |
||
| 209 | 14 | protected function getWalletPath($chainIndex = null) { |
|
| 210 | 14 | if ($chainIndex === null) { |
|
| 211 | 12 | return WalletPath::create($this->keyIndex, $this->chainIndex); |
|
| 212 | } else { |
||
| 213 | 6 | if (!is_int($chainIndex)) { |
|
| 214 | 1 | throw new BlocktrailSDKException("Chain index is invalid - should be an integer"); |
|
| 215 | } |
||
| 216 | 5 | return WalletPath::create($this->keyIndex, $chainIndex); |
|
| 217 | } |
||
| 218 | } |
||
| 219 | |||
| 220 | /** |
||
| 221 | * @return bool |
||
| 222 | */ |
||
| 223 | 3 | public function isSegwit() { |
|
| 224 | 3 | return $this->isSegwit; |
|
| 225 | } |
||
| 226 | |||
| 227 | /** |
||
| 228 | * return the wallet identifier |
||
| 229 | * |
||
| 230 | * @return string |
||
| 231 | */ |
||
| 232 | 10 | public function getIdentifier() { |
|
| 233 | 10 | return $this->identifier; |
|
| 234 | } |
||
| 235 | |||
| 236 | /** |
||
| 237 | * Returns the wallets backup public key |
||
| 238 | * |
||
| 239 | * @return [xpub, path] |
||
| 240 | */ |
||
| 241 | 1 | public function getBackupKey() { |
|
| 242 | 1 | return $this->backupPublicKey->tuple(); |
|
| 243 | } |
||
| 244 | |||
| 245 | /** |
||
| 246 | * return list of Blocktrail co-sign extended public keys |
||
| 247 | * |
||
| 248 | * @return array[] [ [xpub, path] ] |
||
| 249 | */ |
||
| 250 | 5 | public function getBlocktrailPublicKeys() { |
|
| 251 | return array_map(function (BIP32Key $key) { |
||
| 252 | 5 | return $key->tuple(); |
|
| 253 | 5 | }, $this->blocktrailPublicKeys); |
|
| 254 | } |
||
| 255 | |||
| 256 | /** |
||
| 257 | * check if wallet is locked |
||
| 258 | * |
||
| 259 | * @return bool |
||
| 260 | */ |
||
| 261 | 10 | public function isLocked() { |
|
| 264 | |||
| 265 | /** |
||
| 266 | * upgrade wallet to different blocktrail cosign key |
||
| 267 | * |
||
| 268 | * @param $keyIndex |
||
| 269 | * @return bool |
||
| 270 | * @throws \Exception |
||
| 271 | */ |
||
| 272 | 5 | public function upgradeKeyIndex($keyIndex) { |
|
| 299 | |||
| 300 | /** |
||
| 301 | * get a new BIP32 derivation for the next (unused) address |
||
| 302 | * by requesting it from the API |
||
| 303 | * |
||
| 304 | * @return string |
||
| 305 | * @param int|null $chainIndex |
||
| 306 | * @throws \Exception |
||
| 307 | */ |
||
| 308 | 14 | protected function getNewDerivation($chainIndex = null) { |
|
| 340 | |||
| 341 | /** |
||
| 342 | * @param string|BIP32Path $path |
||
| 343 | * @return BIP32Key|false |
||
| 344 | * @throws \Exception |
||
| 345 | * |
||
| 346 | * @TODO: hmm? |
||
| 347 | */ |
||
| 348 | 16 | protected function getParentPublicKey($path) { |
|
| 365 | |||
| 366 | /** |
||
| 367 | * get address for the specified path |
||
| 368 | * |
||
| 369 | * @param string|BIP32Path $path |
||
| 370 | * @return string |
||
| 371 | */ |
||
| 372 | 13 | public function getAddressByPath($path) { |
|
| 383 | |||
| 384 | /** |
||
| 385 | * @param string $path |
||
| 386 | * @return WalletScript |
||
| 387 | */ |
||
| 388 | 16 | public function getWalletScriptByPath($path) { |
|
| 400 | |||
| 401 | /** |
||
| 402 | * get address and redeemScript for specified path |
||
| 403 | * |
||
| 404 | * @param string $path |
||
| 405 | * @return array[string, ScriptInterface, ScriptInterface|null] [address, redeemScript, witnessScript] |
||
| 406 | */ |
||
| 407 | 15 | public function getRedeemScriptByPath($path) { |
|
| 414 | |||
| 415 | /** |
||
| 416 | * @param BIP32Key $key |
||
| 417 | * @param string|BIP32Path $path |
||
| 418 | * @return string |
||
| 419 | */ |
||
| 420 | protected function getAddressFromKey(BIP32Key $key, $path) { |
||
| 423 | |||
| 424 | /** |
||
| 425 | * @param BIP32Key $key |
||
| 426 | * @param string|BIP32Path $path |
||
| 427 | * @return WalletScript |
||
| 428 | * @throws \Exception |
||
| 429 | */ |
||
| 430 | 16 | protected function getWalletScriptFromKey(BIP32Key $key, $path) { |
|
| 456 | |||
| 457 | /** |
||
| 458 | * get the path (and redeemScript) to specified address |
||
| 459 | * |
||
| 460 | * @param string $address |
||
| 461 | * @return array |
||
| 462 | */ |
||
| 463 | public function getPathForAddress($address) { |
||
| 466 | |||
| 467 | /** |
||
| 468 | * @param string|BIP32Path $path |
||
| 469 | * @return BIP32Key |
||
| 470 | * @throws \Exception |
||
| 471 | */ |
||
| 472 | 16 | public function getBlocktrailPublicKey($path) { |
|
| 483 | |||
| 484 | /** |
||
| 485 | * generate a new derived key and return the new path and address for it |
||
| 486 | * |
||
| 487 | * @param int|null $chainIndex |
||
| 488 | * @return string[] [path, address] |
||
| 489 | */ |
||
| 490 | 14 | public function getNewAddressPair($chainIndex = null) { |
|
| 496 | |||
| 497 | /** |
||
| 498 | * generate a new derived private key and return the new address for it |
||
| 499 | * |
||
| 500 | * @param int|null $chainIndex |
||
| 501 | * @return string |
||
| 502 | */ |
||
| 503 | 6 | public function getNewAddress($chainIndex = null) { |
|
| 506 | |||
| 507 | /** |
||
| 508 | * generate a new derived private key and return the new address for it |
||
| 509 | * |
||
| 510 | * @return string |
||
| 511 | */ |
||
| 512 | 4 | public function getNewChangeAddress() { |
|
| 515 | |||
| 516 | /** |
||
| 517 | * get the balance for the wallet |
||
| 518 | * |
||
| 519 | * @return int[] [confirmed, unconfirmed] |
||
| 520 | */ |
||
| 521 | 9 | public function getBalance() { |
|
| 526 | |||
| 527 | /** |
||
| 528 | * do wallet discovery (slow) |
||
| 529 | * |
||
| 530 | * @param int $gap the gap setting to use for discovery |
||
| 531 | * @return int[] [confirmed, unconfirmed] |
||
| 532 | */ |
||
| 533 | 2 | public function doDiscovery($gap = 200) { |
|
| 538 | |||
| 539 | /** |
||
| 540 | * @return TransactionBuilder |
||
| 541 | */ |
||
| 542 | 13 | public function createTransaction() { |
|
| 545 | |||
| 546 | /** |
||
| 547 | * create, sign and send a transaction |
||
| 548 | * |
||
| 549 | * @param array $outputs [address => value, ] or [[address, value], ] or [['address' => address, 'value' => value], ] coins to send |
||
| 550 | * value should be INT |
||
| 551 | * @param string $changeAddress change address to use (autogenerated if NULL) |
||
| 552 | * @param bool $allowZeroConf |
||
| 553 | * @param bool $randomizeChangeIdx randomize the location of the change (for increased privacy / anonimity) |
||
| 554 | * @param string $feeStrategy |
||
| 555 | * @param null|int $forceFee set a fixed fee instead of automatically calculating the correct fee, not recommended! |
||
| 556 | * @return string the txid / transaction hash |
||
| 557 | * @throws \Exception |
||
| 558 | */ |
||
| 559 | 9 | public function pay(array $outputs, $changeAddress = null, $allowZeroConf = false, $randomizeChangeIdx = true, $feeStrategy = self::FEE_STRATEGY_OPTIMAL, $forceFee = null) { |
|
| 581 | |||
| 582 | /** |
||
| 583 | * determine max spendable from wallet after fees |
||
| 584 | * |
||
| 585 | * @param bool $allowZeroConf |
||
| 586 | * @param string $feeStrategy |
||
| 587 | * @param null|int $forceFee set a fixed fee instead of automatically calculating the correct fee, not recommended! |
||
| 588 | * @param int $outputCnt |
||
| 589 | * @return string |
||
| 590 | * @throws BlocktrailSDKException |
||
| 591 | */ |
||
| 592 | public function getMaxSpendable($allowZeroConf = false, $feeStrategy = self::FEE_STRATEGY_OPTIMAL, $forceFee = null, $outputCnt = 1) { |
||
| 595 | |||
| 596 | /** |
||
| 597 | * parse outputs into normalized struct |
||
| 598 | * |
||
| 599 | * @param array $outputs [address => value, ] or [[address, value], ] or [['address' => address, 'value' => value], ] |
||
| 600 | * @return array [['address' => address, 'value' => value], ] |
||
| 601 | */ |
||
| 602 | 10 | public static function normalizeOutputsStruct(array $outputs) { |
|
| 630 | |||
| 631 | /** |
||
| 632 | * 'fund' the txBuilder with UTXOs (modified in place) |
||
| 633 | * |
||
| 634 | * @param TransactionBuilder $txBuilder |
||
| 635 | * @param bool|true $lockUTXOs |
||
| 636 | * @param bool|false $allowZeroConf |
||
| 637 | * @param null|int $forceFee |
||
| 638 | * @return TransactionBuilder |
||
| 639 | */ |
||
| 640 | 11 | public function coinSelectionForTxBuilder(TransactionBuilder $txBuilder, $lockUTXOs = true, $allowZeroConf = false, $forceFee = null) { |
|
| 668 | |||
| 669 | /** |
||
| 670 | * build inputs and outputs lists for TransactionBuilder |
||
| 671 | * |
||
| 672 | * @param TransactionBuilder $txBuilder |
||
| 673 | * @return [TransactionInterface, SignInfo[]] |
||
| 674 | * @throws \Exception |
||
| 675 | */ |
||
| 676 | 7 | public function buildTx(TransactionBuilder $txBuilder) { |
|
| 765 | |||
| 766 | 7 | public function determineFeeAndChange(TransactionBuilder $txBuilder, $optimalFeePerKB, $lowPriorityFeePerKB) { |
|
| 822 | |||
| 823 | /** |
||
| 824 | * create, sign and send transction based on TransactionBuilder |
||
| 825 | * |
||
| 826 | * @param TransactionBuilder $txBuilder |
||
| 827 | * @param bool $apiCheckFee let the API check if the fee is correct |
||
| 828 | * @return string |
||
| 829 | * @throws \Exception |
||
| 830 | */ |
||
| 831 | 4 | public function sendTx(TransactionBuilder $txBuilder, $apiCheckFee = true) { |
|
| 836 | |||
| 837 | /** |
||
| 838 | * !! INTERNAL METHOD, public for testing purposes !! |
||
| 839 | * create, sign and send transction based on inputs and outputs |
||
| 840 | * |
||
| 841 | * @param Transaction $tx |
||
| 842 | * @param SignInfo[] $signInfo |
||
| 843 | * @param bool $apiCheckFee let the API check if the fee is correct |
||
| 844 | * @return string |
||
| 845 | * @throws \Exception |
||
| 846 | * @internal |
||
| 847 | */ |
||
| 848 | 4 | public function _sendTx(Transaction $tx, array $signInfo, $apiCheckFee = true) { |
|
| 870 | |||
| 871 | /** |
||
| 872 | * only supports estimating fee for 2of3 multsig UTXOs and P2PKH/P2SH outputs |
||
| 873 | * |
||
| 874 | * @todo: mark this as deprecated, insist on the utxo's or qualified scripts. |
||
| 875 | * @param int $utxoCnt number of unspent inputs in transaction |
||
| 876 | * @param int $outputCnt number of outputs in transaction |
||
| 877 | * @return float |
||
| 878 | * @access public reminder that people might use this! |
||
| 879 | */ |
||
| 880 | 1 | public static function estimateFee($utxoCnt, $outputCnt) { |
|
| 885 | |||
| 886 | /** |
||
| 887 | * @param int $size size in bytes |
||
| 888 | * @return int fee in satoshi |
||
| 889 | */ |
||
| 890 | 5 | public static function baseFeeForSize($size) { |
|
| 895 | |||
| 896 | /** |
||
| 897 | * @todo: variable varint |
||
| 898 | * @todo: deprecate |
||
| 899 | * @param int $txinSize |
||
| 900 | * @param int $txoutSize |
||
| 901 | * @return float |
||
| 902 | */ |
||
| 903 | 2 | public static function estimateSize($txinSize, $txoutSize) { |
|
| 906 | |||
| 907 | /** |
||
| 908 | * only supports estimating size for P2PKH/P2SH outputs |
||
| 909 | * |
||
| 910 | * @param int $outputCnt number of outputs in transaction |
||
| 911 | * @return float |
||
| 912 | */ |
||
| 913 | 2 | public static function estimateSizeOutputs($outputCnt) { |
|
| 916 | |||
| 917 | /** |
||
| 918 | * only supports estimating size for 2of3 multsig UTXOs |
||
| 919 | * |
||
| 920 | * @param int $utxoCnt number of unspent inputs in transaction |
||
| 921 | * @return float |
||
| 922 | */ |
||
| 923 | 3 | public static function estimateSizeUTXOs($utxoCnt) { |
|
| 959 | |||
| 960 | /** |
||
| 961 | * determine how much fee is required based on the inputs and outputs |
||
| 962 | * this is an estimation, not a proper 100% correct calculation |
||
| 963 | * |
||
| 964 | * @param UTXO[] $utxos |
||
| 965 | * @param array[] $outputs |
||
| 966 | * @param $feeStrategy |
||
| 967 | * @param $optimalFeePerKB |
||
| 968 | * @param $lowPriorityFeePerKB |
||
| 969 | * @return int |
||
| 970 | * @throws BlocktrailSDKException |
||
| 971 | */ |
||
| 972 | 7 | protected function determineFee($utxos, $outputs, $feeStrategy, $optimalFeePerKB, $lowPriorityFeePerKB) { |
|
| 990 | |||
| 991 | /** |
||
| 992 | * determine how much change is left over based on the inputs and outputs and the fee |
||
| 993 | * |
||
| 994 | * @param UTXO[] $utxos |
||
| 995 | * @param array[] $outputs |
||
| 996 | * @param int $fee |
||
| 997 | * @return int |
||
| 998 | */ |
||
| 999 | 7 | protected function determineChange($utxos, $outputs, $fee) { |
|
| 1007 | |||
| 1008 | /** |
||
| 1009 | * sign a raw transaction with the private keys that we have |
||
| 1010 | * |
||
| 1011 | * @param Transaction $tx |
||
| 1012 | * @param SignInfo[] $signInfo |
||
| 1013 | * @return TransactionInterface |
||
| 1014 | * @throws \Exception |
||
| 1015 | */ |
||
| 1016 | 4 | protected function signTransaction(Transaction $tx, array $signInfo) { |
|
| 1048 | |||
| 1049 | /** |
||
| 1050 | * send the transaction using the API |
||
| 1051 | * |
||
| 1052 | * @param string|array $signed |
||
| 1053 | * @param string[] $paths |
||
| 1054 | * @param bool $checkFee |
||
| 1055 | * @return string the complete raw transaction |
||
| 1056 | * @throws \Exception |
||
| 1057 | */ |
||
| 1058 | 4 | protected function sendTransaction($signed, $paths, $checkFee = false) { |
|
| 1061 | |||
| 1062 | /** |
||
| 1063 | * @param \array[] $outputs |
||
| 1064 | * @param bool $lockUTXO |
||
| 1065 | * @param bool $allowZeroConf |
||
| 1066 | * @param int|null|string $feeStrategy |
||
| 1067 | * @param null $forceFee |
||
| 1068 | * @return array |
||
| 1069 | */ |
||
| 1070 | 11 | public function coinSelection($outputs, $lockUTXO = true, $allowZeroConf = false, $feeStrategy = self::FEE_STRATEGY_OPTIMAL, $forceFee = null) { |
|
| 1079 | |||
| 1080 | 7 | public function getOptimalFeePerKB() { |
|
| 1087 | |||
| 1088 | 7 | public function getLowPriorityFeePerKB() { |
|
| 1095 | |||
| 1096 | 3 | public function updateFeePerKB() { |
|
| 1104 | |||
| 1105 | /** |
||
| 1106 | * delete the wallet |
||
| 1107 | * |
||
| 1108 | * @param bool $force ignore warnings (such as non-zero balance) |
||
| 1109 | * @return mixed |
||
| 1110 | * @throws \Exception |
||
| 1111 | */ |
||
| 1112 | 10 | public function deleteWallet($force = false) { |
|
| 1120 | |||
| 1121 | /** |
||
| 1122 | * create checksum to verify ownership of the master primary key |
||
| 1123 | * |
||
| 1124 | * @return string[] [address, signature] |
||
| 1125 | */ |
||
| 1126 | 10 | protected function createChecksumVerificationSignature() { |
|
| 1137 | |||
| 1138 | /** |
||
| 1139 | * setup a webhook for our wallet |
||
| 1140 | * |
||
| 1141 | * @param string $url URL to receive webhook events |
||
| 1142 | * @param string $identifier identifier for the webhook, defaults to WALLET-{$this->identifier} |
||
| 1143 | * @return array |
||
| 1144 | */ |
||
| 1145 | 1 | public function setupWebhook($url, $identifier = null) { |
|
| 1149 | |||
| 1150 | /** |
||
| 1151 | * @param string $identifier identifier for the webhook, defaults to WALLET-{$this->identifier} |
||
| 1152 | * @return mixed |
||
| 1153 | */ |
||
| 1154 | 1 | public function deleteWebhook($identifier = null) { |
|
| 1158 | |||
| 1159 | /** |
||
| 1160 | * lock a specific unspent output |
||
| 1161 | * |
||
| 1162 | * @param $txHash |
||
| 1163 | * @param $txIdx |
||
| 1164 | * @param int $ttl |
||
| 1165 | * @return bool |
||
| 1166 | */ |
||
| 1167 | public function lockUTXO($txHash, $txIdx, $ttl = 3) { |
||
| 1170 | |||
| 1171 | /** |
||
| 1172 | * unlock a specific unspent output |
||
| 1173 | * |
||
| 1174 | * @param $txHash |
||
| 1175 | * @param $txIdx |
||
| 1176 | * @return bool |
||
| 1177 | */ |
||
| 1178 | public function unlockUTXO($txHash, $txIdx) { |
||
| 1181 | |||
| 1182 | /** |
||
| 1183 | * get all transactions for the wallet (paginated) |
||
| 1184 | * |
||
| 1185 | * @param integer $page pagination: page number |
||
| 1186 | * @param integer $limit pagination: records per page (max 500) |
||
| 1187 | * @param string $sortDir pagination: sort direction (asc|desc) |
||
| 1188 | * @return array associative array containing the response |
||
| 1189 | */ |
||
| 1190 | 1 | public function transactions($page = 1, $limit = 20, $sortDir = 'asc') { |
|
| 1193 | |||
| 1194 | /** |
||
| 1195 | * get all addresses for the wallet (paginated) |
||
| 1196 | * |
||
| 1197 | * @param integer $page pagination: page number |
||
| 1198 | * @param integer $limit pagination: records per page (max 500) |
||
| 1199 | * @param string $sortDir pagination: sort direction (asc|desc) |
||
| 1200 | * @return array associative array containing the response |
||
| 1201 | */ |
||
| 1202 | 1 | public function addresses($page = 1, $limit = 20, $sortDir = 'asc') { |
|
| 1205 | |||
| 1206 | /** |
||
| 1207 | * get all UTXOs for the wallet (paginated) |
||
| 1208 | * |
||
| 1209 | * @param integer $page pagination: page number |
||
| 1210 | * @param integer $limit pagination: records per page (max 500) |
||
| 1211 | * @param string $sortDir pagination: sort direction (asc|desc) |
||
| 1212 | * @param boolean $zeroconf include zero confirmation transactions |
||
| 1213 | * @return array associative array containing the response |
||
| 1214 | */ |
||
| 1215 | 1 | public function utxos($page = 1, $limit = 20, $sortDir = 'asc', $zeroconf = true) { |
|
| 1218 | } |
||
| 1219 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..