Implementing events with the bitcoind notifications using PHP

1

1

Bitcoind has 3 methods

  • blocknotify=cmd
  • walletnotify=cmd
  • alertnotify=cmd

I understand that these 3 command line parameters needs to be used for get notifications from bitcoin daemon. Could someone suggest how it needs to be integrated or communicate with PHP application.

Abishek R Srikaanth

Posted 2013-12-07T17:15:27.113

Reputation: 111

Answers

1

I would recommend that you use blocknotify to execute a CLI PHP script. The script would then use PHP JSON-RPC to call listsinceblock to get the transactions that occurred in the latest block and put them in a MySQL database.

Bitlab.co

Posted 2013-12-07T17:15:27.113

Reputation: 724

0

When parsing incoming bitcoin payments, I wanted to show people a record of their topup's. Whenever funds arrived in an address the wallet owned, the -walletnotify callback was run using curl to call the website's URL, and specified the transaction ID. It checked the transaction corresponded to a user (checked the address was in a particular MySQL table). Once this was true, it would be stored with the userid, transaction id, send/receive, and confirmations (=0)

Before they could spend it, 6 confirmations had to pass. So every time the blocknotify trigger was run, it would gather all transactions in the table which had confirmations <50, and rescanned them every time a block came through. At 7 confirmations they were finally credited to the users database.

Since users 'spending' on my site only affected the database I ran into trouble, so if you're considering this you might just go with multi-signature transactions, I'm rewriting to build in support for multisig at the moment.

karimkorun

Posted 2013-12-07T17:15:27.113

Reputation: 763