5

I tried to get a notification for an incoming transaction?? What is the best way?

As I see, I have three options now. (Updated 02/20/2018)

  1. Make a script to check rpc log file. Then get wallet information.

  2. (Not working) Run incoming_transaction on RPC regularly. Then get new inputs.

  3. Modify source and build it.

Any other options there??

Thank you,

  • In my test, #2 doesn't work. So my option is #1. Guys.. any other options? or suggestion/advice?? Thank you, – lambdax Feb 19 '18 at 9:53
  • how do you solve the situation if your server goes off for a few hours and you miss the incoming_transactions during those hours? – Patoshi パトシ Feb 19 '18 at 20:58
  • I already mentioned that #2 didn't work. My approach is #1 (1. Make a script to check rpc log file. Then get wallet information) – lambdax Feb 20 '18 at 1:10
3

Using the --tx-notify parameter to monero-wallet-cli/monero-wallet-rpc, you can run an arbitrary program when the wallet receives a transaction. The option takes a command line as parameter. The binary in that command line should have a path if necessary. Before being called, any instance of the "%s" string will be replaced by the transaction hash.

For instance:

monero-wallet-cli --wallet-file example-wallet --tx-notify "/usr/local/bin/on-new-tx %s"

This on-new-tx binary will be called when the tx appears in the pool, and again when it is mined. In both cases, the txid will be passed as first and only parameter.

1

I would suggest the wallet RPC get_transfers as this will be more efficient than checking the log file and give you more useful information. When calling this method, you will want to store the height each time you call it so you can pick up transfers since last call (using the parameters for height filtering such as filter_by_height).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.