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 | * Returns the private key associated with address in this node’s wallet. Use with caution – any node with access to this |
||
118 | * private key can perform any action restricted to the address, including granting permissions and spending funds. |
||
119 | * |
||
120 | * @param $address |
||
121 | * @return mixed |
||
122 | */ |
||
123 | public function dumpPrivateKey($address){ |
||
126 | |||
127 | /** |
||
128 | * Adds the privkey private key (as obtained from a prior call to dumpprivkey) to the wallet, together with its |
||
129 | * associated public address. If rescan is true, the entire blockchain is checked for transactions relating to |
||
130 | * all addresses in the wallet, including the added one. |
||
131 | * |
||
132 | * @param $privkey |
||
133 | * @param string $label |
||
134 | * @param bool $rescan |
||
135 | * @return mixed |
||
136 | */ |
||
137 | public function importPrivateKey($privkey, $label="", $rescan=true){ |
||
140 | |||
141 | /** |
||
142 | * Sends one or more assets to address, returning the txid. In Bitcoin Core, the amount field is the quantity of |
||
143 | * the bitcoin currency. For MultiChain, an {"asset":qty, ...} object can be used for amount, in which each asset |
||
144 | * is an asset name, ref or issuance txid, and each qty is the quantity of that asset to send (see native assets). |
||
145 | * Use "" as the asset inside this object to specify a quantity of the native blockchain currency. See also |
||
146 | * sendassettoaddress for sending a single asset and sendfromaddress to control the address whose funds are used. |
||
147 | * |
||
148 | * @param string $address |
||
149 | * @param string $amount |
||
150 | * @param string $comment |
||
151 | * @param string $commentTo |
||
152 | * @return mixed |
||
153 | */ |
||
154 | public function sendToAddress($address, $amount, $comment = '', $commentTo = '') |
||
158 | |||
159 | /** |
||
160 | * Outputs a list of available API commands, including MultiChain-specific commands. |
||
161 | * |
||
162 | * @return mixed |
||
163 | */ |
||
164 | public function help() |
||
168 | |||
169 | /** |
||
170 | * Adds to the atomic exchange transaction in hexstring given by a previous call to createrawexchange or |
||
171 | * appendrawexchange. This adds an offer to exchange the asset/s in output vout of transaction txid for qty units |
||
172 | * of asset, where asset is an asset name, ref or issuance txid. The txid and vout should generally be taken from |
||
173 | * the response to preparelockunspent or preparelockunspentfrom. Multiple items can be specified within the fourth |
||
174 | * parameter to request multiple assets. Returns a raw hexadecimal transaction in the hex field alongside a |
||
175 | * complete field stating whether the exchange is complete (i.e. balanced) or not. If complete, the transaction can |
||
176 | * be transmitted to the network using sendrawtransaction. If not, it can be passed to a further counterparty, who |
||
177 | * can call decoderawexchange and appendrawexchange as appropriate. |
||
178 | * |
||
179 | * @param $hexString |
||
180 | * @param $txId |
||
181 | * @param $vOut |
||
182 | * @param $extra ({"asset":qty, ...}) |
||
183 | * @return mixed |
||
184 | */ |
||
185 | public function appendRawExchange($hexString, $txId, $vOut, $extra) |
||
189 | |||
190 | /** |
||
191 | * Adds a metadata output to the raw transaction in tx-hex given by a previous call to createrawtransaction. The |
||
192 | * metadata is specified in data-hex in hexadecimal form and added in a new OP_RETURN transaction output. The |
||
193 | * transaction can then be signed and transmitted to the network using signrawtransaction and sendrawtransaction. |
||
194 | * |
||
195 | * @param $txHex |
||
196 | * @param $dataHex |
||
197 | * @return mixed |
||
198 | */ |
||
199 | public function appendRawMetadata($txHex, $dataHex) |
||
203 | |||
204 | /** |
||
205 | * Sends transactions to combine large groups of unspent outputs (UTXOs) belonging to the same address into a |
||
206 | * single unspent output, returning a list of txids. This can improve wallet performance, especially for miners in |
||
207 | * a chain with short block times and non-zero block rewards. Set addresses to a comma-separated list of addresses |
||
208 | * to combine outputs for, or * for all addresses in the wallet. Only combine outputs with at least minconf |
||
209 | * confirmations, and use between mininputs and maxinputs per transaction. A single call to combineunspent can |
||
210 | * create up to maxcombines transactions over up to maxtime seconds. See also the autocombine runtime parameters. |
||
211 | * |
||
212 | * @param string $addresses |
||
213 | * @param int $minConf |
||
214 | * @param int $maxCombines |
||
215 | * @param int $minInputs |
||
216 | * @param int $maxInputs |
||
217 | * @param int $maxTime |
||
218 | * @return mixed |
||
219 | */ |
||
220 | public function combineUnspent($addresses = "*", $minConf = 1, $maxCombines = 1, $minInputs = 10, $maxInputs = 100, $maxTime = 30) |
||
224 | |||
225 | /** |
||
226 | * Creates a new atomic exchange transaction which offers to exchange the asset/s in output vout of transaction |
||
227 | * txid for qty units of asset, where asset is an asset name, ref or issuance txid. The txid and vout should |
||
228 | * generally be taken from the response to preparelockunspent or preparelockunspentfrom. Multiple items can be |
||
229 | * specified within the third parameter to request multiple assets. Returns a raw partial transaction in |
||
230 | * hexadecimal which can be passed to the counterparty, who can call decoderawexchange and appendrawexchange as |
||
231 | * appropriate. |
||
232 | * |
||
233 | * @param $txId |
||
234 | * @param $vOut |
||
235 | * @param $extra |
||
236 | * @return mixed |
||
237 | */ |
||
238 | public function createRawExchange($txId, $vOut, $extra) |
||
242 | |||
243 | /** |
||
244 | * Decodes the raw exchange transaction in hexstring, given by a previous call to createrawexchange or |
||
245 | * appendrawexchange. Returns details on the offer represented by the exchange and its present state. The offer |
||
246 | * field in the response lists the quantity of native currency and/or assets which are being offered for exchange. |
||
247 | * The ask field lists the native currency and/or assets which are being asked for. The candisable field specifies |
||
248 | * whether this wallet can disable the exchange transaction by double-spending against one of its inputs. The |
||
249 | * cancomplete field specifies whether this wallet has the assets required to complete the exchange. The complete |
||
250 | * field specifies whether the exchange is already complete (i.e. balanced) and ready for sending. If verbose is |
||
251 | * true then all of the individual stages in the exchange are listed. Other fields relating to fees are only |
||
252 | * relevant for blockchains which use a native currency. |
||
253 | * |
||
254 | * @param $hexString |
||
255 | * @param bool $verbose |
||
256 | * @return mixed |
||
257 | */ |
||
258 | public function decodeRawExchange($hexString, $verbose = false) |
||
262 | |||
263 | /** |
||
264 | * Sends a transaction to disable the offer of exchange in hexstring, returning the txid. This is achieved by |
||
265 | * spending one of the exchange transaction’s inputs and sending it back to the wallet. To check whether this can |
||
266 | * be used on an exchange transaction, check the candisable field of the output of decoderawexchange. |
||
267 | * |
||
268 | * @param $hexString |
||
269 | * @return mixed |
||
270 | */ |
||
271 | public function disableRawTransaction($hexString) |
||
275 | |||
276 | /** |
||
277 | * Returns a list of all the asset balances for address in this node’s wallet, with at least minconf confirmations. |
||
278 | * Use includeLocked to include unspent outputs which have been locked, e.g. by a call to preparelockunspent. |
||
279 | * |
||
280 | * @param $address |
||
281 | * @param int $minConf |
||
282 | * @param bool $includeLocked |
||
283 | * @return mixed |
||
284 | */ |
||
285 | public function getAddressBalances($address, $minConf = 1, $includeLocked = false) |
||
289 | |||
290 | /** |
||
291 | * Returns a list of addresses in this node’s wallet. Set verbose to true to get more information about each |
||
292 | * address, formatted like the output of the validateaddress command. |
||
293 | * |
||
294 | * @param bool $verbose |
||
295 | * @return mixed |
||
296 | */ |
||
297 | public function getAddresses($verbose = false) |
||
301 | |||
302 | /** |
||
303 | * Provides information about transaction txid related to address in this node’s wallet, including how it affected |
||
304 | * that address’s balance. Use verbose to provide details of transaction inputs and outputs. |
||
305 | * |
||
306 | * @param $address |
||
307 | * @param $txId |
||
308 | * @param bool $verbose |
||
309 | * @return mixed |
||
310 | */ |
||
311 | public function getAddressTransaction($address, $txId, $verbose = false) |
||
315 | |||
316 | /** |
||
317 | * Returns a list of all the asset balances for account in this node’s wallet, with at least minconf confirmations. |
||
318 | * Omit the account parameter or use "" for the default account – see note about accounts. Use includeWatchOnly to |
||
319 | * include the balance of watch-only addresses and includeLocked to include unspent outputs which have been locked, |
||
320 | * e.g. by a call to preparelockunspent. |
||
321 | * |
||
322 | * @param string $account |
||
323 | * @param int $minConf |
||
324 | * @param bool $includeWatchOnly |
||
325 | * @param bool $includeLocked |
||
326 | * @return mixed |
||
327 | */ |
||
328 | public function getAssetBalances($account = "", $minConf = 1, $includeWatchOnly = false, $includeLocked = false) |
||
332 | |||
333 | /** |
||
334 | * Returns a list of all the asset balances in this node’s wallet, with at least minconf confirmations. Use |
||
335 | * includeWatchOnly to include the balance of watch-only addresses and includeLocked to include unspent outputs |
||
336 | * which have been locked, e.g. by a call to preparelockunspent. |
||
337 | * |
||
338 | * @param int $minConf |
||
339 | * @param bool $includeWatchOnly |
||
340 | * @param bool $includeLocked |
||
341 | * @return mixed |
||
342 | */ |
||
343 | public function getTotalBalances($minConf = 1, $includeWatchOnly = false, $includeLocked = false) |
||
347 | |||
348 | /** |
||
349 | * Returns information about address including a check for its validity. |
||
350 | * |
||
351 | * @param $address |
||
352 | * @return mixed |
||
353 | */ |
||
354 | public function validateAddress($address) |
||
358 | |||
359 | /** |
||
360 | * Provides information about transaction txid in this node’s wallet, including how it affected the node’s total |
||
361 | * balance. Use includeWatchOnly to consider watch-only addresses as if they belong to this wallet and verbose to |
||
362 | * provide details of transaction inputs and outputs. |
||
363 | * |
||
364 | * @param $txId |
||
365 | * @param bool $includeWatchOnly |
||
366 | * @param bool $verbose |
||
367 | * @return mixed |
||
368 | */ |
||
369 | public function getWalletTransaction($txId, $includeWatchOnly = false, $verbose = false) |
||
373 | |||
374 | /** |
||
375 | * Grants permissions to addresses, where addresses is a comma-separated list of addresses and permissions is one |
||
376 | * of connect, send, receive, issue, mine, admin, or a comma-separated list thereof. If the chain uses a native |
||
377 | * currency, you can send some to each recipient using the native-amount parameter. Returns the txid of the |
||
378 | * transaction granting the permissions. For more information, see permissions management. |
||
379 | * |
||
380 | * @param $addresses |
||
381 | * @param $permissions |
||
382 | * @param int $nativeAmount |
||
383 | * @param string $comment |
||
384 | * @param string $commentTo |
||
385 | * @param int $startBlock |
||
386 | * @param null $endBlock |
||
387 | * @return mixed |
||
388 | */ |
||
389 | public function grant($addresses, $permissions, $nativeAmount = 0, $comment = '', $commentTo = '', $startBlock = 0, $endBlock = null) |
||
393 | |||
394 | /** |
||
395 | * This works like grant, but with control over the from-address used to grant the permissions. If there are |
||
396 | * multiple addresses with administrator permissions on one node, this allows control over which address is used. |
||
397 | * |
||
398 | * @param $fromAddress |
||
399 | * @param $toAddresses |
||
400 | * @param $permissions |
||
401 | * @param int $nativeAmount |
||
402 | * @param string $comment |
||
403 | * @param string $commentTo |
||
404 | * @param int $startBlock |
||
405 | * @param null $endBlock |
||
406 | * @return mixed |
||
407 | */ |
||
408 | public function grantFrom($fromAddress, $toAddresses, $permissions, $nativeAmount = 0, $comment = '', $commentTo = '', $startBlock = 0, $endBlock = null) |
||
412 | |||
413 | /** |
||
414 | * Creates a new asset name on the blockchain, sending the initial qty units to address. The smallest transactable |
||
415 | * unit is given by units, e.g. 0.01. If the chain uses a native currency, you can send some with the new asset |
||
416 | * using the native-amount parameter. |
||
417 | * |
||
418 | * @param $address |
||
419 | * @param $name |
||
420 | * @param $qty |
||
421 | * @param int $units |
||
422 | * @param int $nativeAmount |
||
423 | * @param null $custom |
||
424 | * @param bool $open |
||
425 | * @return mixed |
||
426 | */ |
||
427 | public function issue($address, $name, $qty, $units = 1, $nativeAmount = 0, $custom = null, $open=false) |
||
435 | |||
436 | /** |
||
437 | * Issues qty additional units of asset, sending them to address. The asset can be specified using its name, ref or |
||
438 | * issuance txid – see native assets for more information. If the chain uses a native currency, you can send some with the |
||
439 | * new asset units using the native-amount parameter. Any custom fields will be attached to the new issuance event, and not |
||
440 | * affect the original values (use listassets with verbose=true to see both sets). Returns the txid of the issuance |
||
441 | * transaction. For more information, see native assets. |
||
442 | * |
||
443 | * @param $address |
||
444 | * @param $asset |
||
445 | * @param $qty |
||
446 | * @param int $nativeAmount |
||
447 | * @param null $custom |
||
448 | * @return mixed |
||
449 | */ |
||
450 | public function issueMore($address, $asset, $qty, $nativeAmount=0, $custom = null){ |
||
457 | |||
458 | /** |
||
459 | * This works like issue, but with control over the from-address used to issue the asset. If there are multiple |
||
460 | * addresses with asset issuing permissions on one node, this allows control over which address is used. |
||
461 | * |
||
462 | * @param $fromAddress |
||
463 | * @param $toAddress |
||
464 | * @param $name |
||
465 | * @param $qty |
||
466 | * @param int $units |
||
467 | * @param int $nativeAmount |
||
468 | * @param null $custom |
||
469 | * @return mixed |
||
470 | */ |
||
471 | public function issueFrom($fromAddress, $toAddress, $name, $qty, $units = 1, $nativeAmount = 0, $custom = null) |
||
475 | |||
476 | /** |
||
477 | * Lists information about the count most recent transactions related to address in this node’s wallet, including |
||
478 | * how they affected that address’s balance. Use skip to go back further in history and verbose to provide details |
||
479 | * of transaction inputs and outputs. |
||
480 | * |
||
481 | * @param $address |
||
482 | * @param int $count |
||
483 | * @param int $skip |
||
484 | * @param bool $verbose |
||
485 | * @return mixed |
||
486 | */ |
||
487 | public function listAddressTransactions($address, $count = 10, $skip = 0, $verbose = false) |
||
491 | |||
492 | /** |
||
493 | * Returns information about all assets issued on the blockchain. If an issuance txid |
||
494 | * (see native assets) is provided in asset, then information is only returned about that one asset. |
||
495 | * |
||
496 | * @param null $asset |
||
497 | * @return mixed |
||
498 | */ |
||
499 | public function listAssets($asset = null) |
||
503 | |||
504 | /** |
||
505 | * Returns a list of all permissions currently granted to addresses. To list information about specific permissions |
||
506 | * only, set permissions to one of connect, send, receive, issue, mine, admin, or a comma-separated list thereof. |
||
507 | * Omit or pass all to list all permissions. Provide a comma-delimited list in addresses to list the permissions |
||
508 | * for particular addresses only or * for all addresses. If verbose is true, the admins output field lists the |
||
509 | * administrator/s who assigned the corresponding permission, and the pending field lists permission changes which |
||
510 | * are waiting to reach consensus. |
||
511 | * |
||
512 | * @param string $permissions |
||
513 | * @param string $addresses |
||
514 | * @param bool $verbose |
||
515 | * @return mixed |
||
516 | */ |
||
517 | public function listPermissions($permissions = "all", $addresses = "*", $verbose = false) |
||
521 | |||
522 | /** |
||
523 | * Lists information about the count most recent transactions in this node’s wallet, including how they affected |
||
524 | * the node’s total balance. Use skip to go back further in history and includeWatchOnly to consider watch-only |
||
525 | * addresses as if they belong to this wallet. Use verbose to provide the details of transaction inputs and outputs. |
||
526 | * Note that unlike Bitcoin Core’s listtransactions command, the response contains one element per transaction, |
||
527 | * rather than one per transaction output. |
||
528 | * |
||
529 | * @param int $count |
||
530 | * @param int $skip |
||
531 | * @param bool $includeWatchOnly |
||
532 | * @param bool $verbose |
||
533 | * @return mixed |
||
534 | */ |
||
535 | public function listWalletTransactions($count = 10, $skip = 0, $includeWatchOnly = false, $verbose = false) |
||
539 | |||
540 | /** |
||
541 | * Prepares an unspent transaction output (useful for building atomic exchange transactions) containing qty units |
||
542 | * of asset, where asset is an asset name, ref or issuance txid. Multiple items can be specified within the first |
||
543 | * parameter to include several assets within the output. The output will be locked against automatic selection for |
||
544 | * spending unless the optional lock parameter is set to false. Returns the txid and vout of the prepared output. |
||
545 | * |
||
546 | * @param $assetsToLock |
||
547 | * @param bool $lock |
||
548 | * @return mixed |
||
549 | */ |
||
550 | public function prepareLockUnspent($assetsToLock, $lock = true) |
||
554 | |||
555 | /** |
||
556 | * This works like preparelockunspent, but with control over the from-address whose funds are used to prepare the |
||
557 | * unspent transaction output. Any change from the transaction is send back to from-address. |
||
558 | * |
||
559 | * @param $fromAddress |
||
560 | * @param $assetsToLock |
||
561 | * @param bool $lock |
||
562 | * @return mixed |
||
563 | */ |
||
564 | public function prepareLockUnspentFrom($fromAddress, $assetsToLock, $lock = true) |
||
568 | |||
569 | /** |
||
570 | * Revokes permissions from addresses, where addresses is a comma-separated list of addresses and permissions is |
||
571 | * one of connect, send, receive, issue, mine, admin, or a comma-separated list thereof. Equivalent to calling |
||
572 | * grant with start-block=0 and end-block=0. Returns the txid of transaction revoking the permissions. For more |
||
573 | * information, see permissions management. |
||
574 | * |
||
575 | * @param $addresses |
||
576 | * @param $permissions |
||
577 | * @param int $nativeAmount |
||
578 | * @param string $comment |
||
579 | * @param string $commentTo |
||
580 | * @return mixed |
||
581 | */ |
||
582 | public function revoke($addresses, $permissions, $nativeAmount = 0, $comment = '', $commentTo = '') |
||
586 | |||
587 | /** |
||
588 | * This works like revoke, but with control over the from-address used to revoke the permissions. If there are |
||
589 | * multiple addresses with administrator permissions on one node, this allows control over which address is used. |
||
590 | * |
||
591 | * @param $fromAddress |
||
592 | * @param $toAddresses |
||
593 | * @param $permissions |
||
594 | * @param int $nativeAmount |
||
595 | * @param string $comment |
||
596 | * @param string $commentTo |
||
597 | * @return mixed |
||
598 | */ |
||
599 | public function revokeFrom($fromAddress, $toAddresses, $permissions, $nativeAmount = 0, $comment = '', $commentTo = '') |
||
603 | |||
604 | /** |
||
605 | * This works like sendassettoaddress, but with control over the from-address whose funds are used. Any change from |
||
606 | * the transaction is sent back to from-address. See also sendfromaddress for sending multiple assets in one |
||
607 | * transaction. |
||
608 | * |
||
609 | * @param $fromAddress |
||
610 | * @param $toAddress |
||
611 | * @param $asset |
||
612 | * @param $qty |
||
613 | * @param null $nativeAmount |
||
614 | * @param string $comment |
||
615 | * @param string $commentTo |
||
616 | * @return mixed |
||
617 | */ |
||
618 | public function sendAssetFrom($fromAddress, $toAddress, $asset, $qty, $nativeAmount = null, $comment = '', $commentTo = '') |
||
623 | |||
624 | /** |
||
625 | * Returns a list of all the parameters of this blockchain, reflecting the content of its params.dat file. |
||
626 | * |
||
627 | * @return mixed |
||
628 | */ |
||
629 | public function getBlockchainParams() |
||
633 | |||
634 | /** |
||
635 | * Sends qty of asset to address, returning the txid. The asset can be specified using its name, ref or issuance |
||
636 | * txid – see native assets for more information. See also sendassetfrom to control the address whose funds are |
||
637 | * used, sendtoaddress for sending multiple assets in one transaction, and sendfromaddress to combine both of these. |
||
638 | * |
||
639 | * @param $address |
||
640 | * @param $asset |
||
641 | * @param $qty |
||
642 | * @param null $nativeAmount |
||
643 | * @param string $comment |
||
644 | * @param string $commentTo |
||
645 | * @return mixed |
||
646 | */ |
||
647 | public function sendAssetToAddress($address, $asset, $qty, $nativeAmount = null, $comment = '', $commentTo = '') |
||
652 | |||
653 | /** |
||
654 | * This works like sendtoaddress, but with control over the from-address whose funds are used. Any |
||
655 | * change from the transaction is sent back to from-address. |
||
656 | * |
||
657 | * @param $fromAddress |
||
658 | * @param $toAddress |
||
659 | * @param $amount |
||
660 | * @param string $comment |
||
661 | * @param string $commentTo |
||
662 | * @return mixed |
||
663 | */ |
||
664 | public function sendFromAddress($fromAddress, $toAddress, $amount, $comment = '', $commentTo = '') |
||
668 | |||
669 | /** |
||
670 | * This works like sendtoaddress (listed above), but includes the data-hex hexadecimal metadata in an additional |
||
671 | * OP_RETURN transaction output. |
||
672 | * |
||
673 | * @param $address |
||
674 | * @param $amount |
||
675 | * @param $dataHex |
||
676 | * @return mixed |
||
677 | */ |
||
678 | public function sendWithMetadata($address, $amount, $dataHex) |
||
682 | |||
683 | /** |
||
684 | * This works like sendtoaddress (listed above), but with control over the from-address whose funds are used, and |
||
685 | * with the data-hex hexadecimal metadata added in an additional OP_RETURN transaction output. Any change from the |
||
686 | * transaction is sent back to from-address. |
||
687 | * |
||
688 | * @param $fromAddress |
||
689 | * @param $toAddress |
||
690 | * @param $amount |
||
691 | * @param $dataHex |
||
692 | * @return mixed |
||
693 | */ |
||
694 | public function sendWithMetadataFrom($fromAddress, $toAddress, $amount, $dataHex) |
||
698 | |||
699 | /** |
||
700 | * Creates a transaction spending the specified inputs, sending to the given addresses. In Bitcoin Core, each |
||
701 | * amount field is a quantity of the bitcoin currency. For MultiChain, an {"asset":qty, ...} object can be used for |
||
702 | * amount, in which each asset is an asset name, ref or issuance txid, and each qty is the quantity of that asset |
||
703 | * to send (see native assets). Use "" as the asset inside this object to specify a quantity of the native |
||
704 | * blockchain currency. |
||
705 | * |
||
706 | * @param $inputs |
||
707 | * @param $addresses |
||
708 | * @return mixed |
||
709 | */ |
||
710 | public function createRawTransaction($inputs, $addresses) |
||
714 | |||
715 | /** |
||
716 | * Returns a JSON object describing the serialized transaction in hexstring. For a MultiChain blockchain, each |
||
717 | * transaction output includes assets and permissions fields listing any assets or permission changes encoded |
||
718 | * within that output. There will also be a data field listing the content of any OP_RETURN outputs in the |
||
719 | * transaction. |
||
720 | * |
||
721 | * @param $hexString |
||
722 | * @return mixed |
||
723 | */ |
||
724 | public function decodeRawTransaction($hexString) |
||
728 | |||
729 | /** |
||
730 | * Returns information about the block with hash. If this is a MultiChain blockchain and format is true or omitted, |
||
731 | * then the output includes a field miner showing the address of the miner of the block. |
||
732 | * |
||
733 | * @param $hash |
||
734 | * @param bool $format |
||
735 | * @return mixed |
||
736 | */ |
||
737 | public function getBlock($hash, $format = true) |
||
741 | |||
742 | /** |
||
743 | * If verbose is 1, returns a JSON object describing transaction txid. For a MultiChain blockchain, each transaction |
||
744 | * output includes assets and permissions fields listing any assets or permission changes encoded within that |
||
745 | * output. There will also be a data field listing the content of any OP_RETURN outputs in the transaction. |
||
746 | * |
||
747 | * @param $txId |
||
748 | * @param int $verbose |
||
749 | * @return mixed |
||
750 | */ |
||
751 | public function getRawTransaction($txId, $verbose = 0) |
||
755 | |||
756 | /** |
||
757 | * Returns details about an unspent transaction output vout of txid. For a MultiChain blockchain, includes assets |
||
758 | * and permissions fields listing any assets or permission changes encoded within the output. Set confirmed to true |
||
759 | * to include unconfirmed transaction outputs. |
||
760 | * |
||
761 | * @param $txId |
||
762 | * @param $vOut |
||
763 | * @param bool $unconfirmed |
||
764 | * @return mixed |
||
765 | */ |
||
766 | public function getTxOut($txId, $vOut, $unconfirmed = false) |
||
770 | |||
771 | /** |
||
772 | * Returns a list of unspent transaction outputs in the wallet, with between minconf and maxconf confirmations. For |
||
773 | * a MultiChain blockchain, each transaction output includes assets and permissions fields listing any assets or |
||
774 | * permission changes encoded within that output. If addresses is provided, only outputs which pay an address in |
||
775 | * this array will be included. |
||
776 | * |
||
777 | * @param int $minConf |
||
778 | * @param int $maxConf |
||
779 | * @param null $addresses |
||
780 | * @return mixed |
||
781 | */ |
||
782 | public function listUnspent($minConf = 1, $maxConf = 999999, $addresses = null) |
||
786 | |||
787 | /** |
||
788 | * @param $nativeAmount |
||
789 | * @return mixed |
||
790 | */ |
||
791 | private function findDefaultMinimumPerOutput($nativeAmount) |
||
800 | |||
801 | /** |
||
802 | * Submits raw transaction (serialized, hex-encoded) to local node and network. |
||
803 | * Returns the transaction hash in hex |
||
804 | * |
||
805 | * @param $hex |
||
806 | * @param bool $allowHighFees |
||
807 | * @return mixed |
||
808 | */ |
||
809 | public function sendRawTransaction($hex, $allowHighFees = false) |
||
813 | } |
||
814 |