Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify witness signing #4455

Merged
merged 4 commits into from Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/src/main/resources/i18n/displayStrings.properties
Expand Up @@ -967,7 +967,7 @@ support.tab.legacyArbitration.support=Legacy Arbitration
support.tab.ArbitratorsSupportTickets={0}'s tickets
support.filter=Search disputes
support.filter.prompt=Enter trade ID, date, onion address or account data
support.reOpenByTrader.prompt=Are you sure you want to re-open the dispute?
support.reOpenByTrader.prompt=Are you sure you want to re-open the dispute?
support.reOpenButton.label=Re-open dispute
support.sendNotificationButton.label=Send private notification
support.reportButton.label=Generate report
Expand Down Expand Up @@ -1241,6 +1241,7 @@ setting.about.shortcuts.sendPrivateNotification.value=Open peer info at avatar o
account.tab.arbitratorRegistration=Arbitrator registration
account.tab.mediatorRegistration=Mediator registration
account.tab.refundAgentRegistration=Refund agent registration
account.tab.signing=Signing
account.tab.account=Account
account.info.headline=Welcome to your Bisq Account
account.info.msg=Here you can add trading accounts for national currencies & altcoins and create a backup of your wallet & account data.\n\n\
Expand Down
55 changes: 43 additions & 12 deletions desktop/src/main/java/bisq/desktop/main/account/AccountView.java
Expand Up @@ -33,6 +33,7 @@
import bisq.desktop.main.account.register.arbitrator.ArbitratorRegistrationView;
import bisq.desktop.main.account.register.mediator.MediatorRegistrationView;
import bisq.desktop.main.account.register.refundagent.RefundAgentRegistrationView;
import bisq.desktop.main.account.register.signing.SigningView;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.presentation.AccountPresentation;

