mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-03-14 18:06:34 -04:00
Use security deposit as flat rate instead of percentage, remove wording of collateral
This commit is contained in:
parent
1fddf079b7
commit
98b6f72f90
Binary file not shown.
Before Width: | Height: | Size: 6.2 KiB |
@ -48,10 +48,10 @@ public class SeedNode extends Thread {
|
||||
private static final List<SeedNodeAddress.StaticSeedNodeAddresses> staticSedNodeAddresses = SeedNodeAddress
|
||||
.StaticSeedNodeAddresses.getAllSeedNodeAddresses();
|
||||
|
||||
public static void mainForTest(String[] args) {
|
||||
Peer peer = null;
|
||||
|
||||
public static void main1(String[] args) {
|
||||
try {
|
||||
peer = new PeerBuilder(Number160.createHash("digitalocean1.bitsquare.io")).ports(5000).start();
|
||||
Peer peer = new PeerBuilder(Number160.createHash("digitalocean1.bitsquare.io")).ports(5000).start();
|
||||
new PeerBuilderDHT(peer).start();
|
||||
new PeerBuilderNAT(peer).start();
|
||||
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
package io.bitsquare.arbitrator;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.List;
|
||||
@ -33,11 +35,7 @@ public class Arbitrator implements Serializable {
|
||||
private ID_TYPE idType;
|
||||
private List<Locale> languages;
|
||||
private Reputation reputation;
|
||||
private double maxTradeVolume;
|
||||
private double passiveServiceFee;
|
||||
private double minPassiveServiceFee;
|
||||
private double arbitrationFee;
|
||||
private double minArbitrationFee;
|
||||
private Coin fee;
|
||||
private List<METHOD> arbitrationMethods;
|
||||
private List<ID_VERIFICATION> idVerifications;
|
||||
|
||||
@ -54,11 +52,7 @@ public class Arbitrator implements Serializable {
|
||||
ID_TYPE idType,
|
||||
List<Locale> languages,
|
||||
Reputation reputation,
|
||||
double maxTradeVolume,
|
||||
double passiveServiceFee,
|
||||
double minPassiveServiceFee,
|
||||
double arbitrationFee,
|
||||
double minArbitrationFee,
|
||||
Coin fee,
|
||||
List<METHOD> arbitrationMethods,
|
||||
List<ID_VERIFICATION> idVerifications,
|
||||
String webUrl,
|
||||
@ -69,11 +63,7 @@ public class Arbitrator implements Serializable {
|
||||
this.idType = idType;
|
||||
this.languages = languages;
|
||||
this.reputation = reputation;
|
||||
this.maxTradeVolume = maxTradeVolume;
|
||||
this.passiveServiceFee = passiveServiceFee;
|
||||
this.minPassiveServiceFee = minPassiveServiceFee;
|
||||
this.arbitrationFee = arbitrationFee;
|
||||
this.minArbitrationFee = minArbitrationFee;
|
||||
this.fee = fee;
|
||||
this.arbitrationMethods = arbitrationMethods;
|
||||
this.idVerifications = idVerifications;
|
||||
this.webUrl = webUrl;
|
||||
@ -90,11 +80,7 @@ public class Arbitrator implements Serializable {
|
||||
this.idType = persistedArbitrator.getIdType();
|
||||
this.languages = persistedArbitrator.getLanguages();
|
||||
this.reputation = persistedArbitrator.getReputation();
|
||||
this.maxTradeVolume = persistedArbitrator.getMaxTradeVolume();
|
||||
this.passiveServiceFee = persistedArbitrator.getPassiveServiceFee();
|
||||
this.minPassiveServiceFee = persistedArbitrator.getMinPassiveServiceFee();
|
||||
this.arbitrationFee = persistedArbitrator.getArbitrationFee();
|
||||
this.minArbitrationFee = persistedArbitrator.getMinArbitrationFee();
|
||||
this.fee = persistedArbitrator.getFee();
|
||||
this.arbitrationMethods = persistedArbitrator.getArbitrationMethods();
|
||||
this.idVerifications = persistedArbitrator.getIdVerifications();
|
||||
this.webUrl = persistedArbitrator.getWebUrl();
|
||||
@ -127,17 +113,14 @@ public class Arbitrator implements Serializable {
|
||||
return id != null && id.equals(other.getId());
|
||||
}
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public String getPubKeyAsHex() {
|
||||
return pubKeyAsHex;
|
||||
}
|
||||
|
||||
|
||||
public String getMessagePubKeyAsHex() {
|
||||
return messagePubKeyAsHex;
|
||||
}
|
||||
@ -152,57 +135,34 @@ public class Arbitrator implements Serializable {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public ID_TYPE getIdType() {
|
||||
return idType;
|
||||
}
|
||||
|
||||
|
||||
public List<Locale> getLanguages() {
|
||||
return languages;
|
||||
}
|
||||
|
||||
|
||||
public Reputation getReputation() {
|
||||
return reputation;
|
||||
}
|
||||
|
||||
public double getMaxTradeVolume() {
|
||||
return maxTradeVolume;
|
||||
public Coin getFee() {
|
||||
return fee;
|
||||
}
|
||||
|
||||
public double getPassiveServiceFee() {
|
||||
return passiveServiceFee;
|
||||
}
|
||||
|
||||
public double getMinPassiveServiceFee() {
|
||||
return minPassiveServiceFee;
|
||||
}
|
||||
|
||||
public double getArbitrationFee() {
|
||||
return arbitrationFee;
|
||||
}
|
||||
|
||||
public double getMinArbitrationFee() {
|
||||
return minArbitrationFee;
|
||||
}
|
||||
|
||||
|
||||
public List<METHOD> getArbitrationMethods() {
|
||||
return arbitrationMethods;
|
||||
}
|
||||
|
||||
|
||||
public List<ID_VERIFICATION> getIdVerifications() {
|
||||
return idVerifications;
|
||||
}
|
||||
|
||||
|
||||
public String getWebUrl() {
|
||||
return webUrl;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@
|
||||
GridPane.rowIndex="4"/>
|
||||
|
||||
<Label text="Arbitration fee:" GridPane.rowIndex="5"/>
|
||||
<TextField fx:id="arbitrationFeeTextField" editable="false" focusTraversable="false" GridPane.columnIndex="1"
|
||||
<TextField fx:id="feeTextField" editable="false" focusTraversable="false" GridPane.columnIndex="1"
|
||||
GridPane.columnSpan="2" GridPane.rowIndex="5"/>
|
||||
|
||||
<Label text="Methods of arbitration:" GridPane.rowIndex="6"/>
|
||||
|
@ -39,12 +39,11 @@ public class ArbitratorProfileViewCB extends CachedViewCB {
|
||||
|
||||
private final Persistence persistence;
|
||||
private BSFormatter formatter;
|
||||
private Arbitrator arbitrator;
|
||||
|
||||
|
||||
@FXML Label nameLabel;
|
||||
@FXML TextField nameTextField, languagesTextField, reputationTextField, maxTradeVolumeTextField,
|
||||
passiveServiceFeeTextField, arbitrationFeeTextField, methodsTextField,
|
||||
@FXML TextField nameTextField, languagesTextField, reputationTextField,
|
||||
feeTextField, methodsTextField,
|
||||
idVerificationsTextField, webPageTextField;
|
||||
@FXML TextArea descriptionTextArea;
|
||||
|
||||
@ -116,11 +115,7 @@ public class ArbitratorProfileViewCB extends CachedViewCB {
|
||||
nameTextField.setText(arbitrator.getName());
|
||||
languagesTextField.setText(formatter.languageLocalesToString(arbitrator.getLanguages()));
|
||||
reputationTextField.setText(arbitrator.getReputation().toString());
|
||||
maxTradeVolumeTextField.setText(String.valueOf(arbitrator.getMaxTradeVolume()) + " BTC");
|
||||
passiveServiceFeeTextField.setText(String.valueOf(arbitrator.getPassiveServiceFee()) + " % (Min. " +
|
||||
String.valueOf(arbitrator.getMinPassiveServiceFee()) + " BTC)");
|
||||
arbitrationFeeTextField.setText(String.valueOf(arbitrator.getArbitrationFee()) + " % (Min. " + String
|
||||
.valueOf(arbitrator.getMinArbitrationFee()) + " BTC)");
|
||||
feeTextField.setText(String.valueOf(arbitrator.getFee() + " BTC"));
|
||||
methodsTextField.setText(formatter.arbitrationMethodsToString(arbitrator.getArbitrationMethods()));
|
||||
idVerificationsTextField.setText(
|
||||
formatter.arbitrationIDVerificationsToString(arbitrator.getIdVerifications()));
|
||||
|
@ -128,7 +128,7 @@
|
||||
</GridPane>
|
||||
</TitledPane>
|
||||
|
||||
<TitledPane fx:id="payCollateralTitledPane" text="Pay collateral">
|
||||
<TitledPane fx:id="paySecurityDepositTitledPane" text="Pay security deposit">
|
||||
<AnchorPane>
|
||||
<VBox spacing="20" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
@ -137,8 +137,8 @@
|
||||
|
||||
<GridPane hgap="5.0" vgap="5.0">
|
||||
|
||||
<Label text="Collateral address:"/>
|
||||
<TextField fx:id="collateralAddressTextField" editable="false" focusTraversable="false"
|
||||
<Label text="Security deposit address:"/>
|
||||
<TextField fx:id="securityDepositAddressTextField" editable="false" focusTraversable="false"
|
||||
GridPane.columnIndex="1"/>
|
||||
<Label fx:id="copyIcon" id="copy-icon" GridPane.columnIndex="2">
|
||||
<padding>
|
||||
|
@ -22,7 +22,6 @@ import io.bitsquare.arbitrator.Reputation;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
||||
import io.bitsquare.gui.main.account.arbitrator.profile.ArbitratorProfileViewCB;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.locale.LanguageUtil;
|
||||
@ -61,8 +60,6 @@ import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static com.google.common.base.Preconditions.*;
|
||||
|
||||
// TODO Arbitration is very basic yet
|
||||
public class ArbitratorRegistrationViewCB extends CachedViewCB {
|
||||
private static final Logger log = LoggerFactory.getLogger(ArbitratorRegistrationViewCB.class);
|
||||
@ -73,7 +70,6 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
|
||||
private final User user;
|
||||
private BSFormatter formatter;
|
||||
private Arbitrator arbitrator = new Arbitrator();
|
||||
private ArbitratorProfileViewCB arbitratorProfileViewCB;
|
||||
private boolean isEditMode;
|
||||
|
||||
private List<Locale> languageList = new ArrayList<>();
|
||||
@ -84,7 +80,7 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
|
||||
private Arbitrator.ID_TYPE idType;
|
||||
|
||||
@FXML Accordion accordion;
|
||||
@FXML TitledPane profileTitledPane, payCollateralTitledPane;
|
||||
@FXML TitledPane profileTitledPane, paySecurityDepositTitledPane;
|
||||
@FXML Button saveProfileButton, paymentDoneButton;
|
||||
@FXML Label nameLabel, infoLabel, copyIcon, confirmationLabel;
|
||||
@FXML ComboBox<Locale> languageComboBox;
|
||||
@ -94,7 +90,7 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
|
||||
@FXML TextField nameTextField, idTypeTextField, languagesTextField, maxTradeVolumeTextField,
|
||||
passiveServiceFeeTextField, minPassiveServiceFeeTextField, arbitrationFeeTextField,
|
||||
minArbitrationFeeTextField, methodsTextField, idVerificationsTextField, webPageTextField,
|
||||
collateralAddressTextField, balanceTextField;
|
||||
securityDepositAddressTextField, balanceTextField;
|
||||
@FXML TextArea descriptionTextArea;
|
||||
@FXML ConfidenceProgressIndicator progressIndicator;
|
||||
|
||||
@ -225,7 +221,7 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
|
||||
if (isEditMode) {
|
||||
saveProfileButton.setText("Save");
|
||||
profileTitledPane.setCollapsible(false);
|
||||
payCollateralTitledPane.setVisible(false);
|
||||
paySecurityDepositTitledPane.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -321,8 +317,8 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
|
||||
close();
|
||||
}
|
||||
else {
|
||||
setupPayCollateralScreen();
|
||||
accordion.setExpandedPane(payCollateralTitledPane);
|
||||
setupPaySecurityDepositScreen();
|
||||
accordion.setExpandedPane(paySecurityDepositTitledPane);
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,24 +335,25 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void setupPayCollateralScreen() {
|
||||
infoLabel.setText("You need to pay 10 x the max. trading volume as collateral.\n\nThat payment will be " +
|
||||
private void setupPaySecurityDepositScreen() {
|
||||
infoLabel.setText("You need to pay 2 x the max. trading volume as security deposit.\n\nThat payment will be " +
|
||||
"locked into a MultiSig fund and be refunded when you leave the arbitration pool.\nIn case of fraud " +
|
||||
"(collusion, not fulfilling the min. dispute quality requirements) you will lose your collateral.\n" +
|
||||
"If you have a negative feedback from your clients you will lose a part of the collateral,\n" +
|
||||
"(collusion, not fulfilling the min. dispute quality requirements) you will lose your security " +
|
||||
"deposit.\n" +
|
||||
"If you have a negative feedback from your clients you will lose a part of the security deposit,\n" +
|
||||
"depending on the overall relation of negative to positive ratings you received after a dispute " +
|
||||
"resolution.\n\nPlease pay in " + arbitrator.getMaxTradeVolume() * 10 + " BTC");
|
||||
"resolution.\n\nPlease pay in 2 BTC");
|
||||
|
||||
|
||||
String collateralAddress = walletFacade.getRegistrationAddressEntry() != null ?
|
||||
String securityDepositAddress = walletFacade.getRegistrationAddressEntry() != null ?
|
||||
walletFacade.getRegistrationAddressEntry().toString() : "";
|
||||
collateralAddressTextField.setText(collateralAddress);
|
||||
securityDepositAddressTextField.setText(securityDepositAddress);
|
||||
|
||||
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
|
||||
copyIcon.setOnMouseClicked(e -> {
|
||||
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(collateralAddress);
|
||||
content.putString(securityDepositAddress);
|
||||
clipboard.setContent(content);
|
||||
});
|
||||
|
||||
@ -419,11 +416,7 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
|
||||
nameTextField.setText(arbitrator.getName());
|
||||
idTypeTextField.setText(BSResources.get(arbitrator.getIdType().toString()));
|
||||
languagesTextField.setText(formatter.languageLocalesToString(arbitrator.getLanguages()));
|
||||
maxTradeVolumeTextField.setText(String.valueOf(arbitrator.getMaxTradeVolume()));
|
||||
passiveServiceFeeTextField.setText(String.valueOf(arbitrator.getPassiveServiceFee()));
|
||||
minPassiveServiceFeeTextField.setText(String.valueOf(arbitrator.getMinPassiveServiceFee()));
|
||||
arbitrationFeeTextField.setText(String.valueOf(arbitrator.getArbitrationFee()));
|
||||
minArbitrationFeeTextField.setText(String.valueOf(arbitrator.getMinArbitrationFee()));
|
||||
arbitrationFeeTextField.setText(String.valueOf(arbitrator.getFee()));
|
||||
methodsTextField.setText(formatter.arbitrationMethodsToString(arbitrator.getArbitrationMethods()));
|
||||
idVerificationsTextField.setText(
|
||||
formatter.arbitrationIDVerificationsToString(arbitrator.getIdVerifications()));
|
||||
@ -442,13 +435,7 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
|
||||
String pubKeyAsHex = walletFacade.getArbitratorDepositAddressEntry().getPubKeyAsHexString();
|
||||
String messagePubKeyAsHex = DSAKeyUtil.getHexStringFromPublicKey(user.getMessagePublicKey());
|
||||
String name = nameTextField.getText();
|
||||
|
||||
double maxTradeVolume = parseToDouble(maxTradeVolumeTextField.getText());
|
||||
double passiveServiceFee = parseToDouble(passiveServiceFeeTextField.getText());
|
||||
double minPassiveServiceFee = parseToDouble(minPassiveServiceFeeTextField.getText());
|
||||
double arbitrationFee = parseToDouble(arbitrationFeeTextField.getText());
|
||||
double minArbitrationFee = parseToDouble(minArbitrationFeeTextField.getText());
|
||||
|
||||
Coin fee = formatter.parseToCoin(arbitrationFeeTextField.getText());
|
||||
String webUrl = webPageTextField.getText();
|
||||
String description = descriptionTextArea.getText();
|
||||
|
||||
@ -458,11 +445,7 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
|
||||
idType,
|
||||
languageList,
|
||||
new Reputation(),
|
||||
maxTradeVolume,
|
||||
passiveServiceFee,
|
||||
minPassiveServiceFee,
|
||||
arbitrationFee,
|
||||
minArbitrationFee,
|
||||
fee,
|
||||
methodList,
|
||||
idVerificationList,
|
||||
webUrl,
|
||||
@ -473,16 +456,5 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
|
||||
Stage stage = (Stage) root.getScene().getWindow();
|
||||
stage.close();
|
||||
}
|
||||
|
||||
private double parseToDouble(String input) {
|
||||
try {
|
||||
checkNotNull(input);
|
||||
checkArgument(input.length() > 0);
|
||||
input = input.replace(",", ".").trim();
|
||||
return Double.parseDouble(input);
|
||||
} catch (Exception e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.DSAKeyUtil;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.ECKey;
|
||||
import org.bitcoinj.core.Utils;
|
||||
|
||||
@ -203,11 +204,7 @@ class RestrictionsModel extends UIModel {
|
||||
Arbitrator.ID_TYPE.REAL_LIFE_ID,
|
||||
languages,
|
||||
new Reputation(),
|
||||
1,
|
||||
0.01,
|
||||
0.001,
|
||||
10,
|
||||
0.1,
|
||||
Coin.parseCoin("0.1"),
|
||||
arbitrationMethods,
|
||||
idVerifications,
|
||||
"http://bitsquare.io/",
|
||||
|
@ -314,11 +314,11 @@ class PendingTradesModel extends UIModel {
|
||||
.TX_FEE).toString());
|
||||
// return walletFacade.getBalanceForAddress(addressEntry.getAddress()).subtract(FeePolicy.TX_FEE);
|
||||
|
||||
// TODO handle overpaid collateral
|
||||
// TODO handle overpaid securityDeposit
|
||||
if (isOfferer())
|
||||
return getTrade().getTradeAmount().add(getTrade().getOffer().getCollateralAmount());
|
||||
return getTrade().getTradeAmount().add(getTrade().getOffer().getSecurityDeposit());
|
||||
else
|
||||
return getTrade().getCollateralAmount();
|
||||
return getTrade().getSecurityDeposit();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -236,13 +236,13 @@ public class PendingTradesPM extends PresentationModel<PendingTradesModel> {
|
||||
return formatter.formatCoinWithCode(model.getTotalFees());
|
||||
}
|
||||
|
||||
String getCollateral() {
|
||||
// collateral is handled different for offerer and taker.
|
||||
// Offerer have paid in the max amount, but taker might have taken less so also paid in less collateral
|
||||
String getSecurityDeposit() {
|
||||
// securityDeposit is handled different for offerer and taker.
|
||||
// Offerer have paid in the max amount, but taker might have taken less so also paid in less securityDeposit
|
||||
if (model.isOfferer())
|
||||
return formatter.formatCoinWithCode(model.getTrade().getOffer().getCollateralAmount());
|
||||
return formatter.formatCoinWithCode(model.getTrade().getOffer().getSecurityDeposit());
|
||||
else
|
||||
return formatter.formatCoinWithCode(model.getTrade().getCollateralAmount());
|
||||
return formatter.formatCoinWithCode(model.getTrade().getSecurityDeposit());
|
||||
}
|
||||
|
||||
BtcAddressValidator getBtcAddressValidator() {
|
||||
|
@ -181,9 +181,9 @@
|
||||
<TextField fx:id="feesTextField" GridPane.rowIndex="7" GridPane.columnIndex="1" editable="false"
|
||||
focusTraversable="false" mouseTransparent="true" managed="false" visible="false"/>
|
||||
|
||||
<Label fx:id="collateralLabel" text="Refunded collateral:" GridPane.rowIndex="8" managed="false"
|
||||
<Label fx:id="securityDepositLabel" text="Refunded security deposit:" GridPane.rowIndex="8" managed="false"
|
||||
visible="false"/>
|
||||
<TextField fx:id="collateralTextField" GridPane.rowIndex="8" GridPane.columnIndex="1" editable="false"
|
||||
<TextField fx:id="securityDepositTextField" GridPane.rowIndex="8" GridPane.columnIndex="1" editable="false"
|
||||
focusTraversable="false" mouseTransparent="true" managed="false" visible="false"/>
|
||||
|
||||
<InfoDisplay fx:id="summaryInfoDisplay" onAction="#onOpenSummaryHelp" rowIndex="9" gridPane="$gridPane"
|
||||
|
@ -68,10 +68,10 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
|
||||
@FXML TitledGroupBg titledGroupBg, paymentsGroupBg, summaryGroupBg, withdrawGroupBg;
|
||||
@FXML ProcessStepBar processBar;
|
||||
@FXML Label statusLabel, txIdLabel, paymentMethodLabel, fiatAmountLabel, holderNameLabel, primaryIdLabel,
|
||||
secondaryIdLabel, btcTradeAmountLabel, fiatTradeAmountLabel, feesLabel, collateralLabel,
|
||||
secondaryIdLabel, btcTradeAmountLabel, fiatTradeAmountLabel, feesLabel, securityDepositLabel,
|
||||
withdrawAmountLabel, withdrawAddressLabel;
|
||||
@FXML TextField statusTextField, paymentMethodTextField, btcTradeAmountTextField, fiatTradeAmountTextField,
|
||||
feesTextField, collateralTextField, withdrawAmountTextField;
|
||||
feesTextField, securityDepositTextField, withdrawAmountTextField;
|
||||
@FXML InputTextField withdrawAddressTextField;
|
||||
@FXML TxIdTextField txIdTextField;
|
||||
@FXML InfoDisplay infoDisplay, paymentsInfoDisplay, summaryInfoDisplay;
|
||||
@ -355,7 +355,7 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
|
||||
btcTradeAmountTextField.setText(presentationModel.getTradeVolume());
|
||||
fiatTradeAmountTextField.setText(presentationModel.getFiatVolume());
|
||||
feesTextField.setText(presentationModel.getTotalFees());
|
||||
collateralTextField.setText(presentationModel.getCollateral());
|
||||
securityDepositTextField.setText(presentationModel.getSecurityDeposit());
|
||||
summaryInfoDisplay.setText("Your security deposit has been refunded to you. " +
|
||||
"You can review the details to that trade any time in the closed trades section.");
|
||||
|
||||
@ -430,7 +430,7 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
|
||||
btcTradeAmountTextField.setText(presentationModel.getTradeVolume());
|
||||
fiatTradeAmountTextField.setText(presentationModel.getFiatVolume());
|
||||
feesTextField.setText(presentationModel.getTotalFees());
|
||||
collateralTextField.setText(presentationModel.getCollateral());
|
||||
securityDepositTextField.setText(presentationModel.getSecurityDeposit());
|
||||
summaryInfoDisplay.setText("Your security deposit has been refunded to you. " +
|
||||
"You can review the details to that trade any time in the closed trades section.");
|
||||
|
||||
@ -490,8 +490,8 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
|
||||
fiatTradeAmountTextField.setVisible(visible);
|
||||
feesLabel.setVisible(visible);
|
||||
feesTextField.setVisible(visible);
|
||||
collateralLabel.setVisible(visible);
|
||||
collateralTextField.setVisible(visible);
|
||||
securityDepositLabel.setVisible(visible);
|
||||
securityDepositTextField.setVisible(visible);
|
||||
summaryInfoDisplay.setVisible(visible);
|
||||
|
||||
withdrawGroupBg.setVisible(visible);
|
||||
@ -508,8 +508,8 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
|
||||
fiatTradeAmountTextField.setManaged(visible);
|
||||
feesLabel.setManaged(visible);
|
||||
feesTextField.setManaged(visible);
|
||||
collateralLabel.setManaged(visible);
|
||||
collateralTextField.setManaged(visible);
|
||||
securityDepositLabel.setManaged(visible);
|
||||
securityDepositTextField.setManaged(visible);
|
||||
summaryInfoDisplay.setManaged(visible);
|
||||
|
||||
withdrawGroupBg.setManaged(visible);
|
||||
|
@ -42,10 +42,8 @@ import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.LongProperty;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleLongProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
@ -88,8 +86,6 @@ class CreateOfferModel extends UIModel {
|
||||
final StringProperty fiatCode = new SimpleStringProperty();
|
||||
final StringProperty btcCode = new SimpleStringProperty();
|
||||
|
||||
final LongProperty collateralAsLong = new SimpleLongProperty();
|
||||
|
||||
final BooleanProperty requestPlaceOfferSuccess = new SimpleBooleanProperty();
|
||||
final BooleanProperty isWalletFunded = new SimpleBooleanProperty();
|
||||
final BooleanProperty useMBTC = new SimpleBooleanProperty();
|
||||
@ -99,9 +95,9 @@ class CreateOfferModel extends UIModel {
|
||||
final ObjectProperty<Fiat> priceAsFiat = new SimpleObjectProperty<>();
|
||||
final ObjectProperty<Fiat> volumeAsFiat = new SimpleObjectProperty<>();
|
||||
final ObjectProperty<Coin> totalToPayAsCoin = new SimpleObjectProperty<>();
|
||||
final ObjectProperty<Coin> collateralAsCoin = new SimpleObjectProperty<>();
|
||||
final ObjectProperty<Coin> offerFeeAsCoin = new SimpleObjectProperty<>();
|
||||
final ObjectProperty<Coin> networkFeeAsCoin = new SimpleObjectProperty<>();
|
||||
final ObjectProperty<Coin> securityDepositAsCoin = new SimpleObjectProperty<>();
|
||||
|
||||
final ObservableList<Country> acceptedCountries = FXCollections.observableArrayList();
|
||||
final ObservableList<Locale> acceptedLanguages = FXCollections.observableArrayList();
|
||||
@ -160,7 +156,7 @@ class CreateOfferModel extends UIModel {
|
||||
|
||||
// we need to set it here already as initWithData is called before activate
|
||||
if (settings != null)
|
||||
collateralAsLong.set(settings.getCollateral());
|
||||
securityDepositAsCoin.set(settings.getSecurityDeposit());
|
||||
|
||||
super.initialize();
|
||||
}
|
||||
@ -171,9 +167,9 @@ class CreateOfferModel extends UIModel {
|
||||
|
||||
// might be changed after screen change
|
||||
if (settings != null) {
|
||||
// set it here again to cover the case of an collateral change after a screen change
|
||||
// set it here again to cover the case of an securityDeposit change after a screen change
|
||||
if (settings != null)
|
||||
collateralAsLong.set(settings.getCollateral());
|
||||
securityDepositAsCoin.set(settings.getSecurityDeposit());
|
||||
|
||||
acceptedCountries.setAll(settings.getAcceptedCountries());
|
||||
acceptedLanguages.setAll(settings.getAcceptedLanguageLocales());
|
||||
@ -238,7 +234,6 @@ class CreateOfferModel extends UIModel {
|
||||
(volumeAsFiat.get())));
|
||||
|
||||
calculateTotalToPay();
|
||||
calculateCollateral();
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// Should be never reached
|
||||
@ -247,27 +242,10 @@ class CreateOfferModel extends UIModel {
|
||||
}
|
||||
|
||||
void calculateTotalToPay() {
|
||||
calculateCollateral();
|
||||
try {
|
||||
if (collateralAsCoin.get() != null) {
|
||||
totalToPayAsCoin.set(offerFeeAsCoin.get().add(networkFeeAsCoin.get()).add(collateralAsCoin.get()));
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// Should be never reached
|
||||
log.error(t.toString());
|
||||
}
|
||||
if (securityDepositAsCoin.get() != null)
|
||||
totalToPayAsCoin.set(offerFeeAsCoin.get().add(networkFeeAsCoin.get()).add(securityDepositAsCoin.get()));
|
||||
}
|
||||
|
||||
void calculateCollateral() {
|
||||
try {
|
||||
|
||||
if (amountAsCoin.get() != null)
|
||||
collateralAsCoin.set(amountAsCoin.get().multiply(collateralAsLong.get()).divide(1000L));
|
||||
} catch (Throwable t) {
|
||||
// The multiply might lead to too large numbers, we don't handle it but it should not break the app
|
||||
log.error(t.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
boolean isMinAmountLessOrEqualAmount() {
|
||||
|
@ -57,10 +57,9 @@ class CreateOfferPM extends PresentationModel<CreateOfferModel> {
|
||||
final StringProperty minAmount = new SimpleStringProperty();
|
||||
final StringProperty price = new SimpleStringProperty();
|
||||
final StringProperty volume = new SimpleStringProperty();
|
||||
final StringProperty collateral = new SimpleStringProperty();
|
||||
final StringProperty securityDeposit = new SimpleStringProperty();
|
||||
final StringProperty totalToPay = new SimpleStringProperty();
|
||||
final StringProperty directionLabel = new SimpleStringProperty();
|
||||
final StringProperty collateralLabel = new SimpleStringProperty();
|
||||
final StringProperty offerFee = new SimpleStringProperty();
|
||||
final StringProperty networkFee = new SimpleStringProperty();
|
||||
final StringProperty bankAccountType = new SimpleStringProperty();
|
||||
@ -319,7 +318,6 @@ class CreateOfferPM extends PresentationModel<CreateOfferModel> {
|
||||
if (isBtcInputValid(newValue).isValid) {
|
||||
setAmountToModel();
|
||||
calculateVolume();
|
||||
model.calculateCollateral();
|
||||
model.calculateTotalToPay();
|
||||
}
|
||||
updateButtonDisableState();
|
||||
@ -334,7 +332,6 @@ class CreateOfferPM extends PresentationModel<CreateOfferModel> {
|
||||
if (isFiatInputValid(newValue).isValid) {
|
||||
setPriceToModel();
|
||||
calculateVolume();
|
||||
model.calculateCollateral();
|
||||
model.calculateTotalToPay();
|
||||
}
|
||||
updateButtonDisableState();
|
||||
@ -345,7 +342,6 @@ class CreateOfferPM extends PresentationModel<CreateOfferModel> {
|
||||
setVolumeToModel();
|
||||
setPriceToModel();
|
||||
model.calculateAmount();
|
||||
model.calculateCollateral();
|
||||
model.calculateTotalToPay();
|
||||
}
|
||||
updateButtonDisableState();
|
||||
@ -380,13 +376,9 @@ class CreateOfferPM extends PresentationModel<CreateOfferModel> {
|
||||
private void setupBindings() {
|
||||
totalToPay.bind(createStringBinding(() -> formatter.formatCoinWithCode(model.totalToPayAsCoin.get()),
|
||||
model.totalToPayAsCoin));
|
||||
collateral.bind(createStringBinding(() -> formatter.formatCoinWithCode(model.collateralAsCoin.get()),
|
||||
model.collateralAsCoin));
|
||||
securityDeposit.bind(createStringBinding(() -> formatter.formatCoinWithCode(model.securityDepositAsCoin.get()),
|
||||
model.securityDepositAsCoin));
|
||||
|
||||
collateralLabel.bind(Bindings.createStringBinding(() ->
|
||||
BSResources.get("createOffer.fundsBox.collateral",
|
||||
formatter.formatCollateralPercent(model.collateralAsLong.get())),
|
||||
model.collateralAsLong));
|
||||
totalToPayAsCoin.bind(model.totalToPayAsCoin);
|
||||
|
||||
offerFee.bind(createStringBinding(() -> formatter.formatCoinWithCode(model.offerFeeAsCoin.get()),
|
||||
|
@ -200,7 +200,7 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
|
||||
"another trader. " +
|
||||
"\nIt will be refunded to you after the trade has successfully completed.",
|
||||
actions);
|
||||
|
||||
|
||||
presentationModel.securityDepositInfoDisplayed();
|
||||
}
|
||||
|
||||
@ -515,8 +515,8 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
|
||||
infoGridPane.setPadding(new Insets(10, 10, 10, 10));
|
||||
|
||||
addPayInfoEntry(infoGridPane, 0,
|
||||
presentationModel.collateralLabel.get(),
|
||||
presentationModel.collateral.get());
|
||||
BSResources.get("createOffer.fundsBox.securityDeposit"),
|
||||
presentationModel.securityDeposit.get());
|
||||
addPayInfoEntry(infoGridPane, 1, BSResources.get("createOffer.fundsBox.offerFee"),
|
||||
presentationModel.offerFee.get());
|
||||
addPayInfoEntry(infoGridPane, 2, BSResources.get("createOffer.fundsBox.networkFee"),
|
||||
|
@ -73,7 +73,7 @@ class TakeOfferModel extends UIModel {
|
||||
final ObjectProperty<Coin> amountAsCoin = new SimpleObjectProperty<>();
|
||||
final ObjectProperty<Fiat> volumeAsFiat = new SimpleObjectProperty<>();
|
||||
final ObjectProperty<Coin> totalToPayAsCoin = new SimpleObjectProperty<>();
|
||||
final ObjectProperty<Coin> collateralAsCoin = new SimpleObjectProperty<>();
|
||||
final ObjectProperty<Coin> securityDepositAsCoin = new SimpleObjectProperty<>();
|
||||
final ObjectProperty<Coin> offerFeeAsCoin = new SimpleObjectProperty<>();
|
||||
final ObjectProperty<Coin> networkFeeAsCoin = new SimpleObjectProperty<>();
|
||||
|
||||
@ -141,8 +141,8 @@ class TakeOfferModel extends UIModel {
|
||||
amountAsCoin.set(offer.getAmount());
|
||||
}
|
||||
|
||||
securityDepositAsCoin.set(offer.getSecurityDeposit());
|
||||
calculateVolume();
|
||||
calculateCollateral();
|
||||
calculateTotalToPay();
|
||||
|
||||
addressEntry = walletFacade.getAddressInfoByTradeID(offer.getId());
|
||||
@ -192,11 +192,10 @@ class TakeOfferModel extends UIModel {
|
||||
}
|
||||
|
||||
void calculateTotalToPay() {
|
||||
calculateCollateral();
|
||||
try {
|
||||
if (collateralAsCoin.get() != null) {
|
||||
if (securityDepositAsCoin.get() != null) {
|
||||
totalToPayAsCoin.set(offerFeeAsCoin.get().add(amountAsCoin.get()).add(networkFeeAsCoin.get()).add
|
||||
(collateralAsCoin.get()));
|
||||
(securityDepositAsCoin.get()));
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// Should be never reached
|
||||
@ -204,16 +203,6 @@ class TakeOfferModel extends UIModel {
|
||||
}
|
||||
}
|
||||
|
||||
void calculateCollateral() {
|
||||
try {
|
||||
if (amountAsCoin.get() != null && offer != null)
|
||||
collateralAsCoin.set(amountAsCoin.get().multiply(offer.getCollateral()).
|
||||
divide(1000L));
|
||||
} catch (Throwable t) {
|
||||
// The multiply might lead to too large numbers, we don't handle it but it should not break the app
|
||||
log.error(t.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
boolean isMinAmountLessOrEqualAmount() {
|
||||
|
@ -52,7 +52,6 @@ class TakeOfferPM extends PresentationModel<TakeOfferModel> {
|
||||
private String amountRange;
|
||||
private String price;
|
||||
private String directionLabel;
|
||||
private String collateralLabel;
|
||||
private String bankAccountType;
|
||||
private String bankAccountCurrency;
|
||||
private String bankAccountCounty;
|
||||
@ -70,7 +69,7 @@ class TakeOfferPM extends PresentationModel<TakeOfferModel> {
|
||||
|
||||
final StringProperty amount = new SimpleStringProperty();
|
||||
final StringProperty volume = new SimpleStringProperty();
|
||||
final StringProperty collateral = new SimpleStringProperty();
|
||||
final StringProperty securityDeposit = new SimpleStringProperty();
|
||||
final StringProperty totalToPay = new SimpleStringProperty();
|
||||
final StringProperty transactionId = new SimpleStringProperty();
|
||||
final StringProperty requestTakeOfferErrorMessage = new SimpleStringProperty();
|
||||
@ -167,8 +166,6 @@ class TakeOfferPM extends PresentationModel<TakeOfferModel> {
|
||||
addressAsString = model.getAddressEntry().getAddress().toString();
|
||||
address.set(model.getAddressEntry().getAddress());
|
||||
}
|
||||
collateralLabel = BSResources.get("takeOffer.fundsBox.collateral",
|
||||
formatter.formatCollateralPercent(offer.getCollateral()));
|
||||
|
||||
acceptedCountries = formatter.countryLocalesToString(offer.getAcceptedCountries());
|
||||
acceptedLanguages = formatter.languageLocalesToString(offer.getAcceptedLanguageLocales());
|
||||
@ -196,7 +193,7 @@ class TakeOfferPM extends PresentationModel<TakeOfferModel> {
|
||||
model.securityDepositInfoDisplayed();
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// UI events
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -271,10 +268,6 @@ class TakeOfferPM extends PresentationModel<TakeOfferModel> {
|
||||
return directionLabel;
|
||||
}
|
||||
|
||||
String getCollateralLabel() {
|
||||
return collateralLabel;
|
||||
}
|
||||
|
||||
String getBankAccountType() {
|
||||
return bankAccountType;
|
||||
}
|
||||
@ -310,7 +303,7 @@ class TakeOfferPM extends PresentationModel<TakeOfferModel> {
|
||||
Boolean displaySecurityDepositInfo() {
|
||||
return model.displaySecurityDepositInfo();
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Private
|
||||
@ -323,7 +316,6 @@ class TakeOfferPM extends PresentationModel<TakeOfferModel> {
|
||||
if (isBtcInputValid(newValue).isValid) {
|
||||
setAmountToModel();
|
||||
calculateVolume();
|
||||
model.calculateCollateral();
|
||||
model.calculateTotalToPay();
|
||||
}
|
||||
updateButtonDisableState();
|
||||
@ -350,8 +342,8 @@ class TakeOfferPM extends PresentationModel<TakeOfferModel> {
|
||||
model.volumeAsFiat));
|
||||
totalToPay.bind(createStringBinding(() -> formatter.formatCoinWithCode(model.totalToPayAsCoin.get()),
|
||||
model.totalToPayAsCoin));
|
||||
collateral.bind(createStringBinding(() -> formatter.formatCoinWithCode(model.collateralAsCoin.get()),
|
||||
model.collateralAsCoin));
|
||||
securityDeposit.bind(createStringBinding(() -> formatter.formatCoinWithCode(model.securityDepositAsCoin.get()),
|
||||
model.securityDepositAsCoin));
|
||||
|
||||
totalToPayAsCoin.bind(model.totalToPayAsCoin);
|
||||
|
||||
|
@ -439,8 +439,8 @@ public class TakeOfferViewCB extends CachedViewCB<TakeOfferPM> {
|
||||
BSResources.get("takeOffer.fundsBox.amount"),
|
||||
presentationModel.getAmount());
|
||||
addPayInfoEntry(infoGridPane, 1,
|
||||
presentationModel.getCollateralLabel(),
|
||||
presentationModel.collateral.get());
|
||||
BSResources.get("takeOffer.fundsBox.securityDeposit"),
|
||||
presentationModel.securityDeposit.get());
|
||||
addPayInfoEntry(infoGridPane, 2, BSResources.get("takeOffer.fundsBox.offerFee"),
|
||||
presentationModel.getOfferFee());
|
||||
addPayInfoEntry(infoGridPane, 3, BSResources.get("takeOffer.fundsBox.networkFee"),
|
||||
|
@ -153,12 +153,16 @@ public class BSFormatter {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Coin parseToCoin(String input) {
|
||||
try {
|
||||
return coinFormat.parse(cleanInput(input));
|
||||
} catch (Throwable t) {
|
||||
log.warn("Exception at parseToBtc: " + t.toString());
|
||||
if (input != null) {
|
||||
try {
|
||||
return coinFormat.parse(cleanInput(input));
|
||||
} catch (Throwable t) {
|
||||
log.warn("Exception at parseToBtc: " + t.toString());
|
||||
return Coin.ZERO;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return Coin.ZERO;
|
||||
}
|
||||
}
|
||||
@ -171,6 +175,7 @@ public class BSFormatter {
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
|
||||
public Coin parseToCoinWith4Decimals(String input) {
|
||||
try {
|
||||
return Coin.valueOf(new BigDecimal(parseToCoin(cleanInput(input)).value).setScale(-scale - 1,
|
||||
@ -229,9 +234,15 @@ public class BSFormatter {
|
||||
}
|
||||
|
||||
public Fiat parseToFiat(String input) {
|
||||
try {
|
||||
return Fiat.parseFiat(currencyCode, cleanInput(input));
|
||||
} catch (Exception e) {
|
||||
if (input != null) {
|
||||
try {
|
||||
return Fiat.parseFiat(currencyCode, cleanInput(input));
|
||||
} catch (Exception e) {
|
||||
return Fiat.valueOf(currencyCode, 0);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
return Fiat.valueOf(currencyCode, 0);
|
||||
}
|
||||
}
|
||||
@ -244,14 +255,18 @@ public class BSFormatter {
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public Fiat parseToFiatWith2Decimals(String input) {
|
||||
try {
|
||||
return parseToFiat(new BigDecimal(cleanInput(input)).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
||||
} catch (Throwable t) {
|
||||
log.warn("Exception at parseCoinTo4Decimals: " + t.toString());
|
||||
return Fiat.valueOf(currencyCode, 0);
|
||||
}
|
||||
|
||||
public Fiat parseToFiatWith2Decimals(String input) {
|
||||
if (input != null) {
|
||||
try {
|
||||
return parseToFiat(new BigDecimal(cleanInput(input)).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
||||
} catch (Throwable t) {
|
||||
log.warn("Exception at parseCoinTo4Decimals: " + t.toString());
|
||||
return Fiat.valueOf(currencyCode, 0);
|
||||
}
|
||||
|
||||
}
|
||||
return Fiat.valueOf(currencyCode, 0);
|
||||
}
|
||||
|
||||
public boolean hasFiatValidDecimals(String input) {
|
||||
@ -316,14 +331,6 @@ public class BSFormatter {
|
||||
return dateFormatter.format(date) + " " + timeFormatter.format(date);
|
||||
}
|
||||
|
||||
public String formatCollateralPercent(long collateral) {
|
||||
DecimalFormat decimalFormat = (DecimalFormat) DecimalFormat.getInstance(locale);
|
||||
decimalFormat.setMinimumFractionDigits(1);
|
||||
decimalFormat.setMaximumFractionDigits(1);
|
||||
decimalFormat.setGroupingUsed(false);
|
||||
return decimalFormat.format(collateral / 10) + " %";
|
||||
}
|
||||
|
||||
public String formatToPercent(double value) {
|
||||
DecimalFormat decimalFormat = (DecimalFormat) DecimalFormat.getInstance(locale);
|
||||
decimalFormat.setMinimumFractionDigits(1);
|
||||
|
@ -20,6 +20,7 @@ package io.bitsquare.settings;
|
||||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.locale.Country;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.utils.MonetaryFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -27,6 +28,7 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.OptionalLong;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
@ -38,9 +40,6 @@ public class Settings implements Serializable {
|
||||
private List<Country> acceptedCountryLocales = new ArrayList<>();
|
||||
private List<Arbitrator> acceptedArbitrators = new ArrayList<>();
|
||||
|
||||
private long collateral = 100; // is 1/1000 so 100 results to 100/1000 = 0,1 (or 10%)
|
||||
// which will be used for multiplying with the amount to get the collateral size in BTC.
|
||||
|
||||
private Boolean useAnimations = true;
|
||||
private String btcDenominationString = MonetaryFormat.CODE_BTC;
|
||||
final transient StringProperty btcDenomination = new SimpleStringProperty(MonetaryFormat.CODE_BTC);
|
||||
@ -63,7 +62,6 @@ public class Settings implements Serializable {
|
||||
acceptedLanguageLocales = persistedSettings.getAcceptedLanguageLocales();
|
||||
acceptedCountryLocales = persistedSettings.getAcceptedCountries();
|
||||
acceptedArbitrators = persistedSettings.getAcceptedArbitrators();
|
||||
collateral = persistedSettings.getCollateral();
|
||||
setBtcDenomination(persistedSettings.getBtcDenominationString());
|
||||
}
|
||||
}
|
||||
@ -115,12 +113,9 @@ public class Settings implements Serializable {
|
||||
return acceptedCountryLocales;
|
||||
}
|
||||
|
||||
public void setCollateral(long collateral) {
|
||||
this.collateral = collateral;
|
||||
}
|
||||
|
||||
public long getCollateral() {
|
||||
return collateral;
|
||||
public Coin getSecurityDeposit() {
|
||||
OptionalLong result = acceptedArbitrators.stream().mapToLong(e -> e.getFee().getValue()).max();
|
||||
return result.isPresent() ? Coin.valueOf(result.getAsLong()) : Coin.ZERO;
|
||||
}
|
||||
|
||||
public String getBtcDenomination() {
|
||||
|
@ -56,7 +56,7 @@ public class Offer implements Serializable {
|
||||
private final BankAccountType bankAccountType;
|
||||
private final Country bankAccountCountry;
|
||||
|
||||
private final long collateral;
|
||||
private final Coin securityDeposit;
|
||||
private final List<Country> acceptedCountries;
|
||||
private final List<Locale> acceptedLanguageLocales;
|
||||
private final String bankAccountUID;
|
||||
@ -79,7 +79,7 @@ public class Offer implements Serializable {
|
||||
Country bankAccountCountry,
|
||||
String bankAccountUID,
|
||||
List<Arbitrator> arbitrators,
|
||||
long collateral,
|
||||
Coin securityDeposit,
|
||||
List<Country> acceptedCountries,
|
||||
List<Locale> acceptedLanguageLocales) {
|
||||
this.id = id;
|
||||
@ -93,7 +93,7 @@ public class Offer implements Serializable {
|
||||
this.bankAccountCountry = bankAccountCountry;
|
||||
this.bankAccountUID = bankAccountUID;
|
||||
this.arbitrators = arbitrators;
|
||||
this.collateral = collateral;
|
||||
this.securityDeposit = securityDeposit;
|
||||
this.acceptedCountries = acceptedCountries;
|
||||
|
||||
this.acceptedLanguageLocales = acceptedLanguageLocales;
|
||||
@ -186,12 +186,8 @@ public class Offer implements Serializable {
|
||||
return arbitrators;
|
||||
}
|
||||
|
||||
public long getCollateral() {
|
||||
return collateral;
|
||||
}
|
||||
|
||||
public Coin getCollateralAmount() {
|
||||
return amount.multiply(collateral).divide(1000L);
|
||||
public Coin getSecurityDeposit() {
|
||||
return securityDeposit;
|
||||
}
|
||||
|
||||
public String getBankAccountId() {
|
||||
@ -211,7 +207,7 @@ public class Offer implements Serializable {
|
||||
", messagePubKey=" + messagePublicKey.hashCode() +
|
||||
", bankAccountTypeEnum=" + bankAccountType +
|
||||
", bankAccountCountryLocale=" + bankAccountCountry +
|
||||
", collateral=" + collateral +
|
||||
", securityDeposit=" + securityDeposit +
|
||||
", acceptedCountryLocales=" + acceptedCountries +
|
||||
", acceptedLanguageLocales=" + acceptedLanguageLocales +
|
||||
", offerFeePaymentTxID='" + offerFeePaymentTxID + '\'' +
|
||||
|
@ -165,8 +165,8 @@ public class Trade implements Serializable {
|
||||
return fault;
|
||||
}
|
||||
|
||||
public Coin getCollateralAmount() {
|
||||
return tradeAmount.multiply(offer.getCollateral()).divide(1000L);
|
||||
public Coin getSecurityDeposit() {
|
||||
return offer.getSecurityDeposit();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -157,7 +157,7 @@ public class TradeManager {
|
||||
user.getCurrentBankAccount().getCountry(),
|
||||
user.getCurrentBankAccount().getUid(),
|
||||
settings.getAcceptedArbitrators(),
|
||||
settings.getCollateral(),
|
||||
settings.getSecurityDeposit(),
|
||||
settings.getAcceptedCountries(),
|
||||
settings.getAcceptedLanguageLocales());
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class VerifyOffer {
|
||||
checkNotNull(offer.getArbitrators(), "Arbitrator is null");
|
||||
checkNotNull(offer.getBankAccountCountry(), "BankAccountCountry is null");
|
||||
checkNotNull(offer.getBankAccountId(), "BankAccountId is null");
|
||||
checkNotNull(offer.getCollateral(), "Collateral is null");
|
||||
checkNotNull(offer.getSecurityDeposit(), "SecurityDeposit is null");
|
||||
checkNotNull(offer.getCreationDate(), "CreationDate is null");
|
||||
checkNotNull(offer.getCurrency(), "Currency is null");
|
||||
checkNotNull(offer.getDirection(), "Direction is null");
|
||||
@ -57,12 +57,12 @@ public class VerifyOffer {
|
||||
checkArgument(offer.getAmount().compareTo(Restrictions.MIN_TRADE_AMOUNT) >= 0,
|
||||
"Amount is less then " + Restrictions.MIN_TRADE_AMOUNT);
|
||||
checkArgument(offer.getAmount().compareTo(offer.getMinAmount()) >= 0, "MinAmount is larger then Amount");
|
||||
checkArgument(offer.getCollateral() > 0, "Collateral is 0");
|
||||
checkArgument(offer.getSecurityDeposit().isPositive(), "SecurityDeposit is not positive");
|
||||
checkArgument(offer.getPrice().isPositive(), "Price is 0 or negative");
|
||||
|
||||
// TODO check balance
|
||||
// Coin collateralAsCoin = offer.getAmount().divide((long) (1d / offer.getCollateral()));
|
||||
// Coin totalsToFund = collateralAsCoin.add(FeePolicy.CREATE_OFFER_FEE.add(FeePolicy.TX_FEE));
|
||||
// securityDeposit
|
||||
// Coin totalsToFund
|
||||
// getAddressInfoByTradeID(offerId)
|
||||
// TODO when offer is flattened continue here...
|
||||
|
||||
|
@ -221,8 +221,7 @@ public class BuyerAcceptsOfferProtocol {
|
||||
public void onResultVerifyTakeOfferFeePayment() {
|
||||
log.debug("onResultVerifyTakeOfferFeePayment called " + step++);
|
||||
|
||||
Coin collateral = trade.getCollateralAmount();
|
||||
Coin offererInputAmount = collateral.add(FeePolicy.TX_FEE);
|
||||
Coin offererInputAmount = trade.getSecurityDeposit().add(FeePolicy.TX_FEE);
|
||||
state = State.CreateDepositTx;
|
||||
CreateDepositTx.run(this::onResultCreateDepositTx, this::onFault, walletFacade, tradeId, offererInputAmount,
|
||||
takerPubKey, arbitratorPubKey);
|
||||
@ -375,7 +374,7 @@ public class BuyerAcceptsOfferProtocol {
|
||||
// next task
|
||||
String depositTransactionId = trade.getDepositTx().getHashAsString();
|
||||
Coin tradeAmount = trade.getTradeAmount();
|
||||
Coin collateral = trade.getCollateralAmount();
|
||||
Coin securityDeposit = trade.getSecurityDeposit();
|
||||
state = State.SendSignedPayoutTx;
|
||||
SendSignedPayoutTx.run(this::onResultSendSignedPayoutTx,
|
||||
this::onFault,
|
||||
@ -386,7 +385,7 @@ public class BuyerAcceptsOfferProtocol {
|
||||
peersPayoutAddress,
|
||||
payoutAddress,
|
||||
depositTransactionId,
|
||||
collateral,
|
||||
securityDeposit,
|
||||
tradeAmount);
|
||||
}
|
||||
|
||||
|
@ -46,12 +46,12 @@ public class SendSignedPayoutTx {
|
||||
String takerPayoutAddress,
|
||||
String offererPayoutAddress,
|
||||
String depositTransactionId,
|
||||
Coin collateral,
|
||||
Coin securityDeposit,
|
||||
Coin tradeAmount) {
|
||||
log.trace("Run task");
|
||||
try {
|
||||
Coin offererPaybackAmount = tradeAmount.add(collateral);
|
||||
@SuppressWarnings("UnnecessaryLocalVariable") Coin takerPaybackAmount = collateral;
|
||||
Coin offererPaybackAmount = tradeAmount.add(securityDeposit);
|
||||
@SuppressWarnings("UnnecessaryLocalVariable") Coin takerPaybackAmount = securityDeposit;
|
||||
|
||||
Pair<ECKey.ECDSASignature, String> result = walletFacade.offererCreatesAndSignsPayoutTx(
|
||||
depositTransactionId, offererPaybackAmount, takerPaybackAmount, takerPayoutAddress, tradeId);
|
||||
|
@ -102,7 +102,7 @@ public class SellerTakesOfferProtocol {
|
||||
private final String pubKeyForThatTrade;
|
||||
private final ECKey accountKey;
|
||||
private final PublicKey peersMessagePublicKey;
|
||||
private final Coin collateral;
|
||||
private final Coin securityDeposit;
|
||||
private final String arbitratorPubKey;
|
||||
|
||||
// written/read by task
|
||||
@ -149,7 +149,7 @@ public class SellerTakesOfferProtocol {
|
||||
offer = trade.getOffer();
|
||||
tradeId = trade.getId();
|
||||
tradeAmount = trade.getTradeAmount();
|
||||
collateral = trade.getCollateralAmount();
|
||||
securityDeposit = trade.getSecurityDeposit();
|
||||
//TODO use 1. for now
|
||||
arbitratorPubKey = trade.getOffer().getArbitrators().get(0).getPubKeyAsHex();
|
||||
|
||||
@ -279,7 +279,7 @@ public class SellerTakesOfferProtocol {
|
||||
trade.setContractTakerSignature(signature);
|
||||
|
||||
state = State.PayDeposit;
|
||||
PayDeposit.run(this::onResultPayDeposit, this::onFault, walletFacade, collateral, tradeAmount, tradeId,
|
||||
PayDeposit.run(this::onResultPayDeposit, this::onFault, walletFacade, securityDeposit, tradeAmount, tradeId,
|
||||
pubKeyForThatTrade, arbitratorPubKey, peersPubKey, preparedPeersDepositTxAsHex);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class PayDeposit {
|
||||
public static void run(ResultHandler resultHandler,
|
||||
ExceptionHandler exceptionHandler,
|
||||
WalletFacade walletFacade,
|
||||
Coin collateral,
|
||||
Coin securityDeposit,
|
||||
Coin tradeAmount,
|
||||
String tradeId,
|
||||
String pubKeyForThatTrade,
|
||||
@ -42,8 +42,8 @@ public class PayDeposit {
|
||||
String preparedOffererDepositTxAsHex) {
|
||||
log.trace("Run task");
|
||||
try {
|
||||
Coin amountToPay = tradeAmount.add(collateral);
|
||||
Coin msOutputAmount = amountToPay.add(collateral);
|
||||
Coin amountToPay = tradeAmount.add(securityDeposit);
|
||||
Coin msOutputAmount = amountToPay.add(securityDeposit);
|
||||
|
||||
Transaction signedTakerDepositTx = walletFacade.takerAddPaymentAndSignTx(amountToPay,
|
||||
msOutputAmount,
|
||||
|
@ -52,7 +52,7 @@ createOffer.fundsBox.totalsNeeded.prompt=Will be calculated from the Bitcoin amo
|
||||
createOffer.fundsBox.address=Trade wallet address:
|
||||
createOffer.fundsBox.balance=Trade wallet balance:
|
||||
createOffer.fundsBox.info=For every offer there is a dedicated trade wallet. You need to fund that trade wallet with the necessary Bitcoin amount. Those funds are reserved and will be used in the case that your offer gets executed. If you cancel your offer you can withdraw your funds from that trading wallet. The only payment which will be done now when placing the offer is the offer fee payment.
|
||||
createOffer.fundsBox.collateral=Security deposit ({0}):
|
||||
createOffer.fundsBox.securityDeposit=Security deposit:
|
||||
createOffer.fundsBox.offerFee=Offer fee:
|
||||
createOffer.fundsBox.networkFee=Mining fee:
|
||||
createOffer.fundsBox.total=Total:
|
||||
@ -101,9 +101,10 @@ takeOffer.fundsBox.totalsNeeded=Funds needed for that trade:
|
||||
takeOffer.fundsBox.totalsNeeded.prompt=Will be calculated from the Bitcoin amount entered above
|
||||
takeOffer.fundsBox.address=Trade wallet address:
|
||||
takeOffer.fundsBox.balance=Trade wallet balance:
|
||||
takeOffer.fundsBox.info=For every offer there is a dedicated trade wallet. You need to fund that trade wallet with the necessary Bitcoin amount. Those funds will be paid in to a locked deposit address. At the end of a successful trade you will get back your collateral and the Bitcoin amount you sold will be transferred to the buyer.
|
||||
takeOffer.fundsBox.info=For every offer there is a dedicated trade wallet. You need to fund that trade wallet with the necessary Bitcoin amount. Those funds will be paid in to a locked deposit address. At the end of a successful trade you will get back your security deposit and the Bitcoin amount you sold will be transferred to the \
|
||||
buyer.
|
||||
takeOffer.fundsBox.amount=Amount to sell:
|
||||
takeOffer.fundsBox.collateral=Security deposit ({0}):
|
||||
takeOffer.fundsBox.securityDeposit=Security deposit:
|
||||
takeOffer.fundsBox.offerFee=Offer fee:
|
||||
takeOffer.fundsBox.networkFee=Mining fee:
|
||||
takeOffer.fundsBox.total=Total:
|
||||
|
@ -57,14 +57,6 @@ public class CreateOfferPMTest {
|
||||
|
||||
@Test
|
||||
public void testBindings() {
|
||||
model.collateralAsLong.set(100);
|
||||
presenter.price.set("500");
|
||||
presenter.amount.set("1");
|
||||
assertEquals("500.00", presenter.volume.get());
|
||||
assertEquals(Coin.COIN, model.amountAsCoin.get());
|
||||
assertEquals(Fiat.valueOf("USD", 500 * 10000), model.priceAsFiat.get());
|
||||
assertEquals(Fiat.valueOf("USD", 500 * 10000), model.volumeAsFiat.get());
|
||||
|
||||
presenter.price.set("500");
|
||||
presenter.volume.set("500");
|
||||
assertEquals("1.00", presenter.amount.get());
|
||||
|
@ -56,10 +56,10 @@ public class CreateOfferControllerUIMock implements Initializable {
|
||||
@FXML private TextField addressTextField;
|
||||
@FXML private TextField balanceTextField;
|
||||
|
||||
@FXML private Label buyLabel, confirmationLabel, txTitleLabel, collateralLabel;
|
||||
@FXML private Label buyLabel, confirmationLabel, txTitleLabel, securityDepositLabel;
|
||||
@FXML private TextField amountTextField, minAmountTextField, priceTextField, volumeTextField;
|
||||
@FXML private Button placeOfferButton, closeButton;
|
||||
@FXML private TextField totalToPayTextField, collateralTextField, bankAccountTypeTextField,
|
||||
@FXML private TextField totalToPayTextField, securityDepositTextField, bankAccountTypeTextField,
|
||||
bankAccountCurrencyTextField, bankAccountCountyTextField, acceptedCountriesTextField,
|
||||
acceptedLanguagesTextField,
|
||||
summaryBtcTextField, transactionIdTextField;
|
||||
@ -72,49 +72,6 @@ public class CreateOfferControllerUIMock implements Initializable {
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
/*
|
||||
paymentInfoPane.setVisible(false);
|
||||
collateralLabel.setVisible(false);
|
||||
collateralTextField.setVisible(false);
|
||||
offerFeeLabel.setVisible(false);
|
||||
offerFeeTextField.setVisible(false);
|
||||
networkFeeLabel.setVisible(false);
|
||||
networkFeeTextField.setVisible(false);
|
||||
totalsSeparator.setVisible(false);
|
||||
summaryBtcLabel.setVisible(false);
|
||||
summaryBtcTextField.setVisible(false);
|
||||
paymentInfoLabel.setVisible(false);
|
||||
paymentInfoIcon.setVisible(false);
|
||||
showPayFundsScreenButton.setVisible(false);
|
||||
|
||||
payFundsPane.setVisible(false);
|
||||
totalToPayLabel.setVisible(false);
|
||||
totalToPayTextField.setVisible(false);
|
||||
addressLabel.setVisible(false);
|
||||
addressTextField.setVisible(false);
|
||||
balanceLabel.setVisible(false);
|
||||
balanceTextField.setVisible(false);
|
||||
payFundsInfoIcon.setVisible(false);
|
||||
payFundsInfoLabel.setVisible(false);
|
||||
placeOfferButton.setVisible(false);
|
||||
showDetailsButton.setVisible(false);
|
||||
|
||||
showDetailsPane.setVisible(false);
|
||||
showDetailsTitleLabel.setVisible(false);
|
||||
acceptedCountriesLabel.setVisible(false);
|
||||
acceptedCountriesTextField.setVisible(false);
|
||||
acceptedLanguagesLabel.setVisible(false);
|
||||
acceptedLanguagesTextField.setVisible(false);
|
||||
acceptedArbitratorsLabel.setVisible(false);
|
||||
acceptedArbitratorsTextField.setVisible(false);
|
||||
bankAccountTypeLabel.setVisible(false);
|
||||
bankAccountTypeTextField.setVisible(false);
|
||||
bankAccountCurrencyLabel.setVisible(false);
|
||||
bankAccountCurrencyTextField.setVisible(false);
|
||||
bankAccountCountyLabel.setVisible(false);
|
||||
bankAccountCountyTextField.setVisible(false);
|
||||
showDetailsInfoIcon.setVisible(false);
|
||||
showDetailsInfoLabel.setVisible(false);*/
|
||||
}
|
||||
|
||||
/* @FXML
|
||||
@ -143,8 +100,8 @@ public class CreateOfferControllerUIMock implements Initializable {
|
||||
showPaymentInfoScreenButton.setVisible(false);
|
||||
|
||||
paymentInfoPane.setVisible(true);
|
||||
collateralLabel.setVisible(true);
|
||||
collateralTextField.setVisible(true);
|
||||
securityDepositLabel.setVisible(true);
|
||||
securityDepositTextField.setVisible(true);
|
||||
offerFeeLabel.setVisible(true);
|
||||
offerFeeTextField.setVisible(true);
|
||||
networkFeeLabel.setVisible(true);
|
||||
|
@ -133,7 +133,7 @@ public class DHTTestController implements Initializable {
|
||||
CountryUtil.getDefaultCountry(),
|
||||
"bankAccountUID",
|
||||
new ArrayList<>(),
|
||||
10,
|
||||
Coin.parseCoin("0.1"),
|
||||
new ArrayList<>(),
|
||||
new ArrayList<>());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user