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