Pages:
Author

Topic: howto nlocktime - page 2. (Read 6919 times)

sr. member
Activity: 333
Merit: 252
November 01, 2013, 06:18:59 AM
#8
hm. is there at least a tool to convert a raw transaction to a readable form _and back_?

https://blockchain.info/decode-tx
then
https://blockchain.info/pushtx

The OP is specifically interested in encoding transactions, and those (otherwise useful) pages can't do that. 'createrawtransaction' does but it doesn't accept setting the nlocktime.

@OP: anyway, according to the wiki nlocktime is always the last item in the transaction, ie the last four bytes. You'll see that your raw transaction ends with 4 zero bytes. Play with them until you achieve your desired nlocktime. Beware, it's a little endian integer:

Code:
01000000 =>          1: block 1
0a000000 =>         10: block 10
ff000000 =>        255: block 255
00010000 =>        256: block 256
00020000 =>        512: block 512
00100000 =>       4096: block 4096
00000001 =>   16777216: block 16777216
ff64cd1d =>  499999999: block 499999999
0065cd1d =>  500000000: Nov 5 1985 00:53:20 UTC, note it isn't a block number anymore!
805ac352 => 1388534400: Jan 1 2014 00:00:00 UTC

So if you have this transaction:

Code:
01000000010fff030dfce93c3e4457af8ad0cd47c184a9671db28cb3cb1188b4366ce5906800000000473045022100a4b143ff81dd6ab899aef5234a02054354de8a309eff811d654cd21d6e0b536102207100585568dafba3663720a710aa0cafed27e2379292c246cf0b3cb5b21b3579ffffffff01905f0100000000001976a91428d4cb88f005376046ab1fca64ae9c8a4bcfc73a88ac00000000

which decodes to:

Code:
{
   "lock_time":0,
   "inputs":[ blah blah ],
   "vout_sz":1,
   "hash":"72d9c8951e543ce7a370aec3c3007e8f4e6e3d244a770631ae55a23b00457be4",
   "vin_sz":1,
   "out":[ blah blah ],
   "size":156,
   "version":1
}

and change the last 4 bytes:

Code:
01000000010fff030dfce93c3e4457af8ad0cd47c184a9671db28cb3cb1188b4366ce5906800000000473045022100a4b143ff81dd6ab899aef5234a02054354de8a309eff811d654cd21d6e0b536102207100585568dafba3663720a710aa0cafed27e2379292c246cf0b3cb5b21b3579ffffffff01905f0100000000001976a91428d4cb88f005376046ab1fca64ae9c8a4bcfc73a88ac1b787352

you obtain an identical transaction except for the nlocktime (and the hash of course)

Code:
{
   "lock_time":1383299099,
   "inputs":[ blah blah ],
   "vout_sz":1,
   "hash":"ace99d8d6301982e7978997a7c47f8807314eaaca5c3f7b03576b2d036faed2c",
   "vin_sz":1,
   "out":[ blah blah ],
   "size":156,
   "version":1
}

That value corresponds to Nov 1 2013 09:44:59 UTC (ie right now).

great, thanks for the detailed answer! I think should be able to do this now.

legendary
Activity: 1974
Merit: 1029
November 01, 2013, 04:48:24 AM
#7
hm. is there at least a tool to convert a raw transaction to a readable form _and back_?

https://blockchain.info/decode-tx
then
https://blockchain.info/pushtx

The OP is specifically interested in encoding transactions, and those (otherwise useful) pages can't do that. 'createrawtransaction' does but it doesn't accept setting the nlocktime.

@OP: anyway, according to the wiki nlocktime is always the last item in the transaction, ie the last four bytes. You'll see that your raw transaction ends with 4 zero bytes. Play with them until you achieve your desired nlocktime. Beware, it's a little endian integer:

Code:
01000000 =>          1: block 1
0a000000 =>         10: block 10
ff000000 =>        255: block 255
00010000 =>        256: block 256
00020000 =>        512: block 512
00100000 =>       4096: block 4096
00000001 =>   16777216: block 16777216
ff64cd1d =>  499999999: block 499999999
0065cd1d =>  500000000: Nov 5 1985 00:53:20 UTC, note it isn't a block number anymore!
805ac352 => 1388534400: Jan 1 2014 00:00:00 UTC

