Bitcoin Forum
May 21, 2024, 11:51:17 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: can't get walletnotify to work  (Read 1543 times)
rezalnik (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
February 13, 2015, 02:51:17 PM
 #1

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!)
goregrind
Full Member
***
Offline Offline

Activity: 149
Merit: 100


View Profile
February 13, 2015, 05:32:08 PM
Last edit: February 15, 2015, 09:41:21 AM by goregrind
 #2

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.


woot?
rezalnik (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
February 13, 2015, 06:36:26 PM
 #3

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"?
goregrind
Full Member
***
Offline Offline

Activity: 149
Merit: 100


View Profile
February 15, 2015, 09:43:47 AM
 #4

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

woot?
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!