LearnBitcoin

Bitcoin Dev Archive 2016

nSequence multiple uses

3 messages, 22 to 23 Jan 2016. Started by Andrew C.

Andrew C (2), David A. Harding

Permalink Original thread on gnusha.org

Andrew C permalink original

With 0.12 and opt-in RBF, nSequence will have multiple uses. It can be used for locktime and now signaling for opting in to RBF. However, there is nothing that I could find that distinguishes the uses for nSequence. Spending a time locked output requires setting nSequence to less than MAX_INT but opting into RBF also requires setting nSequence to less than MAX_INT. By spending a time locked output, you would also be opting into RBF, which may not be desired behavior. Since using nSequence to signal a certain behavior will probably be used in the future, is there any plan to change nSequence so that the features the transaction is using can be distinguished? Perhaps something like version bits?

Thanks, Andrew

David A. Harding in reply to Andrew C permalink original

On Fri, Jan 22, 2016 at 04:36:58PM +0000, Andrew C via bitcoin-dev wrote:

Quoted text (3 lines)
> Spending a time locked output requires setting nSequence to less than
> MAX_INT but opting into RBF also requires setting nSequence to less than
> MAX_INT.

Hi Andrew,

Opt-in RBF requires setting nSequence to less than MAX-1 (not merely less than MAX), so an nSequence of exactly MAX-1 (which appears in hex-encoded serialized transactions as feffffff) enables locktime enforcement but doesn't opt in to RBF.

For more information, please see BIP125:

    https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki

-Dave

Andrew C in reply to David A. Harding permalink original

Ahh. I see. Thanks, I must have missed that when going through the BIP. Guess I need to read more carefully next time.

Thanks, Andrew

On Fri, Jan 22, 2016 at 11:11 PM David A. Harding <dave@dtrt•org> wrote:

Quoted text (19 lines)
> On Fri, Jan 22, 2016 at 04:36:58PM +0000, Andrew C via bitcoin-dev wrote:
> > Spending a time locked output requires setting nSequence to less than
> > MAX_INT but opting into RBF also requires setting nSequence to less than
> > MAX_INT.
>
> Hi Andrew,
>
> Opt-in RBF requires setting nSequence to less than MAX-1 (not merely
> less than MAX), so an nSequence of exactly MAX-1 (which appears in
> hex-encoded serialized transactions as feffffff) enables locktime
> enforcement but doesn't opt in to RBF.
>
> For more information, please see BIP125:
>
>     https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki
>
> -Dave
>
>