monero-integrations / monerophp

Monero PHP library + JsonRPC Client
MIT License
116 stars 76 forks source link

Passing array as parameter to get_transfers method causes exception #112

Closed mrmena closed 3 years ago

mrmena commented 4 years ago

When calling the get_transfers method with an array parameter I get an "Undefined offset: 0" exception.

Example code:

$transfer_params = array(
    'input_types' => array('in', 'out'),
    'account_index' => 0,
);

$transfers = $walletRPC->get_transfers($transfer_params);    //<-- Exception here

Offending source line:

  1347|    $params = array('account_index' => $account_index, 'subaddr_indices' => $subaddr_indices, 'min_height' => $min_height, 'max_height' => $max_height);
  1347|      for ($i = 0; $i < count($input_types); $i++) {
> 1348|        $params[$input_types[$i]] = true;
  1349|      }
  1350|    }

If I change the following source line from:

  1324|      if (is_object($input_types)) { // Parameters passed in as object/dictionary`

to

  1324|      if (is_array($input_types)) { // Parameters passed in as array?`

then it works fine.

The documentation says that you can pass an object but the only way I could get it to work was by changing it to an array. Is there a better way to construct the $transfer_params parameter in my example?