mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-11 08:00:32 -04:00
fixed trade process
This commit is contained in:
parent
ebf2c559db
commit
d9410f91a0
8 changed files with 745 additions and 131 deletions
|
@ -234,6 +234,8 @@ public class TakerTradeController implements Initializable, ChildController
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (trading.isOfferTradable(offer))
|
||||||
|
{
|
||||||
trade = trading.createTrade(offer);
|
trade = trading.createTrade(offer);
|
||||||
trade.setTradeAmount(BtcFormatter.stringValueToSatoshis(amountTextField.getText()));
|
trade.setTradeAmount(BtcFormatter.stringValueToSatoshis(amountTextField.getText()));
|
||||||
|
|
||||||
|
@ -330,6 +332,7 @@ public class TakerTradeController implements Initializable, ChildController
|
||||||
|
|
||||||
takerPaymentProtocol.takeOffer();
|
takerPaymentProtocol.takeOffer();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("EmptyMethod")
|
@SuppressWarnings("EmptyMethod")
|
||||||
private void updateTx(Trade trade)
|
private void updateTx(Trade trade)
|
||||||
|
|
|
@ -1,13 +1,52 @@
|
||||||
package io.bitsquare.gui.orders.pending;
|
package io.bitsquare.gui.orders.pending;
|
||||||
|
|
||||||
|
import com.google.bitcoin.core.ECKey;
|
||||||
|
import com.google.bitcoin.core.Transaction;
|
||||||
|
import com.google.bitcoin.core.Wallet;
|
||||||
|
import com.google.bitcoin.core.WalletEventListener;
|
||||||
|
import com.google.bitcoin.script.Script;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||||
|
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||||
|
import io.bitsquare.bank.BankAccount;
|
||||||
|
import io.bitsquare.bank.BankAccountType;
|
||||||
|
import io.bitsquare.btc.BtcFormatter;
|
||||||
|
import io.bitsquare.btc.FeePolicy;
|
||||||
|
import io.bitsquare.btc.WalletFacade;
|
||||||
import io.bitsquare.gui.ChildController;
|
import io.bitsquare.gui.ChildController;
|
||||||
import io.bitsquare.gui.Hibernate;
|
import io.bitsquare.gui.Hibernate;
|
||||||
import io.bitsquare.gui.NavigationController;
|
import io.bitsquare.gui.NavigationController;
|
||||||
|
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
||||||
|
import io.bitsquare.gui.util.BitSquareFormatter;
|
||||||
|
import io.bitsquare.gui.util.ConfidenceDisplay;
|
||||||
|
import io.bitsquare.gui.util.Icons;
|
||||||
|
import io.bitsquare.locale.Country;
|
||||||
|
import io.bitsquare.locale.Localisation;
|
||||||
|
import io.bitsquare.trade.Direction;
|
||||||
|
import io.bitsquare.trade.Offer;
|
||||||
|
import io.bitsquare.trade.Trade;
|
||||||
|
import io.bitsquare.trade.Trading;
|
||||||
|
import java.math.BigInteger;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ResourceBundle;
|
import java.util.*;
|
||||||
|
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ListChangeListener;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.control.*;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.input.Clipboard;
|
||||||
|
import javafx.scene.input.ClipboardContent;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.util.Callback;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -15,14 +54,40 @@ public class PendingTradeController implements Initializable, ChildController, H
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(PendingTradeController.class);
|
private static final Logger log = LoggerFactory.getLogger(PendingTradeController.class);
|
||||||
|
|
||||||
|
private Trading trading;
|
||||||
|
private WalletFacade walletFacade;
|
||||||
|
private Trade currentTrade;
|
||||||
|
private NavigationController navigationController;
|
||||||
|
private Image buyIcon = Icons.getIconImage(Icons.BUY);
|
||||||
|
private Image sellIcon = Icons.getIconImage(Icons.SELL);
|
||||||
|
private ConfidenceDisplay confidenceDisplay;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private VBox rootContainer;
|
||||||
|
@FXML
|
||||||
|
private TableView openTradesTable;
|
||||||
|
@FXML
|
||||||
|
private TableColumn<String, PendingTradesListItem> directionColumn, countryColumn, bankAccountTypeColumn, priceColumn, amountColumn, volumeColumn, statusColumn, selectColumn;
|
||||||
|
@FXML
|
||||||
|
private ConfidenceProgressIndicator progressIndicator;
|
||||||
|
@FXML
|
||||||
|
private Label txTitleLabel, txHeaderLabel, confirmationLabel, txIDCopyIcon, holderNameCopyIcon, primaryBankAccountIDCopyIcon, secondaryBankAccountIDCopyIcon, bankAccountDetailsHeaderLabel,
|
||||||
|
bankAccountTypeTitleLabel, holderNameTitleLabel, primaryBankAccountIDTitleLabel, secondaryBankAccountIDTitleLabel;
|
||||||
|
@FXML
|
||||||
|
private TextField txTextField, bankAccountTypeTextField, holderNameTextField, primaryBankAccountIDTextField, secondaryBankAccountIDTextField;
|
||||||
|
@FXML
|
||||||
|
private Button bankTransferInitedButton;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PendingTradeController()
|
public PendingTradeController(Trading trading, WalletFacade walletFacade)
|
||||||
{
|
{
|
||||||
|
this.trading = trading;
|
||||||
|
this.walletFacade = walletFacade;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,6 +98,7 @@ public class PendingTradeController implements Initializable, ChildController, H
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL url, ResourceBundle rb)
|
public void initialize(URL url, ResourceBundle rb)
|
||||||
{
|
{
|
||||||
|
awake();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,18 +107,15 @@ public class PendingTradeController implements Initializable, ChildController, H
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNavigationController(@NotNull NavigationController navigationController)
|
public void setNavigationController(NavigationController navigationController)
|
||||||
{
|
{
|
||||||
log.debug("setNavigationController" + this);
|
this.navigationController = navigationController;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanup()
|
public void cleanup()
|
||||||
{
|
{
|
||||||
log.debug("cleanup" + this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Interface implementation: Hibernate
|
// Interface implementation: Hibernate
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -65,19 +128,426 @@ public class PendingTradeController implements Initializable, ChildController, H
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void awake()
|
public void awake()
|
||||||
|
{
|
||||||
|
Map<String, Trade> trades = trading.getTrades();
|
||||||
|
List<Trade> tradeList = new ArrayList<>(trades.values());
|
||||||
|
ObservableList<PendingTradesListItem> tradeItems = FXCollections.observableArrayList();
|
||||||
|
for (Iterator<Trade> iterator = tradeList.iterator(); iterator.hasNext(); )
|
||||||
|
{
|
||||||
|
Trade trade = iterator.next();
|
||||||
|
tradeItems.add(new PendingTradesListItem(trade));
|
||||||
|
}
|
||||||
|
|
||||||
|
setCountryColumnCellFactory();
|
||||||
|
setBankAccountTypeColumnCellFactory();
|
||||||
|
setDirectionColumnCellFactory();
|
||||||
|
setSelectColumnCellFactory();
|
||||||
|
|
||||||
|
openTradesTable.setItems(tradeItems);
|
||||||
|
openTradesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||||
|
|
||||||
|
openTradesTable.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
|
||||||
|
if (newValue instanceof PendingTradesListItem)
|
||||||
|
{
|
||||||
|
showTradeDetails((PendingTradesListItem) newValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
trading.getNewTradeProperty().addListener(new ChangeListener<String>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends String> observableValue, String oldTradeUid, String newTradeUid)
|
||||||
|
{
|
||||||
|
Trade newTrade = trading.getTrades().get(newTradeUid);
|
||||||
|
tradeItems.add(new PendingTradesListItem(newTrade));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
initCopyIcons();
|
||||||
|
|
||||||
|
if (tradeItems.size() > 0)
|
||||||
|
{
|
||||||
|
openTradesTable.getSelectionModel().select(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
tradeItems.addListener(new ListChangeListener<PendingTradesListItem>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onChanged(Change<? extends PendingTradesListItem> change)
|
||||||
|
{
|
||||||
|
if (openTradesTable.getSelectionModel().getSelectedItem() == null && tradeItems.size() > 0)
|
||||||
|
{
|
||||||
|
openTradesTable.getSelectionModel().select(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// GUI handlers
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public void bankTransferInited(ActionEvent actionEvent)
|
||||||
|
{
|
||||||
|
trading.onBankTransferInited(currentTrade.getId());
|
||||||
|
bankTransferInitedButton.setDisable(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close(ActionEvent actionEvent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// GUI Event handlers
|
// Private methods
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
private void showTradeDetails(PendingTradesListItem tradesTableItem)
|
||||||
|
{
|
||||||
|
fillData(tradesTableItem.getTrade());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTx(Transaction transaction)
|
||||||
|
{
|
||||||
|
txTextField.setText(transaction.getHashAsString());
|
||||||
|
|
||||||
|
confidenceDisplay = new ConfidenceDisplay(walletFacade.getWallet(), confirmationLabel, transaction, progressIndicator);
|
||||||
|
|
||||||
|
int depthInBlocks = transaction.getConfidence().getDepthInBlocks();
|
||||||
|
bankTransferInitedButton.setDisable(depthInBlocks == 0);
|
||||||
|
|
||||||
|
walletFacade.getWallet().addEventListener(new WalletEventListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx)
|
||||||
|
{
|
||||||
|
int depthInBlocks = tx.getConfidence().getDepthInBlocks();
|
||||||
|
bankTransferInitedButton.setDisable(depthInBlocks == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCoinsReceived(Wallet wallet, Transaction tx, BigInteger prevBalance, BigInteger newBalance)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCoinsSent(Wallet wallet, Transaction tx, BigInteger prevBalance, BigInteger newBalance)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReorganize(Wallet wallet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onWalletChanged(Wallet wallet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onKeysAdded(Wallet wallet, List<ECKey> keys)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onScriptsAdded(Wallet wallet, List<Script> scripts)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillData(Trade trade)
|
||||||
|
{
|
||||||
|
currentTrade = trade;
|
||||||
|
Transaction transaction = trade.getDepositTransaction();
|
||||||
|
if (transaction == null)
|
||||||
|
{
|
||||||
|
trade.getDepositTxChangedProperty().addListener(new ChangeListener<Boolean>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean aBoolean2)
|
||||||
|
{
|
||||||
|
updateTx(trade.getDepositTransaction());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
updateTx(trade.getDepositTransaction());
|
||||||
|
}
|
||||||
|
|
||||||
|
// back details
|
||||||
|
if (trade.getContract() != null)
|
||||||
|
{
|
||||||
|
setBankData(trade);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
trade.getContractChangedProperty().addListener(new ChangeListener<Boolean>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean aBoolean2)
|
||||||
|
{
|
||||||
|
setBankData(trade);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// state
|
||||||
|
trade.getStateChangedProperty().addListener(new ChangeListener<String>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends String> observableValue, String aString, String aString2)
|
||||||
|
{
|
||||||
|
setState(trade);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setState(Trade trade)
|
||||||
|
{
|
||||||
|
if (trade.getState() == Trade.State.COMPLETED)
|
||||||
|
{
|
||||||
|
Transaction transaction = trade.getPayoutTransaction();
|
||||||
|
|
||||||
|
confidenceDisplay.destroy();
|
||||||
|
confidenceDisplay = new ConfidenceDisplay(walletFacade.getWallet(), confirmationLabel, transaction, progressIndicator);
|
||||||
|
|
||||||
|
txTextField.setText(transaction.getHashAsString());
|
||||||
|
|
||||||
|
txHeaderLabel.setText("Payout transaction");
|
||||||
|
txTitleLabel.setText("Payout transaction ID:");
|
||||||
|
|
||||||
|
bankAccountDetailsHeaderLabel.setText("Summary");
|
||||||
|
bankAccountTypeTitleLabel.setText("You have bought (BTC):");
|
||||||
|
holderNameTitleLabel.setText("You have payed (" + trade.getOffer().getCurrency() + "):");
|
||||||
|
primaryBankAccountIDTitleLabel.setText("Total fees (offer fee + tx fee):");
|
||||||
|
secondaryBankAccountIDTitleLabel.setText("Refunded collateral:");
|
||||||
|
|
||||||
|
String fiatPayed = BitSquareFormatter.formatVolume(trade.getOffer().getPrice() * BtcFormatter.satoshiToBTC(trade.getTradeAmount()));
|
||||||
|
|
||||||
|
bankAccountTypeTextField.setText(BtcFormatter.satoshiToString(trade.getTradeAmount()));
|
||||||
|
holderNameTextField.setText(fiatPayed);
|
||||||
|
primaryBankAccountIDTextField.setText(BtcFormatter.satoshiToString(FeePolicy.CREATE_OFFER_FEE.add(FeePolicy.TX_FEE)));
|
||||||
|
secondaryBankAccountIDTextField.setText(BtcFormatter.satoshiToString(trade.getCollateralAmount()));
|
||||||
|
|
||||||
|
holderNameCopyIcon.setVisible(false);
|
||||||
|
primaryBankAccountIDCopyIcon.setVisible(false);
|
||||||
|
secondaryBankAccountIDCopyIcon.setVisible(false);
|
||||||
|
|
||||||
|
bankTransferInitedButton.setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setBankData(Trade trade)
|
||||||
|
{
|
||||||
|
BankAccount bankAccount = trade.getContract().getTakerBankAccount();
|
||||||
|
bankAccountTypeTextField.setText(bankAccount.getBankAccountType().toString());
|
||||||
|
holderNameTextField.setText(bankAccount.getAccountHolderName());
|
||||||
|
primaryBankAccountIDTextField.setText(bankAccount.getAccountPrimaryID());
|
||||||
|
secondaryBankAccountIDTextField.setText(bankAccount.getAccountSecondaryID());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initCopyIcons()
|
||||||
|
{
|
||||||
|
AwesomeDude.setIcon(txIDCopyIcon, AwesomeIcon.COPY);
|
||||||
|
txIDCopyIcon.setOnMouseClicked(e -> {
|
||||||
|
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||||
|
ClipboardContent content = new ClipboardContent();
|
||||||
|
content.putString(txTextField.getText());
|
||||||
|
clipboard.setContent(content);
|
||||||
|
});
|
||||||
|
|
||||||
|
AwesomeDude.setIcon(holderNameCopyIcon, AwesomeIcon.COPY);
|
||||||
|
holderNameCopyIcon.setOnMouseClicked(e -> {
|
||||||
|
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||||
|
ClipboardContent content = new ClipboardContent();
|
||||||
|
content.putString(holderNameTextField.getText());
|
||||||
|
clipboard.setContent(content);
|
||||||
|
});
|
||||||
|
|
||||||
|
AwesomeDude.setIcon(primaryBankAccountIDCopyIcon, AwesomeIcon.COPY);
|
||||||
|
primaryBankAccountIDCopyIcon.setOnMouseClicked(e -> {
|
||||||
|
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||||
|
ClipboardContent content = new ClipboardContent();
|
||||||
|
content.putString(primaryBankAccountIDTextField.getText());
|
||||||
|
clipboard.setContent(content);
|
||||||
|
});
|
||||||
|
|
||||||
|
AwesomeDude.setIcon(secondaryBankAccountIDCopyIcon, AwesomeIcon.COPY);
|
||||||
|
secondaryBankAccountIDCopyIcon.setOnMouseClicked(e -> {
|
||||||
|
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||||
|
ClipboardContent content = new ClipboardContent();
|
||||||
|
content.putString(secondaryBankAccountIDTextField.getText());
|
||||||
|
clipboard.setContent(content);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Private Methods
|
// Table columns
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
private void setCountryColumnCellFactory()
|
||||||
|
{
|
||||||
|
countryColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue()));
|
||||||
|
countryColumn.setCellFactory(new Callback<TableColumn<String, PendingTradesListItem>, TableCell<String, PendingTradesListItem>>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public TableCell<String, PendingTradesListItem> call(TableColumn<String, PendingTradesListItem> directionColumn)
|
||||||
|
{
|
||||||
|
return new TableCell<String, PendingTradesListItem>()
|
||||||
|
{
|
||||||
|
final HBox hBox = new HBox();
|
||||||
|
|
||||||
|
{
|
||||||
|
hBox.setSpacing(3);
|
||||||
|
hBox.setAlignment(Pos.CENTER);
|
||||||
|
setGraphic(hBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateItem(final PendingTradesListItem tradesTableItem, boolean empty)
|
||||||
|
{
|
||||||
|
super.updateItem(tradesTableItem, empty);
|
||||||
|
|
||||||
|
hBox.getChildren().clear();
|
||||||
|
if (tradesTableItem != null)
|
||||||
|
{
|
||||||
|
Country country = tradesTableItem.getTrade().getOffer().getBankAccountCountry();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
hBox.getChildren().add(Icons.getIconImageView("/images/countries/" + country.getCode().toLowerCase() + ".png"));
|
||||||
|
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
log.warn("Country icon not found: " + "/images/countries/" + country.getCode().toLowerCase() + ".png country name: " + country.getName());
|
||||||
|
}
|
||||||
|
Tooltip.install(this, new Tooltip(country.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setBankAccountTypeColumnCellFactory()
|
||||||
|
{
|
||||||
|
bankAccountTypeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue()));
|
||||||
|
bankAccountTypeColumn.setCellFactory(new Callback<TableColumn<String, PendingTradesListItem>, TableCell<String, PendingTradesListItem>>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public TableCell<String, PendingTradesListItem> call(TableColumn<String, PendingTradesListItem> directionColumn)
|
||||||
|
{
|
||||||
|
return new TableCell<String, PendingTradesListItem>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void updateItem(final PendingTradesListItem tradesTableItem, boolean empty)
|
||||||
|
{
|
||||||
|
super.updateItem(tradesTableItem, empty);
|
||||||
|
|
||||||
|
if (tradesTableItem != null)
|
||||||
|
{
|
||||||
|
BankAccountType bankAccountType = tradesTableItem.getTrade().getOffer().getBankAccountType();
|
||||||
|
setText(Localisation.get(bankAccountType.toString()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDirectionColumnCellFactory()
|
||||||
|
{
|
||||||
|
directionColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue()));
|
||||||
|
directionColumn.setCellFactory(new Callback<TableColumn<String, PendingTradesListItem>, TableCell<String, PendingTradesListItem>>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public TableCell<String, PendingTradesListItem> call(TableColumn<String, PendingTradesListItem> directionColumn)
|
||||||
|
{
|
||||||
|
return new TableCell<String, PendingTradesListItem>()
|
||||||
|
{
|
||||||
|
final ImageView iconView = new ImageView();
|
||||||
|
final Button button = new Button();
|
||||||
|
|
||||||
|
{
|
||||||
|
button.setGraphic(iconView);
|
||||||
|
button.setMinWidth(70);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateItem(final PendingTradesListItem tradesTableItem, boolean empty)
|
||||||
|
{
|
||||||
|
super.updateItem(tradesTableItem, empty);
|
||||||
|
|
||||||
|
if (tradesTableItem != null)
|
||||||
|
{
|
||||||
|
String title;
|
||||||
|
Image icon;
|
||||||
|
Offer offer = tradesTableItem.getTrade().getOffer();
|
||||||
|
|
||||||
|
if (offer.getDirection() == Direction.SELL)
|
||||||
|
{
|
||||||
|
icon = buyIcon;
|
||||||
|
title = BitSquareFormatter.formatDirection(Direction.BUY, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
icon = sellIcon;
|
||||||
|
title = BitSquareFormatter.formatDirection(Direction.SELL, true);
|
||||||
|
}
|
||||||
|
button.setDisable(true);
|
||||||
|
iconView.setImage(icon);
|
||||||
|
button.setText(title);
|
||||||
|
setGraphic(button);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setGraphic(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSelectColumnCellFactory()
|
||||||
|
{
|
||||||
|
selectColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue()));
|
||||||
|
selectColumn.setCellFactory(new Callback<TableColumn<String, PendingTradesListItem>, TableCell<String, PendingTradesListItem>>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public TableCell<String, PendingTradesListItem> call(TableColumn<String, PendingTradesListItem> directionColumn)
|
||||||
|
{
|
||||||
|
return new TableCell<String, PendingTradesListItem>()
|
||||||
|
{
|
||||||
|
final Button button = new Button("Select");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateItem(final PendingTradesListItem tradesTableItem, boolean empty)
|
||||||
|
{
|
||||||
|
super.updateItem(tradesTableItem, empty);
|
||||||
|
|
||||||
|
if (tradesTableItem != null)
|
||||||
|
{
|
||||||
|
button.setOnAction(event -> showTradeDetails(tradesTableItem));
|
||||||
|
setGraphic(button);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setGraphic(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,146 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.scene.control.Label?>
|
<?import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator?>
|
||||||
|
<?import javafx.geometry.*?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.control.cell.PropertyValueFactory?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.orders.pending.PendingTradeController" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
|
<VBox fx:id="rootContainer" fx:controller="io.bitsquare.gui.orders.pending.PendingTradeController" spacing="10" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0"
|
||||||
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
|
AnchorPane.topAnchor="0" xmlns="http://javafx.com/javafx/8"
|
||||||
xmlns="http://javafx.com/javafx/8">
|
xmlns:fx="http://javafx.com/fxml/1">
|
||||||
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<TableView id="orderbook-table" fx:id="openTradesTable" prefHeight="150.0">
|
||||||
|
<columns>
|
||||||
|
<TableColumn fx:id="amountColumn" minWidth="120" text="Amount (Min.)">
|
||||||
|
<cellValueFactory>
|
||||||
|
<PropertyValueFactory property="amount"/>
|
||||||
|
</cellValueFactory>
|
||||||
|
</TableColumn>
|
||||||
|
<TableColumn fx:id="priceColumn" minWidth="70" text="Price">
|
||||||
|
<cellValueFactory>
|
||||||
|
<PropertyValueFactory property="price"/>
|
||||||
|
</cellValueFactory>
|
||||||
|
</TableColumn>
|
||||||
|
<TableColumn fx:id="volumeColumn" minWidth="130" text="Volume (Min.)">
|
||||||
|
<cellValueFactory>
|
||||||
|
<PropertyValueFactory property="volume"/>
|
||||||
|
</cellValueFactory>
|
||||||
|
</TableColumn>
|
||||||
|
<TableColumn fx:id="countryColumn" minWidth="60" text="Country"/>
|
||||||
|
<TableColumn fx:id="bankAccountTypeColumn" minWidth="140" text="Bank transfer type"/>
|
||||||
|
<TableColumn fx:id="directionColumn" minWidth="80" sortable="false" text="Offer type"/>
|
||||||
|
<TableColumn fx:id="statusColumn" minWidth="80" text="Status">
|
||||||
|
<cellValueFactory>
|
||||||
|
<PropertyValueFactory property="status"/>
|
||||||
|
</cellValueFactory>
|
||||||
|
</TableColumn>
|
||||||
|
|
||||||
<Label id="headline-label" text="Pending"/>
|
<TableColumn fx:id="selectColumn" minWidth="60" sortable="false" text=""/>
|
||||||
|
</columns>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets left="10.0" right="10.0"/>
|
||||||
|
</VBox.margin>
|
||||||
|
</TableView>
|
||||||
|
|
||||||
</VBox>
|
|
||||||
</AnchorPane>
|
<Label text="After you received 1 blockchain confirmation you are safe to start the bank transfer.">
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="10.0" left="10.0" top="10.0"/>
|
||||||
|
</VBox.margin>
|
||||||
|
</Label>
|
||||||
|
|
||||||
|
<GridPane hgap="5.0" vgap="5.0">
|
||||||
|
|
||||||
|
<!-- row 0 -->
|
||||||
|
<Label fx:id="txHeaderLabel" id="headline-label" text="Deposit transaction" GridPane.columnSpan="2" GridPane.halignment="LEFT"/>
|
||||||
|
|
||||||
|
<!-- row 1 -->
|
||||||
|
<Label fx:id="txTitleLabel" text="Deposit transaction ID:" GridPane.rowIndex="1"/>
|
||||||
|
<TextField fx:id="txTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||||
|
<Label fx:id="txIDCopyIcon" id="copy-icon" minWidth="10" GridPane.columnIndex="2" GridPane.rowIndex="1">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="0.0" left="0.0" right="0.0" top="-1.0"/>
|
||||||
|
</padding>
|
||||||
|
<tooltip>
|
||||||
|
<Tooltip text="Copy address to clipboard"/>
|
||||||
|
</tooltip>
|
||||||
|
</Label>
|
||||||
|
<ConfidenceProgressIndicator fx:id="progressIndicator" visible="false" progress="0" GridPane.columnIndex="3" GridPane.halignment="LEFT" GridPane.rowIndex="1"
|
||||||
|
GridPane.rowSpan="2" GridPane.valignment="TOP">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets top="2.0"/>
|
||||||
|
</GridPane.margin>
|
||||||
|
</ConfidenceProgressIndicator>
|
||||||
|
<Label fx:id="confirmationLabel" visible="false" GridPane.columnIndex="4" GridPane.rowIndex="1"/>
|
||||||
|
|
||||||
|
<!-- row 2 -->
|
||||||
|
<Label fx:id="bankAccountDetailsHeaderLabel" id="headline-label" text="Bank details" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.halignment="LEFT"
|
||||||
|
GridPane.rowIndex="2"/>
|
||||||
|
|
||||||
|
<!-- row 3 -->
|
||||||
|
<Label fx:id="bankAccountTypeTitleLabel" text="Bank account type:" GridPane.columnIndex="0" GridPane.rowIndex="3"/>
|
||||||
|
<TextField fx:id="bankAccountTypeTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||||
|
|
||||||
|
<!-- row 4 -->
|
||||||
|
<Label fx:id="holderNameTitleLabel" text="Holder name:" GridPane.columnIndex="0" GridPane.rowIndex="4"/>
|
||||||
|
<TextField fx:id="holderNameTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="4"/>
|
||||||
|
<Label fx:id="holderNameCopyIcon" id="copy-icon" minWidth="10" GridPane.columnIndex="2" GridPane.rowIndex="4">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="0.0" left="0.0" right="0.0" top="-1.0"/>
|
||||||
|
</padding>
|
||||||
|
<tooltip>
|
||||||
|
<Tooltip text="Copy address to clipboard"/>
|
||||||
|
</tooltip>
|
||||||
|
</Label>
|
||||||
|
|
||||||
|
<!-- row 5 -->
|
||||||
|
<Label fx:id="primaryBankAccountIDTitleLabel" text="Primary bank account ID:" GridPane.columnIndex="0" GridPane.rowIndex="5"/>
|
||||||
|
<TextField fx:id="primaryBankAccountIDTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
|
||||||
|
<Label fx:id="primaryBankAccountIDCopyIcon" id="copy-icon" minWidth="10" GridPane.columnIndex="2" GridPane.rowIndex="5">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="0.0" left="0.0" right="0.0" top="-1.0"/>
|
||||||
|
</padding>
|
||||||
|
<tooltip>
|
||||||
|
<Tooltip text="Copy address to clipboard"/>
|
||||||
|
</tooltip>
|
||||||
|
</Label>
|
||||||
|
|
||||||
|
<!-- row 6 -->
|
||||||
|
<Label fx:id="secondaryBankAccountIDTitleLabel" text="Secondary bank account ID:" GridPane.columnIndex="0" GridPane.rowIndex="6"/>
|
||||||
|
<TextField fx:id="secondaryBankAccountIDTextField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="6"/>
|
||||||
|
<Label fx:id="secondaryBankAccountIDCopyIcon" id="copy-icon" minWidth="10" GridPane.columnIndex="2" GridPane.rowIndex="6">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="0.0" left="0.0" right="0.0" top="-1.0"/>
|
||||||
|
</padding>
|
||||||
|
<tooltip>
|
||||||
|
<Tooltip text="Copy address to clipboard"/>
|
||||||
|
</tooltip>
|
||||||
|
</Label>
|
||||||
|
|
||||||
|
<!-- row 7 -->
|
||||||
|
<Button fx:id="bankTransferInitedButton" defaultButton="true" onAction="#bankTransferInited" disable="true" text="Bank transfer inited"
|
||||||
|
GridPane.columnIndex="1"
|
||||||
|
GridPane.rowIndex="7"/>
|
||||||
|
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES"/>
|
||||||
|
<ColumnConstraints hgrow="ALWAYS"/>
|
||||||
|
<ColumnConstraints fillWidth="false" hgrow="SOMETIMES" minWidth="20"/>
|
||||||
|
<ColumnConstraints fillWidth="false" hgrow="SOMETIMES" minWidth="20" prefWidth="20"/>
|
||||||
|
<ColumnConstraints fillWidth="false" hgrow="SOMETIMES"/>
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
|
||||||
|
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
|
||||||
|
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
|
||||||
|
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
|
||||||
|
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
|
||||||
|
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
|
||||||
|
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
|
||||||
|
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
|
||||||
|
<RowConstraints/>
|
||||||
|
</rowConstraints>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets left="10.0" right="10.0"/>
|
||||||
|
</VBox.margin>
|
||||||
|
</GridPane>
|
||||||
|
</VBox>
|
||||||
|
|
|
@ -6,17 +6,16 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
class TradesTableItem extends OrderBookListItem
|
public class PendingTradesListItem extends OrderBookListItem
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(TradesTableItem.class);
|
private static final Logger log = LoggerFactory.getLogger(PendingTradesListItem.class);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final Trade trade;
|
private final Trade trade;
|
||||||
|
|
||||||
private TradesTableItem(@NotNull Trade trade)
|
public PendingTradesListItem(@NotNull Trade trade)
|
||||||
{
|
{
|
||||||
super(trade.getOffer());
|
super(trade.getOffer());
|
||||||
|
|
||||||
this.trade = trade;
|
this.trade = trade;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,6 @@ public class MessageFacade
|
||||||
private static final Logger log = LoggerFactory.getLogger(MessageFacade.class);
|
private static final Logger log = LoggerFactory.getLogger(MessageFacade.class);
|
||||||
private static final int MASTER_PEER_PORT = 5000;
|
private static final int MASTER_PEER_PORT = 5000;
|
||||||
@NotNull
|
@NotNull
|
||||||
private static String MASTER_PEER_IP = "192.168.1.33";
|
|
||||||
private final List<OrderBookListener> orderBookListeners = new ArrayList<>();
|
private final List<OrderBookListener> orderBookListeners = new ArrayList<>();
|
||||||
private final List<TakeOfferRequestListener> takeOfferRequestListeners = new ArrayList<>();
|
private final List<TakeOfferRequestListener> takeOfferRequestListeners = new ArrayList<>();
|
||||||
private final List<ArbitratorListener> arbitratorListeners = new ArrayList<>();
|
private final List<ArbitratorListener> arbitratorListeners = new ArrayList<>();
|
||||||
|
@ -57,7 +56,6 @@ public class MessageFacade
|
||||||
private Peer myPeer;
|
private Peer myPeer;
|
||||||
@Nullable
|
@Nullable
|
||||||
private KeyPair keyPair;
|
private KeyPair keyPair;
|
||||||
private Peer masterPeer;
|
|
||||||
private Long lastTimeStamp = -3L;
|
private Long lastTimeStamp = -3L;
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,9 +84,9 @@ public class MessageFacade
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
int port = Bindings.MAX_PORT - Math.abs(new Random().nextInt()) % (Bindings.MAX_PORT - Bindings.MIN_DYN_PORT);
|
int port = Bindings.MAX_PORT - Math.abs(new Random().nextInt()) % (Bindings.MAX_PORT - Bindings.MIN_DYN_PORT);
|
||||||
if ("taker".equals(BitSquare.ID))
|
if (BitSquare.ID.contains("taker"))
|
||||||
port = 4501;
|
port = 4501;
|
||||||
else if ("offerer".equals(BitSquare.ID))
|
else if (BitSquare.ID.contains("offerer"))
|
||||||
port = 4500;
|
port = 4500;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -109,9 +107,6 @@ public class MessageFacade
|
||||||
{
|
{
|
||||||
if (myPeer != null)
|
if (myPeer != null)
|
||||||
myPeer.shutdown();
|
myPeer.shutdown();
|
||||||
|
|
||||||
if (masterPeer != null)
|
|
||||||
masterPeer.shutdown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -272,13 +267,13 @@ public class MessageFacade
|
||||||
@Override
|
@Override
|
||||||
public void operationComplete(@NotNull BaseFuture future) throws Exception
|
public void operationComplete(@NotNull BaseFuture future) throws Exception
|
||||||
{
|
{
|
||||||
Data data = removeFuture.getData();
|
@NotNull Data data = removeFuture.getData();
|
||||||
Platform.runLater(() -> onOfferRemoved(data, future.isSuccess(), locationKey));
|
Platform.runLater(() -> onOfferRemoved(data, future.isSuccess(), locationKey));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onOfferRemoved(Data data, boolean success, @NotNull Number160 locationKey)
|
private void onOfferRemoved(@NotNull Data data, boolean success, @NotNull Number160 locationKey)
|
||||||
{
|
{
|
||||||
log.debug("onOfferRemoved");
|
log.debug("onOfferRemoved");
|
||||||
setDirty(locationKey);
|
setDirty(locationKey);
|
||||||
|
@ -595,7 +590,7 @@ public class MessageFacade
|
||||||
if (sendFuture.isSuccess())
|
if (sendFuture.isSuccess())
|
||||||
{
|
{
|
||||||
@NotNull final String pong = (String) sendFuture.getObject();
|
@NotNull final String pong = (String) sendFuture.getObject();
|
||||||
Platform.runLater(() -> onResponseFromPing(pong.equals(PONG)));
|
Platform.runLater(() -> onResponseFromPing(PONG.equals(pong)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -703,7 +698,7 @@ public class MessageFacade
|
||||||
keyPair = DSAKeyUtil.getKeyPair();
|
keyPair = DSAKeyUtil.getKeyPair();
|
||||||
myPeer = new PeerMaker(keyPair).setPorts(port).makeAndListen();
|
myPeer = new PeerMaker(keyPair).setPorts(port).makeAndListen();
|
||||||
final FutureBootstrap futureBootstrap = myPeer.bootstrap().setBroadcast().setPorts(MASTER_PEER_PORT).start();
|
final FutureBootstrap futureBootstrap = myPeer.bootstrap().setBroadcast().setPorts(MASTER_PEER_PORT).start();
|
||||||
// futureBootstrap.awaitUninterruptibly();
|
futureBootstrap.awaitUninterruptibly();
|
||||||
futureBootstrap.addListener(new BaseFutureAdapter<BaseFuture>()
|
futureBootstrap.addListener(new BaseFutureAdapter<BaseFuture>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -713,7 +708,7 @@ public class MessageFacade
|
||||||
{
|
{
|
||||||
PeerAddress masterPeerAddress = futureBootstrap.getBootstrapTo().iterator().next();
|
PeerAddress masterPeerAddress = futureBootstrap.getBootstrapTo().iterator().next();
|
||||||
final FutureDiscover futureDiscover = myPeer.discover().setPeerAddress(masterPeerAddress).start();
|
final FutureDiscover futureDiscover = myPeer.discover().setPeerAddress(masterPeerAddress).start();
|
||||||
//futureDiscover.awaitUninterruptibly();
|
futureDiscover.awaitUninterruptibly();
|
||||||
futureDiscover.addListener(new BaseFutureListener<BaseFuture>()
|
futureDiscover.addListener(new BaseFutureListener<BaseFuture>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -752,22 +747,27 @@ public class MessageFacade
|
||||||
|
|
||||||
private void setupReplyHandler()
|
private void setupReplyHandler()
|
||||||
{
|
{
|
||||||
myPeer.setObjectDataReply((sender, request) -> {
|
/* myPeer.setObjectDataReply((sender, request) -> {
|
||||||
if (!sender.equals(myPeer.getPeerAddress()))
|
if (!sender.equals(myPeer.getPeerAddress()))
|
||||||
{
|
{
|
||||||
Platform.runLater(() -> onMessage(request, sender));
|
Platform.runLater(() -> onMessage(request, sender));
|
||||||
}
|
}
|
||||||
//noinspection ReturnOfNull
|
//noinspection ReturnOfNull
|
||||||
return null;
|
return null;
|
||||||
});
|
}); */
|
||||||
|
|
||||||
//noinspection Convert2Lambda
|
//noinspection Convert2Lambda
|
||||||
myPeer.setObjectDataReply(new ObjectDataReply()
|
myPeer.setObjectDataReply(new ObjectDataReply()
|
||||||
{
|
{
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Object reply(PeerAddress peerAddress, Object o) throws Exception
|
public Object reply(PeerAddress sender, Object request) throws Exception
|
||||||
{
|
{
|
||||||
|
if (!sender.equals(myPeer.getPeerAddress()))
|
||||||
|
{
|
||||||
|
Platform.runLater(() -> onMessage(request, sender));
|
||||||
|
}
|
||||||
|
//noinspection ReturnOfNull
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.google.inject.Inject;
|
||||||
import io.bitsquare.btc.BlockChainFacade;
|
import io.bitsquare.btc.BlockChainFacade;
|
||||||
import io.bitsquare.btc.WalletFacade;
|
import io.bitsquare.btc.WalletFacade;
|
||||||
import io.bitsquare.crypto.CryptoFacade;
|
import io.bitsquare.crypto.CryptoFacade;
|
||||||
|
import io.bitsquare.gui.popups.Popups;
|
||||||
import io.bitsquare.msg.MessageFacade;
|
import io.bitsquare.msg.MessageFacade;
|
||||||
import io.bitsquare.msg.TradeMessage;
|
import io.bitsquare.msg.TradeMessage;
|
||||||
import io.bitsquare.storage.Storage;
|
import io.bitsquare.storage.Storage;
|
||||||
|
@ -114,12 +115,14 @@ public class Trading
|
||||||
messageFacade.removeOffer(offer);
|
messageFacade.removeOffer(offer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOfferTradable(@NotNull Offer offer)
|
||||||
|
{
|
||||||
|
return !trades.containsKey(offer.getId());
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Trade createTrade(@NotNull Offer offer)
|
public Trade createTrade(@NotNull Offer offer)
|
||||||
{
|
{
|
||||||
if (trades.containsKey(offer.getId()))
|
|
||||||
throw new IllegalStateException("trades contains already a trade with the ID " + offer.getId());
|
|
||||||
|
|
||||||
@NotNull Trade trade = new Trade(offer);
|
@NotNull Trade trade = new Trade(offer);
|
||||||
trades.put(offer.getId(), trade);
|
trades.put(offer.getId(), trade);
|
||||||
//TODO for testing
|
//TODO for testing
|
||||||
|
@ -161,6 +164,8 @@ public class Trading
|
||||||
public void createOffererPaymentProtocol(@NotNull TradeMessage tradeMessage, PeerAddress sender)
|
public void createOffererPaymentProtocol(@NotNull TradeMessage tradeMessage, PeerAddress sender)
|
||||||
{
|
{
|
||||||
Offer offer = myOffers.get(tradeMessage.getOfferUID());
|
Offer offer = myOffers.get(tradeMessage.getOfferUID());
|
||||||
|
if (isOfferTradable(offer))
|
||||||
|
{
|
||||||
@NotNull Trade trade = createTrade(offer);
|
@NotNull Trade trade = createTrade(offer);
|
||||||
@NotNull OffererPaymentProtocol offererPaymentProtocol = addOffererPaymentProtocol(trade, new OffererPaymentProtocolListener()
|
@NotNull OffererPaymentProtocol offererPaymentProtocol = addOffererPaymentProtocol(trade, new OffererPaymentProtocolListener()
|
||||||
{
|
{
|
||||||
|
@ -209,6 +214,11 @@ public class Trading
|
||||||
// will probably created earlier, so let it for the moment like that....
|
// will probably created earlier, so let it for the moment like that....
|
||||||
offererPaymentProtocol.onTakeOfferRequested(sender);
|
offererPaymentProtocol.onTakeOfferRequested(sender);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Popups.openWarningPopup("Offer already taken", "You have that offer already taken. Find that trade under Orders/Open or Pending.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void onBankTransferInited(String tradeUID)
|
public void onBankTransferInited(String tradeUID)
|
||||||
|
|
|
@ -86,7 +86,6 @@ public class OrderBook implements OrderBookListener
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
messageFacade.removeOffer(offer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyFilter(@Nullable OrderBookFilter orderBookFilter)
|
public void applyFilter(@Nullable OrderBookFilter orderBookFilter)
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
-->
|
-->
|
||||||
<logger name="com.google.bitcoin.core.Wallet" level="DEBUG"/>
|
<logger name="com.google.bitcoin.core.Wallet" level="INFO"/>
|
||||||
<logger name="com.google.bitcoin.core.MemoryPool" level="INFO" additivity="false"/>
|
<logger name="com.google.bitcoin.core.MemoryPool" level="WARN" additivity="false"/>
|
||||||
<logger name="com.google.bitcoin.net.discovery.DnsDiscovery" level="INFO" additivity="false"/>
|
<logger name="com.google.bitcoin.net.discovery.DnsDiscovery" level="WARN" additivity="false"/>
|
||||||
|
|
||||||
<logger name="com.google.bitcoin.core.DownloadListener" level="WARN" additivity="false"/>
|
<logger name="com.google.bitcoin.core.DownloadListener" level="WARN" additivity="false"/>
|
||||||
<logger name="com.google.bitcoin.core.TransactionOutput" level="WARN" additivity="false"/>
|
<logger name="com.google.bitcoin.core.TransactionOutput" level="WARN" additivity="false"/>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue