revert getters for peer and arbitrator node addresses to avoid NPEs
This commit is contained in:
parent
767f4cf8c0
commit
79021dc9c6
@ -42,14 +42,14 @@ public class TradeInfo implements Payload {
|
|||||||
// view and interact with trades.
|
// view and interact with trades.
|
||||||
|
|
||||||
private static final Function<Trade, String> toPeerNodeAddress = (trade) ->
|
private static final Function<Trade, String> toPeerNodeAddress = (trade) ->
|
||||||
trade.getTradingPeer() == null || trade.getTradingPeer().getNodeAddress() == null
|
trade.getTradingPeerNodeAddress() == null
|
||||||
? ""
|
? ""
|
||||||
: trade.getTradingPeer().getNodeAddress().getFullAddress();
|
: trade.getTradingPeerNodeAddress().getFullAddress();
|
||||||
|
|
||||||
private static final Function<Trade, String> toArbitratorNodeAddress = (trade) ->
|
private static final Function<Trade, String> toArbitratorNodeAddress = (trade) ->
|
||||||
trade.getArbitrator() == null || trade.getArbitrator().getNodeAddress() == null
|
trade.getArbitratorNodeAddress() == null
|
||||||
? ""
|
? ""
|
||||||
: trade.getArbitrator().getNodeAddress().getFullAddress();
|
: trade.getArbitratorNodeAddress().getFullAddress();
|
||||||
|
|
||||||
private static final Function<Trade, String> toRoundedVolume = (trade) ->
|
private static final Function<Trade, String> toRoundedVolume = (trade) ->
|
||||||
trade.getVolume() == null
|
trade.getVolume() == null
|
||||||
|
@ -139,7 +139,7 @@ public class Balances {
|
|||||||
if (trade.getContract() == null) continue;
|
if (trade.getContract() == null) continue;
|
||||||
Long reservedAmt;
|
Long reservedAmt;
|
||||||
OfferPayload offerPayload = trade.getContract().getOfferPayload();
|
OfferPayload offerPayload = trade.getContract().getOfferPayload();
|
||||||
if (trade.getArbitrator().getNodeAddress().equals(P2PService.getMyNodeAddress())) { // TODO (woodser): this only works if node address does not change
|
if (trade.getArbitratorNodeAddress().equals(P2PService.getMyNodeAddress())) { // TODO (woodser): this only works if node address does not change
|
||||||
reservedAmt = offerPayload.getAmount() + offerPayload.getBuyerSecurityDeposit() + offerPayload.getSellerSecurityDeposit(); // arbitrator reserved balance is sum of amounts sent to multisig
|
reservedAmt = offerPayload.getAmount() + offerPayload.getBuyerSecurityDeposit() + offerPayload.getSellerSecurityDeposit(); // arbitrator reserved balance is sum of amounts sent to multisig
|
||||||
} else {
|
} else {
|
||||||
reservedAmt = trade.getContract().isMyRoleBuyer(tradeManager.getKeyRing().getPubKeyRing()) ? offerPayload.getBuyerSecurityDeposit() : offerPayload.getAmount() + offerPayload.getSellerSecurityDeposit();
|
reservedAmt = trade.getContract().isMyRoleBuyer(tradeManager.getKeyRing().getPubKeyRing()) ? offerPayload.getBuyerSecurityDeposit() : offerPayload.getAmount() + offerPayload.getSellerSecurityDeposit();
|
||||||
|
@ -22,7 +22,6 @@ import bisq.core.monetary.Volume;
|
|||||||
import bisq.core.offer.Offer;
|
import bisq.core.offer.Offer;
|
||||||
import bisq.core.offer.OpenOffer;
|
import bisq.core.offer.OpenOffer;
|
||||||
import bisq.core.provider.price.PriceFeedService;
|
import bisq.core.provider.price.PriceFeedService;
|
||||||
import bisq.core.trade.protocol.TradingPeer;
|
|
||||||
import bisq.core.trade.statistics.TradeStatisticsManager;
|
import bisq.core.trade.statistics.TradeStatisticsManager;
|
||||||
import bisq.core.user.Preferences;
|
import bisq.core.user.Preferences;
|
||||||
|
|
||||||
@ -192,10 +191,9 @@ public class ClosedTradableManager implements PersistedDataHost {
|
|||||||
if (isOpenOffer(tradable)) {
|
if (isOpenOffer(tradable)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
NodeAddress addressInTrade = castToTradeModel(tradable).getTradingPeer().getNodeAddress();
|
NodeAddress addressInTrade = castToTradeModel(tradable).getTradingPeerNodeAddress();
|
||||||
return (int) getTradeModelStream()
|
return (int) getTradeModelStream()
|
||||||
.map(Trade::getTradingPeer)
|
.map(Trade::getTradingPeerNodeAddress)
|
||||||
.map(TradingPeer::getNodeAddress)
|
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.filter(address -> address.equals(addressInTrade))
|
.filter(address -> address.equals(addressInTrade))
|
||||||
.count();
|
.count();
|
||||||
|
@ -76,6 +76,6 @@ public interface Tradable extends PersistablePayload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default Optional<NodeAddress> getOptionalTradingPeerNodeAddress() {
|
default Optional<NodeAddress> getOptionalTradingPeerNodeAddress() {
|
||||||
return asTradeModel().map(Trade::getTradingPeer).map(TradingPeer::getNodeAddress);
|
return asTradeModel().map(Trade::getTradingPeerNodeAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -600,7 +600,7 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initialize(ProcessModelServiceProvider serviceProvider) {
|
public void initialize(ProcessModelServiceProvider serviceProvider) {
|
||||||
serviceProvider.getArbitratorManager().getDisputeAgentByNodeAddress(getArbitrator().getNodeAddress()).ifPresent(arbitrator -> {
|
serviceProvider.getArbitratorManager().getDisputeAgentByNodeAddress(getArbitratorNodeAddress()).ifPresent(arbitrator -> {
|
||||||
getArbitrator().setPubKeyRing(arbitrator.getPubKeyRing());
|
getArbitrator().setPubKeyRing(arbitrator.getPubKeyRing());
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -616,6 +616,14 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
getSelf().setNodeAddress(P2PService.getMyNodeAddress());
|
getSelf().setNodeAddress(P2PService.getMyNodeAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NodeAddress getTradingPeerNodeAddress() {
|
||||||
|
return getTradingPeer() == null ? null : getTradingPeer().getNodeAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeAddress getArbitratorNodeAddress() {
|
||||||
|
return getArbitrator() == null ? null : getArbitrator().getNodeAddress();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a contract based on the current state.
|
* Create a contract based on the current state.
|
||||||
*
|
*
|
||||||
|
@ -837,7 +837,6 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||||||
|
|
||||||
// If trade was completed (closed without fault but might be closed by a dispute) we move it to the closed trades
|
// If trade was completed (closed without fault but might be closed by a dispute) we move it to the closed trades
|
||||||
public void onTradeCompleted(Trade trade) {
|
public void onTradeCompleted(Trade trade) {
|
||||||
if (trade.getState() == Trade.State.WITHDRAW_COMPLETED) return;
|
|
||||||
closedTradableManager.add(trade);
|
closedTradableManager.add(trade);
|
||||||
trade.setState(Trade.State.WITHDRAW_COMPLETED);
|
trade.setState(Trade.State.WITHDRAW_COMPLETED);
|
||||||
maybeRemoveTrade(trade);
|
maybeRemoveTrade(trade);
|
||||||
|
@ -81,7 +81,7 @@ public final class TradeStatistics2 implements ProcessOncePersistableNetworkPayl
|
|||||||
extraDataMap.put(OfferPayload.REFERRAL_ID, referralId);
|
extraDataMap.put(OfferPayload.REFERRAL_ID, referralId);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeAddress arbitratorNodeAddress = trade.getArbitrator().getNodeAddress();
|
NodeAddress arbitratorNodeAddress = trade.getArbitratorNodeAddress();
|
||||||
if (arbitratorNodeAddress != null) {
|
if (arbitratorNodeAddress != null) {
|
||||||
// The first 4 chars are sufficient to identify a arbitrator.
|
// The first 4 chars are sufficient to identify a arbitrator.
|
||||||
// For testing with regtest/localhost we use the full address as its localhost and would result in
|
// For testing with regtest/localhost we use the full address as its localhost and would result in
|
||||||
|
@ -208,7 +208,7 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
|
|||||||
rows++;
|
rows++;
|
||||||
if (trade.hasFailed())
|
if (trade.hasFailed())
|
||||||
rows += 2;
|
rows += 2;
|
||||||
if (trade.getTradingPeer().getNodeAddress() != null)
|
if (trade.getTradingPeerNodeAddress() != null)
|
||||||
rows++;
|
rows++;
|
||||||
if (showXmrProofResult)
|
if (showXmrProofResult)
|
||||||
rows++;
|
rows++;
|
||||||
@ -232,16 +232,16 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
|
|||||||
Res.get("shared.takerTxFee", formatter.formatCoinWithCode(trade.getTxFee().multiply(3)));
|
Res.get("shared.takerTxFee", formatter.formatCoinWithCode(trade.getTxFee().multiply(3)));
|
||||||
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.txFee"), txFee);
|
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.txFee"), txFee);
|
||||||
|
|
||||||
NodeAddress arbitratorNodeAddress = trade.getArbitrator().getNodeAddress();
|
NodeAddress arbitratorNodeAddress = trade.getArbitratorNodeAddress();
|
||||||
if (arbitratorNodeAddress != null) {
|
if (arbitratorNodeAddress != null) {
|
||||||
addConfirmationLabelTextField(gridPane, ++rowIndex,
|
addConfirmationLabelTextField(gridPane, ++rowIndex,
|
||||||
Res.get("tradeDetailsWindow.agentAddresses"),
|
Res.get("tradeDetailsWindow.agentAddresses"),
|
||||||
arbitratorNodeAddress.getFullAddress());
|
arbitratorNodeAddress.getFullAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trade.getTradingPeer().getNodeAddress() != null)
|
if (trade.getTradingPeerNodeAddress() != null)
|
||||||
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradingPeersOnion"),
|
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradingPeersOnion"),
|
||||||
trade.getTradingPeer().getNodeAddress().getFullAddress());
|
trade.getTradingPeerNodeAddress().getFullAddress());
|
||||||
|
|
||||||
if (showXmrProofResult) {
|
if (showXmrProofResult) {
|
||||||
// As the window is already overloaded we replace the tradingPeersPubKeyHash field with the auto-conf state
|
// As the window is already overloaded we replace the tradingPeersPubKeyHash field with the auto-conf state
|
||||||
|
@ -501,7 +501,7 @@ public class ClosedTradesView extends ActivatableViewAndModel<VBox, ClosedTrades
|
|||||||
if (!empty && item != null && item.getTradable() instanceof Trade) {
|
if (!empty && item != null && item.getTradable() instanceof Trade) {
|
||||||
Trade tradeModel = (Trade) item.getTradable();
|
Trade tradeModel = (Trade) item.getTradable();
|
||||||
int numPastTrades = item.getNumPastTrades();
|
int numPastTrades = item.getNumPastTrades();
|
||||||
NodeAddress tradingPeerNodeAddress = tradeModel.getTradingPeer().getNodeAddress();
|
NodeAddress tradingPeerNodeAddress = tradeModel.getTradingPeerNodeAddress();
|
||||||
String role = Res.get("peerInfoIcon.tooltip.tradePeer");
|
String role = Res.get("peerInfoIcon.tooltip.tradePeer");
|
||||||
Node peerInfoIcon = new PeerInfoIconTrading(tradingPeerNodeAddress,
|
Node peerInfoIcon = new PeerInfoIconTrading(tradingPeerNodeAddress,
|
||||||
role,
|
role,
|
||||||
|
@ -849,7 +849,7 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
|
|||||||
super.updateItem(newItem, empty);
|
super.updateItem(newItem, empty);
|
||||||
if (!empty && newItem != null) {
|
if (!empty && newItem != null) {
|
||||||
final Trade trade = newItem.getTrade();
|
final Trade trade = newItem.getTrade();
|
||||||
final NodeAddress tradingPeerNodeAddress = trade.getTradingPeer() == null ? null : trade.getTradingPeer().getNodeAddress();
|
final NodeAddress tradingPeerNodeAddress = trade.getTradingPeerNodeAddress();
|
||||||
int numPastTrades = model.getNumPastTrades(trade);
|
int numPastTrades = model.getNumPastTrades(trade);
|
||||||
String role = Res.get("peerInfoIcon.tooltip.tradePeer");
|
String role = Res.get("peerInfoIcon.tooltip.tradePeer");
|
||||||
Node peerInfoIcon = new PeerInfoIconTrading(tradingPeerNodeAddress, // TODO: display maker and taker node addresses for arbitrator
|
Node peerInfoIcon = new PeerInfoIconTrading(tradingPeerNodeAddress, // TODO: display maker and taker node addresses for arbitrator
|
||||||
|
@ -372,9 +372,9 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||||||
.filter(e -> {
|
.filter(e -> {
|
||||||
if (e instanceof Trade) {
|
if (e instanceof Trade) {
|
||||||
Trade t = (Trade) e;
|
Trade t = (Trade) e;
|
||||||
return t.getTradingPeer().getNodeAddress() != null &&
|
return t.getTradingPeerNodeAddress() != null &&
|
||||||
trade.getTradingPeer().getNodeAddress() != null &&
|
trade.getTradingPeerNodeAddress() != null &&
|
||||||
t.getTradingPeer().getNodeAddress().getFullAddress().equals(trade.getTradingPeer().getNodeAddress().getFullAddress());
|
t.getTradingPeerNodeAddress().getFullAddress().equals(trade.getTradingPeerNodeAddress().getFullAddress());
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user