feat(wallet): show pending mempool balance and exclude unconfirmed UTXOs from spending

TransactionFactory now selects only confirmed UTXOs (height > 0), so
mempool funds are visible as pending balance but never spendable, with
a clear error when only unconfirmed funds are available. GUI and CLI
labels updated to "in attesa di conferma (non spendibile)".
This commit is contained in:
2026-06-11 11:34:13 +02:00
parent af10482e54
commit ece634f42e
4 changed files with 27 additions and 6 deletions
+9 -2
View File
@@ -50,9 +50,16 @@ public sealed class TransactionFactory(HdAccount account)
int changeIndex,
bool sendAll = false)
{
var spendable = utxos.Where(u => !u.Frozen).ToList();
// Si spendono solo UTXO confermati: i fondi in mempool si vedono nel
// saldo "in attesa" ma non sono spendibili finché non confermano.
var spendable = utxos.Where(u => !u.Frozen && u.Height > 0).ToList();
if (spendable.Count == 0)
throw new WalletSpendException("Nessun UTXO spendibile selezionato.");
{
var pending = utxos.Where(u => !u.Frozen && u.Height <= 0).Sum(u => u.ValueSats);
throw new WalletSpendException(pending > 0
? $"Nessun fondo confermato: {CoinAmount.Format(pending)} in attesa di conferma (non spendibile)."
: "Nessun UTXO spendibile selezionato.");
}
var coins = spendable.Select(u => new Coin(
new OutPoint(uint256.Parse(u.Txid), (uint)u.Vout),