Wallet builds oversized transactions from mining dust; needs smarter coin selection and optional auto-consolidation #55

Open
opened 2026-11-14 22:12:46 +00:00 by endciv · 1 comment

Version: dobbscoin-qt 0.14.1 (protocol 70005), Windows 10

Problem

Wallets that receive regular mining payouts pile up thousands of small coins. The wallet then builds needlessly large transactions from them, and normal users have no way to know why or what to do about it. Manual consolidation, or Coin Control (hidden behind a setting), is expert-only knowledge.

Real-world example (2026-11-14)

Wallet contents:

Coin size (BOB) Count Total (BOB)
< 1 375 235
1–10 2,674 10,831
10–100 7 76
1,000+ 2 —

Nearly all of the small coins are pool payouts to a single address: 3,058 payouts averaging about 4 BOB since a manual consolidation on 2026-10-10.

A send of 1,000 BOB (tx ce91a7ba322b848d493a2436c6556745565ace40a925a07c35f43dd194cb64a9) used 23 inputs (22 payouts of about 8.5 BOB plus one 808 BOB coin), 4,208 bytes, with change of only 0.01004906, even though either of the two large coins could have covered it alone. The keys are uncompressed, so each input is about 180 bytes.

Cause

Coin selection is the pre-0.17 Bitcoin knapsack (ApproximateBestSubset in src/wallet.cpp): it prefers a near-exact match from many small coins over one larger coin, in order to avoid change. Fees on this chain are cheap, but transaction size still makes sends slow to propagate, more likely to get stuck, and dangerous at scale. A wallet with 3,000+ small coins cannot be swept in one transaction under the 100,000-byte standard size limit (MAX_STANDARD_TX_SIZE).

Proposal

Part A: coin selection (the main fix)

  • Port, or approximate, Bitcoin Core's waste-metric selection (Branch-and-Bound plus a waste score, Core 0.17 onward).
  • At low fee rates the waste score prefers spending a few extra small coins, so every normal send does some cleanup automatically, while a larger coin keeps the transaction a reasonable size.
  • Cap the input count per send, or prefer the smallest single coin that covers the amount, when the knapsack result would exceed N inputs.

Part B: optional auto-consolidation (backstop for mining wallets)

  • Setting: "Automatically consolidate small coins," on by default, can be turned off.
  • Trigger: more than about 500 confirmed coins below a size threshold. Skip unconfirmed coins and immature coinbase outputs.
  • Batch at about 400 inputs per transaction (under 100 KB), one batch at a time, each waiting for confirmation before the next.
  • Destination: a fresh address in the same wallet.
  • Encrypted wallets: queue the roll-up and run it at the next unlock. Never prompt out of nowhere.
  • Label these "Consolidation" in the transaction list so users don't think funds left the wallet.

Privacy note

Combining coins from different addresses publicly links them to one owner. Offer a "same-address only" mode. In the example above it would still cover nearly all of the small coins, since they sit on one payout address.

  • #53 Built-in stratum server serves coinbase-only jobs
  • #54 Wallet tx not reaching the network after peer set turns over
  • Interim workaround: Settings → Options → Wallet → "Enable coin control features," then pick one large coin in the Send tab.
