Author

Topic: howto nlocktime (Read 6912 times)

legendary
Activity: 3038
Merit: 1032
RIP Mommy
August 28, 2015, 03:17:58 PM
#28
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?

Nope, it's slightly ruder than that.

Well it must be something to do with this...

Code:
{"ver":1,"size":225,"inputs":[{"sequence":142620501,"prev_out":{"spent":true,"tx_index":68671943,"type":0,"addr":"1JDBngCAx8Vc4MXKo5Ye54rg4eEsgovfUT","value":8990000,"n":1,"script":"76a914bcc8228412c4780c304847487816226b55a4088a88ac"},"script":"4730440220273d23cb2bdc6f6b4a9c9e112c06a6399cc8ba7ffe5f32fda777e5b595482fed022016f4f0148d86b571b2d7ad29953c7d6de4c9d15706d1bbb4b017baf6aa0916bf0121022e9d2a251a345c77ce8ded0ceae6906bcdb83d15cf2ce4890600bbda105cb2d0"}],"double_spend":false,"time":1415337539,"block_height":328916,"tx_index":68673323,"vin_sz":1,"hash":"8b8486d428cd5aade180437b09ce95f65ca2e9f3e3b5ea69f6ca9c47f1bd249c","vout_sz":2,"relayed_by":"209.190.122.2","out":[{"spent":false,"tx_index":68673323,"type":0,"addr":"1LASSfaBQbSAxyA4feP82fLDDEUwNbC5S3","value":1000000,"n":0,"script":"76a914d2335f3362c0b82f624b6c32d3829831f8e5b4b388ac"},{"spent":false,"tx_index":68673323,"type":0,"addr":"1JDBngCAx8Vc4MXKo5Ye54rg4eEsgovfUT","value":7980000,"n":1,"script":"76a914bcc8228412c4780c304847487816226b55a4088a88ac"}]}

Might be because it is sent from 1JD.

Did anyone win the BTC0.1, dooglus? I see "SAxy" in there.
hero member
Activity: 560
Merit: 509
I prefer Zakir over Muhammed when mentioning me!
August 08, 2015, 11:27:39 AM
#27

All inputs will be loaded manually when you enter an address or private key*.

Script determines how the person who receive that Bitcoins can access it. Read more at https://en.bitcoin.it/wiki/Script.

You can use http://btc.blockr.io/api/v1/tx/info/txid api to get raw transaction data. It displays script.

* I recommend entering an address instead of private key and sign unsigned raw transaction using Bitcoin Core or any other client which supports signing raw transaction.
sr. member
Activity: 448
Merit: 250
Craig Wright is scammer.
August 08, 2015, 08:25:07 AM
#26
hero member
Activity: 560
Merit: 509
I prefer Zakir over Muhammed when mentioning me!
August 07, 2015, 11:18:59 PM
#25
hi, I've done some successful transactions using nlocktime and changing sequence numbers.
I used brainwallet service to do the raw transaction, but now that site is dead.
What method can I use to do a nlocktime transaction?

https://coinb.in/#newTransaction
sr. member
Activity: 448
Merit: 250
Craig Wright is scammer.
August 07, 2015, 06:09:49 PM
#24
hi, I've done some successful transactions using nlocktime and changing sequence numbers.
I used brainwallet service to do the raw transaction, but now that site is dead.
What method can I use to do a nlocktime transaction?
sr. member
Activity: 467
Merit: 267
November 07, 2014, 09:47:05 PM
#23
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?

Nope, it's slightly ruder than that.
ASS?
sr. member
Activity: 728
Merit: 256
November 07, 2014, 02:42:59 PM
#22
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?

Nope, it's slightly ruder than that.

Well it must be something to do with this...

Code:
{"ver":1,"size":225,"inputs":[{"sequence":142620501,"prev_out":{"spent":true,"tx_index":68671943,"type":0,"addr":"1JDBngCAx8Vc4MXKo5Ye54rg4eEsgovfUT","value":8990000,"n":1,"script":"76a914bcc8228412c4780c304847487816226b55a4088a88ac"},"script":"4730440220273d23cb2bdc6f6b4a9c9e112c06a6399cc8ba7ffe5f32fda777e5b595482fed022016f4f0148d86b571b2d7ad29953c7d6de4c9d15706d1bbb4b017baf6aa0916bf0121022e9d2a251a345c77ce8ded0ceae6906bcdb83d15cf2ce4890600bbda105cb2d0"}],"double_spend":false,"time":1415337539,"block_height":328916,"tx_index":68673323,"vin_sz":1,"hash":"8b8486d428cd5aade180437b09ce95f65ca2e9f3e3b5ea69f6ca9c47f1bd249c","vout_sz":2,"relayed_by":"209.190.122.2","out":[{"spent":false,"tx_index":68673323,"type":0,"addr":"1LASSfaBQbSAxyA4feP82fLDDEUwNbC5S3","value":1000000,"n":0,"script":"76a914d2335f3362c0b82f624b6c32d3829831f8e5b4b388ac"},{"spent":false,"tx_index":68673323,"type":0,"addr":"1JDBngCAx8Vc4MXKo5Ye54rg4eEsgovfUT","value":7980000,"n":1,"script":"76a914bcc8228412c4780c304847487816226b55a4088a88ac"}]}

Might be because it is sent from 1JD.
legendary
Activity: 2940
Merit: 1333
November 07, 2014, 01:56:34 PM
#21
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?

Nope, it's slightly ruder than that.
sr. member
Activity: 467
Merit: 267
November 07, 2014, 01:45:04 PM
#20
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:

Quote
$ bitcoin-cli sendrawtransaction $tx
error: {"code":-26,"message":"64: non-final"}

The second time, it worked:

Quote
$ 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
Code:
    // 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.

Quote
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?
legendary
Activity: 2940
Merit: 1333
November 07, 2014, 12:12:38 PM
#19
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:

Quote
$ bitcoin-cli sendrawtransaction $tx
error: {"code":-26,"message":"64: non-final"}

The second time, it worked:

Quote
$ 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.
sr. member
Activity: 467
Merit: 267
November 07, 2014, 08:01:00 AM
#18
People won't hold your transaction in their memory pool for a year...
legendary
Activity: 2940
Merit: 1333
November 07, 2014, 01:03:22 AM
#17
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)"

Code:
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::max());
    }
}
full member
Activity: 125
Merit: 101
November 02, 2013, 07:30:16 PM
#16
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").
staff
Activity: 4242
Merit: 8672
November 02, 2013, 07:18:40 PM
#15
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.
legendary
Activity: 1092
Merit: 1016
760930
November 02, 2013, 06:21:36 PM
#14
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.
sr. member
Activity: 333
Merit: 252
November 02, 2013, 11:05:35 AM
#13
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
legendary
Activity: 1092
Merit: 1016
760930
November 02, 2013, 10:04:35 AM
#12
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.
legendary
Activity: 3640
Merit: 1571
November 02, 2013, 07:52:01 AM
#11
Is nlocktime supported by bitcoin nodes? I remember reading on this forum that most nodes don't support it.
legendary
Activity: 1974
Merit: 1029
November 01, 2013, 09:31:26 AM
#10
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".
b!z
legendary
Activity: 1582
Merit: 1010
November 01, 2013, 09:01:49 AM
#9
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.

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.
sr. member
Activity: 333
Merit: 252
November 01, 2013, 07: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, 05: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
November 01, 2013, 12:41:49 AM
#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, 08:08:08 PM
#5
alright, how do I find nlocktime in the hex?
legendary
Activity: 1974
Merit: 1029
October 30, 2013, 04: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, 04: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, 03: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, 03: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
Jump to: