Bitcoin Forum
May 05, 2024, 10:12:53 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Max Locktime  (Read 1044 times)
manuelra (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 3


View Profile
November 25, 2016, 06:15:59 PM
Last edit: November 27, 2016, 01:20:02 PM by manuelra
Merited by ABCbits (2)
 #1

Suppose Doc Brown wants to send x bitcoins to himself when he reaches 2110 so that he can dispose the Quantum Mind Jar (https://en.wikipedia.org/wiki/Doc_Brown_Saves_the_World - although Doc only needed to jump to 2075, for this problem assume that in fact he needs to jump to 2110). For that purpose he wants to setup a delayed bitcoin transaction, to 2110-01-01 0:00

What value should he use to set locktime on his bitcoin transaction?

Thank you.

Notes:
- locktime is an unsigned 32 bit, which, if above 500.000.000, represents the number of seconds since 1970-1-1 0:00:
- assume that Doc knows that bitcoin will last at least until then
- bitcoin is able to issue new coins until 2140
1714903973
Hero Member
*
Offline Offline

Posts: 1714903973

View Profile Personal Message (Offline)

Ignore
1714903973
Reply with quote  #2

1714903973
Report to moderator
1714903973
Hero Member
*
Offline Offline

Posts: 1714903973

View Profile Personal Message (Offline)

Ignore
1714903973
Reply with quote  #2

1714903973
Report to moderator
1714903973
Hero Member
*
Offline Offline

Posts: 1714903973

View Profile Personal Message (Offline)

Ignore
1714903973
Reply with quote  #2

1714903973
Report to moderator
Activity + Trust + Earned Merit == The Most Recognized Users on Bitcointalk
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
YIz
Hero Member
*****
Offline Offline

Activity: 686
Merit: 502


View Profile
November 25, 2016, 09:34:37 PM
Last edit: November 25, 2016, 09:45:03 PM by YIz
 #2

The timestamp of 4417977600 represents January 1st 2110, at 12:00 AM. is this what you're asking?
manuelra (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 3


View Profile
November 25, 2016, 11:22:41 PM
 #3

Yiz,

Kind of...

The thing is that that value is above 2^32. So it cannot be represented within the locktime field. From what I understand the max value for locktime is somewhere around 2106.

Please note that BIP65 (whether already supported or not) relies on that field as well.

The good news is that we have ~80yrs to review it (less any reasonable advance we a user may want to use to make a payment), and that review will only become necessary if bitcoin presents that longevity.

But I think it would be prudent to create a BIP for this issue. A possible solution would be to upgrade this to 64 bit, but that may break compatibility. Another would be to allow the user to specify the locktime within the script, but that may create aditional work for miners (to retrieve that info from the script => parsing, etc).

For values below 500.000.000, which represent the block number, this should not be a problem in the near time.
Coding Enthusiast
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
November 26, 2016, 05:35:35 PM
Merited by ABCbits (2)
 #4

The max value is 4294967295 = 2106-02-07T06:28:15+00:00 (in ISO 8601)

(my personal opinion) And the solution can be turning it into a Compact size UInt like the rest of the numbers in a transaction. That way it can be as big as 0xffffffffffffffff (8 Bytes with 9 Bytes used) and maybe don't break much of the code.

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
manuelra (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 3


View Profile
November 27, 2016, 01:24:02 PM
 #5

Whatever the fix, it probably can leverage and/or follow, options taken for similar problems (OSes, languages, etc). Apparently at the OS level the trend is towards using 64 bit to represent time.

The links below provide some info on similar problems.

https://en.wikipedia.org/wiki/Year_2038_problem
https://en.wikipedia.org/wiki/System_time
manuelra (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 3


View Profile
November 30, 2016, 02:36:15 PM
 #6

As an additional note, the same problem applies to the blockheader timestamp. So with the current data structures blocks cannot exist beyond 2106.

https://github.com/bitcoin/bitcoin/blob/master/src/primitives/block.h

class CBlockHeader
{
public:
    // header
    int32_t nVersion;
    uint256 hashPrevBlock;
    uint256 hashMerkleRoot;
    uint32_t nTime;
[...]


Interestingly the method that returns nTime already casts this value to 64 bits, so in this case the problem might be solved by "only" reviewing block header serialization code.

    int64_t GetBlockTime() const
    {
        return (int64_t)nTime;
    }

But because nodes upgrade incrementally, this code will have to have a way to distinguish formats, and thus a new block header version might be needed so that the serialization code can determine how to un/serialize. And, at least for a while, the upgraded code will have to support serialization to/from both formats.
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6581


Just writing some code


View Profile WWW
November 30, 2016, 03:55:08 PM
Merited by ABCbits (1)
 #7

Any change to the timestamps for nLocktime and the block header will require a hard fork. Given that this is a long term problem, it is not particularly urgent right now to fix this.

gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4158
Merit: 8382



View Profile WWW
December 02, 2016, 03:30:49 AM
Merited by ABCbits (3)
 #8

Any change to the timestamps for nLocktime and the block header will require a hard fork. Given that this is a long term problem, it is not particularly urgent right now to fix this.
And hardforks tend to break nlocktimed transactoins, potentially forever destroying their funds...

It's really inadvisable to use locktimes set in the far future.  Though everyone working on the Bitcoin project works hard to not invalidate existing transactions, we don't know what new challenges the future may bring-- and the Bitcoin of 2110 might well not accept a signed transaction drafted today.

For your example it's far better to just store the private key needed to spend the funds.. you'll need that anyways in any case... (unless he intends to just give his funds to miners in the far future...)

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!