Ich habe kürzlich bemerkt, dass Bitcoin Core Transaktionen mit einer Sperrzeit ungleich Null und Sequenznummern von Eingaben von 0xFFFFFFFE produziert, obwohl ich es nicht dazu angewiesen habe. Die Sperrzeit scheint die aktuelle Blocknummer zu sein.
(Ich weiß, dass mindestens eine Eingabe eine Sequenznummer kleiner als 0xFFFFFFFF haben muss. Setzt der Core nur die erste Eingabe oder alle Eingaben? Ich konnte dies nicht überprüfen, da ich keine Transaktion mit mehr als einer Eingabe habe.)
Danke für deine Antworten!
TL;DR: Das Ziel ist es, Reorganisationen zu verhindern und die Privatsphäre zu erhöhen.
In wallet.cpp, direkt über der Stelle, an der nLockTime festgelegt wird, heißt es:
// Discourage fee sniping.
//
// For a large miner the value of the transactions in the best block and
// the mempool can exceed the cost of deliberately attempting to mine two
// blocks to orphan the current best block. By setting nLockTime such that
// only the next block can include the transaction, we discourage this
// practice as the height restricted and limited blocksize gives miners
// considering fee sniping fewer options for pulling off this attack.
//
// A simple way to think about this is from the wallet's point of view we
// always want the blockchain to move forward. By setting nLockTime this
// way we're basically making the statement that we only want this
// transaction to appear in the next block; we don't want to potentially
// encourage reorgs by allowing transactions to appear at lower heights
// than the next block in forks of the best chain.
//
// Of course, the subsidy is high enough, and transaction volume low
// enough, that fee sniping isn't a problem yet, but by implementing a fix
// now we ensure code won't be written that makes assumptions about
// nLockTime that preclude a fix later.
txNew.nLockTime = chainActive.Height();
// Secondly occasionally randomly pick a nLockTime even further back, so
// that transactions that are delayed after signing for whatever reason,
// e.g. high-latency mix networks and some CoinJoin implementations, have
// better privacy.
if (GetRandInt(10) == 0)
txNew.nLockTime = std::max(0, (int)txNew.nLockTime - GetRandInt(100));
Wie Martin Habovštiak bemerkte, wird die Sequenznummer MAX-1
für jeden Eingang auf gesetzt. Es befindet sich im Code direkt unter dem zuvor erwähnten Codeabschnitt .
Martin Habovštiak
Fährgroß
Murch
knokte
Murch
nLockTime
ist nur aktiv, wenn die Sequenznummer kleiner ist alsUINT_MAX
.