WalletNotify Script

simplebtc

New Member
Oct 1, 2014
15
5
3
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.

[email protected]
 
Last edited by a moderator:

Light

Well-known Member
Foundation Member
Jun 4, 2014
346
256
233
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.

[email protected]
Can these sms and email updates about sent/received funds create a pattern overtime that can compromise the user?
 

simplebtc

New Member
Oct 1, 2014
15
5
3
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:

fernando

Powered by Dash
Dash Core Team
Moderator
Foundation Member
May 9, 2014
1,527
2,058
283
I understand that you need to have the wallet running for this to work, don't you?
 

simplebtc

New Member
Oct 1, 2014
15
5
3
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.
 

Rux

Member
Mar 9, 2014
68
32
58
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


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

any clues? ;) im noob so dont mind me please :D
 

simplebtc

New Member
Oct 1, 2014
15
5
3
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.
 

Rux

Member
Mar 9, 2014
68
32
58
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
 

simplebtc

New Member
Oct 1, 2014
15
5
3
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.
 

Rux

Member
Mar 9, 2014
68
32
58
//- 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');
 

Rux

Member
Mar 9, 2014
68
32
58
you mean like this? ;)
define('WN_RPC_HOST','localhost');
 
Last edited by a moderator:

Rux

Member
Mar 9, 2014
68
32
58
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
 

Rux

Member
Mar 9, 2014
68
32
58
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
 

simplebtc

New Member
Oct 1, 2014
15
5
3
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__);
 

Dxa58

New Member
Jun 24, 2015
1
0
1
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