sweep/wallet: consolidate small wallet UTXOs when fees are low

Aperta
#11,522 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
30/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go
Ambito
backend, payments

Direzione di ricerca

Start by reading the sweeper changes in #11485 and how channel funding and SendCoins select wallet UTXOs. Compare the three proposed approaches, then trace how wallet coin selection, fee estimates, RBF, locked coins, and the anchor reserve are handled. Done means a chosen approach consolidates economical UTXOs at low fees while respecting the listed privacy, timing, and transaction-size constraints.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Background

With #11485 the sweeper selects wallet UTXOs for budget input sets in order
of value per weight unit, highest first, and only adds a UTXO if it raises
the fee rate the sweep can reach. Channel funding and SendCoins already use
coin-selection-strategy=largest by default.

As a result, nothing in lnd spends small wallet UTXOs on its own anymore.
Before #11485 the sweeper selected smallest first, which consolidated small
UTXOs as a side effect, but it did so during deadline-critical sweeps, which
is the most expensive time to do it.

Problem

Small UTXOs that are economical at low fee rates (say 5k–50k sats) now
accumulate over time: closes of small channels, swept outputs of small HTLCs,
small on-chain receives. They stay in the wallet until the larger UTXOs are
used up. By then, the wallet often has to spend them under fee pressure,
for example to fund an anchor CPFP before an HTLC deadline. They then add
weight and lower the fee rate the sweep can reach, or they don't pay for
themselves at all and can't be used.

Proposal

Consolidate small, economical wallet UTXOs into fewer outputs while fees are
low, so they are cheap to spend when they are needed. Possible approaches:

  1. Opportunistic, inside the sweeper. When sweeping inputs with no
    deadline pressure (e.g. to_local or second-level HTLC outputs) and the
    current estimate is below a configurable threshold, add small wallet
    UTXOs to the sweep as long as each one pays for its own input weight with
    a margin.
  2. Background consolidation. When the estimate for a long conf target
    (e.g. 144 or 1008 blocks) is below a threshold and the wallet holds more
    than N UTXOs under X sats, publish a low-fee, RBF-signalling self-send
    that merges them.
  3. Manual. An RPC / lncli wallet consolidate command with a fee rate,
    a value ceiling and a max input count, so operators can do it themselves.

Option 3 is the smallest step and is useful on its own; options 1 and 2 could
build on it.

Considerations

  • Uneconomical UTXOs. Only consolidate UTXOs that pay for their own input
    weight at the consolidation fee rate with a clear margin. UTXOs worth less
    than that should be left alone, including dust sent to the wallet by third
    parties.
  • Privacy. Merging UTXOs links them on-chain (common input ownership),
    e.g. outputs from different channels or receives. This should be opt-in or
    at least configurable.
  • Locked coins. An unconfirmed consolidation ties up its inputs and makes
    its output unconfirmed, which can block channel opens and wallet-funded
    sweeps that require confirmed inputs. Low fee rates make this window
    longer, so it should not run while time-sensitive sweeps are pending, and
    it must respect the anchor reserve.
  • Size. Cap the number of inputs per consolidation transaction, and stay
    well below the standardness weight limit.
Lingua principale
Go
Stelle
8.2k
Fork
2.3k
Merge medio
1g 11h
PR unite (30g)
103

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di lightningnetwork/lnd

Tutte le issue di lightningnetwork/lnd

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.