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) |
||
54 | |||
55 | /** |
||
56 | * @param boolean $debug |
||
57 | * @return MultichainClient |
||
58 | */ |
||
59 | public function setDebug($debug) |
||
68 | |||
69 | /** |
||
70 | * Returns general information about this node and blockchain. MultiChain adds some fields to Bitcoin Core’s |
||
71 | * response, giving the blockchain’s chainname, description, protocol, peer-to-peer port. The setupblocks field |
||
72 | * gives the length in blocks of the setup phase in which some consensus constraints are not applied. The |
||
73 | * nodeaddress can be passed to other nodes for connecting. |
||
74 | * |
||
75 | * @return mixed |
||
76 | */ |
||
77 | public function getInfo() |
||
81 | |||
82 | /** |
||
83 | * Returns information about the other nodes to which this node is connected. If this is a MultiChain blockchain, |
||
84 | * includes handshake and handshakelocal fields showing the remote and local address used during the handshaking |
||
85 | * for that connection. |
||
86 | * |
||
87 | * @return mixed |
||
88 | */ |
||
89 | public function getPeerInfo() |
||
93 | |||
94 | /** |
||
95 | * Returns a new address for receiving payments. Omit the account parameter for the default account – see note below |
||
96 | * |
||
97 | * NOTE: |
||
98 | * Bitcoin Core has a notion of “accounts”, whereby each address can belong to specific account, which is credited |
||
99 | * when bitcoin is sent to that address. However the separation of accounts is not preserved when bitcoin is sent |
||
100 | * out, because the internal accounting mechanism has no relationship to the bitcoin protocol itself. Because of |
||
101 | * all the confusion this has caused, Bitcoin Core’s accounts mechanism is to be deprecated in future. |
||
102 | * |
||
103 | * MultiChain preserves the accounts mechanism and parameters for full backwards compatibility with the Bitcoin |
||
104 | * Core API. However, because of its forthcoming deprecation, the mechanism is not applied to native asset |
||
105 | * balances, all of which are considered as belonging to a single global account. Therefore we recommend not using |
||
106 | * accounts at all with MultiChain, and using "" for any account parameter in the API. |
||
107 | * |
||
108 | * To support multiple users in a single MultiChain node’s wallet, call getnewaddress to get a different address |
||
109 | * for each user. You should then use MultiChain’s *from* APIs, such as sendassetfrom and sendfromaddress, to |
||
110 | * control whose funds are spent in each transaction. Unlike bitcoin-style accounts, this method maps directly to |
||
111 | * the blockchain protocol. |
||
112 | * |
||
113 | * @param string $account |
||
114 | * @return mixed |
||
115 | */ |
||
116 | public function getNewAddress($account = '') |
||
120 | |||
121 | /** |
||
122 | * Returns the private key associated with address in this node’s wallet. Use with caution – any node with access to this |
||
123 | * private key can perform any action restricted to the address, including granting permissions and spending funds. |
||
124 | * |
||
125 | * @param $address |
||
126 | * @return mixed |
||
127 | */ |
||
128 | public function dumpPrivateKey($address){ |
||
131 | |||
132 | /** |
||
133 | * Adds the privkey private key (as obtained from a prior call to dumpprivkey) to the wallet, together with its |
||
134 | * associated public address. If rescan is true, the entire blockchain is checked for transactions relating to |
||
135 | * all addresses in the wallet, including the added one. |
||
136 | * |
||
137 | * @param $privkey |
||
138 | * @param string $label |
||
139 | * @param bool $rescan |
||
140 | * @return mixed |
||
141 | */ |
||
142 | public function importPrivateKey($privkey, $label="", $rescan=true){ |
||
145 | |||
146 | /** |
||
147 | * Sends one or more assets to address, returning the txid. In Bitcoin Core, the amount field is the quantity of |
||
148 | * the bitcoin currency. For MultiChain, an {"asset":qty, ...} object can be used for amount, in which each asset |
||
149 | * is an asset name, ref or issuance txid, and each qty is the quantity of that asset to send (see native assets). |
||
150 | * Use "" as the asset inside this object to specify a quantity of the native blockchain currency. See also |
||
151 | * sendassettoaddress for sending a single asset and sendfromaddress to control the address whose funds are used. |
||
152 | * |
||
153 | * @param string $address |
||
154 | * @param string $amount |
||
155 | * @param string $comment |
||
156 | * @param string $commentTo |
||
157 | * @return mixed |
||
158 | */ |
||
159 | public function sendToAddress($address, $amount, $comment = '', $commentTo = '') |
||
163 | |||
164 | /** |
||
165 | * Outputs a list of available API commands, including MultiChain-specific commands. |
||
166 | * |
||
167 | * @return mixed |
||
168 | */ |
||
169 | public function help() |
||
173 | |||
174 | /** |
||
175 | * Adds to the atomic exchange transaction in hexstring given by a previous call to createrawexchange or |
||
176 | * appendrawexchange. This adds an offer to exchange the asset/s in output vout of transaction txid for qty units |
||
177 | * of asset, where asset is an asset name, ref or issuance txid. The txid and vout should generally be taken from |
||
178 | * the response to preparelockunspent or preparelockunspentfrom. Multiple items can be specified within the fourth |
||
179 | * parameter to request multiple assets. Returns a raw hexadecimal transaction in the hex field alongside a |
||
180 | * complete field stating whether the exchange is complete (i.e. balanced) or not. If complete, the transaction can |
||
181 | * be transmitted to the network using sendrawtransaction. If not, it can be passed to a further counterparty, who |
||
182 | * can call decoderawexchange and appendrawexchange as appropriate. |
||
183 | * |
||
184 | * @param $hexString |
||
185 | * @param $txId |
||
186 | * @param $vOut |
||
187 | * @param $extra ({"asset":qty, ...}) |
||
188 | * @return mixed |
||
189 | */ |
||
190 | public function appendRawExchange($hexString, $txId, $vOut, $extra) |
||
194 | |||
195 | /** |
||
196 | * Adds a metadata output to the raw transaction in tx-hex given by a previous call to createrawtransaction. The |
||
197 | * metadata is specified in data-hex in hexadecimal form and added in a new OP_RETURN transaction output. The |
||
198 | * transaction can then be signed and transmitted to the network using signrawtransaction and sendrawtransaction. |
||
199 | * |
||
200 | * @param $txHex |
||
201 | * @param $dataHex |
||
202 | * @return mixed |
||
203 | */ |
||
204 | public function appendRawMetadata($txHex, $dataHex) |
||
208 | |||
209 | /** |
||
210 | * Sends transactions to combine large groups of unspent outputs (UTXOs) belonging to the same address into a |
||
211 | * single unspent output, returning a list of txids. This can improve wallet performance, especially for miners in |
||
212 | * a chain with short block times and non-zero block rewards. Set addresses to a comma-separated list of addresses |
||
213 | * to combine outputs for, or * for all addresses in the wallet. Only combine outputs with at least minconf |
||
214 | * confirmations, and use between mininputs and maxinputs per transaction. A single call to combineunspent can |
||
215 | * create up to maxcombines transactions over up to maxtime seconds. See also the autocombine runtime parameters. |
||
216 | * |
||
217 | * @param string $addresses |
||
218 | * @param int $minConf |
||
219 | * @param int $maxCombines |
||
220 | * @param int $minInputs |
||
221 | * @param int $maxInputs |
||
222 | * @param int $maxTime |
||
223 | * @return mixed |
||
224 | */ |
||
225 | public function combineUnspent($addresses = "*", $minConf = 1, $maxCombines = 1, $minInputs = 10, $maxInputs = 100, $maxTime = 30) |
||
229 | |||
230 | /** |
||
231 | * Creates a new atomic exchange transaction which offers to exchange the asset/s in output vout of transaction |
||
232 | * txid for qty units of asset, where asset is an asset name, ref or issuance txid. The txid and vout should |
||
233 | * generally be taken from the response to preparelockunspent or preparelockunspentfrom. Multiple items can be |
||
234 | * specified within the third parameter to request multiple assets. Returns a raw partial transaction in |
||
235 | * hexadecimal which can be passed to the counterparty, who can call decoderawexchange and appendrawexchange as |
||
236 | * appropriate. |
||
237 | * |
||
238 | * @param $txId |
||
239 | * @param $vOut |
||
240 | * @param $extra |
||
241 | * @return mixed |
||
242 | */ |
||
243 | public function createRawExchange($txId, $vOut, $extra) |
||
247 | |||
248 | /** |
||
249 | * Decodes the raw exchange transaction in hexstring, given by a previous call to createrawexchange or |
||
250 | * appendrawexchange. Returns details on the offer represented by the exchange and its present state. The offer |
||
251 | * field in the response lists the quantity of native currency and/or assets which are being offered for exchange. |
||
252 | * The ask field lists the native currency and/or assets which are being asked for. The candisable field specifies |
||
253 | * whether this wallet can disable the exchange transaction by double-spending against one of its inputs. The |
||
254 | * cancomplete field specifies whether this wallet has the assets required to complete the exchange. The complete |
||
255 | * field specifies whether the exchange is already complete (i.e. balanced) and ready for sending. If verbose is |
||
256 | * true then all of the individual stages in the exchange are listed. Other fields relating to fees are only |
||
257 | * relevant for blockchains which use a native currency. |
||
258 | * |
||
259 | * @param $hexString |
||
260 | * @param bool $verbose |
||
261 | * @return mixed |
||
262 | */ |
||
263 | public function decodeRawExchange($hexString, $verbose = false) |
||
267 | |||
268 | /** |
||
269 | * Sends a transaction to disable the offer of exchange in hexstring, returning the txid. This is achieved by |
||
270 | * spending one of the exchange transaction’s inputs and sending it back to the wallet. To check whether this can |
||
271 | * be used on an exchange transaction, check the candisable field of the output of decoderawexchange. |
||
272 | * |
||
273 | * @param $hexString |
||
274 | * @return mixed |
||
275 | */ |
||
276 | public function disableRawTransaction($hexString) |
||
280 | |||
281 | /** |
||
282 | * Returns a list of all the asset balances for address in this node’s wallet, with at least minconf confirmations. |
||
283 | * Use includeLocked to include unspent outputs which have been locked, e.g. by a call to preparelockunspent. |
||
284 | * |
||
285 | * @param $address |
||
286 | * @param int $minConf |
||
287 | * @param bool $includeLocked |
||
288 | * @return mixed |
||
289 | */ |
||
290 | public function getAddressBalances($address, $minConf = 1, $includeLocked = false) |
||
294 | |||
295 | /** |
||
296 | * Returns a list of addresses in this node’s wallet. Set verbose to true to get more information about each |
||
297 | * address, formatted like the output of the validateaddress command. |
||
298 | * |
||
299 | * @param bool $verbose |
||
300 | * @return mixed |
||
301 | */ |
||
302 | public function getAddresses($verbose = false) |
||
306 | |||
307 | /** |
||
308 | * Provides information about transaction txid related to address in this node’s wallet, including how it affected |
||
309 | * that address’s balance. Use verbose to provide details of transaction inputs and outputs. |
||
310 | * |
||
311 | * @param $address |
||
312 | * @param $txId |
||
313 | * @param bool $verbose |
||
314 | * @return mixed |
||
315 | */ |
||
316 | public function getAddressTransaction($address, $txId, $verbose = false) |
||
320 | |||
321 | /** |
||
322 | * Returns a list of all the asset balances for account in this node’s wallet, with at least minconf confirmations. |
||
323 | * Omit the account parameter or use "" for the default account – see note about accounts. Use includeWatchOnly to |
||
324 | * include the balance of watch-only addresses and includeLocked to include unspent outputs which have been locked, |
||
325 | * e.g. by a call to preparelockunspent. |
||
326 | * |
||
327 | * @param string $account |
||
328 | * @param int $minConf |
||
329 | * @param bool $includeWatchOnly |
||
330 | * @param bool $includeLocked |
||
331 | * @return mixed |
||
332 | */ |
||
333 | public function getAssetBalances($account = "", $minConf = 1, $includeWatchOnly = false, $includeLocked = false) |
||
337 | |||
338 | /** |
||
339 | * Returns a list of all the asset balances in this node’s wallet, with at least minconf confirmations. Use |
||
340 | * includeWatchOnly to include the balance of watch-only addresses and includeLocked to include unspent outputs |
||
341 | * which have been locked, e.g. by a call to preparelockunspent. |
||
342 | * |
||
343 | * @param int $minConf |
||
344 | * @param bool $includeWatchOnly |
||
345 | * @param bool $includeLocked |
||
346 | * @return mixed |
||
347 | */ |
||
348 | public function getTotalBalances($minConf = 1, $includeWatchOnly = false, $includeLocked = false) |
||
352 | |||
353 | /** |
||
354 | * Returns information about address including a check for its validity. |
||
355 | * |
||
356 | * @param $address |
||
357 | * @return mixed |
||
358 | */ |
||
359 | public function validateAddress($address) |
||
363 | |||
364 | /** |
||
365 | * Provides information about transaction txid in this node’s wallet, including how it affected the node’s total |
||
366 | * balance. Use includeWatchOnly to consider watch-only addresses as if they belong to this wallet and verbose to |
||
367 | * provide details of transaction inputs and outputs. |
||
368 | * |
||
369 | * @param $txId |
||
370 | * @param bool $includeWatchOnly |
||
371 | * @param bool $verbose |
||
372 | * @return mixed |
||
373 | */ |
||
374 | public function getWalletTransaction($txId, $includeWatchOnly = false, $verbose = false) |
||
378 | |||
379 | /** |
||
380 | * Grants permissions to addresses, where addresses is a comma-separated list of addresses and permissions is one |
||
381 | * of connect, send, receive, issue, mine, admin, or a comma-separated list thereof. If the chain uses a native |
||
382 | * currency, you can send some to each recipient using the native-amount parameter. Returns the txid of the |
||
383 | * transaction granting the permissions. For more information, see permissions management. |
||
384 | * |
||
385 | * @param $addresses |
||
386 | * @param $permissions |
||
387 | * @param int $nativeAmount |
||
388 | * @param string $comment |
||
389 | * @param string $commentTo |
||
390 | * @param int $startBlock |
||
391 | * @param null $endBlock |
||
392 | * @return mixed |
||
393 | */ |
||
394 | public function grant($addresses, $permissions, $nativeAmount = 0, $comment = '', $commentTo = '', $startBlock = 0, $endBlock = null) |
||
398 | |||
399 | /** |
||
400 | * This works like grant, but with control over the from-address used to grant the permissions. If there are |
||
401 | * multiple addresses with administrator permissions on one node, this allows control over which address is used. |
||
402 | * |
||
403 | * @param $fromAddress |
||
404 | * @param $toAddresses |
||
405 | * @param $permissions |
||
406 | * @param int $nativeAmount |
||
407 | * @param string $comment |
||
408 | * @param string $commentTo |
||
409 | * @param int $startBlock |
||
410 | * @param null $endBlock |
||
411 | * @return mixed |
||
412 | */ |
||
413 | public function grantFrom($fromAddress, $toAddresses, $permissions, $nativeAmount = 0, $comment = '', $commentTo = '', $startBlock = 0, $endBlock = null) |
||
417 | |||
418 | /** |
||
419 | * Creates a new asset name on the blockchain, sending the initial qty units to address. The smallest transactable |
||
420 | * unit is given by units, e.g. 0.01. If the chain uses a native currency, you can send some with the new asset |
||
421 | * using the native-amount parameter. |
||
422 | * |
||
423 | * @param $address |
||
424 | * @param $name |
||
425 | * @param $qty |
||
426 | * @param int $units |
||
427 | * @param int $nativeAmount |
||
428 | * @param null $custom |
||
429 | * @param bool $open |
||
430 | * @return mixed |
||
431 | */ |
||
432 | public function issue($address, $name, $qty, $units = 1, $nativeAmount = 0, $custom = null, $open=false) |
||
440 | |||
441 | /** |
||
442 | * Issues qty additional units of asset, sending them to address. The asset can be specified using its name, ref or |
||
443 | * issuance txid – see native assets for more information. If the chain uses a native currency, you can send some with the |
||
444 | * new asset units using the native-amount parameter. Any custom fields will be attached to the new issuance event, and not |
||
445 | * affect the original values (use listassets with verbose=true to see both sets). Returns the txid of the issuance |
||
446 | * transaction. For more information, see native assets. |
||
447 | * |
||
448 | * @param $address |
||
449 | * @param $asset |
||
450 | * @param $qty |
||
451 | * @param int $nativeAmount |
||
452 | * @param null $custom |
||
453 | * @return mixed |
||
454 | */ |
||
455 | public function issueMore($address, $asset, $qty, $nativeAmount=0, $custom = null){ |
||
462 | |||
463 | /** |
||
464 | * This works like issue, but with control over the from-address used to issue the asset. If there are multiple |
||
465 | * addresses with asset issuing permissions on one node, this allows control over which address is used. |
||
466 | * |
||
467 | * @param $fromAddress |
||
468 | * @param $toAddress |
||
469 | * @param $name |
||
470 | * @param $qty |
||
471 | * @param int $units |
||
472 | * @param int $nativeAmount |
||
473 | * @param null $custom |
||
474 | * @return mixed |
||
475 | */ |
||
476 | public function issueFrom($fromAddress, $toAddress, $name, $qty, $units = 1, $nativeAmount = 0, $custom = null) |
||
480 | |||
481 | /** |
||
482 | * Lists information about the count most recent transactions related to address in this node’s wallet, including |
||
483 | * how they affected that address’s balance. Use skip to go back further in history and verbose to provide details |
||
484 | * of transaction inputs and outputs. |
||
485 | * |
||
486 | * @param $address |
||
487 | * @param int $count |
||
488 | * @param int $skip |
||
489 | * @param bool $verbose |
||
490 | * @return mixed |
||
491 | */ |
||
492 | public function listAddressTransactions($address, $count = 10, $skip = 0, $verbose = false) |
||
496 | |||
497 | /** |
||
498 | * Returns information about all assets issued on the blockchain. If an issuance txid |
||
499 | * (see native assets) is provided in asset, then information is only returned about that one asset. |
||
500 | * |
||
501 | * @param null $asset |
||
502 | * @return mixed |
||
503 | */ |
||
504 | public function listAssets($asset = null) |
||
508 | |||
509 | /** |
||
510 | * Returns a list of all permissions currently granted to addresses. To list information about specific permissions |
||
511 | * only, set permissions to one of connect, send, receive, issue, mine, admin, or a comma-separated list thereof. |
||
512 | * Omit or pass all to list all permissions. Provide a comma-delimited list in addresses to list the permissions |
||
513 | * for particular addresses only or * for all addresses. If verbose is true, the admins output field lists the |
||
514 | * administrator/s who assigned the corresponding permission, and the pending field lists permission changes which |
||
515 | * are waiting to reach consensus. |
||
516 | * |
||
517 | * @param string $permissions |
||
518 | * @param string $addresses |
||
519 | * @param bool $verbose |
||
520 | * @return mixed |
||
521 | */ |
||
522 | public function listPermissions($permissions = "all", $addresses = "*", $verbose = false) |
||
526 | |||
527 | /** |
||
528 | * Lists information about the count most recent transactions in this node’s wallet, including how they affected |
||
529 | * the node’s total balance. Use skip to go back further in history and includeWatchOnly to consider watch-only |
||
530 | * addresses as if they belong to this wallet. Use verbose to provide the details of transaction inputs and outputs. |
||
531 | * Note that unlike Bitcoin Core’s listtransactions command, the response contains one element per transaction, |
||
532 | * rather than one per transaction output. |
||
533 | * |
||
534 | * @param int $count |
||
535 | * @param int $skip |
||
536 | * @param bool $includeWatchOnly |
||
537 | * @param bool $verbose |
||
538 | * @return mixed |
||
539 | */ |
||
540 | public function listWalletTransactions($count = 10, $skip = 0, $includeWatchOnly = false, $verbose = false) |
||
544 | |||
545 | /** |
||
546 | * Prepares an unspent transaction output (useful for building atomic exchange transactions) containing qty units |
||
547 | * of asset, where asset is an asset name, ref or issuance txid. Multiple items can be specified within the first |
||
548 | * parameter to include several assets within the output. The output will be locked against automatic selection for |
||
549 | * spending unless the optional lock parameter is set to false. Returns the txid and vout of the prepared output. |
||
550 | * |
||
551 | * @param $assetsToLock |
||
552 | * @param bool $lock |
||
553 | * @return mixed |
||
554 | */ |
||
555 | public function prepareLockUnspent($assetsToLock, $lock = true) |
||
559 | |||
560 | /** |
||
561 | * This works like preparelockunspent, but with control over the from-address whose funds are used to prepare the |
||
562 | * unspent transaction output. Any change from the transaction is send back to from-address. |
||
563 | * |
||
564 | * @param $fromAddress |
||
565 | * @param $assetsToLock |
||
566 | * @param bool $lock |
||
567 | * @return mixed |
||
568 | */ |
||
569 | public function prepareLockUnspentFrom($fromAddress, $assetsToLock, $lock = true) |
||
573 | |||
574 | /** |
||
575 | * Revokes permissions from addresses, where addresses is a comma-separated list of addresses and permissions is |
||
576 | * one of connect, send, receive, issue, mine, admin, or a comma-separated list thereof. Equivalent to calling |
||
577 | * grant with start-block=0 and end-block=0. Returns the txid of transaction revoking the permissions. For more |
||
578 | * information, see permissions management. |
||
579 | * |
||
580 | * @param $addresses |
||
581 | * @param $permissions |
||
582 | * @param int $nativeAmount |
||
583 | * @param string $comment |
||
584 | * @param string $commentTo |
||
585 | * @return mixed |
||
586 | */ |
||
587 | public function revoke($addresses, $permissions, $nativeAmount = 0, $comment = '', $commentTo = '') |
||
591 | |||
592 | /** |
||
593 | * This works like revoke, but with control over the from-address used to revoke the permissions. If there are |
||
594 | * multiple addresses with administrator permissions on one node, this allows control over which address is used. |
||
595 | * |
||
596 | * @param $fromAddress |
||
597 | * @param $toAddresses |
||
598 | * @param $permissions |
||
599 | * @param int $nativeAmount |
||
600 | * @param string $comment |
||
601 | * @param string $commentTo |
||
602 | * @return mixed |
||
603 | */ |
||
604 | public function revokeFrom($fromAddress, $toAddresses, $permissions, $nativeAmount = 0, $comment = '', $commentTo = '') |
||
608 | |||
609 | /** |
||
610 | * This works like sendassettoaddress, but with control over the from-address whose funds are used. Any change from |
||
611 | * the transaction is sent back to from-address. See also sendfromaddress for sending multiple assets in one |
||
612 | * transaction. |
||
613 | * |
||
614 | * @param $fromAddress |
||
615 | * @param $toAddress |
||
616 | * @param $asset |
||
617 | * @param $qty |
||
618 | * @param null $nativeAmount |
||
619 | * @param string $comment |
||
620 | * @param string $commentTo |
||
621 | * @return mixed |
||
622 | */ |
||
623 | public function sendAssetFrom($fromAddress, $toAddress, $asset, $qty, $nativeAmount = null, $comment = '', $commentTo = '') |
||
628 | |||
629 | /** |
||
630 | * Returns a list of all the parameters of this blockchain, reflecting the content of its params.dat file. |
||
631 | * |
||
632 | * @return mixed |
||
633 | */ |
||
634 | public function getBlockchainParams() |
||
638 | |||
639 | /** |
||
640 | * Sends qty of asset to address, returning the txid. The asset can be specified using its name, ref or issuance |
||
641 | * txid – see native assets for more information. See also sendassetfrom to control the address whose funds are |
||
642 | * used, sendtoaddress for sending multiple assets in one transaction, and sendfromaddress to combine both of these. |
||
643 | * |
||
644 | * @param $address |
||
645 | * @param $asset |
||
646 | * @param $qty |
||
647 | * @param null $nativeAmount |
||
648 | * @param string $comment |
||
649 | * @param string $commentTo |
||
650 | * @return mixed |
||
651 | */ |
||
652 | public function sendAssetToAddress($address, $asset, $qty, $nativeAmount = null, $comment = '', $commentTo = '') |
||
657 | |||
658 | /** |
||
659 | * This works like sendtoaddress, but with control over the from-address whose funds are used. Any |
||
660 | * change from the transaction is sent back to from-address. |
||
661 | * |
||
662 | * @param $fromAddress |
||
663 | * @param $toAddress |
||
664 | * @param $amount |
||
665 | * @param string $comment |
||
666 | * @param string $commentTo |
||
667 | * @return mixed |
||
668 | */ |
||
669 | public function sendFromAddress($fromAddress, $toAddress, $amount, $comment = '', $commentTo = '') |
||
673 | |||
674 | /** |
||
675 | * This works like sendtoaddress (listed above), but includes the data-hex hexadecimal metadata in an additional |
||
676 | * OP_RETURN transaction output. |
||
677 | * |
||
678 | * @param $address |
||
679 | * @param $amount |
||
680 | * @param $dataHex |
||
681 | * @return mixed |
||
682 | */ |
||
683 | public function sendWithMetadata($address, $amount, $dataHex) |
||
687 | |||
688 | /** |
||
689 | * This works like sendtoaddress (listed above), but with control over the from-address whose funds are used, and |
||
690 | * with the data-hex hexadecimal metadata added in an additional OP_RETURN transaction output. Any change from the |
||
691 | * transaction is sent back to from-address. |
||
692 | * |
||
693 | * @param $fromAddress |
||
694 | * @param $toAddress |
||
695 | * @param $amount |
||
696 | * @param $dataHex |
||
697 | * @return mixed |
||
698 | */ |
||
699 | public function sendWithMetadataFrom($fromAddress, $toAddress, $amount, $dataHex) |
||
703 | |||
704 | /** |
||
705 | * Creates a transaction spending the specified inputs, sending to the given addresses. In Bitcoin Core, each |
||
706 | * amount field is a quantity of the bitcoin currency. For MultiChain, an {"asset":qty, ...} object can be used for |
||
707 | * amount, in which each asset is an asset name, ref or issuance txid, and each qty is the quantity of that asset |
||
708 | * to send (see native assets). Use "" as the asset inside this object to specify a quantity of the native |
||
709 | * blockchain currency. |
||
710 | * |
||
711 | * @param $inputs |
||
712 | * @param $addresses |
||
713 | * @return mixed |
||
714 | */ |
||
715 | public function createRawTransaction($inputs, $addresses) |
||
719 | |||
720 | /** |
||
721 | * Returns a JSON object describing the serialized transaction in hexstring. For a MultiChain blockchain, each |
||
722 | * transaction output includes assets and permissions fields listing any assets or permission changes encoded |
||
723 | * within that output. There will also be a data field listing the content of any OP_RETURN outputs in the |
||
724 | * transaction. |
||
725 | * |
||
726 | * @param $hexString |
||
727 | * @return mixed |
||
728 | */ |
||
729 | public function decodeRawTransaction($hexString) |
||
733 | |||
734 | /** |
||
735 | * Returns information about the block with hash. If this is a MultiChain blockchain and format is true or omitted, |
||
736 | * then the output includes a field miner showing the address of the miner of the block. |
||
737 | * |
||
738 | * @param $hash |
||
739 | * @param bool $format |
||
740 | * @return mixed |
||
741 | */ |
||
742 | public function getBlock($hash, $format = true) |
||
746 | |||
747 | /** |
||
748 | * If verbose is 1, returns a JSON object describing transaction txid. For a MultiChain blockchain, each transaction |
||
749 | * output includes assets and permissions fields listing any assets or permission changes encoded within that |
||
750 | * output. There will also be a data field listing the content of any OP_RETURN outputs in the transaction. |
||
751 | * |
||
752 | * @param $txId |
||
753 | * @param int $verbose |
||
754 | * @return mixed |
||
755 | */ |
||
756 | public function getRawTransaction($txId, $verbose = 0) |
||
760 | |||
761 | /** |
||
762 | * Returns details about an unspent transaction output vout of txid. For a MultiChain blockchain, includes assets |
||
763 | * and permissions fields listing any assets or permission changes encoded within the output. Set confirmed to true |
||
764 | * to include unconfirmed transaction outputs. |
||
765 | * |
||
766 | * @param $txId |
||
767 | * @param $vOut |
||
768 | * @param bool $unconfirmed |
||
769 | * @return mixed |
||
770 | */ |
||
771 | public function getTxOut($txId, $vOut, $unconfirmed = false) |
||
775 | |||
776 | /** |
||
777 | * Returns a list of unspent transaction outputs in the wallet, with between minconf and maxconf confirmations. For |
||
778 | * a MultiChain blockchain, each transaction output includes assets and permissions fields listing any assets or |
||
779 | * permission changes encoded within that output. If addresses is provided, only outputs which pay an address in |
||
780 | * this array will be included. |
||
781 | * |
||
782 | * @param int $minConf |
||
783 | * @param int $maxConf |
||
784 | * @param null $addresses |
||
785 | * @return mixed |
||
786 | */ |
||
787 | public function listUnspent($minConf = 1, $maxConf = 999999, $addresses = null) |
||
791 | |||
792 | /** |
||
793 | * @param $nativeAmount |
||
794 | * @return mixed |
||
795 | */ |
||
796 | private function findDefaultMinimumPerOutput($nativeAmount) |
||
805 | |||
806 | /** |
||
807 | * Submits raw transaction (serialized, hex-encoded) to local node and network. |
||
808 | * Returns the transaction hash in hex |
||
809 | * |
||
810 | * @param $hex |
||
811 | * @param bool $allowHighFees |
||
812 | * @return mixed |
||
813 | */ |
||
814 | public function sendRawTransaction($hex, $allowHighFees = false) |
||
818 | } |
||
819 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.