Complex classes like MultichainClient 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 MultichainClient, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 13 | class MultichainClient  | 
            ||
| 14 | { | 
            ||
| 15 | |||
| 16 | /**  | 
            ||
| 17 | * The JsonRPC client used to call the multichain api  | 
            ||
| 18 | *  | 
            ||
| 19 | * @var \JsonRPC\Client  | 
            ||
| 20 | */  | 
            ||
| 21 | private $jsonRPCClient;  | 
            ||
| 22 | |||
| 23 | /**  | 
            ||
| 24 | * Default HTTP headers to send to the server  | 
            ||
| 25 | *  | 
            ||
| 26 | * @var array  | 
            ||
| 27 | */  | 
            ||
| 28 | private $headers = array(  | 
            ||
| 29 | 'User-Agent: Unofficial Multichain PHP Client <https://github.com/kunstmaan/libphp-multichain>',  | 
            ||
| 30 | );  | 
            ||
| 31 | |||
| 32 | /**  | 
            ||
| 33 | * Enable debug output to the php error log  | 
            ||
| 34 | *  | 
            ||
| 35 | * @var boolean  | 
            ||
| 36 | */  | 
            ||
| 37 | private $debug = false;  | 
            ||
| 38 | |||
| 39 | /**  | 
            ||
| 40 | * Constructor  | 
            ||
| 41 | *  | 
            ||
| 42 | * @param string $url Multichain JSON RPC url + port  | 
            ||
| 43 | * @param string $username Multichain JSON RPC username  | 
            ||
| 44 | * @param string $password Multichain JSON RPC password  | 
            ||
| 45 | * @param integer $timeout HTTP timeout  | 
            ||
| 46 | */  | 
            ||
| 47 | public function __construct($url, $username, $password, $timeout = 3)  | 
            ||
| 48 |     { | 
            ||
| 49 | $this->jsonRPCClient = new JsonRPCClient($url, $timeout, $this->headers);  | 
            ||
| 50 | $this->jsonRPCClient->authentication($username, $password);  | 
            ||
| 51 | }  | 
            ||
| 52 | |||
| 53 | /**  | 
            ||
| 54 | * @param boolean $debug  | 
            ||
| 55 | * @return MultichainClient  | 
            ||
| 56 | */  | 
            ||
| 57 | public function setDebug($debug)  | 
            ||
| 58 |     { | 
            ||
| 59 | $this->debug = $debug;  | 
            ||
| 60 | $this->jsonRPCClient->debug = $debug;  | 
            ||
| 61 | return $this;  | 
            ||
| 62 | }  | 
            ||
| 63 | |||
| 64 | /**  | 
            ||
| 65 | * Returns general information about this node and blockchain. MultiChain adds some fields to Bitcoin Core’s  | 
            ||
| 66 | * response, giving the blockchain’s chainname, description, protocol, peer-to-peer port. The setupblocks field  | 
            ||
| 67 | * gives the length in blocks of the setup phase in which some consensus constraints are not applied. The  | 
            ||
| 68 | * nodeaddress can be passed to other nodes for connecting.  | 
            ||
| 69 | *  | 
            ||
| 70 | * @return mixed  | 
            ||
| 71 | */  | 
            ||
| 72 | public function getInfo()  | 
            ||
| 76 | |||
| 77 | /**  | 
            ||
| 78 | * Returns information about the other nodes to which this node is connected. If this is a MultiChain blockchain,  | 
            ||
| 79 | * includes handshake and handshakelocal fields showing the remote and local address used during the handshaking  | 
            ||
| 80 | * for that connection.  | 
            ||
| 81 | *  | 
            ||
| 82 | * @return mixed  | 
            ||
| 83 | */  | 
            ||
| 84 | public function getPeerInfo()  | 
            ||
| 88 | |||
| 89 | /**  | 
            ||
| 90 | * Returns a new address for receiving payments. Omit the account parameter for the default account – see note below  | 
            ||
| 91 | *  | 
            ||
| 92 | * NOTE:  | 
            ||
| 93 | * Bitcoin Core has a notion of “accounts”, whereby each address can belong to specific account, which is credited  | 
            ||
| 94 | * when bitcoin is sent to that address. However the separation of accounts is not preserved when bitcoin is sent  | 
            ||
| 95 | * out, because the internal accounting mechanism has no relationship to the bitcoin protocol itself. Because of  | 
            ||
| 96 | * all the confusion this has caused, Bitcoin Core’s accounts mechanism is to be deprecated in future.  | 
            ||
| 97 | *  | 
            ||
| 98 | * MultiChain preserves the accounts mechanism and parameters for full backwards compatibility with the Bitcoin  | 
            ||
| 99 | * Core API. However, because of its forthcoming deprecation, the mechanism is not applied to native asset  | 
            ||
| 100 | * balances, all of which are considered as belonging to a single global account. Therefore we recommend not using  | 
            ||
| 101 | * accounts at all with MultiChain, and using "" for any account parameter in the API.  | 
            ||
| 102 | *  | 
            ||
| 103 | * To support multiple users in a single MultiChain node’s wallet, call getnewaddress to get a different address  | 
            ||
| 104 | * for each user. You should then use MultiChain’s *from* APIs, such as sendassetfrom and sendfromaddress, to  | 
            ||
| 105 | * control whose funds are spent in each transaction. Unlike bitcoin-style accounts, this method maps directly to  | 
            ||
| 106 | * the blockchain protocol.  | 
            ||
| 107 | *  | 
            ||
| 108 | * @param string $account  | 
            ||
| 109 | * @return mixed  | 
            ||
| 110 | */  | 
            ||
| 111 | public function getNewAddress($account = '')  | 
            ||
| 115 | |||
| 116 | /**  | 
            ||
| 117 | * Sends one or more assets to address, returning the txid. In Bitcoin Core, the amount field is the quantity of  | 
            ||
| 118 |      * the bitcoin currency. For MultiChain, an {"asset":qty, ...} object can be used for amount, in which each asset | 
            ||
| 119 | * is an asset name, ref or issuance txid, and each qty is the quantity of that asset to send (see native assets).  | 
            ||
| 120 | * Use "" as the asset inside this object to specify a quantity of the native blockchain currency. See also  | 
            ||
| 121 | * sendassettoaddress for sending a single asset and sendfromaddress to control the address whose funds are used.  | 
            ||
| 122 | *  | 
            ||
| 123 | * @param string $address  | 
            ||
| 124 | * @param string $amount  | 
            ||
| 125 | * @param string $comment  | 
            ||
| 126 | * @param string $commentTo  | 
            ||
| 127 | * @return mixed  | 
            ||
| 128 | */  | 
            ||
| 129 | public function sendToAddress($address, $amount, $comment = '', $commentTo = '')  | 
            ||
| 133 | |||
| 134 | /**  | 
            ||
| 135 | * Outputs a list of available API commands, including MultiChain-specific commands.  | 
            ||
| 136 | *  | 
            ||
| 137 | * @return mixed  | 
            ||
| 138 | */  | 
            ||
| 139 | public function help()  | 
            ||
| 143 | |||
| 144 | /**  | 
            ||
| 145 | * Adds to the atomic exchange transaction in hexstring given by a previous call to createrawexchange or  | 
            ||
| 146 | * appendrawexchange. This adds an offer to exchange the asset/s in output vout of transaction txid for qty units  | 
            ||
| 147 | * of asset, where asset is an asset name, ref or issuance txid. The txid and vout should generally be taken from  | 
            ||
| 148 | * the response to preparelockunspent or preparelockunspentfrom. Multiple items can be specified within the fourth  | 
            ||
| 149 | * parameter to request multiple assets. Returns a raw hexadecimal transaction in the hex field alongside a  | 
            ||
| 150 | * complete field stating whether the exchange is complete (i.e. balanced) or not. If complete, the transaction can  | 
            ||
| 151 | * be transmitted to the network using sendrawtransaction. If not, it can be passed to a further counterparty, who  | 
            ||
| 152 | * can call decoderawexchange and appendrawexchange as appropriate.  | 
            ||
| 153 | *  | 
            ||
| 154 | * @param $hexString  | 
            ||
| 155 | * @param $txId  | 
            ||
| 156 | * @param $vOut  | 
            ||
| 157 |      * @param $extra ({"asset":qty, ...}) | 
            ||
| 158 | * @return mixed  | 
            ||
| 159 | */  | 
            ||
| 160 | public function appendRawExchange($hexString, $txId, $vOut, $extra)  | 
            ||
| 164 | |||
| 165 | /**  | 
            ||
| 166 | * Adds a metadata output to the raw transaction in tx-hex given by a previous call to createrawtransaction. The  | 
            ||
| 167 | * metadata is specified in data-hex in hexadecimal form and added in a new OP_RETURN transaction output. The  | 
            ||
| 168 | * transaction can then be signed and transmitted to the network using signrawtransaction and sendrawtransaction.  | 
            ||
| 169 | *  | 
            ||
| 170 | * @param $txHex  | 
            ||
| 171 | * @param $dataHex  | 
            ||
| 172 | * @return mixed  | 
            ||
| 173 | */  | 
            ||
| 174 | public function appendRawMetadata($txHex, $dataHex)  | 
            ||
| 178 | |||
| 179 | /**  | 
            ||
| 180 | * Sends transactions to combine large groups of unspent outputs (UTXOs) belonging to the same address into a  | 
            ||
| 181 | * single unspent output, returning a list of txids. This can improve wallet performance, especially for miners in  | 
            ||
| 182 | * a chain with short block times and non-zero block rewards. Set addresses to a comma-separated list of addresses  | 
            ||
| 183 | * to combine outputs for, or * for all addresses in the wallet. Only combine outputs with at least minconf  | 
            ||
| 184 | * confirmations, and use between mininputs and maxinputs per transaction. A single call to combineunspent can  | 
            ||
| 185 | * create up to maxcombines transactions over up to maxtime seconds. See also the autocombine runtime parameters.  | 
            ||
| 186 | *  | 
            ||
| 187 | * @param string $addresses  | 
            ||
| 188 | * @param int $minConf  | 
            ||
| 189 | * @param int $maxCombines  | 
            ||
| 190 | * @param int $minInputs  | 
            ||
| 191 | * @param int $maxInputs  | 
            ||
| 192 | * @param int $maxTime  | 
            ||
| 193 | * @return mixed  | 
            ||
| 194 | */  | 
            ||
| 195 | public function combineUnspent($addresses = "*", $minConf = 1, $maxCombines = 1, $minInputs = 10, $maxInputs = 100, $maxTime = 30)  | 
            ||
| 199 | |||
| 200 | /**  | 
            ||
| 201 | * Creates a new atomic exchange transaction which offers to exchange the asset/s in output vout of transaction  | 
            ||
| 202 | * txid for qty units of asset, where asset is an asset name, ref or issuance txid. The txid and vout should  | 
            ||
| 203 | * generally be taken from the response to preparelockunspent or preparelockunspentfrom. Multiple items can be  | 
            ||
| 204 | * specified within the third parameter to request multiple assets. Returns a raw partial transaction in  | 
            ||
| 205 | * hexadecimal which can be passed to the counterparty, who can call decoderawexchange and appendrawexchange as  | 
            ||
| 206 | * appropriate.  | 
            ||
| 207 | *  | 
            ||
| 208 | * @param $txId  | 
            ||
| 209 | * @param $vOut  | 
            ||
| 210 | * @param $extra  | 
            ||
| 211 | * @return mixed  | 
            ||
| 212 | */  | 
            ||
| 213 | public function createRawExchange($txId, $vOut, $extra)  | 
            ||
| 217 | |||
| 218 | /**  | 
            ||
| 219 | * Decodes the raw exchange transaction in hexstring, given by a previous call to createrawexchange or  | 
            ||
| 220 | * appendrawexchange. Returns details on the offer represented by the exchange and its present state. The offer  | 
            ||
| 221 | * field in the response lists the quantity of native currency and/or assets which are being offered for exchange.  | 
            ||
| 222 | * The ask field lists the native currency and/or assets which are being asked for. The candisable field specifies  | 
            ||
| 223 | * whether this wallet can disable the exchange transaction by double-spending against one of its inputs. The  | 
            ||
| 224 | * cancomplete field specifies whether this wallet has the assets required to complete the exchange. The complete  | 
            ||
| 225 | * field specifies whether the exchange is already complete (i.e. balanced) and ready for sending. If verbose is  | 
            ||
| 226 | * true then all of the individual stages in the exchange are listed. Other fields relating to fees are only  | 
            ||
| 227 | * relevant for blockchains which use a native currency.  | 
            ||
| 228 | *  | 
            ||
| 229 | * @param $hexString  | 
            ||
| 230 | * @param bool $verbose  | 
            ||
| 231 | * @return mixed  | 
            ||
| 232 | */  | 
            ||
| 233 | public function decodeRawExchange($hexString, $verbose = false)  | 
            ||
| 237 | |||
| 238 | /**  | 
            ||
| 239 | * Sends a transaction to disable the offer of exchange in hexstring, returning the txid. This is achieved by  | 
            ||
| 240 | * spending one of the exchange transaction’s inputs and sending it back to the wallet. To check whether this can  | 
            ||
| 241 | * be used on an exchange transaction, check the candisable field of the output of decoderawexchange.  | 
            ||
| 242 | *  | 
            ||
| 243 | * @param $hexString  | 
            ||
| 244 | * @return mixed  | 
            ||
| 245 | */  | 
            ||
| 246 | public function disableRawTransaction($hexString)  | 
            ||
| 250 | |||
| 251 | /**  | 
            ||
| 252 | * Returns a list of all the asset balances for address in this node’s wallet, with at least minconf confirmations.  | 
            ||
| 253 | * Use includeLocked to include unspent outputs which have been locked, e.g. by a call to preparelockunspent.  | 
            ||
| 254 | *  | 
            ||
| 255 | * @param $address  | 
            ||
| 256 | * @param int $minConf  | 
            ||
| 257 | * @param bool $includeLocked  | 
            ||
| 258 | * @return mixed  | 
            ||
| 259 | */  | 
            ||
| 260 | public function getAddressBalances($address, $minConf = 1, $includeLocked = false)  | 
            ||
| 264 | |||
| 265 | /**  | 
            ||
| 266 | * Returns a list of addresses in this node’s wallet. Set verbose to true to get more information about each  | 
            ||
| 267 | * address, formatted like the output of the validateaddress command.  | 
            ||
| 268 | *  | 
            ||
| 269 | * @param bool $verbose  | 
            ||
| 270 | * @return mixed  | 
            ||
| 271 | */  | 
            ||
| 272 | public function getAddresses($verbose = false)  | 
            ||
| 276 | |||
| 277 | /**  | 
            ||
| 278 | * Provides information about transaction txid related to address in this node’s wallet, including how it affected  | 
            ||
| 279 | * that address’s balance. Use verbose to provide details of transaction inputs and outputs.  | 
            ||
| 280 | *  | 
            ||
| 281 | * @param $address  | 
            ||
| 282 | * @param $txId  | 
            ||
| 283 | * @param bool $verbose  | 
            ||
| 284 | * @return mixed  | 
            ||
| 285 | */  | 
            ||
| 286 | public function getAddressTransaction($address, $txId, $verbose = false)  | 
            ||
| 290 | |||
| 291 | /**  | 
            ||
| 292 | * Returns a list of all the asset balances for account in this node’s wallet, with at least minconf confirmations.  | 
            ||
| 293 | * Omit the account parameter or use "" for the default account – see note about accounts. Use includeWatchOnly to  | 
            ||
| 294 | * include the balance of watch-only addresses and includeLocked to include unspent outputs which have been locked,  | 
            ||
| 295 | * e.g. by a call to preparelockunspent.  | 
            ||
| 296 | *  | 
            ||
| 297 | * @param string $account  | 
            ||
| 298 | * @param int $minConf  | 
            ||
| 299 | * @param bool $includeWatchOnly  | 
            ||
| 300 | * @param bool $includeLocked  | 
            ||
| 301 | * @return mixed  | 
            ||
| 302 | */  | 
            ||
| 303 | public function getAssetBalances($account = "", $minConf = 1, $includeWatchOnly = false, $includeLocked = false)  | 
            ||
| 307 | |||
| 308 | /**  | 
            ||
| 309 | * Returns a list of all the asset balances in this node’s wallet, with at least minconf confirmations. Use  | 
            ||
| 310 | * includeWatchOnly to include the balance of watch-only addresses and includeLocked to include unspent outputs  | 
            ||
| 311 | * which have been locked, e.g. by a call to preparelockunspent.  | 
            ||
| 312 | *  | 
            ||
| 313 | * @param int $minConf  | 
            ||
| 314 | * @param bool $includeWatchOnly  | 
            ||
| 315 | * @param bool $includeLocked  | 
            ||
| 316 | * @return mixed  | 
            ||
| 317 | */  | 
            ||
| 318 | public function getTotalBalances($minConf = 1, $includeWatchOnly = false, $includeLocked = false)  | 
            ||
| 322 | |||
| 323 | /**  | 
            ||
| 324 | * Returns information about address including a check for its validity.  | 
            ||
| 325 | *  | 
            ||
| 326 | * @param $address  | 
            ||
| 327 | * @return mixed  | 
            ||
| 328 | */  | 
            ||
| 329 | public function validateAddress($address)  | 
            ||
| 333 | |||
| 334 | /**  | 
            ||
| 335 | * Provides information about transaction txid in this node’s wallet, including how it affected the node’s total  | 
            ||
| 336 | * balance. Use includeWatchOnly to consider watch-only addresses as if they belong to this wallet and verbose to  | 
            ||
| 337 | * provide details of transaction inputs and outputs.  | 
            ||
| 338 | *  | 
            ||
| 339 | * @param $txId  | 
            ||
| 340 | * @param bool $includeWatchOnly  | 
            ||
| 341 | * @param bool $verbose  | 
            ||
| 342 | * @return mixed  | 
            ||
| 343 | */  | 
            ||
| 344 | public function getWalletTransaction($txId, $includeWatchOnly = false, $verbose = false)  | 
            ||
| 348 | |||
| 349 | /**  | 
            ||
| 350 | * Grants permissions to addresses, where addresses is a comma-separated list of addresses and permissions is one  | 
            ||
| 351 | * of connect, send, receive, issue, mine, admin, or a comma-separated list thereof. If the chain uses a native  | 
            ||
| 352 | * currency, you can send some to each recipient using the native-amount parameter. Returns the txid of the  | 
            ||
| 353 | * transaction granting the permissions. For more information, see permissions management.  | 
            ||
| 354 | *  | 
            ||
| 355 | * @param $addresses  | 
            ||
| 356 | * @param $permissions  | 
            ||
| 357 | * @param int $nativeAmount  | 
            ||
| 358 | * @param string $comment  | 
            ||
| 359 | * @param string $commentTo  | 
            ||
| 360 | * @param int $startBlock  | 
            ||
| 361 | * @param null $endBlock  | 
            ||
| 362 | * @return mixed  | 
            ||
| 363 | */  | 
            ||
| 364 | public function grant($addresses, $permissions, $nativeAmount = 0, $comment = '', $commentTo = '', $startBlock = 0, $endBlock = null)  | 
            ||
| 368 | |||
| 369 | /**  | 
            ||
| 370 | * This works like grant, but with control over the from-address used to grant the permissions. If there are  | 
            ||
| 371 | * multiple addresses with administrator permissions on one node, this allows control over which address is used.  | 
            ||
| 372 | *  | 
            ||
| 373 | * @param $fromAddress  | 
            ||
| 374 | * @param $toAddresses  | 
            ||
| 375 | * @param $permissions  | 
            ||
| 376 | * @param int $nativeAmount  | 
            ||
| 377 | * @param string $comment  | 
            ||
| 378 | * @param string $commentTo  | 
            ||
| 379 | * @param int $startBlock  | 
            ||
| 380 | * @param null $endBlock  | 
            ||
| 381 | * @return mixed  | 
            ||
| 382 | */  | 
            ||
| 383 | public function grantFrom($fromAddress, $toAddresses, $permissions, $nativeAmount = 0, $comment = '', $commentTo = '', $startBlock = 0, $endBlock = null)  | 
            ||
| 387 | |||
| 388 | /**  | 
            ||
| 389 | * Creates a new asset name on the blockchain, sending the initial qty units to address. The smallest transactable  | 
            ||
| 390 | * unit is given by units, e.g. 0.01. If the chain uses a native currency, you can send some with the new asset  | 
            ||
| 391 | * using the native-amount parameter.  | 
            ||
| 392 | *  | 
            ||
| 393 | * @param $address  | 
            ||
| 394 | * @param $name  | 
            ||
| 395 | * @param $qty  | 
            ||
| 396 | * @param int $units  | 
            ||
| 397 | * @param int $nativeAmount  | 
            ||
| 398 | * @param null $custom  | 
            ||
| 399 | * @return mixed  | 
            ||
| 400 | */  | 
            ||
| 401 | public function issue($address, $name, $qty, $units = 1, $nativeAmount = 0, $custom = null)  | 
            ||
| 402 |     { | 
            ||
| 403 | $params = array($address, $name, $qty, $units, $nativeAmount);  | 
            ||
| 404 |         if (!is_null($custom)) { | 
            ||
| 405 | $params[] = $custom;  | 
            ||
| 406 | }  | 
            ||
| 407 |         return $this->jsonRPCClient->execute("issue", $params); | 
            ||
| 408 | }  | 
            ||
| 409 | |||
| 410 | /**  | 
            ||
| 411 | * This works like issue, but with control over the from-address used to issue the asset. If there are multiple  | 
            ||
| 412 | * addresses with asset issuing permissions on one node, this allows control over which address is used.  | 
            ||
| 413 | *  | 
            ||
| 414 | * @param $fromAddress  | 
            ||
| 415 | * @param $toAddress  | 
            ||
| 416 | * @param $name  | 
            ||
| 417 | * @param $qty  | 
            ||
| 418 | * @param int $units  | 
            ||
| 419 | * @param int $nativeAmount  | 
            ||
| 420 | * @param null $custom  | 
            ||
| 421 | * @return mixed  | 
            ||
| 422 | */  | 
            ||
| 423 | public function issueFrom($fromAddress, $toAddress, $name, $qty, $units = 1, $nativeAmount = 0, $custom = null)  | 
            ||
| 427 | |||
| 428 | /**  | 
            ||
| 429 | * Lists information about the count most recent transactions related to address in this node’s wallet, including  | 
            ||
| 430 | * how they affected that address’s balance. Use skip to go back further in history and verbose to provide details  | 
            ||
| 431 | * of transaction inputs and outputs.  | 
            ||
| 432 | *  | 
            ||
| 433 | * @param $address  | 
            ||
| 434 | * @param int $count  | 
            ||
| 435 | * @param int $skip  | 
            ||
| 436 | * @param bool $verbose  | 
            ||
| 437 | * @return mixed  | 
            ||
| 438 | */  | 
            ||
| 439 | public function listAddressTransactions($address, $count = 10, $skip = 0, $verbose = false)  | 
            ||
| 443 | |||
| 444 | /**  | 
            ||
| 445 | * Returns information about all assets issued on the blockchain. If an issuance txid  | 
            ||
| 446 | * (see native assets) is provided in asset, then information is only returned about that one asset.  | 
            ||
| 447 | *  | 
            ||
| 448 | * @param null $asset  | 
            ||
| 449 | * @return mixed  | 
            ||
| 450 | */  | 
            ||
| 451 | public function listAssets($asset = null)  | 
            ||
| 455 | |||
| 456 | /**  | 
            ||
| 457 | * Returns a list of all permissions currently granted to addresses. To list information about specific permissions  | 
            ||
| 458 | * only, set permissions to one of connect, send, receive, issue, mine, admin, or a comma-separated list thereof.  | 
            ||
| 459 | * Omit or pass all to list all permissions. Provide a comma-delimited list in addresses to list the permissions  | 
            ||
| 460 | * for particular addresses only or * for all addresses. If verbose is true, the admins output field lists the  | 
            ||
| 461 | * administrator/s who assigned the corresponding permission, and the pending field lists permission changes which  | 
            ||
| 462 | * are waiting to reach consensus.  | 
            ||
| 463 | *  | 
            ||
| 464 | * @param string $permissions  | 
            ||
| 465 | * @param string $addresses  | 
            ||
| 466 | * @param bool $verbose  | 
            ||
| 467 | * @return mixed  | 
            ||
| 468 | */  | 
            ||
| 469 | public function listPermissions($permissions = "all", $addresses = "*", $verbose = false)  | 
            ||
| 473 | |||
| 474 | /**  | 
            ||
| 475 | * Lists information about the count most recent transactions in this node’s wallet, including how they affected  | 
            ||
| 476 | * the node’s total balance. Use skip to go back further in history and includeWatchOnly to consider watch-only  | 
            ||
| 477 | * addresses as if they belong to this wallet. Use verbose to provide the details of transaction inputs and outputs.  | 
            ||
| 478 | * Note that unlike Bitcoin Core’s listtransactions command, the response contains one element per transaction,  | 
            ||
| 479 | * rather than one per transaction output.  | 
            ||
| 480 | *  | 
            ||
| 481 | * @param int $count  | 
            ||
| 482 | * @param int $skip  | 
            ||
| 483 | * @param bool $includeWatchOnly  | 
            ||
| 484 | * @param bool $verbose  | 
            ||
| 485 | * @return mixed  | 
            ||
| 486 | */  | 
            ||
| 487 | public function listWalletTransactions($count = 10, $skip = 0, $includeWatchOnly = false, $verbose = false)  | 
            ||
| 491 | |||
| 492 | /**  | 
            ||
| 493 | * Prepares an unspent transaction output (useful for building atomic exchange transactions) containing qty units  | 
            ||
| 494 | * of asset, where asset is an asset name, ref or issuance txid. Multiple items can be specified within the first  | 
            ||
| 495 | * parameter to include several assets within the output. The output will be locked against automatic selection for  | 
            ||
| 496 | * spending unless the optional lock parameter is set to false. Returns the txid and vout of the prepared output.  | 
            ||
| 497 | *  | 
            ||
| 498 | * @param $assetsToLock  | 
            ||
| 499 | * @param bool $lock  | 
            ||
| 500 | * @return mixed  | 
            ||
| 501 | */  | 
            ||
| 502 | public function prepareLockUnspent($assetsToLock, $lock = true)  | 
            ||
| 506 | |||
| 507 | /**  | 
            ||
| 508 | * This works like preparelockunspent, but with control over the from-address whose funds are used to prepare the  | 
            ||
| 509 | * unspent transaction output. Any change from the transaction is send back to from-address.  | 
            ||
| 510 | *  | 
            ||
| 511 | * @param $fromAddress  | 
            ||
| 512 | * @param $assetsToLock  | 
            ||
| 513 | * @param bool $lock  | 
            ||
| 514 | * @return mixed  | 
            ||
| 515 | */  | 
            ||
| 516 | public function prepareLockUnspentFrom($fromAddress, $assetsToLock, $lock = true)  | 
            ||
| 520 | |||
| 521 | /**  | 
            ||
| 522 | * Revokes permissions from addresses, where addresses is a comma-separated list of addresses and permissions is  | 
            ||
| 523 | * one of connect, send, receive, issue, mine, admin, or a comma-separated list thereof. Equivalent to calling  | 
            ||
| 524 | * grant with start-block=0 and end-block=0. Returns the txid of transaction revoking the permissions. For more  | 
            ||
| 525 | * information, see permissions management.  | 
            ||
| 526 | *  | 
            ||
| 527 | * @param $addresses  | 
            ||
| 528 | * @param $permissions  | 
            ||
| 529 | * @param int $nativeAmount  | 
            ||
| 530 | * @param string $comment  | 
            ||
| 531 | * @param string $commentTo  | 
            ||
| 532 | * @return mixed  | 
            ||
| 533 | */  | 
            ||
| 534 | public function revoke($addresses, $permissions, $nativeAmount = 0, $comment = '', $commentTo = '')  | 
            ||
| 538 | |||
| 539 | /**  | 
            ||
| 540 | * This works like revoke, but with control over the from-address used to revoke the permissions. If there are  | 
            ||
| 541 | * multiple addresses with administrator permissions on one node, this allows control over which address is used.  | 
            ||
| 542 | *  | 
            ||
| 543 | * @param $fromAddress  | 
            ||
| 544 | * @param $toAddresses  | 
            ||
| 545 | * @param $permissions  | 
            ||
| 546 | * @param int $nativeAmount  | 
            ||
| 547 | * @param string $comment  | 
            ||
| 548 | * @param string $commentTo  | 
            ||
| 549 | * @return mixed  | 
            ||
| 550 | */  | 
            ||
| 551 | public function revokeFrom($fromAddress, $toAddresses, $permissions, $nativeAmount = 0, $comment = '', $commentTo = '')  | 
            ||
| 555 | |||
| 556 | /**  | 
            ||
| 557 | * This works like sendassettoaddress, but with control over the from-address whose funds are used. Any change from  | 
            ||
| 558 | * the transaction is sent back to from-address. See also sendfromaddress for sending multiple assets in one  | 
            ||
| 559 | * transaction.  | 
            ||
| 560 | *  | 
            ||
| 561 | * @param $fromAddress  | 
            ||
| 562 | * @param $toAddress  | 
            ||
| 563 | * @param $asset  | 
            ||
| 564 | * @param $qty  | 
            ||
| 565 | * @param null $nativeAmount  | 
            ||
| 566 | * @param string $comment  | 
            ||
| 567 | * @param string $commentTo  | 
            ||
| 568 | * @return mixed  | 
            ||
| 569 | */  | 
            ||
| 570 | public function sendAssetFrom($fromAddress, $toAddress, $asset, $qty, $nativeAmount = null, $comment = '', $commentTo = '')  | 
            ||
| 571 |     { | 
            ||
| 572 | $nativeAmount = $this->findDefaultMinimumPerOutput($nativeAmount);  | 
            ||
| 573 |         return $this->jsonRPCClient->execute("sendassetfrom", array($fromAddress, $toAddress, $asset, $qty, $nativeAmount, $comment, $commentTo)); | 
            ||
| 574 | }  | 
            ||
| 575 | |||
| 576 | /**  | 
            ||
| 577 | * Returns a list of all the parameters of this blockchain, reflecting the content of its params.dat file.  | 
            ||
| 578 | *  | 
            ||
| 579 | * @return mixed  | 
            ||
| 580 | */  | 
            ||
| 581 | public function getBlockchainParams()  | 
            ||
| 585 | |||
| 586 | /**  | 
            ||
| 587 | * Sends qty of asset to address, returning the txid. The asset can be specified using its name, ref or issuance  | 
            ||
| 588 | * txid – see native assets for more information. See also sendassetfrom to control the address whose funds are  | 
            ||
| 589 | * used, sendtoaddress for sending multiple assets in one transaction, and sendfromaddress to combine both of these.  | 
            ||
| 590 | *  | 
            ||
| 591 | * @param $address  | 
            ||
| 592 | * @param $asset  | 
            ||
| 593 | * @param $qty  | 
            ||
| 594 | * @param null $nativeAmount  | 
            ||
| 595 | * @param string $comment  | 
            ||
| 596 | * @param string $commentTo  | 
            ||
| 597 | * @return mixed  | 
            ||
| 598 | */  | 
            ||
| 599 | public function sendAssetToAddress($address, $asset, $qty, $nativeAmount = null, $comment = '', $commentTo = '')  | 
            ||
| 600 |     { | 
            ||
| 601 | $nativeAmount = $this->findDefaultMinimumPerOutput($nativeAmount);  | 
            ||
| 602 |         return $this->jsonRPCClient->execute("sendassettoaddress", array($address, $asset, $qty, $nativeAmount, $comment, $commentTo)); | 
            ||
| 603 | }  | 
            ||
| 604 | |||
| 605 | /**  | 
            ||
| 606 | * This works like sendtoaddress, but with control over the from-address whose funds are used. Any  | 
            ||
| 607 | * change from the transaction is sent back to from-address.  | 
            ||
| 608 | *  | 
            ||
| 609 | * @param $fromAddress  | 
            ||
| 610 | * @param $toAddress  | 
            ||
| 611 | * @param $amount  | 
            ||
| 612 | * @param string $comment  | 
            ||
| 613 | * @param string $commentTo  | 
            ||
| 614 | * @return mixed  | 
            ||
| 615 | */  | 
            ||
| 616 | public function sendFromAddress($fromAddress, $toAddress, $amount, $comment = '', $commentTo = '')  | 
            ||
| 620 | |||
| 621 | /**  | 
            ||
| 622 | * This works like sendtoaddress (listed above), but includes the data-hex hexadecimal metadata in an additional  | 
            ||
| 623 | * OP_RETURN transaction output.  | 
            ||
| 624 | *  | 
            ||
| 625 | * @param $address  | 
            ||
| 626 | * @param $amount  | 
            ||
| 627 | * @param $dataHex  | 
            ||
| 628 | * @return mixed  | 
            ||
| 629 | */  | 
            ||
| 630 | public function sendWithMetadata($address, $amount, $dataHex)  | 
            ||
| 634 | |||
| 635 | /**  | 
            ||
| 636 | * This works like sendtoaddress (listed above), but with control over the from-address whose funds are used, and  | 
            ||
| 637 | * with the data-hex hexadecimal metadata added in an additional OP_RETURN transaction output. Any change from the  | 
            ||
| 638 | * transaction is sent back to from-address.  | 
            ||
| 639 | *  | 
            ||
| 640 | * @param $fromAddress  | 
            ||
| 641 | * @param $toAddress  | 
            ||
| 642 | * @param $amount  | 
            ||
| 643 | * @param $dataHex  | 
            ||
| 644 | * @return mixed  | 
            ||
| 645 | */  | 
            ||
| 646 | public function sendWithMetadataFrom($fromAddress, $toAddress, $amount, $dataHex)  | 
            ||
| 650 | |||
| 651 | /**  | 
            ||
| 652 | * Creates a transaction spending the specified inputs, sending to the given addresses. In Bitcoin Core, each  | 
            ||
| 653 |      * amount field is a quantity of the bitcoin currency. For MultiChain, an {"asset":qty, ...} object can be used for | 
            ||
| 654 | * amount, in which each asset is an asset name, ref or issuance txid, and each qty is the quantity of that asset  | 
            ||
| 655 | * to send (see native assets). Use "" as the asset inside this object to specify a quantity of the native  | 
            ||
| 656 | * blockchain currency.  | 
            ||
| 657 | *  | 
            ||
| 658 | * @param $inputs  | 
            ||
| 659 | * @param $addresses  | 
            ||
| 660 | * @return mixed  | 
            ||
| 661 | */  | 
            ||
| 662 | public function createRawTransaction($inputs, $addresses)  | 
            ||
| 666 | |||
| 667 | /**  | 
            ||
| 668 | * Returns a JSON object describing the serialized transaction in hexstring. For a MultiChain blockchain, each  | 
            ||
| 669 | * transaction output includes assets and permissions fields listing any assets or permission changes encoded  | 
            ||
| 670 | * within that output. There will also be a data field listing the content of any OP_RETURN outputs in the  | 
            ||
| 671 | * transaction.  | 
            ||
| 672 | *  | 
            ||
| 673 | * @param $hexString  | 
            ||
| 674 | * @return mixed  | 
            ||
| 675 | */  | 
            ||
| 676 | public function decodeRawTransaction($hexString)  | 
            ||
| 680 | |||
| 681 | /**  | 
            ||
| 682 | * Returns information about the block with hash. If this is a MultiChain blockchain and format is true or omitted,  | 
            ||
| 683 | * then the output includes a field miner showing the address of the miner of the block.  | 
            ||
| 684 | *  | 
            ||
| 685 | * @param $hash  | 
            ||
| 686 | * @param bool $format  | 
            ||
| 687 | * @return mixed  | 
            ||
| 688 | */  | 
            ||
| 689 | public function getBlock($hash, $format = true)  | 
            ||
| 693 | |||
| 694 | /**  | 
            ||
| 695 | * If verbose is 1, returns a JSON object describing transaction txid. For a MultiChain blockchain, each transaction  | 
            ||
| 696 | * output includes assets and permissions fields listing any assets or permission changes encoded within that  | 
            ||
| 697 | * output. There will also be a data field listing the content of any OP_RETURN outputs in the transaction.  | 
            ||
| 698 | *  | 
            ||
| 699 | * @param $txId  | 
            ||
| 700 | * @param int $verbose  | 
            ||
| 701 | * @return mixed  | 
            ||
| 702 | */  | 
            ||
| 703 | public function getRawTransaction($txId, $verbose = 0)  | 
            ||
| 707 | |||
| 708 | /**  | 
            ||
| 709 | * Returns details about an unspent transaction output vout of txid. For a MultiChain blockchain, includes assets  | 
            ||
| 710 | * and permissions fields listing any assets or permission changes encoded within the output. Set confirmed to true  | 
            ||
| 711 | * to include unconfirmed transaction outputs.  | 
            ||
| 712 | *  | 
            ||
| 713 | * @param $txId  | 
            ||
| 714 | * @param $vOut  | 
            ||
| 715 | * @param bool $unconfirmed  | 
            ||
| 716 | * @return mixed  | 
            ||
| 717 | */  | 
            ||
| 718 | public function getTxOut($txId, $vOut, $unconfirmed = false)  | 
            ||
| 722 | |||
| 723 | /**  | 
            ||
| 724 | * Returns a list of unspent transaction outputs in the wallet, with between minconf and maxconf confirmations. For  | 
            ||
| 725 | * a MultiChain blockchain, each transaction output includes assets and permissions fields listing any assets or  | 
            ||
| 726 | * permission changes encoded within that output. If addresses is provided, only outputs which pay an address in  | 
            ||
| 727 | * this array will be included.  | 
            ||
| 728 | *  | 
            ||
| 729 | * @param int $minConf  | 
            ||
| 730 | * @param int $maxConf  | 
            ||
| 731 | * @param null $addresses  | 
            ||
| 732 | * @return mixed  | 
            ||
| 733 | */  | 
            ||
| 734 | public function listUnspent($minConf = 1, $maxConf = 999999, $addresses = null)  | 
            ||
| 738 | |||
| 739 | /**  | 
            ||
| 740 | * @param $nativeAmount  | 
            ||
| 741 | * @return mixed  | 
            ||
| 742 | */  | 
            ||
| 743 | private function findDefaultMinimumPerOutput($nativeAmount)  | 
            ||
| 752 | |||
| 753 | /**  | 
            ||
| 754 | * Submits raw transaction (serialized, hex-encoded) to local node and network.  | 
            ||
| 755 | * Returns the transaction hash in hex  | 
            ||
| 756 | *  | 
            ||
| 757 | * @param $hex  | 
            ||
| 758 | * @param bool $allowHighFees  | 
            ||
| 759 | * @return mixed  | 
            ||
| 760 | */  | 
            ||
| 761 | public function sendRawTransaction($hex, $allowHighFees = false)  | 
            ||
| 765 | }  | 
            ||
| 766 |