<div dir="ltr"><div>I think that should be greater than in the comparison?  You want it to fail if the the height of the UTXO plus the sequence number is greater than the spending block&#39;s height.<br><br></div><div>There should be an exception for final inputs.  Otherwise, they will count as relative locktime of 0xFFFFFFFF.  Is this check handled elsewhere?<br><br> if (!tx.vin[i].IsFinal() &amp;&amp; nSpendHeight &lt; coins-&gt;nHeight + tx.vin[i].nSequence)<br>
       return state.Invalid(false, REJECT_INVALID, &quot;bad-txns-non-final-input&quot;);<br></div><div><div><div><div class="gmail_extra"><br></div><div class="gmail_extra">Is the intention to let the script check the sequence number?<br><br></div><div class="gmail_extra">&lt;number&gt; OP_RELATIVELOCKTIMEVERIFY<br><br></div><div class="gmail_extra">would check if &lt;number&gt; is less than or equal to the sequence number.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">It does make sequence mean something completely different from before.  Invalidating previously valid transactions has the potential to reduce confidence in the currency.<br><br></div><div class="gmail_extra">A workaround would be to have a way to enable it in the sigScript by extending Peter Todd&#39;s suggestion in the other email chain.<br><br></div><div class="gmail_extra">&lt;1&gt; OP_NOP2 means OP_CHECKLOCKTIMEVERIFY (absolute)<br></div><div class="gmail_extra">&lt;2&gt; OP_NOP2 means OP_RELATIVECHECKLOCKTIMEVERIFY <br></div><div class="gmail_extra"><br>&lt;3&gt; OP_NOP2 means OP_SEQUENCE_AS_RELATIVE_HEIGHT<br></div><div class="gmail_extra"><br>OP_SEQUENCE_AS_RELATIVE_HEIGHT would cause the script to fail unless it was the first opcode in the script.  It acts as a flag to enable using the sequence number as for relative block height.<br><br></div><div class="gmail_extra">This can be achieved using a simple pattern match.<br><br>bool CScript::IsSequenceAsRelativeHeight() const<br>{<br>    // Extra-fast test for pay-to-script-hash CScripts:<br>    return (this-&gt;size() &gt;= 4 &amp;&amp;<br>            this-&gt;at(0) == OP_PUSHDATA1
 &amp;&amp;<br></div><div class="gmail_extra">            this-&gt;at(1) == 1 &amp;&amp;<br></div><div class="gmail_extra">            this-&gt;at(2) == 0xFF &amp;&amp;<br></div><div class="gmail_extra">            this-&gt;at(3) == OP_NOP2);<br>}<br><br></div><div class="gmail_extra"></div><div class="gmail_extra">if (!tx.vin[i].IsFinal() &amp;&amp; tx.vin[i].scriptSig.IsSequenceAsRelativeHeight() &amp;&amp; nSpendHeight &lt; coins-&gt;nHeight + tx.vin[i].nSequence)<br>
       return state.Invalid(false, REJECT_INVALID, &quot;bad-txns-non-final-input&quot;);</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_quote">On Mon, May 4, 2015 at 12:24 PM, Jorge Timón <span dir="ltr">&lt;<a href="mailto:jtimon@jtimon.cc" target="_blank">jtimon@jtimon.cc</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">for (unsigned int i = 0; i &lt; tx.vin.size(); i++) {<br>
// ...<br>
</span>            if (coins-&gt;nHeight + tx.vin[i].nSequence &lt; nSpendHeight)<br>
                return state.Invalid(false, REJECT_INVALID, &quot;bad-txns-non-final-input&quot;);<br>
// ...<br>
}<br></blockquote><div><br> </div></div></div></div></div></div></div>