Retrieving a transactions timestamp

+2 votes
OK, so let me ask the question in a different way...

How do I retrieve the timestamp for the transaction given just the transaction hash without using the wallet api calls as I need to do this for any transaction on the chain?

Thx

Marty
related to an answer for: Transaction Timestamps
asked Jun 1, 2016 by Marty

2 Answers

+1 vote

Just look at the time or blocktime fields of getrawtransaction (assuming you've left txindex=1 on as per the default runtime parameters).

answered Jun 1, 2016 by MultiChain
I updated my startup script to this:

multichaind test-chain -printtoconsole -txindex=1

and after creating a transaction, I still don't see any timestamp information coming back.  Just to clarify, the getrawtransaction returns hex and then I use decoderawtransaction to get the actual transaction details.  The addresses associated with the transaction are not contained in the client wallet, hence using the raw transaction calls.

Any clues as to what the issue might be??

Cheers

Marty
+2 votes

After some digging you can get the timestamp from getrawtransaction, you just need to pass the additional parameter that sets verbose = 1, for example on the rpc api:


{"method":"getrawtransaction","params":["{{tx-id}}", 1],"id":1,"chain_name":"test-chain"}


This has the added benefit of returning the payload in ascii so no need to decode hex!

Marty

 

 

answered Jun 1, 2016 by marty
Yes, I was about to say that but good you answered your own question!
...