Pass trade if available and use peers keyring

This commit is contained in:
chimp1984 2020-12-15 00:40:45 -05:00
parent 0e7dd21745
commit d7a95fed03
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
3 changed files with 29 additions and 11 deletions

View File

@ -104,7 +104,7 @@ public class PeerInfoIcon extends Group {
role,
numTrades,
privateNotificationManager,
null,
trade.getOffer(),
trade,
preferences,
accountAgeWitnessService,
@ -246,7 +246,7 @@ public class PeerInfoIcon extends Group {
getChildren().addAll(outerBackground, innerBackground, avatarImageView, tagPane, numTradesPane);
addMouseListener(numTrades, privateNotificationManager, offer, preferences, useDevPrivilegeKeys,
addMouseListener(numTrades, privateNotificationManager, trade, offer, preferences, useDevPrivilegeKeys,
isFiatCurrency, accountAge, signAge, peersAccount.third, peersAccount.fourth, peersAccount.fifth);
}
@ -297,6 +297,7 @@ public class PeerInfoIcon extends Group {
protected void addMouseListener(int numTrades,
PrivateNotificationManager privateNotificationManager,
@Nullable Trade trade,
Offer offer,
Preferences preferences,
boolean useDevPrivilegeKeys,
@ -319,7 +320,7 @@ public class PeerInfoIcon extends Group {
Res.get("peerInfo.unknownAge") :
null;
setOnMouseClicked(e -> new PeerInfoWithTagEditor(privateNotificationManager, offer, preferences, useDevPrivilegeKeys)
setOnMouseClicked(e -> new PeerInfoWithTagEditor(privateNotificationManager, trade, offer, preferences, useDevPrivilegeKeys)
.fullAddress(fullAddress)
.numTrades(numTrades)
.accountAge(accountAgeFormatted)

View File

@ -3,13 +3,17 @@ package bisq.desktop.components;
import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.alert.PrivateNotificationManager;
import bisq.core.offer.Offer;
import bisq.core.trade.Trade;
import bisq.core.user.Preferences;
import bisq.network.p2p.NodeAddress;
import javax.annotation.Nullable;
public class PeerInfoIconSmall extends PeerInfoIcon {
public PeerInfoIconSmall(NodeAddress nodeAddress,
String role, Offer offer,
String role,
Offer offer,
Preferences preferences,
AccountAgeWitnessService accountAgeWitnessService,
boolean useDevPrivilegeKeys) {
@ -32,6 +36,7 @@ public class PeerInfoIconSmall extends PeerInfoIcon {
@Override
protected void addMouseListener(int numTrades,
PrivateNotificationManager privateNotificationManager,
@Nullable Trade trade,
Offer offer,
Preferences preferences,
boolean useDevPrivilegeKeys,

View File

@ -25,6 +25,7 @@ import bisq.core.alert.PrivateNotificationManager;
import bisq.core.locale.GlobalSettings;
import bisq.core.locale.Res;
import bisq.core.offer.Offer;
import bisq.core.trade.Trade;
import bisq.core.user.Preferences;
import bisq.common.UserThread;
@ -85,6 +86,8 @@ public class PeerInfoWithTagEditor extends Overlay<PeerInfoWithTagEditor> {
private int numTrades;
private ChangeListener<Boolean> focusListener;
private final PrivateNotificationManager privateNotificationManager;
@Nullable
private final Trade trade;
private final Offer offer;
private final Preferences preferences;
private EventHandler<KeyEvent> keyEventEventHandler;
@ -99,10 +102,12 @@ public class PeerInfoWithTagEditor extends Overlay<PeerInfoWithTagEditor> {
private String signAgeInfo;
public PeerInfoWithTagEditor(PrivateNotificationManager privateNotificationManager,
@Nullable Trade trade,
Offer offer,
Preferences preferences,
boolean useDevPrivilegeKeys) {
this.privateNotificationManager = privateNotificationManager;
this.trade = trade;
this.offer = offer;
this.preferences = preferences;
this.useDevPrivilegeKeys = useDevPrivilegeKeys;
@ -244,13 +249,20 @@ public class PeerInfoWithTagEditor extends Overlay<PeerInfoWithTagEditor> {
// otherwise the text input handler does not work.
doClose();
UserThread.runAfter(() -> {
//TODO only taker could send msg as maker would use its own key from offer....
new SendPrivateNotificationWindow(
privateNotificationManager,
offer.getPubKeyRing(),
offer.getMakerNodeAddress(),
useDevPrivilegeKeys
).show();
PubKeyRing peersPubKeyRing = null;
if (trade != null) {
peersPubKeyRing = trade.getProcessModel().getTradingPeer().getPubKeyRing();
} else if (offer != null) {
peersPubKeyRing = offer.getPubKeyRing();
}
if (peersPubKeyRing != null) {
new SendPrivateNotificationWindow(
privateNotificationManager,
peersPubKeyRing,
offer.getMakerNodeAddress(),
useDevPrivilegeKeys
).show();
}
}, 100, TimeUnit.MILLISECONDS);
}
};