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:
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:
which decodes to:
"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:
you obtain an identical transaction except for the nlocktime (and the hash of course)
"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.