Use byte array instead of PubKeys, Use uid for mailbox msg, Improve storage data structure, Renamings, Cleanup

This commit is contained in:
Manfred Karrer 2016-02-22 23:20:20 +01:00
parent bb6334f6a0
commit 77511a43f5
101 changed files with 869 additions and 1074 deletions

View file

@ -220,7 +220,7 @@ public class BitsquareApp extends Application {
private void showSendAlertMessagePopup() {
AlertManager alertManager = injector.getInstance(AlertManager.class);
new SendAlertMessagePopup()
.onAddAlertMessage((alertMessage, privKeyString) -> alertManager.addAlertMessageIfKeyIsValid(alertMessage, privKeyString))
.onAddAlertMessage((alert, privKeyString) -> alertManager.addAlertMessageIfKeyIsValid(alert, privKeyString))
.onRemoveAlertMessage(privKeyString -> alertManager.removeAlertMessageIfKeyIsValid(privKeyString))
.show();
}

View file

@ -866,7 +866,7 @@ textfield */
-fx-text-fill: white;
-fx-font-weight: bold;
-fx-font-size: 15;
-fx-background-radius: 20;
/*-fx-background-radius: 20;*/
}
#buy-button-big:hover {
@ -878,7 +878,7 @@ textfield */
-fx-text-fill: white;
-fx-font-weight: bold;
-fx-font-size: 15;
-fx-background-radius: 20;
/* -fx-background-radius: 20;*/
}
#sell-button-big:hover {
@ -889,7 +889,7 @@ textfield */
-fx-base: -bs-buy;
-fx-text-fill: white;
-fx-font-weight: bold;
-fx-background-radius: 13;
/* -fx-background-radius: 13;*/
}
#buy-button:hover {
@ -900,7 +900,7 @@ textfield */
-fx-base: -bs-sell;
-fx-text-fill: white;
-fx-font-weight: bold;
-fx-background-radius: 13;
/* -fx-background-radius: 13;*/
}
#sell-button:hover {
@ -911,7 +911,7 @@ textfield */
-fx-base: -bs-light-grey;
-fx-text-fill: white;
-fx-font-weight: bold;
-fx-background-radius: 13;
/* -fx-background-radius: 13;*/
}
#cancel-button:hover {
@ -925,12 +925,12 @@ textfield */
********************************************************************************************************************/
#popup-headline {
-fx-font-size: 18;
-fx-font-size: 16;
-fx-text-fill: #333;
}
#popup-bg {
-fx-font-size: 15;
-fx-font-size: 14;
-fx-text-fill: #333;
-fx-background-color: white;
-fx-background-radius: 5 5 5 5;

View file

