mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-11-05 11:56:37 +00:00
show total in transaction diagram when constructing multiple payment transactions
This commit is contained in:
parent
af4a283b3f
commit
c078aea3b4
2 changed files with 43 additions and 5 deletions
|
|
@ -8,15 +8,13 @@ import com.sparrowwallet.drongo.protocol.Sha256Hash;
|
||||||
import com.sparrowwallet.drongo.protocol.TransactionOutput;
|
import com.sparrowwallet.drongo.protocol.TransactionOutput;
|
||||||
import com.sparrowwallet.drongo.uri.BitcoinURI;
|
import com.sparrowwallet.drongo.uri.BitcoinURI;
|
||||||
import com.sparrowwallet.drongo.wallet.*;
|
import com.sparrowwallet.drongo.wallet.*;
|
||||||
import com.sparrowwallet.sparrow.UnitFormat;
|
import com.sparrowwallet.sparrow.*;
|
||||||
import com.sparrowwallet.sparrow.AppServices;
|
|
||||||
import com.sparrowwallet.sparrow.EventManager;
|
|
||||||
import com.sparrowwallet.sparrow.Theme;
|
|
||||||
import com.sparrowwallet.sparrow.event.ExcludeUtxoEvent;
|
import com.sparrowwallet.sparrow.event.ExcludeUtxoEvent;
|
||||||
import com.sparrowwallet.sparrow.event.ReplaceChangeAddressEvent;
|
import com.sparrowwallet.sparrow.event.ReplaceChangeAddressEvent;
|
||||||
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
|
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
|
||||||
import com.sparrowwallet.sparrow.glyphfont.GlyphUtils;
|
import com.sparrowwallet.sparrow.glyphfont.GlyphUtils;
|
||||||
import com.sparrowwallet.sparrow.io.Config;
|
import com.sparrowwallet.sparrow.io.Config;
|
||||||
|
import com.sparrowwallet.sparrow.net.ExchangeSource;
|
||||||
import com.sparrowwallet.sparrow.wallet.OptimizationStrategy;
|
import com.sparrowwallet.sparrow.wallet.OptimizationStrategy;
|
||||||
import javafx.beans.property.BooleanProperty;
|
import javafx.beans.property.BooleanProperty;
|
||||||
import javafx.beans.property.ObjectProperty;
|
import javafx.beans.property.ObjectProperty;
|
||||||
|
|
@ -229,6 +227,12 @@ public class TransactionDiagram extends GridPane {
|
||||||
getChildren().clear();
|
getChildren().clear();
|
||||||
getChildren().addAll(inputsTypePane, inputsPane, inputsLinesPane, txPane, outputsLinesPane, outputsPane);
|
getChildren().addAll(inputsTypePane, inputsPane, inputsLinesPane, txPane, outputsLinesPane, outputsPane);
|
||||||
|
|
||||||
|
if(!isFinal() && walletTx.getPayments().size() > 1) {
|
||||||
|
Pane totalsPane = getTotalsPane();
|
||||||
|
GridPane.setConstraints(totalsPane, 2, 0, 3, 1);
|
||||||
|
getChildren().add(totalsPane);
|
||||||
|
}
|
||||||
|
|
||||||
if(contextMenu == null) {
|
if(contextMenu == null) {
|
||||||
contextMenu = new ContextMenu();
|
contextMenu = new ContextMenu();
|
||||||
MenuItem menuItem = new MenuItem("Save as Image...");
|
MenuItem menuItem = new MenuItem("Save as Image...");
|
||||||
|
|
@ -839,6 +843,34 @@ public class TransactionDiagram extends GridPane {
|
||||||
return txPane;
|
return txPane;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Pane getTotalsPane() {
|
||||||
|
VBox totalsBox = new VBox();
|
||||||
|
totalsBox.setPadding(new Insets(0, 0, 15, 0));
|
||||||
|
totalsBox.setAlignment(Pos.CENTER);
|
||||||
|
|
||||||
|
long amount = walletTx.getPayments().stream().mapToLong(Payment::getAmount).sum();
|
||||||
|
long count = walletTx.getPayments().size();
|
||||||
|
|
||||||
|
HBox coinLabelBox = new HBox();
|
||||||
|
coinLabelBox.setAlignment(Pos.CENTER);
|
||||||
|
CoinLabel totalCoinLabel = new CoinLabel();
|
||||||
|
totalCoinLabel.setValue(amount);
|
||||||
|
coinLabelBox.getChildren().addAll(totalCoinLabel, new Label(" in "), new Label(Long.toString(count)), new Label(" payments"));
|
||||||
|
totalsBox.getChildren().addAll(createSpacer(), coinLabelBox);
|
||||||
|
|
||||||
|
CurrencyRate currencyRate = AppServices.getFiatCurrencyExchangeRate();
|
||||||
|
if(currencyRate != null && currencyRate.isAvailable() && Config.get().getExchangeSource() != ExchangeSource.NONE) {
|
||||||
|
HBox fiatLabelBox = new HBox();
|
||||||
|
fiatLabelBox.setAlignment(Pos.CENTER);
|
||||||
|
FiatLabel fiatLabel = new FiatLabel();
|
||||||
|
fiatLabel.set(currencyRate, amount);
|
||||||
|
fiatLabelBox.getChildren().add(fiatLabel);
|
||||||
|
totalsBox.getChildren().add(fiatLabelBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalsBox;
|
||||||
|
}
|
||||||
|
|
||||||
private void saveAsImage() {
|
private void saveAsImage() {
|
||||||
Stage window = new Stage();
|
Stage window = new Stage();
|
||||||
FileChooser fileChooser = new FileChooser();
|
FileChooser fileChooser = new FileChooser();
|
||||||
|
|
|
||||||
|
|
@ -981,7 +981,7 @@ public class SendController extends WalletFormController implements Initializabl
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFiatFeeAmount(CurrencyRate currencyRate, Long amount) {
|
private void setFiatFeeAmount(CurrencyRate currencyRate, Long amount) {
|
||||||
if(amount != null && currencyRate != null && currencyRate.isAvailable()) {
|
if(amount != null && currencyRate != null && currencyRate.isAvailable() && Config.get().getExchangeSource() != ExchangeSource.NONE) {
|
||||||
fiatFeeAmount.set(currencyRate, amount);
|
fiatFeeAmount.set(currencyRate, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1519,12 +1519,18 @@ public class SendController extends WalletFormController implements Initializabl
|
||||||
if(event.getExchangeSource() == ExchangeSource.NONE) {
|
if(event.getExchangeSource() == ExchangeSource.NONE) {
|
||||||
fiatFeeAmount.setCurrency(null);
|
fiatFeeAmount.setCurrency(null);
|
||||||
fiatFeeAmount.setBtcRate(0.0);
|
fiatFeeAmount.setBtcRate(0.0);
|
||||||
|
if(paymentTabs.getTabs().size() > 1) {
|
||||||
|
updateTransaction();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void exchangeRatesUpdated(ExchangeRatesUpdatedEvent event) {
|
public void exchangeRatesUpdated(ExchangeRatesUpdatedEvent event) {
|
||||||
setFiatFeeAmount(event.getCurrencyRate(), getFeeValueSats());
|
setFiatFeeAmount(event.getCurrencyRate(), getFeeValueSats());
|
||||||
|
if(paymentTabs.getTabs().size() > 1) {
|
||||||
|
updateTransaction();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue