walllet: use CoinsResult instead of PreSelectedInputs

PreSelectedInputs is confusing to use. it's `total_amount`
might store total amount or effective amount based on SFFO.
ex: we might accidentally sum preselected inputs effective
amount (named `total_amount`) with automatically selected
inputs actual total amount.

CoinsResult has a cleaner interface with separate fields
for both these amounts.

2 behavioural changes:

1. no more default assert error if effective value is unset
    - previously PreSelectedInputs::Insert() called
      COutput::GetEffectiveValue() which assert failed
      if the optional was unset.
    - now we don't default assert anymore.
      * in GUI/getAvailableBalance better not to assert.
      * SelectCoins's preselected inputs always contain a
        feerate, so effective amount should be set.
        explicitly added an assertion to ensure this.

2. FetchSelectedInputs uses OutputType::UNKNOWN as key to
   populate CoinsResult's coins map. it's discarded later.
This commit is contained in:
stratospher
2026-01-28 17:26:20 +05:30
parent e5474079f1
commit 7819da2c16
4 changed files with 24 additions and 18 deletions

View File

@@ -411,7 +411,7 @@ public:
CoinSelectionParams params(rng);
// Note: for now, swallow any error.
if (auto res = FetchSelectedInputs(*m_wallet, coin_control, params)) {
total_amount += res->total_amount;
total_amount += res->GetTotalAmount();
}
}