Bitcoin Forum
October 23, 2017, 06:42:40 AM *
News: Latest stable version of Bitcoin Core: 0.15.0.1  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Relative locktime / CSV enforcement  (Read 354 times)
btcash
Hero Member
*****
Offline Offline

Activity: 577



View Profile
May 03, 2017, 09:12:00 PM
 #1

I don't fully understand how bitcoin prevents relative locktime (rl) /csv transactions from being mined early.

Example:
1. Tx A with csv = 10 blocks  -> The output is spendable 10 blocks after Tx A has been mined
2. Tx A gets mined at height x
3. Tx B spends the output of Tx A, sets rl (sequence) = 12, pushed to the network at height x+1

I am not sure what happens now. The csv of Tx A is checked against the sequence of Tx B and the validation fails if larger?

Code:
if (nSequenceMasked > txToSequenceMasked)
return false;

https://github.com/bitcoin/bitcoin/pull/7524/files

Doesn't this mean that Tx B would be mined before x+10? Why do we compare the locktime to the locktime of the spending TX? Wouldn't it be easier to simply compare it to the current block height or time?

Question 2:
Let's say I set the sequence to +10 blocks and csv +20, which one is valid?
Quote
With relative locktime + CSV you could create an address such that any BTC sent there can only be spent after sitting unspent for 6 months.
https://www.reddit.com/r/Bitcoin/comments/5i1ax7/nsequencenlocktime_vs_checksequenceverify_vs/db4o1b6/

I could do the same thing with either relative locktime or csv?

Question 3:
Which sequence gets chosen if we have multiple inputs with different sequences?
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!