**Version:** dobbscoin-qt 0.14.1 (protocol 70005), Windows 10 ### Problem Wallets that receive regular mining payouts pile up thousands of small coins. The wallet then builds needlessly large transactions from them, and normal users have no way to know why or what to do about it. Manual consolidation, or Coin Control (hidden behind a setting), is expert-only knowledge. ### Real-world example (2026-11-14) Wallet contents: | Coin size (BOB) | Count | Total (BOB) | |---|---|---| | < 1 | 375 | 235 | | 1–10 | 2,674 | 10,831 | | 10–100 | 7 | 76 | | 1,000+ | 2 | — | Nearly all of the small coins are pool payouts to a single address: 3,058 payouts averaging about 4 BOB since a manual consolidation on 2026-10-10. A send of 1,000 BOB (tx `ce91a7ba322b848d493a2436c6556745565ace40a925a07c35f43dd194cb64a9`) used **23 inputs (22 payouts of about 8.5 BOB plus one 808 BOB coin), 4,208 bytes**, with change of only 0.01004906, even though either of the two large coins could have covered it alone. The keys are uncompressed, so each input is about 180 bytes. ### Cause Coin selection is the pre-0.17 Bitcoin knapsack (`ApproximateBestSubset` in `src/wallet.cpp`): it prefers a near-exact match from many small coins over one larger coin, in order to avoid change. Fees on this chain are cheap, but transaction size still makes sends slow to propagate, more likely to get stuck, and dangerous at scale. A wallet with 3,000+ small coins cannot be swept in one transaction under the 100,000-byte standard size limit (`MAX_STANDARD_TX_SIZE`). ### Proposal **Part A: coin selection (the main fix)** - Port, or approximate, Bitcoin Core's waste-metric selection (Branch-and-Bound plus a waste score, Core 0.17 onward). - At low fee rates the waste score prefers spending a few extra small coins, so every normal send does some cleanup automatically, while a larger coin keeps the transaction a reasonable size. - Cap the input count per send, or prefer the smallest single coin that covers the amount, when the knapsack result would exceed N inputs. **Part B: optional auto-consolidation (backstop for mining wallets)** - Setting: "Automatically consolidate small coins," on by default, can be turned off. - Trigger: more than about 500 confirmed coins below a size threshold. Skip unconfirmed coins and immature coinbase outputs. - Batch at about 400 inputs per transaction (under 100 KB), one batch at a time, each waiting for confirmation before the next. - Destination: a fresh address in the same wallet. - Encrypted wallets: queue the roll-up and run it at the next unlock. Never prompt out of nowhere. - Label these "Consolidation" in the transaction list so users don't think funds left the wallet. ### Privacy note Combining coins from different addresses publicly links them to one owner. Offer a "same-address only" mode. In the example above it would still cover nearly all of the small coins, since they sit on one payout address. ### Related - #53 Built-in stratum server serves coinbase-only jobs - #54 Wallet tx not reaching the network after peer set turns over - Interim workaround: Settings → Options → Wallet → "Enable coin control features," then pick one large coin in the Send tab.
Member

Both parts are in EndTimes 0.21.2 beta 3: https://git.subgenius.finance/SubGeniusFinance/dobbscoin-source/releases/tag/v0.21.2-beta3

Part A, coin selection: when the knapsack's pick would take more than 20 coins and one larger coin covers the amount, the wallet spends the larger coin. On a copy of the wallet from this report, a 5,000 BOB send went from 1,059 inputs (about 157 KB, unrelayable) to 1 input, 119 bytes.

Part B, automatic merging: when more than 500 confirmed coins under 10 BOB sit on one address, the wallet merges up to 400 of them back onto that same address, one batch at a time, waiting for each to confirm. Same address only by default, so nothing gets linked (-consolidateall lifts that); it pays back to the coins' own address rather than a fresh one, so a copy of a non-HD 0.14 wallet never moves coins out of the original's sight. Locked wallets wait for unlock, and it waits until the wallet has caught up with the chain. Shown in the list as "Auto coin merge (to yourself)"; off switch in Options > Wallet or -consolidate=0. Live test: 400 coins, 71,644 bytes, fee 0.00072219, confirmed in block 1,953,087.

Leaving this open until the final 0.21.2 release.

Both parts are in EndTimes 0.21.2 beta 3: https://git.subgenius.finance/SubGeniusFinance/dobbscoin-source/releases/tag/v0.21.2-beta3 **Part A, coin selection:** when the knapsack's pick would take more than 20 coins and one larger coin covers the amount, the wallet spends the larger coin. On a copy of the wallet from this report, a 5,000 BOB send went from 1,059 inputs (about 157 KB, unrelayable) to 1 input, 119 bytes. **Part B, automatic merging:** when more than 500 confirmed coins under 10 BOB sit on one address, the wallet merges up to 400 of them back onto that same address, one batch at a time, waiting for each to confirm. Same address only by default, so nothing gets linked (`-consolidateall` lifts that); it pays back to the coins' own address rather than a fresh one, so a copy of a non-HD 0.14 wallet never moves coins out of the original's sight. Locked wallets wait for unlock, and it waits until the wallet has caught up with the chain. Shown in the list as "Auto coin merge (to yourself)"; off switch in Options > Wallet or `-consolidate=0`. Live test: 400 coins, 71,644 bytes, fee 0.00072219, confirmed in block 1,953,087. Leaving this open until the final 0.21.2 release.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
SubGeniusFinance/dobbscoin-source#55
No description provided.