GetRawTransaction not returning time

1

I am trying to write a quick blockchain explorer so that I can lookup transactions on my own server rather than using a 3rd party service - consider this an exercise more than a production service. I have a bitcoind server running with txindex = 1 and all is well, I can lookup transaction with getrawtransaction. But unconfirmed transactions do not have block data, and most importantly the time field.

However many 3rd party lookup services like blockchain, tradeblock, etc return a timestamp for the transaction even when not confirmed. So I have tried to use the walletnotify command to record the time the transaction is seen but it's not getting called - probably due to the fact I have disablewallet=1 or because these transactions do not relate to my server.

So my next step is to continuously check the transactions in the current block and record the timestamp that way - suffice to say this is not the best approach but I am really struggling to think of another way.

Perhaps someone has a better approach?

Alex

Posted 2017-01-05T19:45:32.850

Reputation: 398

Answers

2

getrawtransaction does not return the time, because it only gives you the raw transaction itself, which does not include a timestamp.

However, you can use the getmempoolentry RPC to get mempool metadata about a transaction, which includes the time at which time it entered the mempool.

Pieter Wuille

Posted 2017-01-05T19:45:32.850

Reputation: 54 032

Perfect thank you!Alex 2017-01-05T20:53:22.213