Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: rezalnik on February 13, 2015, 02:51:17 PM



Title: can't get walletnotify to work
Post by: rezalnik on February 13, 2015, 02:51:17 PM
Hey,

I'm trying to Setup a script that executes whenever my wallet receives a Transaction and found out that walletnotify is a good solution to that.  Though there is really only one helpful thread about this on here and that thread's solution didn't work for me.(https://bitcointalk.org/index.php?topic=203438.0)
I would prefer do this with nodejs, though I don't know nodejs's equivalent to argv and argv, so I tried the php solution that the above thread suggests:

my bitcoin.conf:
Code:
bitcoin.conf:
server=1
daemon=1
rpcuser=user
rpcpassword=password
walletnotify =/usr/bin/php /var/www/laravel/app/views/walletnotify.php %s

my walletnotify.php:
Code:
if(2==$argc){
require_once('/var/www/laravel/app/controllers/easybitcoin.php');
$bitcoin = new Bitcoin('user', 'password', 'localhost', '8332');

$walletinfo = $bitcoin->getinfo();
$trxinfo = $bitcoin->gettransaction($argv[1]);

// Append data to the file
$new = "\n\nTransaction hash: ".$argv[1]."\nGetinfo balance: ".$walletinfo["balance"]
."\n Gettransaction amount: ".$trxinfo["amount"]
."\n Gettransaction confirmations: ".$trxinfo["confirmations"]
."\n Gettransaction blockhash: ".$trxinfo["blockhash"]
."\n Gettransaction blockindex: ".$trxinfo["blockindex"]
."\n Gettransaction blocktime: ".$trxinfo["blocktime"]
."\n Gettransaction txid: ".$trxinfo["txid"]
."\n Gettransaction time: ".$trxinfo["time"]
."\n Gettransaction timereceived: ".$trxinfo["timereceived"]
."\n Gettransaction account: ".$trxinfo["details"][0]["account"]
."\n Gettransaction address: ".$trxinfo["details"][0]["address"]
."\n Gettransaction category: ".$trxinfo["details"][0]["category"]
."\n Gettransaction amount: ".$trxinfo["details"][0]["amount"]
//."\n Gettransaction fee: ".$trxinfo["details"][0]["fee"]
$fp=fopen("notify_wallet.txt","a");
fwrite($fp,$new);
}

with this i got the error "Undefined variable: argc", so I did some Research that led me to putting this into my php.ini(line 650):

Code:
register_argc_argv = On

I'm still getting the "undefined variable: argc" error though.

If anyone could help me out here, I would highly appreciate it!(If anyone knows how to do this with nodejs, that would be even better!)


Title: Re: can't get walletnotify to work
Post by: goregrind on February 13, 2015, 05:32:08 PM
Make sure you're modifying the right php.ini
/usr/bin/php -i|grep php.ini
should tell you the location of the php.ini file
/usr/bin/php -i|grep argc_argv
should tell you if register_argc_argv is really on.



Title: Re: can't get walletnotify to work
Post by: rezalnik on February 13, 2015, 06:36:26 PM
Make sure you're modifying the right php.ini
php -i|grep php.ini
should tell you the location of the php.ini file
php -i|grep argc_argv
should tell you if register_argc_argv is really on.



Make sure you're modifying the right php.ini
php -i|grep php.ini
should tell you the location of the php.ini file
php -i|grep argc_argv
should tell you if register_argc_argv is really on.


apperantly I was editing the wrong ini file, but now I edited the right one and when i call
Code:
php-i|grep argc_argv
, it returns
Code:
register_argc_argv => On => On
,
though when it still shows the error "Undefined variable: argc"

Maybe the fact that there is 2 "on"s means that I did something wrong?

Do you know which variables i would use in nodejs instead of "argc" and "argv"?


Title: Re: can't get walletnotify to work
Post by: goregrind on February 15, 2015, 09:43:47 AM
You might have multiple versions of php installed.
Try again the instructions from my edited post, if that still doesn't clear it then I'm out of ideas.
Do do that in nodejs you can start here: https://www.google.com/?gws_rd=ssl#q=node+js+command+line+arguments