Bitcoin Transaction Detection With PHP

3

2

I Hope this isn't a duplicated, however I couldn't find anything about this anywhere. Anyways, I am searching for a way of detecting Bitcoin transactions to a given address. I stumbled across Lazy API, however I couldn't find anything about carrying out what it listed, and I am still not sure how to go about detecting transactions to a given address. I went ahead and went to the given link it provided here (and I stumbled across doing using Transaction By Address from the API reference on blockexplorer, but I am still not clear how to go about detecting if I received a transaction.

Please pardon if this is a stupid question, I am a little new to all of this. Edit: I dont wish to relay on another service, unless it is the way Lazy API does it. (Basically complete minimals, from other services.) Also someone asked to clarify what I meant by detect a transaction, what I mean is have server recognize when someone completed a transaction, either notifying me to do something (such as ship a package), or giving them some sort of virtual product.

UbuntuCake

Posted 2016-08-13T00:08:30.917

Reputation: 31

Can you clarify what you mean by detect if you received a transaction? Are you keeping track off addresses on a database? Are you looking for specific code to run once a new transaction is detected on a specific address? How many addresses do you need to do this with? You're going to need to use either a 3rd party API or run bitcoind to query blockchain data.m1xolyd1an 2016-08-13T04:20:05.433

Answers

2

Im guessing your on ubuntu because of your username ;)
Step 1 add the bitcoin ppa

sudo apt-add-repository ppa:bitcoin/bitcoin

Step 2 install bitcoind

sudo apt install bitcoind

Step 3 set bitcoind up

Make a config file with the following contents in /home/$USER/.bitcoin/bitcoin.conf
https://github.com/bitcoin/bitcoin/blob/master/contrib/debian/examples/bitcoin.conf
Replace some parts like rpc password etc

Step 4 add walletnotify

Walletnotify will run a shell command everytime something changes in your wallet.
I like this repo.
https://github.com/damonp/walletnotify

I hope this helps! :)

Web Weave

Posted 2016-08-13T00:08:30.917

Reputation: 319

Actually I use debian. Old username :pUbuntuCake 2016-08-13T14:53:59.063

Well the concept stays the same install bitcoind and use walletnotify, Build docs: https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md

Web Weave 2016-08-13T14:57:07.560

1

1.) Install Bitcoin Core on your server.

2.) Add a line to bitcoin.conf file that will fire when any funds are received to any addresses you're watching (ie. walletnotify=/usr/bin/php /home/coind/notify.php %s). Start bitcoind.

3.) Run "importaddress" function for any addresses you want to watch (ie. bitcoin-cli importaddress 1myaddresshere).

Done. Any time a tx hits any of the addresses you import, notify.php will automatically fire.

Envrin Group

Posted 2016-08-13T00:08:30.917

Reputation: 11