This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | use be\kunstmaan\multichain\MultichainClient; |
||
4 | use be\kunstmaan\multichain\MultichainHelper; |
||
5 | |||
6 | class MultichainClientTest extends \PHPUnit_Framework_TestCase |
||
7 | { |
||
8 | |||
9 | /** @var MultichainClient */ |
||
10 | protected $multichain; |
||
11 | |||
12 | /** @var MultichainHelper */ |
||
13 | protected $helper; |
||
14 | |||
15 | public function setUp() |
||
16 | { |
||
17 | $this->multichain = new MultichainClient("http://sirius.vanderveer.be:8000", 'multichainrpc', '79pgKQusiH3VDVpyzsM6e3kRz6gWNctAwgJvymG3iiuz', 3); |
||
18 | $this->helper = new MultichainHelper($this->multichain); |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * Returns general information about this node and blockchain. MultiChain adds some fields to Bitcoin Core’s |
||
23 | * response, giving the blockchain’s chainname, description, protocol, peer-to-peer port. The setupblocks field |
||
24 | * gives the length in blocks of the setup phase in which some consensus constraints are not applied. The |
||
25 | * nodeaddress can be passed to other nodes for connecting. |
||
26 | * |
||
27 | * @group info |
||
28 | */ |
||
29 | public function testGetInfo() |
||
30 | { |
||
31 | $info = $this->multichain->setDebug(true)->getInfo(); |
||
0 ignored issues
–
show
|
|||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Returns information about the other nodes to which this node is connected. If this is a MultiChain blockchain, |
||
36 | * includes handshake and handshakelocal fields showing the remote and local address used during the handshaking |
||
37 | * for that connection. |
||
38 | * |
||
39 | * @group info |
||
40 | */ |
||
41 | public function testGetPeerInfo() |
||
42 | { |
||
43 | $peers = $this->multichain->setDebug(true)->getPeerInfo(); |
||
0 ignored issues
–
show
$peers is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Returns a new address for receiving payments. Omit the account parameter for the default account – see note |
||
48 | * about accounts. |
||
49 | * |
||
50 | * @group address |
||
51 | */ |
||
52 | public function testGetNewAddress() |
||
53 | { |
||
54 | $address = $this->multichain->setDebug(true)->getNewAddress(); |
||
0 ignored issues
–
show
$address is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Outputs a list of available API commands, including MultiChain-specific commands. |
||
59 | * |
||
60 | * @group info |
||
61 | */ |
||
62 | public function testHelp() |
||
63 | { |
||
64 | $help = $this->multichain->setDebug(true)->help(); |
||
0 ignored issues
–
show
$help is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Sends one or more assets to address, returning the txid. In Bitcoin Core, the amount field is the quantity of |
||
69 | * the bitcoin currency. For MultiChain, an {"asset":qty, ...} object can be used for amount, in which each asset |
||
70 | * is an asset name, ref or issuance txid, and each qty is the quantity of that asset to send (see native assets). |
||
71 | * Use "" as the asset inside this object to specify a quantity of the native blockchain currency. See also |
||
72 | * sendassettoaddress for sending a single asset and sendfromaddress to control the address whose funds are used. |
||
73 | * |
||
74 | * @group transaction |
||
75 | */ |
||
76 | public function testSendToAddress(){ |
||
77 | $address1 = $this->multichain->getNewAddress(); |
||
78 | $address2 = $this->multichain->getNewAddress(); |
||
79 | $assetInfo = $this->createTestAsset($address1); |
||
80 | $this->multichain->setDebug(true)->sendToAddress($address2, array($assetInfo["name"] => 100)); |
||
0 ignored issues
–
show
array($assetInfo['name'] => 100) is of type array<?,integer> , but the function expects a string .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() $address2 is of type object<JsonRPC\Client>|object<Exception> , but the function expects a string .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
81 | } |
||
82 | |||
83 | /** |
||
84 | * @param $address |
||
85 | * @return mixed |
||
86 | */ |
||
87 | private function createTestAsset($address){ |
||
88 | $name = uniqid("asset"); |
||
89 | $issueQty = 1000000; |
||
90 | $units = 0.01; |
||
91 | $assetTxId = $this->multichain->issue($address, $name, $issueQty, $units); |
||
92 | // before the asset is usable, we need to wait a while |
||
93 | $this->helper->waitForAssetAvailability($assetTxId); |
||
94 | return $this->helper->getAssetInfoFromTxId($assetTxId); |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * Returns information about address including a check for its validity. |
||
99 | * |
||
100 | * @group address |
||
101 | */ |
||
102 | public function testValidateAddress() |
||
103 | { |
||
104 | $address = $this->multichain->getNewAddress(); |
||
105 | $this->multichain->setDebug(true)->validateAddress($address); |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * Adds to the atomic exchange transaction in hexstring given by a previous call to createrawexchange or |
||
110 | * appendrawexchange. This adds an offer to exchange the asset/s in output vout of transaction txid for qty units |
||
111 | * of asset, where asset is an asset name, ref or issuance txid. The txid and vout should generally be taken from |
||
112 | * the response to preparelockunspent or preparelockunspentfrom. Multiple items can be specified within the fourth |
||
113 | * parameter to request multiple assets. Returns a raw hexadecimal transaction in the hex field alongside a |
||
114 | * complete field stating whether the exchange is complete (i.e. balanced) or not. If complete, the transaction |
||
115 | * can be transmitted to the network using sendrawtransaction. If not, it can be passed to a further counterparty, |
||
116 | * who can call decoderawexchange and appendrawexchange as appropriate. |
||
117 | * |
||
118 | * @group exchange |
||
119 | */ |
||
120 | public function testAppendRawExchange(){ |
||
121 | $address1 = $this->multichain->getNewAddress(); |
||
122 | $assetInfo = $this->createTestAsset($address1); |
||
123 | $lock = $this->multichain->prepareLockUnspent(array($assetInfo["name"] => 123)); |
||
124 | $hexString = $this->multichain->createRawExchange($lock["txid"], $lock["vout"], array($assetInfo["name"] => 100)); |
||
125 | $this->multichain->setDebug(true)->appendRawExchange($hexString, $lock["txid"], $lock["vout"], array($assetInfo["name"] => 10)); |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * Creates a new atomic exchange transaction which offers to exchange the asset/s in output vout of transaction |
||
130 | * txid for qty units of asset, where asset is an asset name, ref or issuance txid. The txid and vout should |
||
131 | * generally be taken from the response to preparelockunspent or preparelockunspentfrom. Multiple items can be |
||
132 | * specified within the third parameter to request multiple assets. Returns a raw partial transaction in |
||
133 | * hexadecimal which can be passed to the counterparty, who can call decoderawexchange and appendrawexchange |
||
134 | * as appropriate. |
||
135 | * |
||
136 | * @group exchange |
||
137 | */ |
||
138 | public function testCreateRawExchange(){ |
||
139 | $address1 = $this->multichain->getNewAddress(); |
||
140 | $assetInfo1 = $this->createTestAsset($address1); |
||
141 | $assetInfo2 = $this->createTestAsset($address1); |
||
142 | $lock = $this->multichain->prepareLockUnspent(array($assetInfo1["name"] => 123)); |
||
143 | $this->multichain->setDebug(true)->createRawExchange($lock["txid"], $lock["vout"], array($assetInfo2["name"] => 100)); |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * Decodes the raw exchange transaction in hexstring, given by a previous call to createrawexchange or |
||
148 | * appendrawexchange. Returns details on the offer represented by the exchange and its present state. The offer |
||
149 | * field in the response lists the quantity of native currency and/or assets which are being offered for exchange. |
||
150 | * The ask field lists the native currency and/or assets which are being asked for. The candisable field specifies |
||
151 | * whether this wallet can disable the exchange transaction by double-spending against one of its inputs. The |
||
152 | * cancomplete field specifies whether this wallet has the assets required to complete the exchange. The |
||
153 | * complete field specifies whether the exchange is already complete (i.e. balanced) and ready for sending. If |
||
154 | * verbose is true then all of the individual stages in the exchange are listed. Other fields relating to fees are |
||
155 | * only relevant for blockchains which use a native currency. |
||
156 | * |
||
157 | * @group exchange |
||
158 | */ |
||
159 | public function testDecodeRawExchange(){ |
||
160 | $address1 = $this->multichain->getNewAddress(); |
||
161 | $assetInfo1 = $this->createTestAsset($address1); |
||
162 | $assetInfo2 = $this->createTestAsset($address1); |
||
163 | $lock = $this->multichain->prepareLockUnspent(array($assetInfo1["name"] => 123)); |
||
164 | $hexString = $this->multichain->createRawExchange($lock["txid"], $lock["vout"], array($assetInfo2["name"] => 100)); |
||
165 | $this->multichain->setDebug(true)->decodeRawExchange($hexString, true); |
||
166 | |||
167 | } |
||
168 | |||
169 | /** |
||
170 | * Sends a transaction to disable the offer of exchange in hexstring, returning the txid. This is achieved by |
||
171 | * spending one of the exchange transaction’s inputs and sending it back to the wallet. To check whether this can |
||
172 | * be used on an exchange transaction, check the candisable field of the output of decoderawexchange. |
||
173 | * |
||
174 | * @group exchange |
||
175 | */ |
||
176 | public function testDisableRawTransaction(){ |
||
177 | $address1 = $this->multichain->getNewAddress(); |
||
178 | $assetInfo1 = $this->createTestAsset($address1); |
||
179 | $assetInfo2 = $this->createTestAsset($address1); |
||
180 | $lock = $this->multichain->prepareLockUnspent(array($assetInfo1["name"] => 123)); |
||
181 | $hexString = $this->multichain->createRawExchange($lock["txid"], $lock["vout"], array($assetInfo2["name"] => 100)); |
||
182 | $this->multichain->setDebug(true)->disableRawTransaction($hexString); |
||
183 | } |
||
184 | |||
185 | /** |
||
186 | * Prepares an unspent transaction output (useful for building atomic exchange transactions) containing qty units |
||
187 | * of asset, where asset is an asset name, ref or issuance txid. Multiple items can be specified within the first |
||
188 | * parameter to include several assets within the output. The output will be locked against automatic selection for |
||
189 | * spending unless the optional lock parameter is set to false. Returns the txid and vout of the prepared output. |
||
190 | * |
||
191 | * @group exchange |
||
192 | */ |
||
193 | public function testPrepareLockUnspent(){ |
||
194 | $address1 = $this->multichain->getNewAddress(); |
||
195 | $assetInfo = $this->createTestAsset($address1); |
||
196 | $this->multichain->setDebug(true)->prepareLockUnspent(array($assetInfo["name"] => 123)); |
||
197 | } |
||
198 | |||
199 | /** |
||
200 | * Adds a metadata output to the raw transaction in tx-hex given by a previous call to createrawtransaction. The |
||
201 | * metadata is specified in data-hex in hexadecimal form and added in a new OP_RETURN transaction output. The |
||
202 | * transaction can then be signed and transmitted to the network using signrawtransaction and sendrawtransaction. |
||
203 | * |
||
204 | * @group metadata |
||
205 | */ |
||
206 | public function testAppendRawMetadata(){ |
||
207 | $address1 = $this->multichain->getNewAddress(); |
||
208 | $assetInfo1 = $this->createTestAsset($address1); |
||
209 | $assetInfo2 = $this->createTestAsset($address1); |
||
210 | $lock = $this->multichain->prepareLockUnspent(array($assetInfo1["name"] => 123)); |
||
211 | $txHex = $this->multichain->createRawExchange($lock["txid"], $lock["vout"], array($assetInfo2["name"] => 100)); |
||
212 | $this->multichain->setDebug(true)->appendRawMetadata($txHex, "fakemetadata"); |
||
213 | } |
||
214 | |||
215 | /** |
||
216 | * Sends transactions to combine large groups of unspent outputs (UTXOs) belonging to the same address into a |
||
217 | * single unspent output, returning a list of txids. This can improve wallet performance, especially for miners in |
||
218 | * a chain with short block times and non-zero block rewards. Set addresses to a comma-separated list of addresses |
||
219 | * to combine outputs for, or * for all addresses in the wallet. Only combine outputs with at least minconf |
||
220 | * confirmations, and use between mininputs and maxinputs per transaction. A single call to combineunspent can |
||
221 | * create up to maxcombines transactions over up to maxtime seconds. See also the autocombine runtime parameters. |
||
222 | * |
||
223 | * @group operations |
||
224 | */ |
||
225 | public function testCombineUnspent(){ |
||
226 | //$this->multichain->setDebug(true)->combineUnspent(); |
||
227 | } |
||
228 | |||
229 | /** |
||
230 | * Returns a list of all the asset balances for address in this node’s wallet, with at least minconf confirmations. |
||
231 | * Use includeLocked to include unspent outputs which have been locked, e.g. by a call to preparelockunspent. |
||
232 | * |
||
233 | * @group address |
||
234 | */ |
||
235 | public function testGetAddressBalances(){ |
||
236 | $address1 = $this->multichain->getNewAddress(); |
||
237 | $this->createTestAsset($address1); |
||
238 | $this->multichain->setDebug(true)->getAddressBalances($address1); |
||
239 | } |
||
240 | |||
241 | |||
242 | /** |
||
243 | * Returns a list of addresses in this node’s wallet. Set verbose to true to get more information about each |
||
244 | * address, formatted like the output of the validateaddress command. |
||
245 | * |
||
246 | * @group address |
||
247 | */ |
||
248 | public function testGetAddresses() |
||
249 | { |
||
250 | $this->multichain->setDebug(true)->getAddresses(true); |
||
251 | } |
||
252 | |||
253 | /** |
||
254 | * Provides information about transaction txid related to address in this node’s wallet, including how it affected |
||
255 | * that address’s balance. Use verbose to provide details of transaction inputs and outputs. |
||
256 | * |
||
257 | * @group address |
||
258 | * @group transaction |
||
259 | */ |
||
260 | public function testGetAddressTransaction(){ |
||
261 | $address1 = $this->multichain->getNewAddress(); |
||
262 | $address2 = $this->multichain->getNewAddress(); |
||
263 | $assetInfo = $this->createTestAsset($address1); |
||
264 | $txId = $this->multichain->sendToAddress($address2, array($assetInfo["name"] => 100)); |
||
0 ignored issues
–
show
array($assetInfo['name'] => 100) is of type array<?,integer> , but the function expects a string .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() $address2 is of type object<JsonRPC\Client>|object<Exception> , but the function expects a string .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
265 | $this->multichain->setDebug(true)->getAddressTransaction($address2, $txId, true); |
||
266 | } |
||
267 | |||
268 | /** |
||
269 | * Returns a list of all the asset balances for account in this node’s wallet, with at least minconf confirmations. |
||
270 | * Omit the account parameter or use "" for the default account – see note about accounts. Use includeWatchOnly to |
||
271 | * include the balance of watch-only addresses and includeLocked to include unspent outputs which have been locked, |
||
272 | * e.g. by a call to preparelockunspent. |
||
273 | * |
||
274 | * @group test |
||
275 | */ |
||
276 | public function testGetAssetBalances(){ |
||
277 | $this->multichain->setDebug(true)->getAssetBalances(); |
||
278 | } |
||
279 | |||
280 | /** |
||
281 | * Returns a list of all the parameters of this blockchain, reflecting the content of its params.dat file. |
||
282 | * |
||
283 | * @group info |
||
284 | */ |
||
285 | public function testGetBlockchainParams() |
||
286 | { |
||
287 | $this->multichain->setDebug(true)->getBlockchainParams(); |
||
288 | } |
||
289 | |||
290 | /** |
||
291 | * Creates a new asset name on the blockchain, sending the initial qty units to address. The smallest transactable |
||
292 | * unit is given by units, e.g. 0.01. If the chain uses a native currency, you can send some with the new asset |
||
293 | * using the native-amount parameter. Returns the txid of the issuance transaction. For more information, see |
||
294 | * native assets. |
||
295 | * |
||
296 | * @group asset |
||
297 | */ |
||
298 | public function testIssue() |
||
299 | { |
||
300 | $address = $this->multichain->getNewAddress(); |
||
301 | $name = uniqid("asset"); |
||
302 | $issueQty = 1000000; |
||
303 | $units = 0.01; |
||
304 | $this->multichain->issue($address, $name, $issueQty, $units); |
||
305 | } |
||
306 | |||
307 | /** |
||
308 | * Returns information about all assets issued on the blockchain. If an asset name, ref or issuance txid (see |
||
309 | * native assets) is provided in asset, then information is only returned about that one asset. |
||
310 | * |
||
311 | * @group asset |
||
312 | */ |
||
313 | public function testListAssets() |
||
314 | { |
||
315 | $this->multichain->listAssets(); |
||
316 | } |
||
317 | |||
318 | /** |
||
319 | * Lists information about the count most recent transactions in this node’s wallet, including how they affected |
||
320 | * the node’s total balance. Use skip to go back further in history and includeWatchOnly to consider watch-only |
||
321 | * addresses as if they belong to this wallet. Use verbose to provide the details of transaction inputs and |
||
322 | * outputs. Note that unlike Bitcoin Core’s listtransactions command, the response contains one element per |
||
323 | * transaction, rather than one per transaction output. |
||
324 | * |
||
325 | * @group transaction |
||
326 | */ |
||
327 | public function testListWalletTransactions() |
||
328 | { |
||
329 | $this->multichain->listWalletTransactions(10, 0, false, false); |
||
330 | } |
||
331 | } |
||
332 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.