Bitcoin Forum
May 04, 2024, 01:00:38 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoind new tx callback  (Read 1338 times)
coin_love (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
November 11, 2013, 12:33:22 AM
 #1

Quick question I didn't find an answer to: Is there a (subscribable) callback mechanism in Bitcoind for new tx or do you need to use polling? How do you typically solve this, if you need to push the available funds to the user when their deposit clears out?
The grue lurks in the darkest places of the earth. Its favorite diet is adventurers, but its insatiable appetite is tempered by its fear of light. No grue has ever been seen by the light of day, and few have survived its fearsome jaws to tell the tale.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714827638
Hero Member
*
Offline Offline

Posts: 1714827638

View Profile Personal Message (Offline)

Ignore
1714827638
Reply with quote  #2

1714827638
Report to moderator
1714827638
Hero Member
*
Offline Offline

Posts: 1714827638

View Profile Personal Message (Offline)

Ignore
1714827638
Reply with quote  #2

1714827638
Report to moderator
1714827638
Hero Member
*
Offline Offline

Posts: 1714827638

View Profile Personal Message (Offline)

Ignore
1714827638
Reply with quote  #2

1714827638
Report to moderator
btc4ever
Sr. Member
****
Offline Offline

Activity: 321
Merit: 250


View Profile
November 11, 2013, 12:42:46 AM
 #2

./bitcoind --help | grep notify
  -blocknotify=<cmd>     Execute command when the best block changes (%s in cmd is replaced by block hash)
  -walletnotify=<cmd>    Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)
  -alertnotify=<cmd>     Execute command when a relevant alert is received (%s in cmd is replaced by message)


google above commands for more info.

Psst!!  Wanna make bitcoin unstoppable? Why the Only Real Way to Buy Bitcoins Is on the Streets. Avoid banks and centralized exchanges.   Buy/Sell coins locally.  Meet other bitcoiners and develop your network.   Try localbitcoins.com or find or start a buttonwood / satoshi square in your area.  Pass it on!
coin_love (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
November 11, 2013, 04:58:46 PM
Last edit: November 11, 2013, 05:37:48 PM by coin_love
 #3

Perfect, thanks!

I added the following to bitcoin.conf:
walletnotify=/foo/walletnotify.sh %s

And walletnotify.sh simply wgets to localhost. The shell script works when calling it on the Mac Os X terminal. I've given the script file full permissions to all groups. However, Bitcoind gives the following error when issuing a notify:

runCommand error: system(/foo/walletnotify.sh 5d8fb8dbd106f862cbf80be514e0ea2ad7b4136cbd1c3b91299e5325687529ba) returned 32512

I found the place where this call is made https://github.com/bitcoin/bitcoin/blob/f76c122e2eac8ef66f69d142231bd33c88a24c50/src/wallet.cpp#L497, but wasn't able to find what is happening inside the t() method.

Any ideas as to why this isn't working?

EDIT: I'm using Bitcoin-Qt 0.8.5-beta

EDIT 2: http://stackoverflow.com/questions/5638321/why-child-process-returns-exit-status-32512-in-unix gave an idea to try
walletnotify=sh -c '/foo/walletnotify.sh %s' but to no avail.

EDIT 3: Ah, here it is https://github.com/bitcoin/bitcoin/blob/16d5f2c5e0a7276fb2b09d8dd51b7bac2753c4cc/src/util.cpp#L1490 and it indeed seems to be using system().

EDIT 4 (SOLVED): Apparently the call isn't executed in a shell env, and so the wget inside the .sh needs to be called with an abs path.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!