Commit fc3d41c
fix(key-wallet): defer CoinSelector candidate filter to Utxo::is_spendable
`CoinSelector` carried its own confirmation policy
(`min_confirmations`, `include_unconfirmed`) and filtered candidates
with `(include_unconfirmed || is_confirmed || is_instantlocked)` plus
a `current_height - utxo.height >= min_confirmations` depth check.
Two consequences:
1. `is_trusted` was missing from the OR — mempool change from a tx
the wallet itself authored was rejected, even though the balance
UI shows it as spendable. Users hit this as
`CoinSelection(NoUtxosAvailable)` immediately after sending.
2. The depth check used `>= 1`, which silently rejected a UTXO mined
into the wallet's tip block (depth 0, but 1 confirmation in the
usual sense), and gated all unconfirmed incoming through the same
path.
The `Utxo` itself already has `is_spendable(current_height)` — which
checks not-locked and coinbase maturity — and the wallet decides what
to put in the UTXO map (with `is_confirmed`, `is_instantlocked`,
`is_trusted` flags reflecting its policy). The coin selector having a
*second*, divergent policy on top is what produced the bug.
Drop the duplicated machinery: remove `min_confirmations`,
`include_unconfirmed`, and the per-call helpers. Both filter sites
now defer to `Utxo::is_spendable`, so coin selection accepts every
UTXO the wallet tracks as spendable — confirmed, IS-locked, trusted
self-send change, and incoming mempool alike.
Tightens `tests_transaction_builder.rs` accordingly: the workaround
that mined an extra "bump" tx so `last_processed_height` advanced past
the funding UTXO is no longer needed.
All 482 key-wallet unit tests and 26 dashd_sync integration tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent a5c95be commit fc3d41c
2 files changed
Lines changed: 15 additions & 62 deletions
File tree
- dash-spv/tests/dashd_sync
- key-wallet/src/wallet/managed_wallet_info
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
| 157 | + | |
162 | 158 | | |
163 | 159 | | |
164 | 160 | | |
165 | 161 | | |
166 | 162 | | |
167 | 163 | | |
168 | 164 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
| 165 | + | |
190 | 166 | | |
191 | 167 | | |
192 | 168 | | |
193 | 169 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
198 | 174 | | |
199 | 175 | | |
200 | 176 | | |
| |||
Lines changed: 9 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
84 | 82 | | |
85 | 83 | | |
86 | 84 | | |
87 | 85 | | |
88 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
92 | | - | |
93 | | - | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | 99 | | |
111 | 100 | | |
112 | 101 | | |
| |||
159 | 148 | | |
160 | 149 | | |
161 | 150 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
| 151 | + | |
| 152 | + | |
171 | 153 | | |
172 | 154 | | |
173 | 155 | | |
| |||
261 | 243 | | |
262 | 244 | | |
263 | 245 | | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
| 246 | + | |
270 | 247 | | |
271 | 248 | | |
272 | 249 | | |
| |||
0 commit comments