So if you have this transaction:

Code:
01000000010fff030dfce93c3e4457af8ad0cd47c184a9671db28cb3cb1188b4366ce5906800000000473045022100a4b143ff81dd6ab899aef5234a02054354de8a309eff811d654cd21d6e0b536102207100585568dafba3663720a710aa0cafed27e2379292c246cf0b3cb5b21b3579ffffffff01905f0100000000001976a91428d4cb88f005376046ab1fca64ae9c8a4bcfc73a88ac00000000

which decodes to:

Code:
{
   "lock_time":0,
   "inputs":[ blah blah ],
   "vout_sz":1,
   "hash":"72d9c8951e543ce7a370aec3c3007e8f4e6e3d244a770631ae55a23b00457be4",
   "vin_sz":1,
   "out":[ blah blah ],
   "size":156,
   "version":1
}

and change the last 4 bytes:

Code:
01000000010fff030dfce93c3e4457af8ad0cd47c184a9671db28cb3cb1188b4366ce5906800000000473045022100a4b143ff81dd6ab899aef5234a02054354de8a309eff811d654cd21d6e0b536102207100585568dafba3663720a710aa0cafed27e2379292c246cf0b3cb5b21b3579ffffffff01905f0100000000001976a91428d4cb88f005376046ab1fca64ae9c8a4bcfc73a88ac1b787352

you obtain an identical transaction except for the nlocktime (and the hash of course)

Code:
{
   "lock_time":1383299099,
   "inputs":[ blah blah ],
   "vout_sz":1,
   "hash":"ace99d8d6301982e7978997a7c47f8807314eaaca5c3f7b03576b2d036faed2c",
   "vin_sz":1,
   "out":[ blah blah ],
   "size":156,
   "version":1
}

That value corresponds to Nov 1 2013 09:44:59 UTC (ie right now).
legendary
Activity: 3038
Merit: 1032
RIP Mommy
October 31, 2013, 11:41:49 PM
#6
can anyone explain me how to make an Nlocktime transaction?

As far as I know you have to createrawtransaction, then edit the raw hexadecimal by hand Smiley. When edited, issue a decoderawtransaction to check that everything's ok, then finally sendrawtransaction.
hm. is there at least a tool to convert a raw transaction to a readable form _and back_?

https://blockchain.info/decode-tx
then
https://blockchain.info/pushtx
sr. member
Activity: 333
Merit: 252
October 31, 2013, 07:08:08 PM
#5
alright, how do I find nlocktime in the hex?
legendary
Activity: 1974
Merit: 1029
October 30, 2013, 03:54:15 PM
#4
hm. is there at least a tool to convert a raw transaction to a readable form _and back_?

Sorry I know of none.
sr. member
Activity: 333
Merit: 252
October 30, 2013, 03:31:38 PM
#3
can anyone explain me how to make an Nlocktime transaction?

As far as I know you have to createrawtransaction, then edit the raw hexadecimal by hand Smiley. When edited, issue a decoderawtransaction to check that everything's ok, then finally sendrawtransaction.
hm. is there at least a tool to convert a raw transaction to a readable form _and back_?
legendary
Activity: 1974
Merit: 1029
October 30, 2013, 02:39:56 PM
#2
can anyone explain me how to make an Nlocktime transaction?

As far as I know you have to createrawtransaction, then edit the raw hexadecimal by hand Smiley. When edited, issue a decoderawtransaction to check that everything's ok, then finally sendrawtransaction.
sr. member
Activity: 333
Merit: 252
October 30, 2013, 02:02:32 PM
#1
hi,

can anyone explain me how to make an Nlocktime transaction?

I just want to send all my funds to myself to be spendable in a year or so.
Since it's "all my funds" I want to make sure it's safe.

also, will the current version of multibit and bitcoin-qt handle correclty a
already spendable transacion which had an non-0 nlocktime?

thanks


PS Why do I want to do this - to block myself from gambling
Pages:
Jump to: