Bitcoin walletnotify doesn't pass the txid as %s

0

Thoroughly searched this online but haven't found an answer yet. Basically I'm using the below line in my conf file:

walletnotify=C:\pathname\filename.py %s

It is supposed to run my python file and pass the txid to it as the argument sys.argv[1]. But I get "IndexError: list index out of range" and upon investigating, it is merely opening the python file without passing anything to it, so there are no arguments.

I am using Anaconda for python 3 and I've set the python.exe file in my Appdata\local\conda\conda...subfolders as the default program to open .py files with. This might be relevant because earlier there was a python 2.7 installed on my computer that I wasn't really using, but somehow walletnotify seemed to be working fine at that time. I uninstalled python 2.7 just to clean up my computer and since then I've been facing this issue. I'm using Windows 10 FYI.

I'm a bit frustrated as I've been trying to crack this for about 6 hours now without much success. Please help.

oktested

Posted 2019-03-21T01:55:38.840

Reputation: 11

Try putting double quotes around the entire command that you want to run, i.e. walletnotify="C:\pathname\filename.py %s"Andrew Chow 2019-03-21T02:32:38.900

Thanks for the reply - this didn't work, but when I tried walletnotify= C:\pythonpath\python.exe C:\pathname\filename.py %s then it worked. I don't know why this worked, but if you have any idea, please do tell. Would love to learn. FYI, the txid was passed as sys.argv[1].oktested 2019-03-21T04:28:06.543

In Windows, python file needs to be run within the python path. You can refer https://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows for more details as to how to change the python path. As a workaround, you can also use walletnotify= py C:\pathname\filename.py %s

Ugam Kamat 2019-03-21T08:32:35.487

Thanks @BlockGuru - but if I'm calling a .py file from command line, and I've already set the python.exe program as the default program to open all .py files on Windows, then I wonder why it still requires me to add the pythonpath or the prefix "py " before the command. Anyway, all's well that ends well. Thanks and have a wonderful day!oktested 2019-03-21T08:41:37.470

No answers