Bitcoin Forum
May 24, 2024, 11:36:03 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Bitcoin Technical Support / Re: Wallet notify using a PHP routing system? on: May 15, 2018, 03:35:39 PM
Thanks for the help guys. However i found the following solution:

walletnotify=curl 'http://localhost:8000/wallet/notify/'%s

which is working perfectly, without the need of a script.
2  Bitcoin / Bitcoin Technical Support / Re: Wallet notify using a PHP routing system? on: May 15, 2018, 10:24:35 AM
but it seems like i have to use a bash script.


You should have read my post more carefully  Wink

You don't have to use a bash script. Python/PHP would work too, or any other scripting language.

Can you provide an PHP example? it seems like you want me to link to a file.php (which then takes args as a input), but i'm using controllers without extensions and would like to simply pass it to that :-)

i would really like if i could just do it in one line...
3  Bitcoin / Bitcoin Technical Support / Re: Wallet notify using a PHP routing system? on: May 15, 2018, 10:04:56 AM
Hi.

I'm running a Symfony4 (PHP) project which makes use of a routing system.

I want to use walletnotify in the following way, but i want to make sure that it's right before testing:

bitcoin.conf:

walletnotify=curl http://127.0.0.1:8000/wallet/notify/%s


Route:



how would i use the argv function in this case and would it work without specifying a .php extension?

argv is for CLI - command line - usage. If you are going through an web server (and you will, if you're using Symfony controllers), $argv will not be defined.

If your Symfony route is /wallet/notify/{txid}, then your function will be most likely be prototyped like the following, and you'll be able to retrieve your transaction id using $txid (given as a parameter in your function):

Code:
class WalletNotifyController Extends Controller
{
  /**
   * @Route("/wallet/notify/{txid}, name="user_notify)
   */
  public function notify($txid)
  {
    // Your transaction id will be in $txid;
    echo $txid;
  }
}

Symfony documentation is pretty much complete, with a lot of samples. You should give it a try.

Yes i realise how Symfony works, the primary concern i had was how i should formulate the walletnotify script to be able to pass the TXID parameter into the controller and if the following would work :-) Thanks!

walletnotify=curl http://127.0.0.1:8000/wallet/notify/%s

but it seems like i have to use a bash script.
4  Bitcoin / Bitcoin Technical Support / Re: Wallet notify using a PHP routing system? on: May 15, 2018, 07:29:53 AM
I'm running a Symfony4 (PHP) project which makes use of a routing system.

Routing system?  Huh Mind explaining what you mean?

You can read more here: https://symfony.com/doc/current/routing.html

It's essentially just removing the uglyness in URL's, such as the .php extension...



I want to use walletnotify in the following way, but i want to make sure that it's right before testing:

bitcoin.conf:

walletnotify=curl http://127.0.0.1:8000/wallet/notify/%s

~snip~

how would i use the argv function in this case and would it work?

You have to specify the path to your script.
E.g. :
Code:
walletnotify = /home/path/to/your/script.sh %s

And inside your script.sh you can have the following:
Code:
#!/bin/sh
curl http://127.0.0.1:8000/wallet/notify/$1

%s (transaction ID) will be passed to your script and can be used/accessed via $1 (argv).


Note that walletnotify is called when:
1) You receive a transaction
2) You send a transaction
3) A (receiving) transaction gets the first confirmation

If you want to check for a further status (2+ confirmations), you have to use blocknotify instead of walletnotify.





Thank you very much, i'll try it out! Is there no way to do it directly without the need for a bash script?

Also in regards to the path, is it starting from the folder where bitcoin.conf is located? or the root of the system? I suppose i should create a home folder where the bitcoin.conf is?

& to access the $1 in argv, do i simply do $transactionID = $argv[$1]; ?
5  Bitcoin / Bitcoin Technical Support / Wallet notify using a PHP routing system? on: May 15, 2018, 06:43:17 AM
Hi.

I'm running a Symfony4 (PHP) project which makes use of a routing system.

I want to use walletnotify in the following way, but i want to make sure that it's right before testing:

bitcoin.conf:

walletnotify=curl http://127.0.0.1:8000/wallet/notify/%s


Route:



how would i use the argv function in this case and would it work without specifying a .php extension?


Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!