This commit is contained in:
Manfred Karrer 2016-04-06 23:59:55 +02:00
parent 565c44d94c
commit cc46a81644
12 changed files with 77 additions and 194 deletions

View file

@ -1,35 +0,0 @@
package io.bitsquare.trade;
import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.WalletService;
import org.bitcoinj.core.Coin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.stream.Stream;
public class TradableHelper {
private static final Logger log = LoggerFactory.getLogger(TradableHelper.class);
public static Stream<AddressEntry> getAddressEntriesForAvailableBalanceStream(WalletService walletService) {
Stream<AddressEntry> availableOrPayout = Stream.concat(walletService.getAddressEntries(AddressEntry.Context.TRADE_PAYOUT).stream(), walletService.getFundedAvailableAddressEntries().stream());
Stream<AddressEntry> available = Stream.concat(availableOrPayout, walletService.getAddressEntries(AddressEntry.Context.ARBITRATOR).stream());
available = Stream.concat(available, walletService.getAddressEntries(AddressEntry.Context.OFFER_FUNDING).stream());
return available
.filter(addressEntry -> walletService.getBalanceForAddress(addressEntry.getAddress()).isPositive());
}
public static Stream<Trade> getLockedTradeStream(TradeManager tradeManager) {
return tradeManager.getTrades().stream()
.filter(trade -> trade.getState().getPhase().ordinal() >= Trade.Phase.DEPOSIT_PAID.ordinal() &&
trade.getState().getPhase().ordinal() < Trade.Phase.PAYOUT_PAID.ordinal());
}
public static AddressEntry getLockedTradeAddressEntry(Trade trade, WalletService walletService) {
return walletService.getOrCreateAddressEntry(trade.getId(), AddressEntry.Context.MULTI_SIG);
}
public static Coin getReservedBalance(Tradable tradable, WalletService walletService) {
return walletService.getBalanceForAddress(walletService.getOrCreateAddressEntry(tradable.getId(), AddressEntry.Context.RESERVED_FOR_TRADE).getAddress());
}
}

View file

@ -61,6 +61,7 @@ import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import java.io.File; import java.io.File;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Stream;
import static io.bitsquare.util.Validator.nonEmptyStringOf; import static io.bitsquare.util.Validator.nonEmptyStringOf;
@ -396,4 +397,18 @@ public class TradeManager {
public Optional<Trade> getTradeById(String tradeId) { public Optional<Trade> getTradeById(String tradeId) {
return trades.stream().filter(e -> e.getId().equals(tradeId)).findFirst(); return trades.stream().filter(e -> e.getId().equals(tradeId)).findFirst();
} }
public Stream<AddressEntry> getAddressEntriesForAvailableBalanceStream() {
Stream<AddressEntry> availableOrPayout = Stream.concat(walletService.getAddressEntries(AddressEntry.Context.TRADE_PAYOUT).stream(), walletService.getFundedAvailableAddressEntries().stream());
Stream<AddressEntry> available = Stream.concat(availableOrPayout, walletService.getAddressEntries(AddressEntry.Context.ARBITRATOR).stream());
available = Stream.concat(available, walletService.getAddressEntries(AddressEntry.Context.OFFER_FUNDING).stream());
return available
.filter(addressEntry -> walletService.getBalanceForAddress(addressEntry.getAddress()).isPositive());
}
public Stream<Trade> getLockedTradeStream() {
return getTrades().stream()
.filter(trade -> trade.getState().getPhase().ordinal() >= Trade.Phase.DEPOSIT_PAID.ordinal() &&
trade.getState().getPhase().ordinal() < Trade.Phase.PAYOUT_PAID.ordinal());
}
} }

View file

