Skip to content

Commit

Permalink
Merge pull request #2 from bitsquare/Development
Browse files Browse the repository at this point in the history
update Development branch
  • Loading branch information
SimonTuberlin authored Jan 29, 2017
2 parents bda6046 + ad4e1a8 commit d569ca8
Show file tree
Hide file tree
Showing 18 changed files with 534 additions and 226 deletions.
12 changes: 6 additions & 6 deletions core/src/main/java/io/bitsquare/btc/TradeWalletService.java
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,9 @@ public Transaction emergencySignAndPublishPayoutTx(String depositTxHex,
log.info("buyerAddressString " + buyerAddressString);
log.info("sellerAddressString " + sellerAddressString);
log.info("arbitratorAddressString " + arbitratorAddressString);
log.info("buyerPrivateKeyAsHex " + buyerPrivateKeyAsHex);
log.info("sellerPrivateKeyAsHex " + sellerPrivateKeyAsHex);
log.info("arbitratorPrivateKeyAsHex " + arbitratorPrivateKeyAsHex);
log.info("buyerPrivateKeyAsHex (not displayed for security reasons)");
log.info("sellerPrivateKeyAsHex (not displayed for security reasons)");
log.info("arbitratorPrivateKeyAsHex (not displayed for security reasons)");
log.info("buyerPubKeyAsHex " + buyerPubKeyAsHex);
log.info("sellerPubKeyAsHex " + sellerPubKeyAsHex);
log.info("arbitratorPubKeyAsHex " + arbitratorPubKeyAsHex);
Expand Down Expand Up @@ -1122,12 +1122,12 @@ private Transaction createPayoutTx(Transaction depositTx,
}

private static void printTxWithInputs(String tracePrefix, Transaction tx) {
log.trace(tracePrefix + ": " + tx.toString());
log.info(tracePrefix + ": " + tx.toString());
for (TransactionInput input : tx.getInputs()) {
if (input.getConnectedOutput() != null)
log.trace(tracePrefix + " input value: " + input.getConnectedOutput().getValue().toFriendlyString());
log.info(tracePrefix + " input value: " + input.getConnectedOutput().getValue().toFriendlyString());
else
log.trace(tracePrefix + ": Transaction already has inputs but we don't have the connected outputs, so we don't know the value.");
log.info(tracePrefix + ": Transaction already has inputs but we don't have the connected outputs, so we don't know the value.");
}
}

Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/io/bitsquare/locale/BankUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public static boolean isBankIdRequired(String countryCode) {
case "NZ":
case "AU":
case "SE":
case "CL":
return false;
case "CA":
case "MX":
Expand Down Expand Up @@ -150,6 +151,8 @@ public static String getAccountNrLabel(String countryCode) {
return "Bankgiro number:";
case "MX":
return "CLABE:";
case "CL":
return "Cuenta:";
default:
return "Account no. (IBAN):";
}
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/io/bitsquare/locale/CurrencyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public static List<CryptoCurrency> createAllSortedCryptoCurrenciesList() {
result.add(new CryptoCurrency("BITNZD", "BitNZD", true));
result.add(new CryptoCurrency("BITSEK", "BitSEK", true));
result.add(new CryptoCurrency("BITSGD", "BitSGD", true));
result.add(new CryptoCurrency("GBYTE", "Byte"));
result.add(new CryptoCurrency("SYNQ", "BitSYNQ"));
result.add(new CryptoCurrency("BTS", "BitShares"));
result.add(new CryptoCurrency("BITUSD", "BitUSD", true));
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/io/bitsquare/trade/TradeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ public void shutDown() {
private void initPendingTrades() {
Log.traceCall();

List<Trade> toAdd = new ArrayList<>();
List<Trade> toRemove = new ArrayList<>();
List<Trade> addTradeToFailedTradesList = new ArrayList<>();
List<Trade> removePreparedTradeList = new ArrayList<>();
tradesForStatistics = new ArrayList<>();
for (Trade trade : trades) {
trade.setStorage(tradableListStorage);
Expand All @@ -206,16 +206,16 @@ private void initPendingTrades() {
trade.updateDepositTxFromWallet();
tradesForStatistics.add(trade);
} else if (trade.isTakerFeePaid()) {
toAdd.add(trade);
addTradeToFailedTradesList.add(trade);
} else {
toRemove.add(trade);
removePreparedTradeList.add(trade);
}
}

for (Trade trade : toAdd)
for (Trade trade : addTradeToFailedTradesList)
addTradeToFailedTrades(trade);

for (Trade trade : toRemove)
for (Trade trade : removePreparedTradeList)
removePreparedTrade(trade);

for (Tradable tradable : closedTradableManager.getClosedTrades()) {
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/io/bitsquare/user/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public final class Preferences implements Persistable {
new BlockChainExplorer("Blockonomics", "https://www.blockonomics.co/api/tx?txid=", "https://www.blockonomics.co/#/search?q="),
new BlockChainExplorer("Chainflyer", "http://chainflyer.bitflyer.jp/Transaction/", "http://chainflyer.bitflyer.jp/Address/"),
new BlockChainExplorer("Smartbit", "https://www.smartbit.com.au/tx/", "https://www.smartbit.com.au/address/"),
new BlockChainExplorer("SoChain. Wow.", "https://chain.so/tx/BTC/", "https://chain.so/address/BTC/")
new BlockChainExplorer("SoChain. Wow.", "https://chain.so/tx/BTC/", "https://chain.so/address/BTC/"),
new BlockChainExplorer("Bitaps", "https://bitaps.com/", "https://bitaps.com/")
));

public static List<String> getBtcDenominations() {
Expand Down
28 changes: 28 additions & 0 deletions doc/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Contributing to Bitsquare
============================

Pull requests
--------------------

To contribute a patch, the workflow is as follows:

- Fork repository
- Create topic branch from Development branch
- Commit patches

Please do not make pull requests to the Master branch but always use the Development branch!


Copyright
---------

We are aiming to follow the principles and establish the workflow used at the Bitcoin Core project.
Please check out the [Bitcoin Core documentation](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md) for more info.
The full workflow is not used yet as there are not enough dedicated developers, but as soon that situation changes we will move
to a model with ACK/NACK, code reviews and maintainer roles.

Copyright
---------

By contributing to this repository, you agree to license your work under the AGPL license.
Please include the license header into your files.
1 change: 0 additions & 1 deletion gui/src/main/java/io/bitsquare/gui/main/MainViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ public void start() {
private void initializeAllServices() {*/

log.error("initializeAllServices");
Log.traceCall();

UserThread.runAfter(tacWindow::showIfNeeded, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package io.bitsquare.gui.main.disputes.arbitrator;

import io.bitsquare.alert.PrivateNotificationManager;
import io.bitsquare.arbitration.Dispute;
import io.bitsquare.arbitration.DisputeManager;
import io.bitsquare.common.crypto.KeyRing;
import io.bitsquare.gui.common.view.FxmlView;
Expand All @@ -29,7 +28,6 @@
import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.p2p.P2PService;
import io.bitsquare.trade.TradeManager;
import javafx.collections.transformation.FilteredList;
import javafx.stage.Stage;

import javax.inject.Inject;
Expand All @@ -47,9 +45,24 @@ public ArbitratorDisputeView(DisputeManager disputeManager, KeyRing keyRing, Tra
}

@Override
protected void setFilteredListPredicate(FilteredList<Dispute> filteredList) {
filteredList.setPredicate(dispute -> dispute.getArbitratorPubKeyRing().equals(keyRing.getPubKeyRing()));
public void initialize() {
super.initialize();

filterBox.setVisible(true);
filterBox.setManaged(true);
}

@Override
protected void applyFilteredListPredicate(String filterString) {
// If in arbitrator view we must only display disputes where we are selected as arbitrator (must not receive others anyway)
filteredList.setPredicate(dispute ->
dispute.getArbitratorPubKeyRing().equals(keyRing.getPubKeyRing()) &&
(filterString.isEmpty() ||
(dispute.getId().contains(filterString) ||
formatter.formatDate(dispute.getOpeningDate()).contains(filterString))
));
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import io.bitsquare.gui.common.view.FxmlView;
import io.bitsquare.gui.components.BusyAnimation;
import io.bitsquare.gui.components.HyperlinkWithIcon;
import io.bitsquare.gui.components.InputTextField;
import io.bitsquare.gui.components.TableGroupHeadline;
import io.bitsquare.gui.main.overlays.popups.Popup;
import io.bitsquare.gui.main.overlays.windows.ContractWindow;
Expand Down Expand Up @@ -92,7 +93,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
protected final KeyRing keyRing;
private final TradeManager tradeManager;
private final Stage stage;
private final BSFormatter formatter;
protected final BSFormatter formatter;
private final DisputeSummaryWindow disputeSummaryWindow;
private PrivateNotificationManager privateNotificationManager;
private final ContractWindow contractWindow;
Expand Down Expand Up @@ -124,6 +125,10 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
private Subscription inputTextAreaTextSubscription;
private EventHandler<KeyEvent> keyEventEventHandler;
private Scene scene;
protected FilteredList<Dispute> filteredList;
private InputTextField filterTextField;
private ChangeListener<String> filterTextFieldListener;
protected HBox filterBox;


///////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -148,10 +153,24 @@ public TraderDisputeView(DisputeManager disputeManager, KeyRing keyRing, TradeMa

@Override
public void initialize() {
Label label = new Label("Filter list:");
HBox.setMargin(label, new Insets(5, 0, 0, 0));
filterTextField = new InputTextField();
filterTextFieldListener = (observable, oldValue, newValue) -> applyFilteredListPredicate(filterTextField.getText());

filterBox = new HBox();
filterBox.setSpacing(5);
filterBox.getChildren().addAll(label, filterTextField);
VBox.setVgrow(filterBox, Priority.NEVER);
filterBox.setVisible(false);
filterBox.setManaged(false);

tableView = new TableView<>();
VBox.setVgrow(tableView, Priority.SOMETIMES);
tableView.setMinHeight(150);
root.getChildren().add(tableView);

root.getChildren().addAll(filterBox, tableView);

tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
Label placeholder = new Label("There are no open tickets");
placeholder.setWrapText(true);
Expand Down Expand Up @@ -295,10 +314,11 @@ public void initialize() {

@Override
protected void activate() {
filterTextField.textProperty().addListener(filterTextFieldListener);
disputeManager.cleanupDisputes();

FilteredList<Dispute> filteredList = new FilteredList<>(disputeManager.getDisputesAsObservableList());
setFilteredListPredicate(filteredList);
filteredList = new FilteredList<>(disputeManager.getDisputesAsObservableList());
applyFilteredListPredicate(filterTextField.getText());

sortedList = new SortedList<>(filteredList);
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
Expand All @@ -320,6 +340,7 @@ protected void activate() {

@Override
protected void deactivate() {
filterTextField.textProperty().removeListener(filterTextFieldListener);
sortedList.comparatorProperty().unbind();
selectedDisputeSubscription.unsubscribe();
removeListenersOnSelectDispute();
Expand All @@ -328,7 +349,8 @@ protected void deactivate() {
scene.removeEventHandler(KeyEvent.KEY_RELEASED, keyEventEventHandler);
}

protected void setFilteredListPredicate(FilteredList<Dispute> filteredList) {
protected void applyFilteredListPredicate(String filterString) {
// If in trader view we must not display arbitrators own disputes as trader (must not happen anyway)
filteredList.setPredicate(dispute -> !dispute.getArbitratorPubKeyRing().equals(keyRing.getPubKeyRing()));
}

Expand Down Expand Up @@ -497,8 +519,8 @@ private void addListenersOnSelectDispute() {
private void onSelectDispute(Dispute dispute) {
removeListenersOnSelectDispute();
if (dispute == null) {
if (root.getChildren().size() > 1)
root.getChildren().remove(1);
if (root.getChildren().size() > 2)
root.getChildren().remove(2);

selectedDispute = null;
} else if (selectedDispute != dispute) {
Expand Down Expand Up @@ -805,9 +827,9 @@ private void showArrivedIcon() {
}
});

if (root.getChildren().size() > 1)
root.getChildren().remove(1);
root.getChildren().add(1, messagesAnchorPane);
if (root.getChildren().size() > 2)
root.getChildren().remove(2);
root.getChildren().add(2, messagesAnchorPane);

scrollToBottom();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected void activate() {
UserThread.runAfter(() -> {
amount.set("1");
minAmount.set(amount.get());
price.set("700");
price.set("900");

setAmountToModel();
setMinAmountToModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,19 @@ private void addContent() {
List<String> buyerPubKeys = !buyerPubKeysInputTextField.getText().isEmpty() ? Arrays.asList(buyerPubKeysInputTextField.getText().split(",")) : new ArrayList<>();
List<String> sellerPubKeys = !sellerPubKeysInputTextField.getText().isEmpty() ? Arrays.asList(sellerPubKeysInputTextField.getText().split(",")) : new ArrayList<>();


/*

// Notes:
// Open with alt+g and enable DEV mode
// Priv key is only visible if pw protection is removed (wallet details data (alt+j))
// Take P2SHMultiSigOutputScript from depositTx in blockexplorer
// Take missing buyerPubKeyAsHex and sellerPubKeyAsHex from contract data!
// Lookup sellerPrivateKeyAsHex associated with sellerPubKeyAsHex (or buyers) in wallet details data
// sellerPubKeys/buyerPubKeys are auto generated if used the fields below
// Never set the priv arbitr. key here!

depositTxHex.setText("");

buyerPayoutAmount.setText("0.01");
buyerPayoutAmount.setText("0.51");
sellerPayoutAmount.setText("0.01");
arbitratorPayoutAmount.setText("0");

Expand All @@ -139,7 +147,7 @@ private void addContent() {
sellerPubKeys = Arrays.asList();

buyerPubKeys = Arrays.asList();
*/


actionButtonText("Sign and publish transaction");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package io.bitsquare.gui.util.validation;


import io.bitsquare.gui.util.validation.altcoins.ByteballAddressValidator;
import io.bitsquare.gui.util.validation.params.IOPParams;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
Expand Down Expand Up @@ -92,6 +93,24 @@ public ValidationResult validate(String input) {
return validationResult;
else
return new ValidationResult(false, "ZEC address need to start with t. Addresses starting with z are not supported.");

// TODO test not successful
/*case "XTO":
if (input.matches("^[T2][a-km-zA-HJ-NP-Z1-9]{25,34}$")) {
if (verifyChecksum(input))
try {
new Address(MainNetParams.get(), input);
return new ValidationResult(true);
} catch (AddressFormatException e) {
return new ValidationResult(false, getErrorMessage(e));
}
else
return wrongChecksum;
} else {
return regexTestFailed;
}*/
case "GBYTE":
return ByteballAddressValidator.validate(input);
default:
log.debug("Validation for AltCoinAddress not implemented yet. currencyCode:" + currencyCode);
return validationResult;
Expand Down
Loading

0 comments on commit d569ca8

Please sign in to comment.