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/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?
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?