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?
if (nSequenceMasked > txToSequenceMasked)
return false;
https://github.com/bitcoin/bitcoin/pull/7524/filesDoesn'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?
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?