6

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,

lambdax
  • 61
  • 5

2 Answers2

6

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.

user36303
  • 34,928
  • 2
  • 58
  • 123
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).

jtgrassie
  • 19,601
  • 4
  • 17
  • 54