trout (OP)
|
|
October 30, 2013, 07:02:32 PM |
|
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
|
|
|
|
dserrano5
Legendary
Offline
Activity: 1974
Merit: 1029
|
|
October 30, 2013, 07:39:56 PM |
|
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 . When edited, issue a decoderawtransaction to check that everything's ok, then finally sendrawtransaction.
|
|
|
|
trout (OP)
|
|
October 30, 2013, 08:31:38 PM |
|
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 . 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_?
|
|
|
|
dserrano5
Legendary
Offline
Activity: 1974
Merit: 1029
|
|
October 30, 2013, 08:54:15 PM |
|
hm. is there at least a tool to convert a raw transaction to a readable form _and back_?
Sorry I know of none.
|
|
|
|
trout (OP)
|
|
November 01, 2013, 12:08:08 AM |
|
alright, how do I find nlocktime in the hex?
|
|
|
|
TheButterZone
Legendary
Offline
Activity: 3080
Merit: 1032
RIP Mommy
|
|
November 01, 2013, 04:41:49 AM |
|
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 . 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-txthen https://blockchain.info/pushtx
|
Saying that you don't trust someone because of their behavior is completely valid.
|
|
|
dserrano5
Legendary
Offline
Activity: 1974
Merit: 1029
|
|
November 01, 2013, 09:48:24 AM |
|
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: 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: 01000000010fff030dfce93c3e4457af8ad0cd47c184a9671db28cb3cb1188b4366ce5906800000000473045022100a4b143ff81dd6ab899aef5234a02054354de8a309eff811d654cd21d6e0b536102207100585568dafba3663720a710aa0cafed27e2379292c246cf0b3cb5b21b3579ffffffff01905f0100000000001976a91428d4cb88f005376046ab1fca64ae9c8a4bcfc73a88ac00000000 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: 01000000010fff030dfce93c3e4457af8ad0cd47c184a9671db28cb3cb1188b4366ce5906800000000473045022100a4b143ff81dd6ab899aef5234a02054354de8a309eff811d654cd21d6e0b536102207100585568dafba3663720a710aa0cafed27e2379292c246cf0b3cb5b21b3579ffffffff01905f0100000000001976a91428d4cb88f005376046ab1fca64ae9c8a4bcfc73a88ac1b787352 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).
|
|
|
|
trout (OP)
|
|
November 01, 2013, 11:18:59 AM |
|
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: 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: 01000000010fff030dfce93c3e4457af8ad0cd47c184a9671db28cb3cb1188b4366ce5906800000000473045022100a4b143ff81dd6ab899aef5234a02054354de8a309eff811d654cd21d6e0b536102207100585568dafba3663720a710aa0cafed27e2379292c246cf0b3cb5b21b3579ffffffff01905f0100000000001976a91428d4cb88f005376046ab1fca64ae9c8a4bcfc73a88ac00000000 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: 01000000010fff030dfce93c3e4457af8ad0cd47c184a9671db28cb3cb1188b4366ce5906800000000473045022100a4b143ff81dd6ab899aef5234a02054354de8a309eff811d654cd21d6e0b536102207100585568dafba3663720a710aa0cafed27e2379292c246cf0b3cb5b21b3579ffffffff01905f0100000000001976a91428d4cb88f005376046ab1fca64ae9c8a4bcfc73a88ac1b787352 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.
|
|
|
|
b!z
Legendary
Offline
Activity: 1582
Merit: 1010
|
|
November 01, 2013, 01:01:49 PM |
|
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 . When edited, issue a decoderawtransaction to check that everything's ok, then finally sendrawtransaction. Really? I thought you would do it manually, but on a computer. It would be hard to do it by hand, with a pen and a piece of paper.
|
|
|
|
dserrano5
Legendary
Offline
Activity: 1974
Merit: 1029
|
|
November 01, 2013, 01:31:26 PM |
|
Really? I thought you would do it manually, but on a computer. It would be hard to do it by hand, with a pen and a piece of paper.
You could say that, yes… but you'll agree that having to edit raw hexadecimal output in 2013 qualifies as "by hand" or "manually", as opposed to "automatically". Turns out that "manually" comes from latin "manus" meaning "hand".
|
|
|
|
Abdussamad
Legendary
Offline
Activity: 3696
Merit: 1584
|
|
November 02, 2013, 11:52:01 AM |
|
Is nlocktime supported by bitcoin nodes? I remember reading on this forum that most nodes don't support it.
|
|
|
|
flatfly
Legendary
Offline
Activity: 1092
Merit: 1016
760930
|
|
November 02, 2013, 02:04:35 PM |
|
Nlocktime is not properly supported at this time, so you can't do what you want with it, as far as I know, unfortunately.
However a friend of mine has developed a generic self-discipline time-lock type of app that could, among other things, help you secure those coins. He made it specifically for dealing with gambling addiction issues.
If you're interested, I will check with him what's the status on that.
|
|
|
|
trout (OP)
|
|
November 02, 2013, 03:05:35 PM |
|
Nlocktime is not properly supported at this time, so you can't do what you want with it, as far as I know, unfortunately.
that's a bad news... and just as I was about to spend half a day creating and editing those raw transactions. However a friend of mine has developed a generic self-discipline time-lock type of app that could, among other things, help you secure those coins. He made it specifically for dealing with gambling addiction issues.
If you're interested, I will check with him what's the status on that.
yes, I'm interested. Provided it's secure and trust-free
|
|
|
|
flatfly
Legendary
Offline
Activity: 1092
Merit: 1016
760930
|
|
November 02, 2013, 10:21:36 PM |
|
Nlocktime is not properly supported at this time, so you can't do what you want with it, as far as I know, unfortunately.
that's a bad news... and just as I was about to spend half a day creating and editing those raw transactions. However a friend of mine has developed a generic self-discipline time-lock type of app that could, among other things, help you secure those coins. He made it specifically for dealing with gambling addiction issues.
If you're interested, I will check with him what's the status on that.
yes, I'm interested. Provided it's secure and trust-free Sure, I will check and let you know.
|
|
|
|
gmaxwell
Staff
Legendary
Offline
Activity: 4284
Merit: 8808
|
|
November 02, 2013, 11:18:40 PM |
|
Nlocktime is supported fine, replacement is not. But the OP's request doesn't need replacement.
He needs to create a transaction moving his coins to a key he keeps safe, preferably signed with single|anyone_can_pay so fees could be added later, with an nlocktime for the future... and then he needs to destroy the private key the coins are currently assigned to.
I do not recommend this— at least not for long spans of time, no one knows what the future holds. Future discovered security issues may make a transaction authored today no longer good in the future— unlikely, perhaps, but no one will promise otherwise.
|
|
|
|
jabetizo
|
|
November 02, 2013, 11:30:16 PM |
|
I just did a test with small amounts using this tool: http://brainwallet.org/#tx (all outgoing transactions from 1FBirjB4q1MLH4gZXTKXNUfgMzuQDx49rh have a lock time: example1, example2) As well as setting the "lock_time" to the future block number or unix time, you have to change the "sequence" to 0, otherwise the lock_time is disregarded. I tried to broadcast the tx with https://blockchain.info/pushtx but it's not supported ("invalid sequence"). Broadcasting it with BitcoinQT works, but only when the lock_time has been reached, otherwise it won't broadcast ("transaction rejected").
|
|
|
|
dooglus
Legendary
Offline
Activity: 2940
Merit: 1333
|
|
November 07, 2014, 05:03:22 AM |
|
As well as setting the "lock_time" to the future block number or unix time, you have to change the "sequence" to 0, otherwise the lock_time is disregarded.
Changing the sequence other than 4294967295 (the default) is enough. From the code (with details omitted): "a transaction is final if the locktime is less than the blockheight or blocknumber (depending on whether the locktime is low or high, resp.) otherwise a transaction isn't final if any of its inputs aren't final otherwise it's final an input is final if its sequence is the biggest it can be (4294967295)" bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime) { if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime)) return true; BOOST_FOREACH(const CTxIn& txin, tx.vin) if (!txin.IsFinal()) return false; return true; }
class CTxIn { public: bool IsFinal() const { return (nSequence == std::numeric_limits<unsigned int>::max()); } }
|
Just-Dice | ██ ██████████ ██████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████ ██████████████ ██████ | Play or Invest | ██ ██████████ ██████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████ ██████████████ ██████ | 1% House Edge |
|
|
|
hhanh00
|
|
November 07, 2014, 12:01:00 PM |
|
People won't hold your transaction in their memory pool for a year...
|
|
|
|
dooglus
Legendary
Offline
Activity: 2940
Merit: 1333
|
|
November 07, 2014, 04:12:38 PM |
|
People won't hold your transaction in their memory pool for a year...
I think you misunderstand. You can't send a transaction to the p2p network until the timelock has expired. Until then you keep the transaction somewhere safe, and wait. I tested this with a transaction I made with an nLockTime 10 seconds in the future. The first time I tried to broadcast it, it was still timelocked: $ bitcoin-cli sendrawtransaction $tx error: {"code":-26,"message":"64: non-final"}
The second time, it worked: $ bitcoin-cli sendrawtransaction $tx 8b8486d428cd5aade180437b09ce95f65ca2e9f3e3b5ea69f6ca9c47f1bd249c
Edit: there's a free 0.1 BTC for the first person to discover why I was giggling like a schoolboy when I made that transaction.
|
Just-Dice | ██ ██████████ ██████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████ ██████████████ ██████ | Play or Invest | ██ ██████████ ██████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████ ██████████████ ██████ | 1% House Edge |
|
|
|
hhanh00
|
|
November 07, 2014, 05:45:04 PM |
|
People won't hold your transaction in their memory pool for a year...
I think you misunderstand. You can't send a transaction to the p2p network until the timelock has expired. Until then you keep the transaction somewhere safe, and wait. I tested this with a transaction I made with an nLockTime 10 seconds in the future. The first time I tried to broadcast it, it was still timelocked: $ bitcoin-cli sendrawtransaction $tx error: {"code":-26,"message":"64: non-final"}
The second time, it worked: $ bitcoin-cli sendrawtransaction $tx 8b8486d428cd5aade180437b09ce95f65ca2e9f3e3b5ea69f6ca9c47f1bd249c
Yes but that's just what bitcoind does. It won't relay non-standard tx and using nlocktime makes the tx non standard. The protocol doesn't say that. It should accept it and wait until the locktime expires before allowing mining. However, this feature could be easily abused. From main.cpp // Treat non-final transactions as non-standard to prevent a specific type // of double-spend attack, as well as DoS attacks. (if the transaction // can't be mined, the attacker isn't expending resources broadcasting it) // Basically we don't want to propagate transactions that can't be included in // the next block.
Edit: there's a free 0.1 BTC for the first person to discover why I was giggling like a schoolboy when I made that transaction.
Because the address sent to is 1LASS?
|
|
|
|
|