Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: ltcltcltc on December 13, 2023, 01:30:29 PM



Title: Do transactions need to be accurately timestamped?
Post by: ltcltcltc on December 13, 2023, 01:30:29 PM
A block header must be timestamped less than 2h into the future in order to be confirmed by the network. Is there a similar rule for transaction timestamps?


Title: Re: Do transactions need to be accurately timestamped?
Post by: mocacinno on December 13, 2023, 01:36:46 PM
no, a transaction can have a lock_time, but even that is not mandatory. A lock_time is not equal to the current timestamp!

here's some extra documentation
https://en.bitcoin.it/wiki/Transaction

EDIT: typo... I meant to say that there's no obligation to add a lock_time (it can be zero), so i i forgot the word "not" in front of mandatory.... I'm not a native English speaker, so mistakes like this are bound to happen from time to time :)


Title: Re: Do transactions need to be accurately timestamped?
Post by: pooya87 on December 13, 2023, 01:56:41 PM
Bitcoin transactions are not timestamped, they are included in a block that has a timestamp.
The last 4 bytes of a transaction that is known as a locktime is there to indicate a time or a block height after which the transaction can be included in a block.


Title: Re: Do transactions need to be accurately timestamped?
Post by: Churchillvv on December 13, 2023, 02:04:41 PM
A block header must be timestamped less than 2h into the future in order to be confirmed by the network. Is there a similar rule for transaction timestamps?
Transactions do not have timestamps, so the timestamp that blockchain.info displays is whatever time their node received the transaction. The time shown will also change to the time that it was included in a block. In general, it is not reliable to trust the timestamp given for an unconfirmed transaction on blockchain.info as it is entirely dependent on their node.

Information source (https://bitcoin.stackexchange.com/questions/17349/are-timestamps-in-transactions-trustable/66642#66642)


Title: Re: Do transactions need to be accurately timestamped?
Post by: garlonicon on December 13, 2023, 05:34:06 PM
Quote
Do transactions need to be accurately timestamped?
No, because Bitcoin is not about measuring time. It is about double-spending problem.

Which means, if you run for example regtest, then you can include a lot of mainnet transactions directly, even though they happened in a completely different network, on a completely different time. If regtest would have 21 million coins, it could be copy-pasted "as is", but because amounts are different, it is somewhat limited, because you cannot copy-paste for example a transaction with 500k BTC.

So yes, you can take some mainnet transaction from 2009, and include it into regtest, in 2023. Which means, the time is not really enforced, because if you can clone the coinbase transaction, and if you can clone the whole flow, then you can perform 1:1 testing, on exactly the same transaction hashes. But as I said, there are limitations, like coin amounts, that prevents users from using regtest as a mainnet mirror (but probably testnet3 or signet could still do that; and it is a proof, that time is not really enforced, and transactions are reorg-resistant).


Title: Re: Do transactions need to be accurately timestamped?
Post by: NotATether on December 14, 2023, 06:57:24 AM
It's the blocks that are timestamped, but even they don't need to be accurately timestamped. That's because the full node implementations such as Bitcoin Core has a window within which a block is allowed to be received. It's usually between a few hours before and a few hours after the current system time (on the node), so as long as the timestamp is within that dynamic range, its block is accepted. Otherwise, it is rejected.