Skip to content

qt: coin control's change preview shows change that the wallet adds to the fee #365

Open

Description

@kiwidream

With coin control enabled, the Send page's coin-control panel can show change that the wallet then adds to the fee. The fee and total in the send confirmation are correct; only the preview is wrong. Line numbers are at 1.x.x 993ab7531f.

What happens

CoinControlDialog::updateLabels (src/qt/coincontroldialog.cpp:488-503) decides whether change survives by testing it as dust: it uses a 24-byte dummy script at the dust relay fee. The wallet decides differently. It drops change whose value is below the cost of creating and later spending it at the discard rate. Since #346, with no fee estimate, that rate is the fallback rate. A one-input P2MR transaction is about 3.8 kvB, so the wallet's threshold is far above the dust limit, and the preview keeps change the wallet drops.

Reproduce (regtest, no fee estimates, 250 sat/kvB fallback)

  1. Enable coin control (Settings ▸ Options ▸ Wallet ▸ Enable coin control features).
  2. In a wallet holding 0.01 QBT coins, select one coin under Inputs… and pay 0.00998 QBT to another address.
  3. The panel shows "Change: ≈0.00001039".
  4. The confirmation shows a fee of 0.00002000 and a total of 0.01000000. The broadcast transaction has one output and no change, which is correct.

With a 0.0099 payment, the change of about 0.00009 is shown and kept, as expected. In testing, the wallet kept change from about 0.0000288 QBT upward.

Expected

The preview applies the wallet's change-discard rule, or marks change below that threshold as going to the fee. Upstream has the same dust-based preview. qbit's large P2MR inputs make the difference visible.

Found during the #174 v1.0.1 release testing (qbit-qt on Linux).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions