show error dialog on cpfp if no outputs are spendable

This commit is contained in:
Craig Raw 2023-11-13 14:37:41 +02:00
parent c81c42a87c
commit a5312374a8

View file

@ -352,12 +352,14 @@ public class EntryCell extends TreeTableCell<Entry, Entry> implements Confirmati
List<BlockTransactionHashIndex> ourOutputs = transactionEntry.getChildren().stream() List<BlockTransactionHashIndex> ourOutputs = transactionEntry.getChildren().stream()
.filter(e -> e instanceof HashIndexEntry) .filter(e -> e instanceof HashIndexEntry)
.map(e -> (HashIndexEntry)e) .map(e -> (HashIndexEntry)e)
.filter(e -> e.getType().equals(HashIndexEntry.Type.OUTPUT)) .filter(e -> e.getType().equals(HashIndexEntry.Type.OUTPUT) && e.isSpendable())
.map(HashIndexEntry::getHashIndex) .map(HashIndexEntry::getHashIndex)
.collect(Collectors.toList()); .collect(Collectors.toList());
if(ourOutputs.isEmpty()) { if(ourOutputs.isEmpty()) {
throw new IllegalStateException("Cannot create CPFP without any wallet outputs to spend"); AppServices.showErrorDialog("No spendable outputs", "None of the outputs on this transaction are spendable.\n\n Ensure that the outputs are not frozen" +
(transactionEntry.getConfirmations() <= 0 ? ", and spending unconfirmed UTXOs is allowed." : "."));
return;
} }
BlockTransactionHashIndex cpfpUtxo = ourOutputs.get(0); BlockTransactionHashIndex cpfpUtxo = ourOutputs.get(0);