mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-05 05:46:44 +00:00
show only unspent amount in status bar when refreshing postmix wallets
This commit is contained in:
parent
eb498f2bcc
commit
9bca911b0b
2 changed files with 14 additions and 4 deletions
|
@ -19,7 +19,6 @@ import com.sparrowwallet.drongo.psbt.PSBTSignatureException;
|
||||||
import com.sparrowwallet.drongo.wallet.*;
|
import com.sparrowwallet.drongo.wallet.*;
|
||||||
import com.sparrowwallet.hummingbird.UR;
|
import com.sparrowwallet.hummingbird.UR;
|
||||||
import com.sparrowwallet.hummingbird.registry.CryptoPSBT;
|
import com.sparrowwallet.hummingbird.registry.CryptoPSBT;
|
||||||
import com.sparrowwallet.hummingbird.registry.RegistryType;
|
|
||||||
import com.sparrowwallet.sparrow.control.*;
|
import com.sparrowwallet.sparrow.control.*;
|
||||||
import com.sparrowwallet.sparrow.event.*;
|
import com.sparrowwallet.sparrow.event.*;
|
||||||
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
|
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
|
||||||
|
@ -1930,7 +1929,7 @@ public class AppController implements Initializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<BlockTransaction> blockTransactions = new ArrayList<>(event.getBlockTransactions());
|
List<BlockTransaction> blockTransactions = new ArrayList<>(event.getBlockTransactions());
|
||||||
List<BlockTransaction> whirlpoolTransactions = event.getWhirlpoolMixTransactions();
|
List<BlockTransaction> whirlpoolTransactions = event.getUnspentWhirlpoolMixTransactions();
|
||||||
blockTransactions.removeAll(whirlpoolTransactions);
|
blockTransactions.removeAll(whirlpoolTransactions);
|
||||||
|
|
||||||
if(!whirlpoolTransactions.isEmpty()) {
|
if(!whirlpoolTransactions.isEmpty()) {
|
||||||
|
|
|
@ -7,7 +7,9 @@ import com.sparrowwallet.drongo.wallet.Wallet;
|
||||||
import com.sparrowwallet.sparrow.control.CoinLabel;
|
import com.sparrowwallet.sparrow.control.CoinLabel;
|
||||||
import com.sparrowwallet.sparrow.io.Config;
|
import com.sparrowwallet.sparrow.io.Config;
|
||||||
import com.sparrowwallet.sparrow.wallet.Entry;
|
import com.sparrowwallet.sparrow.wallet.Entry;
|
||||||
|
import com.sparrowwallet.sparrow.wallet.HashIndexEntry;
|
||||||
import com.sparrowwallet.sparrow.wallet.TransactionEntry;
|
import com.sparrowwallet.sparrow.wallet.TransactionEntry;
|
||||||
|
import com.sparrowwallet.sparrow.wallet.TransactionHashIndexEntry;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -60,12 +62,21 @@ public class NewWalletTransactionsEvent {
|
||||||
return String.format(Locale.ENGLISH, "%,d", value) + " sats";
|
return String.format(Locale.ENGLISH, "%,d", value) + " sats";
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BlockTransaction> getWhirlpoolMixTransactions() {
|
public List<BlockTransaction> getUnspentWhirlpoolMixTransactions() {
|
||||||
List<BlockTransaction> mixTransactions = new ArrayList<>();
|
List<BlockTransaction> mixTransactions = new ArrayList<>();
|
||||||
if(wallet.isWhirlpoolMixWallet()) {
|
if(wallet.isWhirlpoolMixWallet()) {
|
||||||
return transactionEntries.stream().filter(txEntry -> txEntry.getValue() == 0).map(TransactionEntry::getBlockTransaction).collect(Collectors.toList());
|
return transactionEntries.stream()
|
||||||
|
.filter(txEntry -> txEntry.getValue() == 0 && !allOutputsSpent(txEntry))
|
||||||
|
.map(TransactionEntry::getBlockTransaction).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
return mixTransactions;
|
return mixTransactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean allOutputsSpent(TransactionEntry txEntry) {
|
||||||
|
return txEntry.getChildren().stream()
|
||||||
|
.map(refEntry -> ((TransactionHashIndexEntry)refEntry))
|
||||||
|
.filter(txRefEntry -> txRefEntry.getType() == HashIndexEntry.Type.OUTPUT)
|
||||||
|
.allMatch(txRefEntry -> txRefEntry.getHashIndex().isSpent());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue