Warum erstellt Bitcoin Core standardmäßig zeitgesperrte Transaktionen?

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.

  • Was ist der Grund für dieses Verhalten?
  • Was ist der Algorithmus zum Festlegen der Sequenznummer?

(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!

Antworten (1)

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-1für jeden Eingang auf gesetzt. Es befindet sich im Code direkt unter dem zuvor erwähnten Codeabschnitt .

Scheint, als wäre die Sequenz für jede Eingabe auf max()-1 gesetzt. Der Code steht direkt unter dem, was Sie erwähnt haben. Vielen Dank für Ihre Antwort!
Haben Sie eine Textversion der Erklärung? Der von Ihnen gepostete Code ist auf dem Handy wirklich nicht lesbar, da Sie für jede Zeile nach rechts scrollen müssen
@Ferrybig: Ich habe das TL;DR oben gesetzt.
Gibt es einen Grund für diese seltsame Sequenznummer? Die in dieser Antwort genannten Gründe scheinen nur die nLockTime zu erklären, nicht die Sequenznummer
@knocte: nLockTimeist nur aktiv, wenn die Sequenznummer kleiner ist als UINT_MAX.