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 |
||
| 28 | abstract class Wallet implements WalletInterface { |
||
| 29 | |||
| 30 | const WALLET_VERSION_V1 = 'v1'; |
||
| 31 | const WALLET_VERSION_V2 = 'v2'; |
||
| 32 | const WALLET_VERSION_V3 = 'v3'; |
||
| 33 | |||
| 34 | const CHAIN_BTC_DEFAULT = 0; |
||
| 35 | const CHAIN_BCC_DEFAULT = 1; |
||
| 36 | const CHAIN_BTC_SEGWIT = 2; |
||
| 37 | |||
| 38 | const BASE_FEE = 10000; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * development / debug setting |
||
| 42 | * when getting a new derivation from the API, |
||
| 43 | * will verify address / redeeemScript with the values the API provides |
||
| 44 | */ |
||
| 45 | const VERIFY_NEW_DERIVATION = true; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @var BlocktrailSDKInterface |
||
| 49 | */ |
||
| 50 | protected $sdk; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var string |
||
| 54 | */ |
||
| 55 | protected $identifier; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * BIP32 master primary private key (m/) |
||
| 59 | * |
||
| 60 | * @var BIP32Key |
||
| 61 | */ |
||
| 62 | protected $primaryPrivateKey; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @var BIP32Key[] |
||
| 66 | */ |
||
| 67 | protected $primaryPublicKeys; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * BIP32 master backup public key (M/) |
||
| 71 | |||
| 72 | * @var BIP32Key |
||
| 73 | */ |
||
| 74 | protected $backupPublicKey; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * map of blocktrail BIP32 public keys |
||
| 78 | * keyed by key index |
||
| 79 | * path should be `M / key_index'` |
||
| 80 | * |
||
| 81 | * @var BIP32Key[] |
||
| 82 | */ |
||
| 83 | protected $blocktrailPublicKeys; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * the 'Blocktrail Key Index' that is used for new addresses |
||
| 87 | * |
||
| 88 | * @var int |
||
| 89 | */ |
||
| 90 | protected $keyIndex; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * 'bitcoin' |
||
| 94 | * |
||
| 95 | * @var string |
||
| 96 | */ |
||
| 97 | protected $network; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * testnet yes / no |
||
| 101 | * |
||
| 102 | * @var bool |
||
| 103 | */ |
||
| 104 | protected $testnet; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * cache of public keys, by path |
||
| 108 | * |
||
| 109 | * @var BIP32Key[] |
||
| 110 | */ |
||
| 111 | protected $pubKeys = []; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * cache of address / redeemScript, by path |
||
| 115 | * |
||
| 116 | * @var string[][] [[address, redeemScript)], ] |
||
| 117 | */ |
||
| 118 | protected $derivations = []; |
||
| 119 | |||
| 120 | /** |
||
| 121 | * reverse cache of paths by address |
||
| 122 | * |
||
| 123 | * @var string[] |
||
| 124 | */ |
||
| 125 | protected $derivationsByAddress = []; |
||
| 126 | |||
| 127 | protected $checksum; |
||
| 128 | |||
| 129 | /** |
||
| 130 | * @var bool |
||
| 131 | */ |
||
| 132 | protected $locked = true; |
||
| 133 | |||
| 134 | /** |
||
| 135 | * @var bool |
||
| 136 | */ |
||
| 137 | protected $isSegwit = false; |
||
| 138 | |||
| 139 | /** |
||
| 140 | * @var int |
||
| 141 | */ |
||
| 142 | protected $chainIndex; |
||
| 143 | |||
| 144 | /** |
||
| 145 | * @var int |
||
| 146 | */ |
||
| 147 | protected $changeIndex; |
||
| 148 | |||
| 149 | protected $optimalFeePerKB; |
||
| 150 | protected $lowPriorityFeePerKB; |
||
| 151 | protected $feePerKBAge; |
||
| 152 | protected $allowedSignModes = [SignInfo::MODE_DONTSIGN, SignInfo::MODE_SIGN]; |
||
| 153 | |||
| 154 | /** |
||
| 155 | * @param BlocktrailSDKInterface $sdk SDK instance used to do requests |
||
| 156 | * @param string $identifier identifier of the wallet |
||
| 157 | * @param BIP32Key[] $primaryPublicKeys |
||
| 158 | * @param BIP32Key $backupPublicKey should be BIP32 master public key M/ |
||
| 159 | * @param BIP32Key[] $blocktrailPublicKeys |
||
| 160 | * @param int $keyIndex |
||
| 161 | * @param string $network |
||
| 162 | * @param bool $testnet |
||
| 163 | * @param bool $segwit |
||
| 164 | * @param string $checksum |
||
| 165 | * @throws BlocktrailSDKException |
||
| 166 | */ |
||
| 167 | 21 | public function __construct(BlocktrailSDKInterface $sdk, $identifier, array $primaryPublicKeys, $backupPublicKey, array $blocktrailPublicKeys, $keyIndex, $network, $testnet, $segwit, $checksum) { |
|
| 200 | |||
| 201 | /** |
||
| 202 | * @param int|null $chainIndex |
||
| 203 | * @return WalletPath |
||
| 204 | */ |
||
| 205 | 12 | protected function getWalletPath($chainIndex = null) { |
|
| 212 | |||
| 213 | /** |
||
| 214 | * @return bool |
||
| 215 | */ |
||
| 216 | 3 | public function isSegwit() { |
|
| 219 | |||
| 220 | /** |
||
| 221 | * return the wallet identifier |
||
| 222 | * |
||
| 223 | * @return string |
||
| 224 | */ |
||
| 225 | 9 | public function getIdentifier() { |
|
| 228 | |||
| 229 | /** |
||
| 230 | * Returns the wallets backup public key |
||
| 231 | * |
||
| 232 | * @return [xpub, path] |
||
|
|
|||
| 233 | */ |
||
| 234 | 1 | public function getBackupKey() { |
|
| 237 | |||
| 238 | /** |
||
| 239 | * return list of Blocktrail co-sign extended public keys |
||
| 240 | * |
||
| 241 | * @return array[] [ [xpub, path] ] |
||
| 242 | */ |
||
| 243 | 4 | public function getBlocktrailPublicKeys() { |
|
| 248 | |||
| 249 | /** |
||
| 250 | * check if wallet is locked |
||
| 251 | * |
||
| 252 | * @return bool |
||
| 253 | */ |
||
| 254 | 10 | public function isLocked() { |
|
| 257 | |||
| 258 | /** |
||
| 259 | * upgrade wallet to different blocktrail cosign key |
||
| 260 | * |
||
| 261 | * @param $keyIndex |
||
| 262 | * @return bool |
||
| 263 | * @throws \Exception |
||
| 264 | */ |
||
| 265 | 5 | public function upgradeKeyIndex($keyIndex) { |
|
| 292 | |||
| 293 | /** |
||
| 294 | * get a new BIP32 derivation for the next (unused) address |
||
| 295 | * by requesting it from the API |
||
| 296 | * |
||
| 297 | * @return string |
||
| 298 | * @param int|null $chainIndex |
||
| 299 | * @throws \Exception |
||
| 300 | */ |
||
| 301 | 12 | protected function getNewDerivation($chainIndex = null) { |
|
| 333 | |||
| 334 | /** |
||
| 335 | * @param string|BIP32Path $path |
||
| 336 | * @return BIP32Key|false |
||
| 337 | * @throws \Exception |
||
| 338 | * |
||
| 339 | * @TODO: hmm? |
||
| 340 | */ |
||
| 341 | 15 | protected function getParentPublicKey($path) { |
|
| 358 | |||
| 359 | /** |
||
| 360 | * get address for the specified path |
||
| 361 | * |
||
| 362 | * @param string|BIP32Path $path |
||
| 363 | * @return string |
||
| 364 | */ |
||
| 365 | 12 | public function getAddressByPath($path) { |
|
| 376 | |||
| 377 | /** |
||
| 378 | * @param string $path |
||
| 379 | * @return WalletScript |
||
| 380 | */ |
||
| 381 | 15 | public function getWalletScriptByPath($path) { |
|
| 393 | |||
| 394 | /** |
||
| 395 | * get address and redeemScript for specified path |
||
| 396 | * |
||
| 397 | * @param string $path |
||
| 398 | * @return array[string, ScriptInterface, ScriptInterface|null] [address, redeemScript, witnessScript] |
||
| 399 | */ |
||
| 400 | 14 | public function getRedeemScriptByPath($path) { |
|
| 407 | |||
| 408 | /** |
||
| 409 | * @param BIP32Key $key |
||
| 410 | * @param string|BIP32Path $path |
||
| 411 | * @return string |
||
| 412 | */ |
||
| 413 | protected function getAddressFromKey(BIP32Key $key, $path) { |
||
| 416 | |||
| 417 | /** |
||
| 418 | * @param BIP32Key $key |
||
| 419 | * @param string|BIP32Path $path |
||
| 420 | * @return WalletScript |
||
| 421 | * @throws \Exception |
||
| 422 | */ |
||
| 423 | 15 | protected function getWalletScriptFromKey(BIP32Key $key, $path) { |
|
| 449 | |||
| 450 | /** |
||
| 451 | * get the path (and redeemScript) to specified address |
||
| 452 | * |
||
| 453 | * @param string $address |
||
| 454 | * @return array |
||
| 455 | */ |
||
| 456 | 1 | public function getPathForAddress($address) { |
|
| 459 | |||
| 460 | /** |
||
| 461 | * @param string|BIP32Path $path |
||
| 462 | * @return BIP32Key |
||
| 463 | * @throws \Exception |
||
| 464 | */ |
||
| 465 | 15 | public function getBlocktrailPublicKey($path) { |
|
| 476 | |||
| 477 | /** |
||
| 478 | * generate a new derived key and return the new path and address for it |
||
| 479 | * |
||
| 480 | * @param int|null $chainIndex |
||
| 481 | * @return string[] [path, address] |
||
| 482 | */ |
||
| 483 | 12 | public function getNewAddressPair($chainIndex = null) { |
|
| 489 | |||
| 490 | /** |
||
| 491 | * generate a new derived private key and return the new address for it |
||
| 492 | * |
||
| 493 | * @param int|null $chainIndex |
||
| 494 | * @return string |
||
| 495 | */ |
||
| 496 | 9 | public function getNewAddress($chainIndex = null) { |
|
| 499 | |||
| 500 | /** |
||
| 501 | * get the balance for the wallet |
||
| 502 | * |
||
| 503 | * @return int[] [confirmed, unconfirmed] |
||
| 504 | */ |
||
| 505 | 9 | public function getBalance() { |
|
| 510 | |||
| 511 | /** |
||
| 512 | * do wallet discovery (slow) |
||
| 513 | * |
||
| 514 | * @param int $gap the gap setting to use for discovery |
||
| 515 | * @return int[] [confirmed, unconfirmed] |
||
| 516 | */ |
||
| 517 | 2 | public function doDiscovery($gap = 200) { |
|
| 522 | |||
| 523 | /** |
||
| 524 | * create, sign and send a transaction |
||
| 525 | * |
||
| 526 | * @param array $outputs [address => value, ] or [[address, value], ] or [['address' => address, 'value' => value], ] coins to send |
||
| 527 | * value should be INT |
||
| 528 | * @param string $changeAddress change address to use (autogenerated if NULL) |
||
| 529 | * @param bool $allowZeroConf |
||
| 530 | * @param bool $randomizeChangeIdx randomize the location of the change (for increased privacy / anonimity) |
||
| 531 | * @param string $feeStrategy |
||
| 532 | * @param null|int $forceFee set a fixed fee instead of automatically calculating the correct fee, not recommended! |
||
| 533 | * @return string the txid / transaction hash |
||
| 534 | * @throws \Exception |
||
| 535 | */ |
||
| 536 | 9 | public function pay(array $outputs, $changeAddress = null, $allowZeroConf = false, $randomizeChangeIdx = true, $feeStrategy = self::FEE_STRATEGY_OPTIMAL, $forceFee = null) { |
|
| 558 | |||
| 559 | /** |
||
| 560 | * determine max spendable from wallet after fees |
||
| 561 | * |
||
| 562 | * @param bool $allowZeroConf |
||
| 563 | * @param string $feeStrategy |
||
| 564 | * @param null|int $forceFee set a fixed fee instead of automatically calculating the correct fee, not recommended! |
||
| 565 | * @param int $outputCnt |
||
| 566 | * @return string |
||
| 567 | * @throws BlocktrailSDKException |
||
| 568 | */ |
||
| 569 | public function getMaxSpendable($allowZeroConf = false, $feeStrategy = self::FEE_STRATEGY_OPTIMAL, $forceFee = null, $outputCnt = 1) { |
||
| 572 | |||
| 573 | /** |
||
| 574 | * parse outputs into normalized struct |
||
| 575 | * |
||
| 576 | * @param array $outputs [address => value, ] or [[address, value], ] or [['address' => address, 'value' => value], ] |
||
| 577 | * @return array [['address' => address, 'value' => value], ] |
||
| 578 | */ |
||
| 579 | 10 | public static function normalizeOutputsStruct(array $outputs) { |
|
| 607 | |||
| 608 | /** |
||
| 609 | * 'fund' the txBuilder with UTXOs (modified in place) |
||
| 610 | * |
||
| 611 | * @param TransactionBuilder $txBuilder |
||
| 612 | * @param bool|true $lockUTXOs |
||
| 613 | * @param bool|false $allowZeroConf |
||
| 614 | * @param null|int $forceFee |
||
| 615 | * @return TransactionBuilder |
||
| 616 | */ |
||
| 617 | 11 | public function coinSelectionForTxBuilder(TransactionBuilder $txBuilder, $lockUTXOs = true, $allowZeroConf = false, $forceFee = null) { |
|
| 645 | |||
| 646 | /** |
||
| 647 | * build inputs and outputs lists for TransactionBuilder |
||
| 648 | * |
||
| 649 | * @param TransactionBuilder $txBuilder |
||
| 650 | * @return [TransactionInterface, SignInfo[]] |
||
| 651 | * @throws \Exception |
||
| 652 | */ |
||
| 653 | 7 | public function buildTx(TransactionBuilder $txBuilder) { |
|
| 741 | |||
| 742 | 7 | public function determineFeeAndChange(TransactionBuilder $txBuilder, $optimalFeePerKB, $lowPriorityFeePerKB) { |
|
| 743 | 7 | $send = $txBuilder->getOutputs(); |
|
| 744 | 7 | $utxos = $txBuilder->getUtxos(); |
|
| 745 | |||
| 746 | 7 | $fee = $txBuilder->getFee(); |
|
| 747 | 7 | $change = null; |
|
| 748 | |||
| 749 | // if the fee is fixed we just need to calculate the change |
||
| 750 | 7 | if ($fee !== null) { |
|
| 751 | 2 | $change = $this->determineChange($utxos, $send, $fee); |
|
| 752 | |||
| 753 | // if change is not dust we need to add a change output |
||
| 754 | 2 | if ($change > Blocktrail::DUST) { |
|
| 755 | 1 | $send[] = ['address' => 'change', 'value' => $change]; |
|
| 756 | } else { |
||
| 757 | // if change is dust we do nothing (implicitly it's added to the fee) |
||
| 758 | 2 | $change = 0; |
|
| 759 | } |
||
| 760 | } else { |
||
| 761 | 7 | $fee = $this->determineFee($utxos, $send, $txBuilder->getFeeStrategy(), $optimalFeePerKB, $lowPriorityFeePerKB); |
|
| 762 | |||
| 763 | 7 | $change = $this->determineChange($utxos, $send, $fee); |
|
| 764 | |||
| 765 | 7 | if ($change > 0) { |
|
| 766 | 6 | $changeIdx = count($send); |
|
| 767 | // set dummy change output |
||
| 768 | 6 | $send[$changeIdx] = ['address' => 'change', 'value' => $change]; |
|
| 769 | |||
| 770 | // recaculate fee now that we know that we have a change output |
||
| 771 | 6 | $fee2 = $this->determineFee($utxos, $send, $txBuilder->getFeeStrategy(), $optimalFeePerKB, $lowPriorityFeePerKB); |
|
| 772 | |||
| 773 | // unset dummy change output |
||
| 774 | 6 | unset($send[$changeIdx]); |
|
| 775 | |||
| 776 | // if adding the change output made the fee bump up and the change is smaller than the fee |
||
| 777 | // then we're not doing change |
||
| 778 | 6 | if ($fee2 > $fee && $fee2 > $change) { |
|
| 779 | 2 | $change = 0; |
|
| 780 | } else { |
||
| 781 | 5 | $change = $this->determineChange($utxos, $send, $fee2); |
|
| 782 | |||
| 783 | // if change is not dust we need to add a change output |
||
| 784 | 5 | if ($change > Blocktrail::DUST) { |
|
| 785 | 5 | $send[$changeIdx] = ['address' => 'change', 'value' => $change]; |
|
| 786 | } else { |
||
| 787 | // if change is dust we do nothing (implicitly it's added to the fee) |
||
| 788 | $change = 0; |
||
| 789 | } |
||
| 790 | } |
||
| 791 | } |
||
| 792 | } |
||
| 793 | |||
| 794 | 7 | $fee = $this->determineFee($utxos, $send, $txBuilder->getFeeStrategy(), $optimalFeePerKB, $lowPriorityFeePerKB); |
|
| 795 | |||
| 796 | 7 | return [$fee, $change]; |
|
| 797 | } |
||
| 798 | |||
| 799 | /** |
||
| 800 | * create, sign and send transction based on TransactionBuilder |
||
| 801 | * |
||
| 802 | * @param TransactionBuilder $txBuilder |
||
| 803 | * @param bool $apiCheckFee let the API check if the fee is correct |
||
| 804 | * @return string |
||
| 805 | * @throws \Exception |
||
| 806 | */ |
||
| 807 | 4 | public function sendTx(TransactionBuilder $txBuilder, $apiCheckFee = true) { |
|
| 812 | |||
| 813 | /** |
||
| 814 | * !! INTERNAL METHOD, public for testing purposes !! |
||
| 815 | * create, sign and send transction based on inputs and outputs |
||
| 816 | * |
||
| 817 | * @param Transaction $tx |
||
| 818 | * @param SignInfo[] $signInfo |
||
| 819 | * @param bool $apiCheckFee let the API check if the fee is correct |
||
| 820 | * @return string |
||
| 821 | * @throws \Exception |
||
| 822 | * @internal |
||
| 823 | */ |
||
| 824 | 4 | public function _sendTx(Transaction $tx, array $signInfo, $apiCheckFee = true) { |
|
| 846 | |||
| 847 | /** |
||
| 848 | * only supports estimating fee for 2of3 multsig UTXOs and P2PKH/P2SH outputs |
||
| 849 | * |
||
| 850 | * @todo: mark this as deprecated, insist on the utxo's or qualified scripts. |
||
| 851 | * @param int $utxoCnt number of unspent inputs in transaction |
||
| 852 | * @param int $outputCnt number of outputs in transaction |
||
| 853 | * @return float |
||
| 854 | * @access public reminder that people might use this! |
||
| 855 | */ |
||
| 856 | 1 | public static function estimateFee($utxoCnt, $outputCnt) { |
|
| 861 | |||
| 862 | /** |
||
| 863 | * @param int $size size in bytes |
||
| 864 | * @return int fee in satoshi |
||
| 865 | */ |
||
| 866 | 5 | public static function baseFeeForSize($size) { |
|
| 871 | |||
| 872 | /** |
||
| 873 | * @todo: variable varint |
||
| 874 | * @todo: deprecate |
||
| 875 | * @param int $txinSize |
||
| 876 | * @param int $txoutSize |
||
| 877 | * @return float |
||
| 878 | */ |
||
| 879 | 2 | public static function estimateSize($txinSize, $txoutSize) { |
|
| 882 | |||
| 883 | /** |
||
| 884 | * only supports estimating size for P2PKH/P2SH outputs |
||
| 885 | * |
||
| 886 | * @param int $outputCnt number of outputs in transaction |
||
| 887 | * @return float |
||
| 888 | */ |
||
| 889 | 2 | public static function estimateSizeOutputs($outputCnt) { |
|
| 892 | |||
| 893 | /** |
||
| 894 | * only supports estimating size for 2of3 multsig UTXOs |
||
| 895 | * |
||
| 896 | * @param int $utxoCnt number of unspent inputs in transaction |
||
| 897 | * @return float |
||
| 898 | */ |
||
| 899 | 3 | public static function estimateSizeUTXOs($utxoCnt) { |
|
| 935 | |||
| 936 | /** |
||
| 937 | * determine how much fee is required based on the inputs and outputs |
||
| 938 | * this is an estimation, not a proper 100% correct calculation |
||
| 939 | * |
||
| 940 | * @param UTXO[] $utxos |
||
| 941 | * @param array[] $outputs |
||
| 942 | * @param $feeStrategy |
||
| 943 | * @param $optimalFeePerKB |
||
| 944 | * @param $lowPriorityFeePerKB |
||
| 945 | * @return int |
||
| 946 | * @throws BlocktrailSDKException |
||
| 947 | */ |
||
| 948 | 7 | protected function determineFee($utxos, $outputs, $feeStrategy, $optimalFeePerKB, $lowPriorityFeePerKB) { |
|
| 966 | |||
| 967 | /** |
||
| 968 | * determine how much change is left over based on the inputs and outputs and the fee |
||
| 969 | * |
||
| 970 | * @param UTXO[] $utxos |
||
| 971 | * @param array[] $outputs |
||
| 972 | * @param int $fee |
||
| 973 | * @return int |
||
| 974 | */ |
||
| 975 | 7 | protected function determineChange($utxos, $outputs, $fee) { |
|
| 983 | |||
| 984 | /** |
||
| 985 | * sign a raw transaction with the private keys that we have |
||
| 986 | * |
||
| 987 | * @param Transaction $tx |
||
| 988 | * @param SignInfo[] $signInfo |
||
| 989 | * @return TransactionInterface |
||
| 990 | * @throws \Exception |
||
| 991 | */ |
||
| 992 | 4 | protected function signTransaction(Transaction $tx, array $signInfo) { |
|
| 1024 | |||
| 1025 | /** |
||
| 1026 | * send the transaction using the API |
||
| 1027 | * |
||
| 1028 | * @param string|array $signed |
||
| 1029 | * @param string[] $paths |
||
| 1030 | * @param bool $checkFee |
||
| 1031 | * @return string the complete raw transaction |
||
| 1032 | * @throws \Exception |
||
| 1033 | */ |
||
| 1034 | 4 | protected function sendTransaction($signed, $paths, $checkFee = false) { |
|
| 1037 | |||
| 1038 | /** |
||
| 1039 | * @param \array[] $outputs |
||
| 1040 | * @param bool $lockUTXO |
||
| 1041 | * @param bool $allowZeroConf |
||
| 1042 | * @param int|null|string $feeStrategy |
||
| 1043 | * @param null $forceFee |
||
| 1044 | * @return array |
||
| 1045 | */ |
||
| 1046 | 11 | public function coinSelection($outputs, $lockUTXO = true, $allowZeroConf = false, $feeStrategy = self::FEE_STRATEGY_OPTIMAL, $forceFee = null) { |
|
| 1055 | |||
| 1056 | 7 | public function getOptimalFeePerKB() { |
|
| 1063 | |||
| 1064 | 7 | public function getLowPriorityFeePerKB() { |
|
| 1071 | |||
| 1072 | 3 | public function updateFeePerKB() { |
|
| 1080 | |||
| 1081 | /** |
||
| 1082 | * delete the wallet |
||
| 1083 | * |
||
| 1084 | * @param bool $force ignore warnings (such as non-zero balance) |
||
| 1085 | * @return mixed |
||
| 1086 | * @throws \Exception |
||
| 1087 | */ |
||
| 1088 | 10 | public function deleteWallet($force = false) { |
|
| 1096 | |||
| 1097 | /** |
||
| 1098 | * create checksum to verify ownership of the master primary key |
||
| 1099 | * |
||
| 1100 | * @return string[] [address, signature] |
||
| 1101 | */ |
||
| 1102 | 10 | protected function createChecksumVerificationSignature() { |
|
| 1113 | |||
| 1114 | /** |
||
| 1115 | * setup a webhook for our wallet |
||
| 1116 | * |
||
| 1117 | * @param string $url URL to receive webhook events |
||
| 1118 | * @param string $identifier identifier for the webhook, defaults to WALLET-{$this->identifier} |
||
| 1119 | * @return array |
||
| 1120 | */ |
||
| 1121 | 1 | public function setupWebhook($url, $identifier = null) { |
|
| 1125 | |||
| 1126 | /** |
||
| 1127 | * @param string $identifier identifier for the webhook, defaults to WALLET-{$this->identifier} |
||
| 1128 | * @return mixed |
||
| 1129 | */ |
||
| 1130 | 1 | public function deleteWebhook($identifier = null) { |
|
| 1134 | |||
| 1135 | /** |
||
| 1136 | * lock a specific unspent output |
||
| 1137 | * |
||
| 1138 | * @param $txHash |
||
| 1139 | * @param $txIdx |
||
| 1140 | * @param int $ttl |
||
| 1141 | * @return bool |
||
| 1142 | */ |
||
| 1143 | public function lockUTXO($txHash, $txIdx, $ttl = 3) { |
||
| 1146 | |||
| 1147 | /** |
||
| 1148 | * unlock a specific unspent output |
||
| 1149 | * |
||
| 1150 | * @param $txHash |
||
| 1151 | * @param $txIdx |
||
| 1152 | * @return bool |
||
| 1153 | */ |
||
| 1154 | public function unlockUTXO($txHash, $txIdx) { |
||
| 1157 | |||
| 1158 | /** |
||
| 1159 | * get all transactions for the wallet (paginated) |
||
| 1160 | * |
||
| 1161 | * @param integer $page pagination: page number |
||
| 1162 | * @param integer $limit pagination: records per page (max 500) |
||
| 1163 | * @param string $sortDir pagination: sort direction (asc|desc) |
||
| 1164 | * @return array associative array containing the response |
||
| 1165 | */ |
||
| 1166 | 1 | public function transactions($page = 1, $limit = 20, $sortDir = 'asc') { |
|
| 1169 | |||
| 1170 | /** |
||
| 1171 | * get all addresses for the wallet (paginated) |
||
| 1172 | * |
||
| 1173 | * @param integer $page pagination: page number |
||
| 1174 | * @param integer $limit pagination: records per page (max 500) |
||
| 1175 | * @param string $sortDir pagination: sort direction (asc|desc) |
||
| 1176 | * @return array associative array containing the response |
||
| 1177 | */ |
||
| 1178 | 1 | public function addresses($page = 1, $limit = 20, $sortDir = 'asc') { |
|
| 1181 | |||
| 1182 | /** |
||
| 1183 | * get all UTXOs 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 | * @param boolean $zeroconf include zero confirmation transactions |
||
| 1189 | * @return array associative array containing the response |
||
| 1190 | */ |
||
| 1191 | 1 | public function utxos($page = 1, $limit = 20, $sortDir = 'asc', $zeroconf = true) { |
|
| 1194 | } |
||
| 1195 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.