Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library returns NULL when it receives a blank response and error. #92

Open
BarneyChambers opened this issue Mar 13, 2019 · 4 comments
Open
Labels

Comments

@BarneyChambers
Copy link

I am using $walletRPC->transfer() among other functions, and whenever I run this command, the function returns null instead of error messages or resulting information from the transfer() function.

For example, I ran the following command:

$result = $walletRPC->transfer(0.00001, '43CHhRBuqiPFevrGEnQeSR76CMhKnV21AfHDsp47oY3CH7dBLFE7egBT2vT3niBXWC8k4WzJ8zFkLdTYVKKuBpwhVXiq7ZS', 'd9e3f557812a49ddaaa096555b22e658d88052c09ec64bde9bcc2be905fb04a2');

$result was NULL, despite my monero-rpc log showing these errors.

ERROR wallet.wallet2 src/wallet/wallet2.cpp:8369 needed_moner + min_fee > unlocked_balance_subtotal. THROW EXCEPTION: error:not_enough_unlocked_money.

What is the correct way to see my error messages through this API?

Thanks!

@BarneyChambers BarneyChambers changed the title $this->_run('transfer', $params); returning null. Notice: Undefined index: result in /var/www/html/monerophp/src/jsonRPCClient.php on line 121 Mar 13, 2019
@serhack serhack changed the title Notice: Undefined index: result in /var/www/html/monerophp/src/jsonRPCClient.php on line 121 Library returns NULL when it encounters an error Mar 13, 2019
@serhack
Copy link
Member

serhack commented Mar 13, 2019

I've changed the title, definitely this feature should be implement in the next version.

@BarneyChambers
Copy link
Author

Sorry I think that maybe my question was not clear. I have done some digging and it seems like this is a bug. If I add a vardump at jsonRPCClient.php:121

...
     }
     var_dump($responseDecoded);
     return $responseDecoded['result'];
}
...

It seems that it runs this code twice because this is the result of that var_dump with error messages enabled.

array(3) { ["error"]=> array(2) { ["code"]=> int(-37) ["message"]=> string(25) "not enough unlocked money" } ["id"]=> int(1) ["jsonrpc"]=> string(3) "2.0" } 
Notice: Undefined index: result in /var/www/html/monerophp/src/jsonRPCClient.php on line 122
array(3) { ["id"]=> int(2) ["jsonrpc"]=> string(3) "2.0" ["result"]=> array(0) { } }

SO it seems to me that it runs correctly on the first pass, then gets confused, runs again and returns null? Sorry I am unfamiliar with the code so maybe I am using it wrong but this seems like a bug. The code I have created to get this bug is simple and displayed below:

$walletRPC = new MoneroIntegrations\MoneroPhp\walletRPC('127.0.0.1', 28083);

$transfer = $walletRPC->transfer((float)$_GET['amount'], $_GET['address'], $_GET['payment_id]);

@BarneyChambers
Copy link
Author

After more digging, it seems that it is because the _run function is being called twice... once for for the JSON RPC transfer call, and once for the JSON RPC store call. And since store does not return a result, we are seeing this error.

@serhack serhack added the bug label Mar 13, 2019
@serhack serhack changed the title Library returns NULL when it encounters an error Library returns NULL when it receives a blank response and error. Mar 13, 2019
@serhack
Copy link
Member

serhack commented Feb 28, 2021

Could you please retest?

@recanman recanman mentioned this issue Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants