0

Is there any method, other than polling, to subscribe to new blocks being published on the Monero network? I want to get notified whenever a new block is published on the network on my app.

1

The current Monero release allows you to call a program in those cases:

When a block in added to the blockchain, you can trigger a command using monerod's --block-notify option.

When a transaction is received by the wallet (both when seen in the txpool and after its first confirmation), you can trigger a command using monero-wallet-{cli,rpc}' --tx-notify option.

Both of those options take as parameter a program and optional parameters. Every instance of %s will be replaced by the block hash or transaction hash which triggered the notification. Note that this is a program and optional parameters, and not a shell command, if you want redirection or pipes, you'll have to call a shell (eg, --tx-notify bash -e 'echo %s >> /tmp/hashes'). Parsing is limited, so you can't use quotes and backslashes to escape spaces. If you need complex parsing, write a script to do it and call the script.

0

No. Polling is the only way. You only need to poll once every couple of minutes at most though.

  • Can't websocket be used for the same? – Alisha Gupta Jun 13 '18 at 11:46
  • No. The daemon doesn't implement a websocket server. Only RPC. – jtgrassie Jun 13 '18 at 11:47

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.