Expand Down Expand Up @@ -77,6 +78,7 @@ public class AccountView extends ActivatableView<TabPane, Void> {
private Tab arbitratorRegistrationTab;
private Tab mediatorRegistrationTab;
private Tab refundAgentRegistrationTab;
private Tab signingTab;
private ArbitratorRegistrationView arbitratorRegistrationView;
private MediatorRegistrationView mediatorRegistrationView;
private RefundAgentRegistrationView refundAgentRegistrationView;
Expand Down Expand Up @@ -110,6 +112,8 @@ public void initialize() {
navigation.navigateTo(MainView.class, AccountView.class, FiatAccountsView.class);
} else if (refundAgentRegistrationTab == null && viewPath.get(2).equals(RefundAgentRegistrationView.class)) {
navigation.navigateTo(MainView.class, AccountView.class, FiatAccountsView.class);
} else if (signingTab == null && viewPath.get(2).equals(SigningView.class)) {
navigation.navigateTo(MainView.class, AccountView.class, FiatAccountsView.class);
} else {
loadView(viewPath.tip());
}
Expand All @@ -120,27 +124,23 @@ public void initialize() {

keyEventEventHandler = event -> {
if (Utilities.isAltOrCtrlPressed(KeyCode.D, event) && mediatorRegistrationTab == null) {
if (arbitratorRegistrationTab != null) {
root.getTabs().remove(arbitratorRegistrationTab);
}
if (refundAgentRegistrationTab != null) {
root.getTabs().remove(refundAgentRegistrationTab);
}
closeOtherExtraTabs(mediatorRegistrationTab);
mediatorRegistrationTab = new Tab(Res.get("account.tab.mediatorRegistration").toUpperCase());
mediatorRegistrationTab.setClosable(true);
root.getTabs().add(mediatorRegistrationTab);
navigation.navigateTo(MainView.class, AccountView.class, MediatorRegistrationView.class);
} else if (Utilities.isAltOrCtrlPressed(KeyCode.N, event) && refundAgentRegistrationTab == null) {
if (arbitratorRegistrationTab != null) {
root.getTabs().remove(arbitratorRegistrationTab);
}
if (mediatorRegistrationTab != null) {
root.getTabs().remove(mediatorRegistrationTab);
}
closeOtherExtraTabs(refundAgentRegistrationTab);
refundAgentRegistrationTab = new Tab(Res.get("account.tab.refundAgentRegistration").toUpperCase());
refundAgentRegistrationTab.setClosable(true);
root.getTabs().add(refundAgentRegistrationTab);
navigation.navigateTo(MainView.class, AccountView.class, RefundAgentRegistrationView.class);
} else if (Utilities.isAltOrCtrlPressed(KeyCode.I, event) && signingTab == null) {
closeOtherExtraTabs(signingTab);
signingTab = new Tab(Res.get("account.tab.signing").toUpperCase());
signingTab.setClosable(true);
root.getTabs().add(signingTab);
navigation.navigateTo(MainView.class, AccountView.class, SigningView.class);
}
};

Expand All @@ -151,6 +151,8 @@ public void initialize() {
navigation.navigateTo(MainView.class, AccountView.class, MediatorRegistrationView.class);
} else if (refundAgentRegistrationTab != null && selectedTab != refundAgentRegistrationTab) {
navigation.navigateTo(MainView.class, AccountView.class, RefundAgentRegistrationView.class);
} else if (signingTab != null && !selectedTab.equals(signingTab)) {
navigation.navigateTo(MainView.class, AccountView.class, SigningView.class);
} else if (newValue == fiatAccountsTab && selectedTab != fiatAccountsTab) {
navigation.navigateTo(MainView.class, AccountView.class, FiatAccountsView.class);
} else if (newValue == altcoinAccountsTab && selectedTab != altcoinAccountsTab) {
Expand All @@ -177,9 +179,27 @@ public void initialize() {

if (removedTabs.size() == 1 && removedTabs.get(0).equals(refundAgentRegistrationTab))
onRefundAgentRegistrationTabRemoved();

if (removedTabs.size() == 1 && removedTabs.get(0).equals(signingTab))
onSigningTabRemoved();
};
}

private void closeOtherExtraTabs(Tab newTab) {
if (arbitratorRegistrationTab != null && !arbitratorRegistrationTab.equals(newTab)) {
root.getTabs().remove(arbitratorRegistrationTab);
}
if (mediatorRegistrationTab != null && !mediatorRegistrationTab.equals(newTab)) {
root.getTabs().remove(mediatorRegistrationTab);
}
if (refundAgentRegistrationTab != null && !refundAgentRegistrationTab.equals(newTab)) {
root.getTabs().remove(refundAgentRegistrationTab);
}
if (signingTab != null && !signingTab.equals(newTab)) {
root.getTabs().remove(signingTab);
}
}

private void onArbitratorRegistrationTabRemoved() {
arbitratorRegistrationTab = null;
navigation.navigateTo(MainView.class, AccountView.class, FiatAccountsView.class);
Expand All @@ -195,6 +215,11 @@ private void onRefundAgentRegistrationTabRemoved() {
navigation.navigateTo(MainView.class, AccountView.class, FiatAccountsView.class);
}

private void onSigningTabRemoved() {
signingTab = null;
navigation.navigateTo(MainView.class, AccountView.class, FiatAccountsView.class);
}

@Override
protected void activate() {
// Hide account new badge if user saw this section
Expand All @@ -216,6 +241,8 @@ else if (mediatorRegistrationTab != null)
navigation.navigateTo(MainView.class, AccountView.class, MediatorRegistrationView.class);
else if (refundAgentRegistrationTab != null)
navigation.navigateTo(MainView.class, AccountView.class, RefundAgentRegistrationView.class);
else if (signingTab != null)
navigation.navigateTo(MainView.class, AccountView.class, SigningView.class);
else if (root.getSelectionModel().getSelectedItem() == fiatAccountsTab)
navigation.navigateTo(MainView.class, AccountView.class, FiatAccountsView.class);
else if (root.getSelectionModel().getSelectedItem() == altcoinAccountsTab)
Expand Down Expand Up @@ -274,6 +301,10 @@ private void loadView(Class<? extends View> viewClass) {
refundAgentRegistrationView = (RefundAgentRegistrationView) view;
refundAgentRegistrationView.onTabSelection(true);
}
} else if (view instanceof SigningView) {
if (signingTab != null) {
selectedTab = signingTab;
}
} else if (view instanceof FiatAccountsView) {
selectedTab = fiatAccountsTab;
} else if (view instanceof AltCoinAccountsView) {
Expand Down
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ This file is part of Bisq.
~
~ Bisq is free software: you can redistribute it and/or modify it
~ under the terms of the GNU Affero General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or (at
~ your option) any later version.
~
~ Bisq is distributed in the hope that it will be useful, but WITHOUT
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
~ License for more details.
~
~ You should have received a copy of the GNU Affero General Public License
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
-->

<?import javafx.scene.layout.AnchorPane?>
<?import javafx.geometry.Insets?>
<AnchorPane fx:id="root" fx:controller="bisq.desktop.main.account.register.signing.SigningView"
xmlns:fx="http://javafx.com/fxml">
<padding>
<Insets left="10.0" right="10.0"/>
</padding>
</AnchorPane>
@@ -0,0 +1,79 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.desktop.main.account.register.signing;


import bisq.desktop.common.view.ActivatableView;
import bisq.desktop.common.view.FxmlView;
import bisq.desktop.main.overlays.windows.SignPaymentAccountsWindow;
import bisq.desktop.main.overlays.windows.SignSpecificWitnessWindow;
import bisq.desktop.main.overlays.windows.SignUnsignedPubKeysWindow;

import bisq.common.util.Utilities;

import javax.inject.Inject;

import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;

import javafx.event.EventHandler;

@FxmlView
public class SigningView extends ActivatableView<AnchorPane, Void> {

private final SignPaymentAccountsWindow signPaymentAccountsWindow;
private final SignSpecificWitnessWindow signSpecificWitnessWindow;
private final SignUnsignedPubKeysWindow signUnsignedPubKeysWindow;
private EventHandler<KeyEvent> keyEventEventHandler;
private Scene scene;

@Inject
public SigningView(SignPaymentAccountsWindow signPaymentAccountsWindow,
SignSpecificWitnessWindow signSpecificWitnessWindow,
SignUnsignedPubKeysWindow signUnsignedPubKeysWindow) {
this.signPaymentAccountsWindow = signPaymentAccountsWindow;
this.signSpecificWitnessWindow = signSpecificWitnessWindow;
this.signUnsignedPubKeysWindow = signUnsignedPubKeysWindow;
keyEventEventHandler = this::handleKeyPressed;
}

@Override
protected void activate() {
scene = root.getScene();
if (scene != null)
scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEventEventHandler);
}

@Override
protected void deactivate() {
if (scene != null)
scene.removeEventHandler(KeyEvent.KEY_RELEASED, keyEventEventHandler);
}

protected void handleKeyPressed(KeyEvent event) {
if (Utilities.isAltOrCtrlPressed(KeyCode.S, event)) {
signPaymentAccountsWindow.show();
} else if (Utilities.isAltOrCtrlPressed(KeyCode.P, event)) {
signSpecificWitnessWindow.show();
} else if (Utilities.isAltOrCtrlPressed(KeyCode.O, event)) {
signUnsignedPubKeysWindow.show();
}
}
}
Expand Up @@ -29,6 +29,7 @@
import bisq.core.support.dispute.arbitration.ArbitrationManager;
import bisq.core.support.dispute.arbitration.TraderDataItem;
import bisq.core.support.dispute.arbitration.arbitrator.ArbitratorManager;
import bisq.core.support.dispute.mediation.MediationManager;
import bisq.core.util.FormattingUtils;

import bisq.common.config.Config;
Expand Down Expand Up @@ -88,18 +89,24 @@ public class SignPaymentAccountsWindow extends Overlay<SignPaymentAccountsWindow
private final AccountAgeWitnessService accountAgeWitnessService;
private final ArbitratorManager arbitratorManager;
private final ArbitrationManager arbitrationManager;
private final MediationManager mediationManager;
private final String appName;
private final boolean useDevPrivilegeKeys;


@Inject
public SignPaymentAccountsWindow(AccountAgeWitnessService accountAgeWitnessService,
ArbitratorManager arbitratorManager,
ArbitrationManager arbitrationManager,
@Named(Config.APP_NAME) String appName) {
MediationManager mediationManager,
@Named(Config.APP_NAME) String appName,
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys) {
this.accountAgeWitnessService = accountAgeWitnessService;
this.arbitratorManager = arbitratorManager;
this.arbitrationManager = arbitrationManager;
this.mediationManager = mediationManager;
this.appName = appName;
this.useDevPrivilegeKeys = useDevPrivilegeKeys;
}

@Override
Expand Down Expand Up @@ -193,7 +200,9 @@ private void addSelectedAccountsContent() {
++rowIndex, Res.get("popup.accountSigning.confirmSelectedAccounts.headline"));
GridPane.setRowSpan(selectedPaymentAccountsTuple.third, 2);
selectedPaymentAccountsList = selectedPaymentAccountsTuple.second;
ObservableList<Dispute> disputesAsObservableList = arbitrationManager.getDisputesAsObservableList();
ObservableList<Dispute> disputesAsObservableList = useDevPrivilegeKeys ?
mediationManager.getDisputesAsObservableList()
: arbitrationManager.getDisputesAsObservableList();
long safeDate = datePicker.getValue().atStartOfDay().toEpochSecond(ZoneOffset.UTC) * 1000;
List<TraderDataItem> traderDataItemList;
StringBuilder sb = new StringBuilder("Summary for ").append(appName).append("\n");
Expand Down
Expand Up @@ -17,14 +17,9 @@

package bisq.desktop.main.support.dispute.agent.arbitration;

import bisq.common.config.Config;
import bisq.common.util.Utilities;
import bisq.desktop.common.view.FxmlView;
import bisq.desktop.main.overlays.windows.ContractWindow;
import bisq.desktop.main.overlays.windows.DisputeSummaryWindow;
import bisq.desktop.main.overlays.windows.SignPaymentAccountsWindow;
import bisq.desktop.main.overlays.windows.SignSpecificWitnessWindow;
import bisq.desktop.main.overlays.windows.SignUnsignedPubKeysWindow;
import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
import bisq.desktop.main.support.dispute.agent.DisputeAgentView;

Expand All @@ -39,21 +34,15 @@
import bisq.core.util.FormattingUtils;
import bisq.core.util.coin.CoinFormatter;

import bisq.common.config.Config;
import bisq.common.crypto.KeyRing;

import javax.inject.Named;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;

import javax.inject.Inject;
import javax.inject.Named;

@FxmlView
public class ArbitratorView extends DisputeAgentView {

private final SignPaymentAccountsWindow signPaymentAccountsWindow;
private final SignSpecificWitnessWindow signSpecificWitnessWindow;
private final SignUnsignedPubKeysWindow signUnsignedPubKeysWindow;

@Inject
public ArbitratorView(ArbitrationManager arbitrationManager,
KeyRing keyRing,
Expand All @@ -64,10 +53,7 @@ public ArbitratorView(ArbitrationManager arbitrationManager,
ContractWindow contractWindow,
TradeDetailsWindow tradeDetailsWindow,
AccountAgeWitnessService accountAgeWitnessService,
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys,
SignPaymentAccountsWindow signPaymentAccountsWindow,
SignSpecificWitnessWindow signSpecificWitnessWindow,
SignUnsignedPubKeysWindow signUnsignedPubKeysWindow) {
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys) {
super(arbitrationManager,
keyRing,
tradeManager,
Expand All @@ -78,9 +64,6 @@ public ArbitratorView(ArbitrationManager arbitrationManager,
tradeDetailsWindow,
accountAgeWitnessService,
useDevPrivilegeKeys);
this.signPaymentAccountsWindow = signPaymentAccountsWindow;
this.signSpecificWitnessWindow = signSpecificWitnessWindow;
this.signUnsignedPubKeysWindow = signUnsignedPubKeysWindow;
}

@Override
Expand All @@ -92,15 +75,4 @@ protected SupportType getType() {
protected DisputeSession getConcreteDisputeChatSession(Dispute dispute) {
return new ArbitrationSession(dispute, disputeManager.isTrader(dispute));
}

@Override
protected void handleKeyPressed(KeyEvent event) {
if (Utilities.isAltOrCtrlPressed(KeyCode.S, event)) {
signPaymentAccountsWindow.show();
} else if (Utilities.isAltOrCtrlPressed(KeyCode.P, event)) {
signSpecificWitnessWindow.show();
} else if (Utilities.isAltOrCtrlPressed(KeyCode.O, event)) {
signUnsignedPubKeysWindow.show();
}
}
}