@ -21,16 +21,11 @@ public class AddressWithIconAndDirection extends AnchorPane {
private final Label directionIcon; private final Label directionIcon;
private final Label label; private final Label label;
public AddressWithIconAndDirection(String text, String address, AwesomeIcon awesomeIcon, boolean received, boolean isInternal) { public AddressWithIconAndDirection(String text, String address, AwesomeIcon awesomeIcon, boolean received) {
directionIcon = new Label(); directionIcon = new Label();
directionIcon.setLayoutY(3); directionIcon.setLayoutY(3);
if (isInternal) {
directionIcon.getStyleClass().add("internal-funds-icon");
AwesomeDude.setIcon(directionIcon, AwesomeIcon.REPEAT);
} else {
directionIcon.getStyleClass().add(received ? "received-funds-icon" : "sent-funds-icon"); directionIcon.getStyleClass().add(received ? "received-funds-icon" : "sent-funds-icon");
AwesomeDude.setIcon(directionIcon, received ? AwesomeIcon.SIGNIN : AwesomeIcon.SIGNOUT); AwesomeDude.setIcon(directionIcon, received ? AwesomeIcon.SIGNIN : AwesomeIcon.SIGNOUT);
}
directionIcon.setMouseTransparent(true); directionIcon.setMouseTransparent(true);
HBox hBox = new HBox(); HBox hBox = new HBox();

View file

@ -26,6 +26,7 @@ import io.bitsquare.app.Version;
import io.bitsquare.arbitration.ArbitratorManager; import io.bitsquare.arbitration.ArbitratorManager;
import io.bitsquare.arbitration.Dispute; import io.bitsquare.arbitration.Dispute;
import io.bitsquare.arbitration.DisputeManager; import io.bitsquare.arbitration.DisputeManager;
import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.TradeWalletService; import io.bitsquare.btc.TradeWalletService;
import io.bitsquare.btc.WalletService; import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.BalanceListener; import io.bitsquare.btc.listeners.BalanceListener;
@ -54,7 +55,6 @@ import io.bitsquare.p2p.network.Connection;
import io.bitsquare.p2p.network.ConnectionListener; import io.bitsquare.p2p.network.ConnectionListener;
import io.bitsquare.p2p.peers.keepalive.messages.Ping; import io.bitsquare.p2p.peers.keepalive.messages.Ping;
import io.bitsquare.payment.OKPayAccount; import io.bitsquare.payment.OKPayAccount;
import io.bitsquare.trade.TradableHelper;
import io.bitsquare.trade.Trade; import io.bitsquare.trade.Trade;
import io.bitsquare.trade.TradeManager; import io.bitsquare.trade.TradeManager;
import io.bitsquare.trade.closed.ClosedTradableManager; import io.bitsquare.trade.closed.ClosedTradableManager;
@ -65,6 +65,7 @@ import io.bitsquare.user.Preferences;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import javafx.beans.property.*; import javafx.beans.property.*;
import javafx.collections.ListChangeListener; import javafx.collections.ListChangeListener;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.Coin; import org.bitcoinj.core.Coin;
import org.bitcoinj.core.Transaction; import org.bitcoinj.core.Transaction;
import org.bitcoinj.store.BlockStoreException; import org.bitcoinj.store.BlockStoreException;
@ -683,7 +684,7 @@ public class MainViewModel implements ViewModel {
} }
private void updateAvailableBalance() { private void updateAvailableBalance() {
Coin totalAvailableBalance = Coin.valueOf(TradableHelper.getAddressEntriesForAvailableBalanceStream(walletService) Coin totalAvailableBalance = Coin.valueOf(tradeManager.getAddressEntriesForAvailableBalanceStream()
.mapToLong(addressEntry -> walletService.getBalanceForAddress(addressEntry.getAddress()).getValue()) .mapToLong(addressEntry -> walletService.getBalanceForAddress(addressEntry.getAddress()).getValue())
.sum()); .sum());
availableBalance.set(formatter.formatCoinWithCode(totalAvailableBalance)); availableBalance.set(formatter.formatCoinWithCode(totalAvailableBalance));
@ -691,7 +692,10 @@ public class MainViewModel implements ViewModel {
private void updateReservedBalance() { private void updateReservedBalance() {
Coin sum = Coin.valueOf(openOfferManager.getOpenOffers().stream() Coin sum = Coin.valueOf(openOfferManager.getOpenOffers().stream()
.map(openOffer -> TradableHelper.getReservedBalance(openOffer, walletService)) .map(openOffer -> {
Address address = walletService.getOrCreateAddressEntry(openOffer.getId(), AddressEntry.Context.RESERVED_FOR_TRADE).getAddress();
return walletService.getBalanceForAddress(address);
})
.mapToLong(Coin::getValue) .mapToLong(Coin::getValue)
.sum()); .sum());
@ -699,8 +703,8 @@ public class MainViewModel implements ViewModel {
} }
private void updateLockedBalance() { private void updateLockedBalance() {
Coin sum = Coin.valueOf(TradableHelper.getLockedTradeStream(tradeManager) Coin sum = Coin.valueOf(tradeManager.getLockedTradeStream()
.mapToLong(trade -> TradableHelper.getLockedTradeAddressEntry(trade, walletService).getLockedTradeAmount().getValue()) .mapToLong(trade -> walletService.getOrCreateAddressEntry(trade.getId(), AddressEntry.Context.MULTI_SIG).getLockedTradeAmount().getValue())
.sum()); .sum());
lockedBalance.set(formatter.formatCoinWithCode(sum)); lockedBalance.set(formatter.formatCoinWithCode(sum));
} }

View file

@ -35,25 +35,19 @@ import org.slf4j.LoggerFactory;
public class DepositListItem { public class DepositListItem {
private final Logger log = LoggerFactory.getLogger(this.getClass()); private final Logger log = LoggerFactory.getLogger(this.getClass());
private final StringProperty balance = new SimpleStringProperty(); private final StringProperty balance = new SimpleStringProperty();
private final WalletService walletService; private final WalletService walletService;
private Coin balanceAsCoin; private Coin balanceAsCoin;
private BSFormatter formatter;
private final ConfidenceProgressIndicator progressIndicator; private final ConfidenceProgressIndicator progressIndicator;
private final Tooltip tooltip; private final Tooltip tooltip;
private String balanceString;
private String addressString; private String addressString;
private String usage = "-"; private String usage = "-";
private TxConfidenceListener txConfidenceListener; private TxConfidenceListener txConfidenceListener;
private int numTxOutputs = 0; private int numTxOutputs = 0;
// public DepositListItem(AddressEntry addressEntry, Transaction transaction, WalletService walletService, Optional<Tradable> tradableOptional, BSFormatter formatter) {
public DepositListItem(AddressEntry addressEntry, WalletService walletService, BSFormatter formatter) { public DepositListItem(AddressEntry addressEntry, WalletService walletService, BSFormatter formatter) {
this.walletService = walletService; this.walletService = walletService;
this.formatter = formatter;
addressString = addressEntry.getAddressString(); addressString = addressEntry.getAddressString();

View file

@ -69,31 +69,28 @@ public class DepositView extends ActivatableView<VBox, Void> {
@FXML @FXML
GridPane gridPane; GridPane gridPane;
@FXML @FXML
TableView<DepositListItem> tableView; TableView<DepositListItem> tableView;
@FXML @FXML
TableColumn<DepositListItem, DepositListItem> selectColumn, addressColumn, balanceColumn, confidenceColumn, usageColumn; TableColumn<DepositListItem, DepositListItem> selectColumn, addressColumn, balanceColumn, confidenceColumn, usageColumn;
private ImageView qrCodeImageView; private ImageView qrCodeImageView;
private int gridRow = 0;
private AddressTextField addressTextField; private AddressTextField addressTextField;
Button generateNewAddressButton; private Button generateNewAddressButton;
private final WalletService walletService;
private final BSFormatter formatter;
private final Preferences preferences;
private final ObservableList<DepositListItem> observableList = FXCollections.observableArrayList();
private final SortedList<DepositListItem> sortedList = new SortedList<>(observableList);
private BalanceListener balanceListener;
private TitledGroupBg titledGroupBg; private TitledGroupBg titledGroupBg;
private Label addressLabel, amountLabel; private Label addressLabel, amountLabel;
private Label qrCodeLabel; private Label qrCodeLabel;
private InputTextField amountTextField; private InputTextField amountTextField;
private Subscription amountTextFieldSubscription;
private String paymentLabel;
private ChangeListener<DepositListItem> tableViewSelectionListener;
private final WalletService walletService;
private final BSFormatter formatter;
private final Preferences preferences;
private final String paymentLabelString;
private final ObservableList<DepositListItem> observableList = FXCollections.observableArrayList();
private final SortedList<DepositListItem> sortedList = new SortedList<>(observableList);
private BalanceListener balanceListener;
private Subscription amountTextFieldSubscription;
private ChangeListener<DepositListItem> tableViewSelectionListener;
private int gridRow = 0;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor, lifecycle // Constructor, lifecycle
@ -106,6 +103,8 @@ public class DepositView extends ActivatableView<VBox, Void> {
this.walletService = walletService; this.walletService = walletService;
this.formatter = formatter; this.formatter = formatter;
this.preferences = preferences; this.preferences = preferences;
paymentLabelString = "Fund Bitsquare wallet";
} }
@Override @Override
@ -153,8 +152,7 @@ public class DepositView extends ActivatableView<VBox, Void> {
//GridPane.setValignment(addressLabel, VPos.TOP); //GridPane.setValignment(addressLabel, VPos.TOP);
//GridPane.setMargin(addressLabel, new Insets(3, 0, 0, 0)); //GridPane.setMargin(addressLabel, new Insets(3, 0, 0, 0));
addressTextField = addressTuple.second; addressTextField = addressTuple.second;
paymentLabel = "Fund Bitsquare wallet"; addressTextField.setPaymentLabel(paymentLabelString);
addressTextField.setPaymentLabel(paymentLabel);
Tuple2<Label, InputTextField> amountTuple = addLabelInputTextField(gridPane, ++gridRow, "Amount in BTC (optional):"); Tuple2<Label, InputTextField> amountTuple = addLabelInputTextField(gridPane, ++gridRow, "Amount in BTC (optional):");
@ -307,7 +305,7 @@ public class DepositView extends ActivatableView<VBox, Void> {
private String getBitcoinURI() { private String getBitcoinURI() {
return BitcoinURI.convertToBitcoinURI(addressTextField.getAddress(), return BitcoinURI.convertToBitcoinURI(addressTextField.getAddress(),
getAmountAsCoin(), getAmountAsCoin(),
paymentLabel, paymentLabelString,
null); null);
} }

View file

@ -30,7 +30,6 @@ import io.bitsquare.gui.main.overlays.windows.OfferDetailsWindow;
import io.bitsquare.gui.main.overlays.windows.TradeDetailsWindow; import io.bitsquare.gui.main.overlays.windows.TradeDetailsWindow;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.trade.Tradable; import io.bitsquare.trade.Tradable;
import io.bitsquare.trade.TradableHelper;
import io.bitsquare.trade.Trade; import io.bitsquare.trade.Trade;
import io.bitsquare.trade.TradeManager; import io.bitsquare.trade.TradeManager;
import io.bitsquare.trade.offer.OpenOffer; import io.bitsquare.trade.offer.OpenOffer;
@ -148,9 +147,9 @@ public class LockedView extends ActivatableView<VBox, Void> {
private void updateList() { private void updateList() {
observableList.forEach(LockedListItem::cleanup); observableList.forEach(LockedListItem::cleanup);
observableList.setAll(TradableHelper.getLockedTradeStream(tradeManager) observableList.setAll(tradeManager.getLockedTradeStream()
.map(trade -> new LockedListItem(trade, .map(trade -> new LockedListItem(trade,
TradableHelper.getLockedTradeAddressEntry(trade, walletService), walletService.getOrCreateAddressEntry(trade.getId(), AddressEntry.Context.MULTI_SIG),
walletService, walletService,
formatter)) formatter))
.collect(Collectors.toList())); .collect(Collectors.toList()));

View file

@ -22,7 +22,6 @@ import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.BalanceListener; import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.trade.Tradable; import io.bitsquare.trade.Tradable;
import io.bitsquare.trade.TradableHelper;
import io.bitsquare.trade.offer.OpenOffer; import io.bitsquare.trade.offer.OpenOffer;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
@ -72,7 +71,8 @@ public class ReservedListItem {
} }
private void updateBalance() { private void updateBalance() {
balance = TradableHelper.getReservedBalance(openOffer, walletService); Address address = walletService.getOrCreateAddressEntry(openOffer.getId(), AddressEntry.Context.RESERVED_FOR_TRADE).getAddress();
balance = walletService.getBalanceForAddress(address);
if (balance != null) if (balance != null)
balanceLabel.setText(formatter.formatCoin(this.balance)); balanceLabel.setText(formatter.formatCoin(this.balance));
} }

View file

@ -40,7 +40,6 @@ public class TransactionsListItem {
private final WalletService walletService; private final WalletService walletService;
private final ConfidenceProgressIndicator progressIndicator; private final ConfidenceProgressIndicator progressIndicator;
private final Tooltip tooltip; private final Tooltip tooltip;
private boolean isInternal;
@Nullable @Nullable
private Tradable tradable; private Tradable tradable;
private String details; private String details;
@ -89,7 +88,7 @@ public class TransactionsListItem {
} }
} }
} }
} else/* if (tradableOptional.isPresent())*/ { } else {
amountAsCoin = valueSentToMe.subtract(valueSentFromMe); amountAsCoin = valueSentToMe.subtract(valueSentFromMe);
boolean outgoing = false; boolean outgoing = false;
for (TransactionOutput transactionOutput : transaction.getOutputs()) { for (TransactionOutput transactionOutput : transaction.getOutputs()) {
@ -107,25 +106,27 @@ public class TransactionsListItem {
direction = "Sent to:"; direction = "Sent to:";
received = false; received = false;
} }
} /*else {
// savings wallet tx
for (TransactionOutput transactionOutput : transaction.getOutputs()) {
if (transactionOutput.isMine(walletService.getWallet())) {
if (transactionOutput.getScriptPubKey().isSentToAddress() ||
transactionOutput.getScriptPubKey().isPayToScriptHash()) {
address = transactionOutput.getScriptPubKey().getToAddress(walletService.getWallet().getParams());
addressString = address.toString();
amountAsCoin = transactionOutput.getValue().multiply(-1);
}
}
} }
direction = "Transferred to:"; // confidence
received = false; progressIndicator = new ConfidenceProgressIndicator();
isInternal = true; progressIndicator.setId("funds-confidence");
details = "Change output"; tooltip = new Tooltip("Not used yet");
}*/ progressIndicator.setProgress(0);
progressIndicator.setPrefHeight(30);
progressIndicator.setPrefWidth(30);
Tooltip.install(progressIndicator, tooltip);
if (address != null) {
txConfidenceListener = new TxConfidenceListener(txId) {
@Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
updateConfidence(confidence);
}
};
walletService.addTxConfidenceListener(txConfidenceListener);
updateConfidence(transaction.getConfidence());
}
if (tradableOptional.isPresent()) { if (tradableOptional.isPresent()) {
@ -148,10 +149,12 @@ public class TransactionsListItem {
trade.getPayoutTx().getHashAsString().equals(txId)) { trade.getPayoutTx().getHashAsString().equals(txId)) {
details = "MultiSig payout: " + tradable.getShortId(); details = "MultiSig payout: " + tradable.getShortId();
} else if (trade.getDisputeState() == Trade.DisputeState.DISPUTE_CLOSED) { } else if (trade.getDisputeState() == Trade.DisputeState.DISPUTE_CLOSED) {
if (valueSentToMe.isPositive()) if (valueSentToMe.isPositive()) {
details = "Dispute payout: " + tradable.getShortId(); details = "Dispute payout: " + tradable.getShortId();
else } else {
details = "Lost dispute case: " + tradable.getShortId(); details = "Lost dispute case: " + tradable.getShortId();
progressIndicator.setVisible(false);
}
} else { } else {
details = "Unknown reason: " + tradable.getShortId(); details = "Unknown reason: " + tradable.getShortId();
} }
@ -159,31 +162,11 @@ public class TransactionsListItem {
} else { } else {
if (amountAsCoin.isZero()) if (amountAsCoin.isZero())
details = "No refund from dispute"; details = "No refund from dispute";
else if (!isInternal) else
details = received ? "Received funds" : "Withdrawn from wallet"; details = received ? "Received funds" : "Withdrawn from wallet";
} }
date = formatter.formatDateTime(transaction.getUpdateTime()); date = formatter.formatDateTime(transaction.getUpdateTime());
// confidence
progressIndicator = new ConfidenceProgressIndicator();
progressIndicator.setId("funds-confidence");
tooltip = new Tooltip("Not used yet");
progressIndicator.setProgress(0);
progressIndicator.setPrefHeight(30);
progressIndicator.setPrefWidth(30);
Tooltip.install(progressIndicator, tooltip);
if (address != null) {
txConfidenceListener = new TxConfidenceListener(txId) {
@Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
updateConfidence(confidence);
}
};
walletService.addTxConfidenceListener(txConfidenceListener);
updateConfidence(transaction.getConfidence());
}
} }
@ -242,10 +225,6 @@ public class TransactionsListItem {
return direction; return direction;
} }
public boolean isInternal() {
return isInternal;
}
public String getTxId() { public String getTxId() {
return txId; return txId;
} }

View file

@ -194,38 +194,6 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
Set<Tradable> all = concat3.collect(Collectors.toSet()); Set<Tradable> all = concat3.collect(Collectors.toSet());
Set<Transaction> transactions = walletService.getWallet().getTransactions(true); Set<Transaction> transactions = walletService.getWallet().getTransactions(true);
/* List<TransactionsListItem> transactionsListItems = new ArrayList<>();
for (Transaction transaction : transactions) {
Optional<Tradable> tradableOptional = all.stream()
.filter(tradable -> {
String txId = transaction.getHashAsString();
if (tradable instanceof OpenOffer)
return tradable.getOffer().getOfferFeePaymentTxID().equals(txId);
else if (tradable instanceof Trade) {
Trade trade = (Trade) tradable;
boolean isTakeOfferFeeTx = txId.equals(trade.getTakeOfferFeeTxId());
boolean isOfferFeeTx = trade.getOffer() != null &&
txId.equals(trade.getOffer().getOfferFeePaymentTxID());
boolean isDepositTx = trade.getDepositTx() != null &&
trade.getDepositTx().getHashAsString().equals(txId);
boolean isPayoutTx = trade.getPayoutTx() != null &&
trade.getPayoutTx().getHashAsString().equals(txId);
boolean isDisputedPayoutTx = disputeManager.getDisputesAsObservableList().stream()
.filter(dispute -> txId.equals(dispute.getDisputePayoutTxId()) &&
tradable.getId().equals(dispute.getTradeId()))
.findAny()
.isPresent();
return isTakeOfferFeeTx || isOfferFeeTx || isDepositTx || isPayoutTx || isDisputedPayoutTx;
} else
return false;
})
.findAny();
// if (tradableOptional.isPresent())
transactionsListItems.add(new TransactionsListItem(transaction, walletService, tradableOptional, formatter));
}*/
List<TransactionsListItem> transactionsListItems = transactions.stream() List<TransactionsListItem> transactionsListItems = transactions.stream()
.map(transaction -> { .map(transaction -> {
Optional<Tradable> tradableOptional = all.stream() Optional<Tradable> tradableOptional = all.stream()
@ -258,12 +226,6 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
/* List<TransactionsListItem> usedSavingWalletEntries = walletService.getUsedSavingWalletTransactions()
.stream()
.map(transaction -> new TransactionsListItem(transaction, walletService, Optional.<Tradable>empty(), formatter))
.collect(Collectors.toList());
transactionsListItems.addAll(usedSavingWalletEntries);*/
// are sorted by getRecentTransactions // are sorted by getRecentTransactions
observableList.forEach(TransactionsListItem::cleanup); observableList.forEach(TransactionsListItem::cleanup);
observableList.setAll(transactionsListItems); observableList.setAll(transactionsListItems);
@ -377,7 +339,7 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
if (item != null && !empty) { if (item != null && !empty) {
String addressString = item.getAddressString(); String addressString = item.getAddressString();
field = new AddressWithIconAndDirection(item.getDirection(), addressString, field = new AddressWithIconAndDirection(item.getDirection(), addressString,
AwesomeIcon.EXTERNAL_LINK, item.getReceived(), item.isInternal()); AwesomeIcon.EXTERNAL_LINK, item.getReceived());
field.setOnAction(event -> openBlockExplorer(item)); field.setOnAction(event -> openBlockExplorer(item));
field.setTooltip(new Tooltip("Open external blockchain explorer for " + field.setTooltip(new Tooltip("Open external blockchain explorer for " +
"address: " + addressString)); "address: " + addressString));

View file

@ -21,10 +21,6 @@ import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.WalletService; import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.BalanceListener; import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.trade.TradeManager;
import io.bitsquare.trade.closed.ClosedTradableManager;
import io.bitsquare.trade.failed.FailedTradesManager;
import io.bitsquare.trade.offer.OpenOfferManager;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import org.bitcoinj.core.Address; import org.bitcoinj.core.Address;
import org.bitcoinj.core.Coin; import org.bitcoinj.core.Coin;
@ -35,25 +31,14 @@ public class WithdrawalListItem {
private final Label balanceLabel; private final Label balanceLabel;
private final AddressEntry addressEntry; private final AddressEntry addressEntry;
private final WalletService walletService; private final WalletService walletService;
private final OpenOfferManager openOfferManager;
private final TradeManager tradeManager;
private final ClosedTradableManager closedTradableManager;
private final FailedTradesManager failedTradesManager;
private final BSFormatter formatter; private final BSFormatter formatter;
private Coin balance; private Coin balance;
private final String addressString; private final String addressString;
public WithdrawalListItem(AddressEntry addressEntry, WalletService walletService, public WithdrawalListItem(AddressEntry addressEntry, WalletService walletService,
OpenOfferManager openOfferManager, TradeManager tradeManager,
ClosedTradableManager closedTradableManager,
FailedTradesManager failedTradesManager,
BSFormatter formatter) { BSFormatter formatter) {
this.addressEntry = addressEntry; this.addressEntry = addressEntry;
this.walletService = walletService; this.walletService = walletService;
this.openOfferManager = openOfferManager;
this.tradeManager = tradeManager;
this.closedTradableManager = closedTradableManager;
this.failedTradesManager = failedTradesManager;
this.formatter = formatter; this.formatter = formatter;
addressString = addressEntry.getAddressString(); addressString = addressEntry.getAddressString();
@ -99,7 +84,6 @@ public class WithdrawalListItem {
WithdrawalListItem that = (WithdrawalListItem) o; WithdrawalListItem that = (WithdrawalListItem) o;
return !(addressEntry != null ? !addressEntry.equals(that.addressEntry) : that.addressEntry != null); return !(addressEntry != null ? !addressEntry.equals(that.addressEntry) : that.addressEntry != null);
} }
@Override @Override

View file

@ -30,18 +30,14 @@ import io.bitsquare.gui.common.view.ActivatableView;
import io.bitsquare.gui.common.view.FxmlView; import io.bitsquare.gui.common.view.FxmlView;
import io.bitsquare.gui.components.HyperlinkWithIcon; import io.bitsquare.gui.components.HyperlinkWithIcon;
import io.bitsquare.gui.main.overlays.popups.Popup; import io.bitsquare.gui.main.overlays.popups.Popup;
import io.bitsquare.gui.main.overlays.windows.OfferDetailsWindow;
import io.bitsquare.gui.main.overlays.windows.TradeDetailsWindow;
import io.bitsquare.gui.main.overlays.windows.WalletPasswordWindow; import io.bitsquare.gui.main.overlays.windows.WalletPasswordWindow;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.gui.util.validation.BtcAddressValidator; import io.bitsquare.gui.util.validation.BtcAddressValidator;
import io.bitsquare.trade.Tradable; import io.bitsquare.trade.Tradable;
import io.bitsquare.trade.TradableHelper;
import io.bitsquare.trade.Trade; import io.bitsquare.trade.Trade;
import io.bitsquare.trade.TradeManager; import io.bitsquare.trade.TradeManager;
import io.bitsquare.trade.closed.ClosedTradableManager; import io.bitsquare.trade.closed.ClosedTradableManager;
import io.bitsquare.trade.failed.FailedTradesManager; import io.bitsquare.trade.failed.FailedTradesManager;
import io.bitsquare.trade.offer.OpenOfferManager;
import io.bitsquare.user.Preferences; import io.bitsquare.user.Preferences;
import javafx.beans.binding.Bindings; import javafx.beans.binding.Bindings;
import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.property.ReadOnlyObjectWrapper;
@ -80,13 +76,10 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
private final TradeManager tradeManager; private final TradeManager tradeManager;
private final ClosedTradableManager closedTradableManager; private final ClosedTradableManager closedTradableManager;
private final FailedTradesManager failedTradesManager; private final FailedTradesManager failedTradesManager;
private final OpenOfferManager openOfferManager;
private final BSFormatter formatter; private final BSFormatter formatter;
private final Preferences preferences; private final Preferences preferences;
private final BtcAddressValidator btcAddressValidator; private final BtcAddressValidator btcAddressValidator;
private final WalletPasswordWindow walletPasswordWindow; private final WalletPasswordWindow walletPasswordWindow;
private final OfferDetailsWindow offerDetailsWindow;
private final TradeDetailsWindow tradeDetailsWindow;
private final ObservableList<WithdrawalListItem> observableList = FXCollections.observableArrayList(); private final ObservableList<WithdrawalListItem> observableList = FXCollections.observableArrayList();
private final SortedList<WithdrawalListItem> sortedList = new SortedList<>(observableList); private final SortedList<WithdrawalListItem> sortedList = new SortedList<>(observableList);
private Set<WithdrawalListItem> selectedItems = new HashSet<>(); private Set<WithdrawalListItem> selectedItems = new HashSet<>();
@ -101,21 +94,17 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
@Inject @Inject
private WithdrawalView(WalletService walletService, TradeManager tradeManager, private WithdrawalView(WalletService walletService, TradeManager tradeManager,
ClosedTradableManager closedTradableManager, ClosedTradableManager closedTradableManager,
FailedTradesManager failedTradesManager, OpenOfferManager openOfferManager, FailedTradesManager failedTradesManager,
BSFormatter formatter, Preferences preferences, BSFormatter formatter, Preferences preferences,
BtcAddressValidator btcAddressValidator, WalletPasswordWindow walletPasswordWindow, BtcAddressValidator btcAddressValidator, WalletPasswordWindow walletPasswordWindow) {
OfferDetailsWindow offerDetailsWindow, TradeDetailsWindow tradeDetailsWindow) {
this.walletService = walletService; this.walletService = walletService;
this.tradeManager = tradeManager; this.tradeManager = tradeManager;
this.closedTradableManager = closedTradableManager; this.closedTradableManager = closedTradableManager;
this.failedTradesManager = failedTradesManager; this.failedTradesManager = failedTradesManager;
this.openOfferManager = openOfferManager;
this.formatter = formatter; this.formatter = formatter;
this.preferences = preferences; this.preferences = preferences;
this.btcAddressValidator = btcAddressValidator; this.btcAddressValidator = btcAddressValidator;
this.walletPasswordWindow = walletPasswordWindow; this.walletPasswordWindow = walletPasswordWindow;
this.offerDetailsWindow = offerDetailsWindow;
this.tradeDetailsWindow = tradeDetailsWindow;
} }
@Override @Override
@ -285,9 +274,8 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
private void updateList() { private void updateList() {
observableList.forEach(WithdrawalListItem::cleanup); observableList.forEach(WithdrawalListItem::cleanup);
observableList.setAll(TradableHelper.getAddressEntriesForAvailableBalanceStream(walletService) observableList.setAll(tradeManager.getAddressEntriesForAvailableBalanceStream()
.map(addressEntry -> new WithdrawalListItem(addressEntry, walletService, openOfferManager, tradeManager, .map(addressEntry -> new WithdrawalListItem(addressEntry, walletService, formatter))
closedTradableManager, failedTradesManager, formatter))
.collect(Collectors.toList())); .collect(Collectors.toList()));
} }