• Forum has been upgraded, all links, images, etc are as they were. Please see Official Announcements for more information

WalletNotify Script

simplebtc

New member
Darkcoind provides a configuration parameter called walletnotify that accepts a script as its parameter. When the wallet receives a transaction for a local address it hits the script configured, passing the txid incoming.

walletnotify.php is a self-contained PHP script for processing walletnotify calls. Use as is or customize for your own needs.

Features
  • Processes darkcoind walletnotify calls and inserts the transaction into a database (MySQL or SQLite).
  • Sends email and SMS notifications on transactions affecting local DRK addresses.
  • Provides a simple interface for chaining other processes.
Usage
  • Receive SMS or email update anytime funds are sent or received.
  • Process payments automatically whenever coins are received.
  • Automatically sweep coins to cold wallets.
  • Automatically pay affiliates / partners per transaction.

WalletNotify@github
 
Last edited by a moderator:
Darkcoind provides a configuration parameter called walletnotify that accepts a script as its parameter. When the wallet receives a transaction for a local address it hits the script configured, passing the txid incoming.

walletnotify.php is a self-contained PHP script for processing walletnotify calls. Use as is or customize for your own needs.

Features
  • Processes darkcoind walletnotify calls and inserts the transaction into a database (MySQL or SQLite).
  • Sends email and SMS notifications on transactions affecting local DRK addresses.
  • Provides a simple interface for chaining other processes.
Usage
  • Receive SMS or email update anytime funds are sent or received.
  • Process payments automatically whenever coins are received.
  • Automatically sweep coins to cold wallets.
  • Automatically pay affiliates / partners pre transaction.

WalletNotify@github

Can these sms and email updates about sent/received funds create a pattern overtime that can compromise the user?
 
Good question. The primary work of the script is to shove transactions affecting the local wallet into a database. For example, to process the transactions in queue by other scripts.

WalletNotify is a stripped down version of a similar script that processes orders. Check out this one for reference: walletnotify.php.

I wouldn't advise running it on a large storage wallet, no. You shouldn't need this type of processing on that kind of wallet.

You can turn off all notifications by commenting out line #158.

What was your planned use case?
 
Last edited by a moderator:
I understand that you need to have the wallet running for this to work, don't you?
 
Yes, the wallet itself calls whatever script is configured in the walletnotify parameter whenever it receives an update from the blockchain that affects one of its addresses.
 
Hi guys im very interested in this script but im having problems setting it up on wamp to test it

when i open cmd and go to php, type
php -f walletnotify.php <txid>

after 30-60sec it returns
eZiKvpj.png


when i go to phpmyadmin ... my database walletnotify and table walletnotify is empty :)

any clues? ;) im noob so dont mind me please :D
 
Have you checked your PHP error log? There are multiple error_log() statements during execution that should be outputting to wherever WAMP is configured for logging.
 
I think that was problem with WAMP

so i started instance on ubuntu 14.04 x64

I setup everything, dashd started with ./dashd -daemon

with configured dash.conf
rpcuser=XXX
rpcpassword=XXX
rpcport=8332
rpcallowip=127.0.0.1
server=1
walletnotify=/usr/bin/php -f /srv/app/bin/walletnotify.php %s

when i want to test with
php -f walletnotify.php TXID

it returns me error
php -f walletnotify.php 3804baab580255f8b24d3ed490741f582d4344d3553e3b59377f97bc0585658fž
PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /srv/app/bin/walletnotify.php on line 74

line 74 is
define('WN_RPC_PORT', '8332');

Cant figure out, little help for the noob ;D
 
Can you post the few lines before and after line #74? That error normally means there is a missing semicolon or quote symbol shortly before the line it references.

Also make sure all of the quotes are normal ' or " quotes. I've seen smart quotes (ie. “ ”) get introduced sometimes which are not valid in code.
 
//- set for local bitcoind access or remote RPC service like rpc.blockchain.info
define('WN_RPC_USER', 'XXX');
define('WN_RPC_PASS', 'XXX');
define('WN_RPC_HOST',localhost');
define('WN_RPC_PORT', '8332');
 
you mean like this? ;)
define('WN_RPC_HOST','localhost');
 
Last edited by a moderator:
ok i did that, now when i start
root@vultr:/srv/app/bin# php -f walletnotify.php 3804baab580255f8b24d3ed490741f582d4344d3553e3b59377f97bc0585658f

it returns right away to
root@vultr:/srv/app/bin#

but no entry in database :(
 
tail -n10 -f /var/log/apache2/error.log

i did this but its not showing any recents error logs... but this is for apache, i need php log?

i really dont know where is it :D
 
This is my lines for accessing db

$dsn = 'mysql:dbname=walletnotify;host=localhost';
$db = new PDO($dsn, 'root', 'password');

and root user have all privileges on waletnotify database and table

:) im sorry for bothering you with this, i just wanna learn :D
 
tail -n10 -f /var/log/apache2/error.log

i did this but its not showing any recents error logs... but this is for apache, i need php log?

i really dont know where is it :D

Yes, you need the PHP log. Depends on versions and how you set it up. Could be log/messages, the Apache error log or even nothing if logging wasn't configured for PHP yet.

Google is your best friend.

Once you find where it's logging, add more logging statements as necessary to narrow down what is happening. Even simple line number outputs can be invaluable to see what code is and isn't executing.

Code:
error_log('LINE: '.__LINE__);
 
If someone could upload their working dash.conf and walletnotify.php I would be really grateful
My error logs don't indicate any errors but the data isn't being passed to the database
 
Back
Top