Chronologically sorting transactions within a block

4

Is there any way to chronologically sort transactions within a block?

jimmy

Posted 2014-01-08T14:59:50.980

Reputation: 51

Answers

3

The arrow-of-time in bitcoin is achieved through the blockchain. The whole point of proof-of-work is to arrange transactions in chronological order, to prevent double-spending.

Under this light, transactions in the same block cannot be put in strict chronological order; the time each miner saw an unverified transaction varies depending on their view of the network. The only certain order is that transactions in a future block happened after transactions in a past block (a parent block) on the blockchain.

You can order transactions heuristically if you want, but this is not cryptographically secure. One way to do it is to look at when they first appeared on the network, e.g. on blockchain.info or some other such service.

dionyziz

Posted 2014-01-08T14:59:50.980

Reputation: 855

1Very true, wouldn't have said it better myself. It is important to realize the relativeness of time in general, especially when considering distributed systems. Even if nobody cheated (a naive assumption), the "chronological ordering" by the time record is not objective. You can see the Blockchain as a heartbeat providing the base frequency, and one block as an elementary time step, just like Planck time in the real world. It makes no sense to ask about the order of inner transactions, as this is the finest granularity you can technically get.Jozef 2014-09-07T11:22:24.447

3There's a minor case where correct ordering is guaranteed: If transaction Y spends coins from transaction X, and if they're both included in a single block, then X must be listed somewhere before Y in the block.theymos 2014-09-07T13:48:49.223

0

Process the raw transaction and look at the time that the transaction hit the network (the epoch time).

Do you need a pointer of how to do that?

Joe White

Posted 2014-01-08T14:59:50.980

Reputation: 538

Does blockchain.info use the epoch time? for example https://blockchain.info/address/192NZPzSXSqXEuNJJDbQrSyy4rsmRLvour?format=json . I don't see the time field defined anywhere.

jimmy 2014-01-08T15:05:59.800

I'm not exactly sure what they use because its a closed sourcecode but I would assume they use epoch time at least to record each new transaction coming in the rawmempool.Joe White 2014-01-08T15:09:49.290

Where else can I get the epoch time of a transaction?jimmy 2014-01-08T15:12:33.577

Get the txid, next get the raw transaction id from bitcoind, then use decoderawtransaction to see the transaction details.Joe White 2014-01-08T15:22:49.750

2Transactions do no have a time stamp. You need to see when you first heard about it (which bitcoind only tracks for wallet transactions).Pieter Wuille 2014-02-07T20:33:47.683