@ -343,7 +343,7 @@ public class MainViewModel implements ViewModel {
numberOfBtcPeersTimer = UserThread.runAfter(() -> {
if (walletService.numPeersProperty().get() == 0) {
walletServiceErrorMsg.set("You lost the connection to all bitcoin network peers.\n" +
"Maybe you lost your internet connection or your computer was in hibernate/sleep mode.");
"Maybe you lost your internet connection or your computer was in standby mode.");
} else {
walletServiceErrorMsg.set(null);
}
@ -534,7 +534,7 @@ public class MainViewModel implements ViewModel {
numberOfP2PNetworkPeersTimer = UserThread.runAfter(() -> {
if (p2PService.getNumConnectedPeers().get() == 0) {
p2PNetworkWarnMsg.set("You lost the connection to all P2P network peers.\n" +
"Maybe you lost your internet connection or your computer was in hibernate/sleep mode.");
"Maybe you lost your internet connection or your computer was in standby mode.");
p2PNetworkLabelId.set("splash-error-state-msg");
} else {
p2PNetworkWarnMsg.set(null);

View file

@ -131,9 +131,9 @@ public class TransactionsListItem {
details = "MultiSig payout: " + tradable.getShortId();
} else if (trade.getDisputeState() == Trade.DisputeState.DISPUTE_CLOSED) {
if (valueSentToMe.isPositive())
details = "Refund from dispute: " + tradable.getShortId();
details = "Dispute payout: " + tradable.getShortId();
else
details = "Nothing refunded from dispute: " + tradable.getShortId();
details = "Lost dispute case: " + tradable.getShortId();
} else {
details = "Unknown reason: " + tradable.getShortId();
}

View file

@ -33,7 +33,7 @@
<PropertyValueFactory property="date"/>
</cellValueFactory>
</TableColumn>
<TableColumn text="Details" fx:id="detailsColumn" minWidth="220" maxWidth="220"/>
<TableColumn text="Details" fx:id="detailsColumn" minWidth="220"/>
<TableColumn text="Address" fx:id="addressColumn" minWidth="180"/>
<TableColumn text="Transaction" fx:id="transactionColumn" minWidth="100"/>
<TableColumn text="Amount (BTC)" fx:id="amountColumn" minWidth="110" maxWidth="110">

View file

@ -172,31 +172,40 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
List<TransactionsListItem> listItems = walletService.getWallet().getRecentTransactions(1000, true).stream()
.map(transaction -> {
log.error("tx ID " + transaction.getHashAsString());
Optional<Tradable> tradableOptional = all.stream()
.filter(e -> {
.filter(tradable -> {
String txId = transaction.getHashAsString();
if (e instanceof OpenOffer)
return e.getOffer().getOfferFeePaymentTxID().equals(txId);
else if (e instanceof Trade) {
Trade trade = (Trade) e;
return (trade.getTakeOfferFeeTxId() != null &&
trade.getTakeOfferFeeTxId().equals(txId)) ||
(trade.getOffer() != null &&
trade.getOffer().getOfferFeePaymentTxID() != null &&
trade.getOffer().getOfferFeePaymentTxID().equals(txId)) ||
(trade.getDepositTx() != null &&
trade.getDepositTx().getHashAsString().equals(txId)) ||
(trade.getPayoutTx() != null &&
trade.getPayoutTx().getHashAsString().equals(txId)) ||
(disputeManager.getDisputesAsObservableList().stream()
.filter(dispute -> dispute.getDisputePayoutTx() != null &&
dispute.getDisputePayoutTx().getHashAsString().equals(txId))
.findAny()
.isPresent());
if (tradable instanceof OpenOffer)
return tradable.getOffer().getOfferFeePaymentTxID().equals(txId);
else if (tradable instanceof Trade) {
Trade trade = (Trade) tradable;
boolean isTakeOfferFeeTx = txId.equals(trade.getTakeOfferFeeTxId());
boolean isOfferFeeTx = trade.getOffer() != null &&
txId.equals(trade.getOffer().getOfferFeePaymentTxID());
boolean isDepositTx = trade.getDepositTx() != null &&
trade.getDepositTx().getHashAsString().equals(txId);
boolean isPayoutTx = trade.getPayoutTx() != null &&
trade.getPayoutTx().getHashAsString().equals(txId);
boolean isDisputedPayoutTx = disputeManager.getDisputesAsObservableList().stream()
.filter(dispute -> txId.equals(dispute.getDisputePayoutTxId()) &&
tradable.getId().equals(dispute.getTradeId()))
.findAny()
.isPresent();
log.error("isTakeOfferFeeTx " + isTakeOfferFeeTx);
log.error("isOfferFeeTx " + isOfferFeeTx);
log.error("isDepositTx " + isDepositTx);
log.error("isPayoutTx " + isPayoutTx);
log.error("isDisputedPayoutTx " + isDisputedPayoutTx);
return isTakeOfferFeeTx || isOfferFeeTx || isDepositTx || isPayoutTx || isDisputedPayoutTx;
} else
return false;
})
.findAny();
if (tradableOptional.isPresent())
log.error("tradableOptional " + tradableOptional.get().getId());
return new TransactionsListItem(transaction, walletService, tradableOptional, formatter);
})
.collect(Collectors.toList());

View file

@ -52,6 +52,7 @@ import org.bitcoinj.utils.ExchangeRate;
import org.bitcoinj.utils.Fiat;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@ -237,9 +238,9 @@ class CreateOfferDataModel extends ActivatableDataModel {
long amount = amountAsCoin.get() != null ? amountAsCoin.get().getValue() : 0L;
long minAmount = minAmountAsCoin.get() != null ? minAmountAsCoin.get().getValue() : 0L;
List<String> acceptedCountryCodes = null;
ArrayList<String> acceptedCountryCodes = new ArrayList<>();
if (paymentAccount instanceof SepaAccount)
acceptedCountryCodes = ((SepaAccount) paymentAccount).getAcceptedCountryCodes();
acceptedCountryCodes.addAll(((SepaAccount) paymentAccount).getAcceptedCountryCodes());
// That is optional and set to null if not supported (AltCoins, OKPay,...)
Country country = paymentAccount.getCountry();
@ -256,7 +257,7 @@ class CreateOfferDataModel extends ActivatableDataModel {
tradeCurrencyCode.get(),
country,
paymentAccount.getId(),
user.getAcceptedArbitratorAddresses(),
new ArrayList<>(user.getAcceptedArbitratorAddresses()),
acceptedCountryCodes);
}

View file

@ -130,7 +130,7 @@ public class ContractPopup extends Popup {
addLabelTextField(gridPane, ++rowIndex, "Seller payment ID:",
((BlockChainAccountContractData) sellerPaymentAccountContractData).getPaymentId());
if (offer.getAcceptedCountryCodes() != null) {
if (offer.getAcceptedCountryCodes() != null && !offer.getAcceptedCountryCodes().isEmpty()) {
String countries;
Tooltip tooltip = null;
if (CountryUtil.containsAllSepaEuroCountries(offer.getAcceptedCountryCodes())) {

View file

@ -71,8 +71,8 @@ public class DisputeSummaryPopup extends Popup {
private ToggleGroup feeToggleGroup;
private String role;
private TextArea summaryNotesTextArea;
private ObjectBinding<Tuple2<DisputeResult.FeePaymentPolicy, Toggle>> feePaymentPolicyChanged;
private ChangeListener<Tuple2<DisputeResult.FeePaymentPolicy, Toggle>> feePaymentPolicyListener;
private ObjectBinding<Tuple2<DisputeResult.DisputeFeePolicy, Toggle>> feePaymentPolicyChanged;
private ChangeListener<Tuple2<DisputeResult.DisputeFeePolicy, Toggle>> feePaymentPolicyListener;
private ChangeListener<Boolean> shareRadioButtonSelectedListener;
private ChangeListener<Toggle> feeToggleSelectionListener;
// keep a reference to not get GCed
@ -163,7 +163,7 @@ public class DisputeSummaryPopup extends Popup {
disputeResult.setBuyerPayoutAmount(peersDisputeResult.getBuyerPayoutAmount());
disputeResult.setSellerPayoutAmount(peersDisputeResult.getSellerPayoutAmount());
disputeResult.setArbitratorPayoutAmount(peersDisputeResult.getArbitratorPayoutAmount());
disputeResult.setFeePaymentPolicy(peersDisputeResult.getFeePaymentPolicy());
disputeResult.setDisputeFeePolicy(peersDisputeResult.getDisputeFeePolicy());
disputeResult.setWinner(peersDisputeResult.getWinner());
if (disputeResult.getBuyerPayoutAmount() != null) {
@ -181,13 +181,13 @@ public class DisputeSummaryPopup extends Popup {
splitFeeRadioButton.setDisable(true);
waiveFeeRadioButton.setDisable(true);
calculatePayoutAmounts(disputeResult.getFeePaymentPolicy());
calculatePayoutAmounts(disputeResult.getDisputeFeePolicy());
applyTradeAmountRadioButtonStates();
} else {
applyPayoutAmounts(disputeResult.feePaymentPolicyProperty().get(), tradeAmountToggleGroup.selectedToggleProperty().get());
applyPayoutAmounts(disputeResult.disputeFeePolicyProperty().get(), tradeAmountToggleGroup.selectedToggleProperty().get());
feePaymentPolicyChanged = Bindings.createObjectBinding(
() -> new Tuple2(disputeResult.feePaymentPolicyProperty().get(), tradeAmountToggleGroup.selectedToggleProperty().get()),
disputeResult.feePaymentPolicyProperty(),
() -> new Tuple2(disputeResult.disputeFeePolicyProperty().get(), tradeAmountToggleGroup.selectedToggleProperty().get()),
disputeResult.disputeFeePolicyProperty(),
tradeAmountToggleGroup.selectedToggleProperty());
feePaymentPolicyListener = (observable, oldValue, newValue) -> {
applyPayoutAmounts(newValue.first, newValue.second);
@ -302,11 +302,11 @@ public class DisputeSummaryPopup extends Popup {
feeToggleSelectionListener = (observable, oldValue, newValue) -> {
if (newValue == loserPaysFeeRadioButton)
disputeResult.setFeePaymentPolicy(DisputeResult.FeePaymentPolicy.LOSER);
disputeResult.setDisputeFeePolicy(DisputeResult.DisputeFeePolicy.LOSER);
else if (newValue == splitFeeRadioButton)
disputeResult.setFeePaymentPolicy(DisputeResult.FeePaymentPolicy.SPLIT);
disputeResult.setDisputeFeePolicy(DisputeResult.DisputeFeePolicy.SPLIT);
else if (newValue == waiveFeeRadioButton)
disputeResult.setFeePaymentPolicy(DisputeResult.FeePaymentPolicy.WAIVE);
disputeResult.setDisputeFeePolicy(DisputeResult.DisputeFeePolicy.WAIVE);
};
feeToggleGroup.selectedToggleProperty().addListener(feeToggleSelectionListener);
@ -315,7 +315,7 @@ public class DisputeSummaryPopup extends Popup {
}
private void setFeeRadioButtonState() {
switch (disputeResult.getFeePaymentPolicy()) {
switch (disputeResult.getDisputeFeePolicy()) {
case LOSER:
feeToggleGroup.selectToggle(loserPaysFeeRadioButton);
break;
@ -417,7 +417,7 @@ public class DisputeSummaryPopup extends Popup {
// Controller
///////////////////////////////////////////////////////////////////////////////////////////
private void applyPayoutAmounts(DisputeResult.FeePaymentPolicy feePayment, Toggle selectedTradeAmountToggle) {
private void applyPayoutAmounts(DisputeResult.DisputeFeePolicy feePayment, Toggle selectedTradeAmountToggle) {
calculatePayoutAmounts(feePayment);
if (selectedTradeAmountToggle != null) {
applyPayoutAmountsToDisputeResult(selectedTradeAmountToggle);
@ -425,7 +425,7 @@ public class DisputeSummaryPopup extends Popup {
}
}
private void calculatePayoutAmounts(DisputeResult.FeePaymentPolicy feePayment) {
private void calculatePayoutAmounts(DisputeResult.DisputeFeePolicy feePayment) {
Contract contract = dispute.getContract();
Coin refund = FeePolicy.getSecurityDeposit();
Coin winnerRefund;

View file

@ -103,23 +103,26 @@ public class Popup {
public void hide() {
animateHide(() -> {
Window window = owner.getScene().getWindow();
window.xProperty().removeListener(positionListener);
window.yProperty().removeListener(positionListener);
window.widthProperty().removeListener(positionListener);
Scene rootScene = owner.getScene();
if (rootScene != null) {
Window window = rootScene.getWindow();
window.xProperty().removeListener(positionListener);
window.yProperty().removeListener(positionListener);
window.widthProperty().removeListener(positionListener);
if (centerTime != null)
centerTime.stop();
if (centerTime != null)
centerTime.stop();
removeEffectFromBackground();
removeEffectFromBackground();
if (stage != null)
stage.hide();
else
log.warn("Stage is null");
if (stage != null)
stage.hide();
else
log.warn("Stage is null");
cleanup();
PopupManager.isHidden(Popup.this);
cleanup();
PopupManager.isHidden(Popup.this);
}
});
}
@ -245,39 +248,42 @@ public class Popup {
if (owner == null)
owner = MainView.getRootContainer();
stage = new Stage();
Scene scene = new Scene(gridPane);
scene.getStylesheets().setAll(owner.getScene().getStylesheets());
scene.setFill(Color.TRANSPARENT);
stage.setScene(scene);
setModality();
stage.initStyle(StageStyle.TRANSPARENT);
Window window = owner.getScene().getWindow();
stage.initOwner(window);
stage.show();
Scene rootScene = owner.getScene();
if (rootScene != null) {
stage = new Stage();
Scene scene = new Scene(gridPane);
scene.getStylesheets().setAll(rootScene.getStylesheets());
scene.setFill(Color.TRANSPARENT);
stage.setScene(scene);
setModality();
stage.initStyle(StageStyle.TRANSPARENT);
Window window = rootScene.getWindow();
stage.initOwner(window);
stage.show();
layout();
layout();
addEffectToBackground();
addEffectToBackground();
// On Linux the owner stage does not move the child stage as it does on Mac
// So we need to apply centerPopup. Further with fast movements the handler loses
// the latest position, with a delay it fixes that.
// Also on Mac sometimes the popups are positioned outside of the main app, so keep it for all OS
positionListener = (observable, oldValue, newValue) -> {
if (stage != null) {
layout();
if (centerTime != null)
centerTime.stop();
// On Linux the owner stage does not move the child stage as it does on Mac
// So we need to apply centerPopup. Further with fast movements the handler loses
// the latest position, with a delay it fixes that.
// Also on Mac sometimes the popups are positioned outside of the main app, so keep it for all OS
positionListener = (observable, oldValue, newValue) -> {
if (stage != null) {
layout();
if (centerTime != null)
centerTime.stop();
centerTime = UserThread.runAfter(this::layout, 3);
}
};
window.xProperty().addListener(positionListener);
window.yProperty().addListener(positionListener);
window.widthProperty().addListener(positionListener);
centerTime = UserThread.runAfter(this::layout, 3);
}
};
window.xProperty().addListener(positionListener);
window.yProperty().addListener(positionListener);
window.widthProperty().addListener(positionListener);
animateDisplay();
animateDisplay();
}
}
protected void animateDisplay() {
@ -302,10 +308,13 @@ public class Popup {
}
protected void layout() {
Window window = owner.getScene().getWindow();
double titleBarHeight = window.getHeight() - owner.getScene().getHeight();
stage.setX(Math.round(window.getX() + (owner.getWidth() - stage.getWidth()) / 2));
stage.setY(Math.round(window.getY() + titleBarHeight + (owner.getHeight() - stage.getHeight()) / 2));
Scene rootScene = owner.getScene();
if (rootScene != null) {
Window window = rootScene.getWindow();
double titleBarHeight = window.getHeight() - rootScene.getHeight();
stage.setX(Math.round(window.getX() + (owner.getWidth() - stage.getWidth()) / 2));
stage.setY(Math.round(window.getY() + titleBarHeight + (owner.getHeight() - stage.getHeight()) / 2));
}
}
protected void addHeadLine() {

View file

@ -180,8 +180,8 @@ public class TradeDetailsPopup extends Popup {
addLabelTxIdTextField(gridPane, ++rowIndex, "Deposit transaction ID:", trade.getDepositTx().getHashAsString());
if (trade.getPayoutTx() != null)
addLabelTxIdTextField(gridPane, ++rowIndex, "Payout transaction ID:", trade.getPayoutTx().getHashAsString());
if (disputeManager.findOwnDispute(trade.getId()).isPresent() && disputeManager.findOwnDispute(trade.getId()).get().getDisputePayoutTx() != null)
addLabelTxIdTextField(gridPane, ++rowIndex, "Disputed payout transaction ID:", disputeManager.findOwnDispute(trade.getId()).get().getDisputePayoutTx().getHashAsString());
if (disputeManager.findOwnDispute(trade.getId()).isPresent() && disputeManager.findOwnDispute(trade.getId()).get().getDisputePayoutTxId() != null)
addLabelTxIdTextField(gridPane, ++rowIndex, "Disputed payout transaction ID:", disputeManager.findOwnDispute(trade.getId()).get().getDisputePayoutTxId());
if (contract != null) {
TextArea textArea = addLabelTextArea(gridPane, ++rowIndex, "Contract in JSON format:", trade.getContractAsJson()).second;

View file

@ -245,13 +245,13 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
public void updateItem(final PendingTradesListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
if (model.showDispute(item.getTrade())) {
/* if (model.showDispute(item.getTrade())) {
setStyle("-fx-text-fill: -bs-error-red");
} else if (model.showWarning(item.getTrade())) {
setStyle("-fx-text-fill: -bs-warning");
} else {
setId("-fx-text-fill: black");
}
}*/
setText(formatter.formatDateTime(item.getTrade().getDate()));
} else {
setText(null);

View file

@ -291,20 +291,19 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
buyerState.set(PendingTradesViewModel.BuyerState.WAIT_FOR_FIAT_PAYMENT_RECEIPT);
break;
case FIAT_PAYMENT_STARTED_MSG_RECEIVED:
case FIAT_PAYMENT_RECEIPT: // In case the msg sending failed we stick in that view state
sellerState.set(REQUEST_CONFIRM_FIAT_PAYMENT_RECEIVED);
break;
case FIAT_PAYMENT_RECEIPT:
break;
case FIAT_PAYMENT_RECEIPT_MSG_SENT:
sellerState.set(WAIT_FOR_PAYOUT_TX);
buyerState.set(PendingTradesViewModel.BuyerState.WAIT_FOR_FIAT_PAYMENT_RECEIPT);
break;
case FIAT_PAYMENT_RECEIPT_MSG_RECEIVED:
buyerState.set(PendingTradesViewModel.BuyerState.WAIT_FOR_FIAT_PAYMENT_RECEIPT);
break;
case PAYOUT_TX_COMMITTED:
case PAYOUT_TX_SENT:
buyerState.set(PendingTradesViewModel.BuyerState.WAIT_FOR_BROADCAST_AFTER_UNLOCK);
break;