Add API functions to initialize Haveno account (#216)

Co-authored-by: woodser@protonmail.com
This commit is contained in:
duriancrepe 2022-02-09 01:39:57 -08:00 committed by GitHub
parent dc4692d97a
commit e3b9a9962b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
81 changed files with 2755 additions and 1660 deletions

View file

@ -40,9 +40,9 @@ import bisq.desktop.util.GUIUtil;
import bisq.core.account.sign.SignedWitnessService;
import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.alert.PrivateNotificationManager;
import bisq.core.api.CoreMoneroConnectionsService;
import bisq.core.app.HavenoSetup;
import bisq.core.btc.nodes.LocalBitcoinNode;
import bisq.core.btc.setup.WalletsSetup;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.locale.CryptoCurrency;
import bisq.core.locale.CurrencyUtil;
@ -53,7 +53,6 @@ import bisq.core.payment.AliPayAccount;
import bisq.core.payment.AmazonGiftCardAccount;
import bisq.core.payment.CryptoCurrencyAccount;
import bisq.core.payment.RevolutAccount;
import bisq.core.payment.payload.AssetsAccountPayload;
import bisq.core.presentation.BalancePresentation;
import bisq.core.presentation.SupportTicketsPresentation;
import bisq.core.presentation.TradePresentation;
@ -109,7 +108,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener {
private final HavenoSetup bisqSetup;
private final WalletsSetup walletsSetup;
private final CoreMoneroConnectionsService connectionService;
private final User user;
private final BalancePresentation balancePresentation;
private final TradePresentation tradePresentation;
@ -140,7 +139,7 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener
private final DoubleProperty combinedSyncProgress = new SimpleDoubleProperty(-1);
private final BooleanProperty isSplashScreenRemoved = new SimpleBooleanProperty();
private final StringProperty footerVersionInfo = new SimpleStringProperty();
private Timer checkNumberOfBtcPeersTimer;
private Timer checkNumberOfXmrPeersTimer;
private Timer checkNumberOfP2pNetworkPeersTimer;
@SuppressWarnings("FieldCanBeLocal")
private MonadicBinding<Boolean> tradesAndUIReady;
@ -153,7 +152,7 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener
@Inject
public MainViewModel(HavenoSetup bisqSetup,
WalletsSetup walletsSetup,
CoreMoneroConnectionsService connectionService,
BtcWalletService btcWalletService,
User user,
BalancePresentation balancePresentation,
@ -178,7 +177,7 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener
TorNetworkSettingsWindow torNetworkSettingsWindow,
CorruptedStorageFileHandler corruptedStorageFileHandler) {
this.bisqSetup = bisqSetup;
this.walletsSetup = walletsSetup;
this.connectionService = connectionService;
this.user = user;
this.balancePresentation = balancePresentation;
this.tradePresentation = tradePresentation;
@ -258,7 +257,7 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener
});
setupP2PNumPeersWatcher();
setupBtcNumPeersWatcher();
setupXmrNumPeersWatcher();
marketPricePresentation.setup();
accountPresentation.setup();
@ -509,19 +508,19 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener
});
}
private void setupBtcNumPeersWatcher() {
walletsSetup.numPeersProperty().addListener((observable, oldValue, newValue) -> {
private void setupXmrNumPeersWatcher() {
connectionService.numPeersProperty().addListener((observable, oldValue, newValue) -> {
int numPeers = (int) newValue;
if ((int) oldValue > 0 && numPeers == 0) {
if (checkNumberOfBtcPeersTimer != null)
checkNumberOfBtcPeersTimer.stop();
if (checkNumberOfXmrPeersTimer != null)
checkNumberOfXmrPeersTimer.stop();
checkNumberOfBtcPeersTimer = UserThread.runAfter(() -> {
checkNumberOfXmrPeersTimer = UserThread.runAfter(() -> {
// check again numPeers
if (walletsSetup.numPeersProperty().get() == 0) {
if (connectionService.numPeersProperty().get() == 0) {
if (localBitcoinNode.shouldBeUsed())
getWalletServiceErrorMsg().set(
Res.get("mainView.networkWarning.localhostBitcoinLost",
Res.get("mainView.networkWarning.localhostBitcoinLost", // TODO: update error message for XMR
Res.getBaseCurrencyName().toLowerCase()));
else
getWalletServiceErrorMsg().set(
@ -532,8 +531,8 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener
}
}, 5);
} else if ((int) oldValue == 0 && numPeers > 0) {
if (checkNumberOfBtcPeersTimer != null)
checkNumberOfBtcPeersTimer.stop();
if (checkNumberOfXmrPeersTimer != null)
checkNumberOfXmrPeersTimer.stop();
getWalletServiceErrorMsg().set(null);
}
});

View file

@ -33,9 +33,8 @@ import bisq.desktop.util.Layout;
import bisq.desktop.util.validation.PasswordValidator;
import bisq.core.btc.wallet.WalletsManager;
import bisq.core.crypto.ScryptUtil;
import bisq.core.locale.Res;
import bisq.common.crypto.ScryptUtil;
import bisq.common.util.Tuple4;
import org.bitcoinj.crypto.KeyCrypterScrypt;

View file

@ -61,7 +61,6 @@ import bisq.core.trade.protocol.tasks.seller_as_maker.SellerAsMakerFinalizesDepo
import bisq.core.trade.protocol.tasks.seller_as_maker.SellerAsMakerSendsInputsForDepositTxResponse;
import bisq.core.trade.protocol.tasks.seller_as_taker.SellerAsTakerCreatesDepositTxInputs;
import bisq.core.trade.protocol.tasks.seller_as_taker.SellerAsTakerSignsDepositTx;
import bisq.core.trade.protocol.tasks.taker.TakerCreateFeeTx;
import bisq.core.trade.protocol.tasks.taker.TakerProcessesInputsForDepositTxResponse;
import bisq.core.trade.protocol.tasks.taker.TakerPublishFeeTx;
import bisq.core.trade.protocol.tasks.taker.TakerVerifyMakerFeePayment;
@ -119,7 +118,6 @@ public class DebugView extends InitializableView<GridPane, Void> {
FXCollections.observableArrayList(Arrays.asList(
ApplyFilter.class,
TakerVerifyMakerFeePayment.class,
TakerCreateFeeTx.class, // TODO (woodser): rename to TakerCreateFeeTx
SellerAsTakerCreatesDepositTxInputs.class,
TakerProcessesInputsForDepositTxResponse.class,
@ -182,7 +180,6 @@ public class DebugView extends InitializableView<GridPane, Void> {
FXCollections.observableArrayList(Arrays.asList(
ApplyFilter.class,
TakerVerifyMakerFeePayment.class,
TakerCreateFeeTx.class,
BuyerAsTakerCreatesDepositTxInputs.class,
TakerProcessesInputsForDepositTxResponse.class,

View file

@ -24,7 +24,7 @@ import bisq.core.support.dispute.refund.RefundManager;
import bisq.core.trade.Tradable;
import bisq.core.trade.Trade;
import bisq.common.crypto.PubKeyRing;
import bisq.common.crypto.PubKeyRingProvider;
import javax.inject.Inject;
import javax.inject.Singleton;
@ -35,17 +35,17 @@ public class TransactionAwareTradableFactory {
private final ArbitrationManager arbitrationManager;
private final RefundManager refundManager;
private final XmrWalletService xmrWalletService;
private final PubKeyRing pubKeyRing;
private final PubKeyRingProvider pubKeyRingProvider;
@Inject
TransactionAwareTradableFactory(ArbitrationManager arbitrationManager,
RefundManager refundManager,
XmrWalletService xmrWalletService,
PubKeyRing pubKeyRing) {
PubKeyRingProvider pubKeyRingProvider) {
this.arbitrationManager = arbitrationManager;
this.refundManager = refundManager;
this.xmrWalletService = xmrWalletService;
this.pubKeyRing = pubKeyRing;
this.pubKeyRingProvider = pubKeyRingProvider;
}
TransactionAwareTradable create(Tradable delegate) {
@ -56,7 +56,7 @@ public class TransactionAwareTradableFactory {
arbitrationManager,
refundManager,
xmrWalletService,
pubKeyRing);
pubKeyRingProvider.get());
} else {
return new DummyTransactionAwareTradable(delegate);
}

View file

@ -28,8 +28,7 @@ import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
import bisq.desktop.util.GUIUtil;
import bisq.core.btc.setup.WalletsSetup;
import bisq.core.api.CoreMoneroConnectionsService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.locale.Res;
import bisq.core.offer.OpenOffer;
@ -103,7 +102,7 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
private final BtcWalletService btcWalletService;
private final P2PService p2PService;
private final WalletsSetup walletsSetup;
private final CoreMoneroConnectionsService connectionService;
private final Preferences preferences;
private final TradeDetailsWindow tradeDetailsWindow;
private final OfferDetailsWindow offerDetailsWindow;
@ -120,14 +119,14 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
@Inject
private TransactionsView(BtcWalletService btcWalletService,
P2PService p2PService,
WalletsSetup walletsSetup,
CoreMoneroConnectionsService connectionService,
Preferences preferences,
TradeDetailsWindow tradeDetailsWindow,
OfferDetailsWindow offerDetailsWindow,
DisplayedTransactionsFactory displayedTransactionsFactory) {
this.btcWalletService = btcWalletService;
this.p2PService = p2PService;
this.walletsSetup = walletsSetup;
this.connectionService = connectionService;
this.preferences = preferences;
this.tradeDetailsWindow = tradeDetailsWindow;
this.offerDetailsWindow = offerDetailsWindow;
@ -537,7 +536,7 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
}
private void revertTransaction(String txId, @Nullable Tradable tradable) {
if (GUIUtil.isReadyForTxBroadcastOrShowPopup(p2PService, walletsSetup)) {
if (GUIUtil.isReadyForTxBroadcastOrShowPopup(p2PService, connectionService)) {
try {
btcWalletService.doubleSpendTransaction(txId, () -> {
if (tradable != null)

View file

@ -27,7 +27,7 @@ import bisq.desktop.util.DisplayUtils;
import bisq.desktop.util.GUIUtil;
import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.btc.setup.WalletsSetup;
import bisq.core.api.CoreMoneroConnectionsService;
import bisq.core.locale.BankUtil;
import bisq.core.locale.CountryUtil;
import bisq.core.locale.CryptoCurrency;
@ -97,8 +97,8 @@ class OfferBookViewModel extends ActivatableViewModel {
private final User user;
private final OfferBook offerBook;
final Preferences preferences;
private final WalletsSetup walletsSetup;
private final P2PService p2PService;
private final CoreMoneroConnectionsService connectionService;
final PriceFeedService priceFeedService;
private final ClosedTradableManager closedTradableManager;
final AccountAgeWitnessService accountAgeWitnessService;
@ -142,7 +142,7 @@ class OfferBookViewModel extends ActivatableViewModel {
OpenOfferManager openOfferManager,
OfferBook offerBook,
Preferences preferences,
WalletsSetup walletsSetup,
CoreMoneroConnectionsService connectionService,
P2PService p2PService,
PriceFeedService priceFeedService,
ClosedTradableManager closedTradableManager,
@ -157,7 +157,7 @@ class OfferBookViewModel extends ActivatableViewModel {
this.user = user;
this.offerBook = offerBook;
this.preferences = preferences;
this.walletsSetup = walletsSetup;
this.connectionService = connectionService;
this.p2PService = p2PService;
this.priceFeedService = priceFeedService;
this.closedTradableManager = closedTradableManager;
@ -561,7 +561,7 @@ class OfferBookViewModel extends ActivatableViewModel {
boolean canCreateOrTakeOffer() {
return GUIUtil.canCreateOrTakeOfferOrShowPopup(user, navigation) &&
GUIUtil.isChainHeightSyncedWithinToleranceOrShowPopup(walletsSetup) &&
GUIUtil.isChainHeightSyncedWithinToleranceOrShowPopup(connectionService) &&
GUIUtil.isBootstrappedOrShowPopup(p2PService);
}

View file

@ -6,8 +6,7 @@ import bisq.desktop.main.overlays.Overlay;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.util.GUIUtil;
import bisq.desktop.util.Transitions;
import bisq.core.btc.setup.WalletsSetup;
import bisq.core.api.CoreMoneroConnectionsService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.btc.wallet.Restrictions;
import bisq.core.locale.Res;
@ -53,7 +52,7 @@ public final class BtcEmptyWalletWindow extends Overlay<BtcEmptyWalletWindow> {
private final WalletPasswordWindow walletPasswordWindow;
private final OpenOfferManager openOfferManager;
private final P2PService p2PService;
private final WalletsSetup walletsSetup;
private final CoreMoneroConnectionsService connectionService;
private final BtcWalletService btcWalletService;
private final CoinFormatter btcFormatter;
@ -65,7 +64,7 @@ public final class BtcEmptyWalletWindow extends Overlay<BtcEmptyWalletWindow> {
public BtcEmptyWalletWindow(WalletPasswordWindow walletPasswordWindow,
OpenOfferManager openOfferManager,
P2PService p2PService,
WalletsSetup walletsSetup,
CoreMoneroConnectionsService connectionService,
BtcWalletService btcWalletService,
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter) {
headLine(Res.get("emptyWalletWindow.headline", "BTC"));
@ -73,13 +72,14 @@ public final class BtcEmptyWalletWindow extends Overlay<BtcEmptyWalletWindow> {
type = Type.Instruction;
this.p2PService = p2PService;
this.walletsSetup = walletsSetup;
this.connectionService = connectionService;
this.btcWalletService = btcWalletService;
this.btcFormatter = btcFormatter;
this.walletPasswordWindow = walletPasswordWindow;
this.openOfferManager = openOfferManager;
}
@Override
public void show() {
createGridPane();
addHeadLine();
@ -143,7 +143,7 @@ public final class BtcEmptyWalletWindow extends Overlay<BtcEmptyWalletWindow> {
}
private void doEmptyWallet(KeyParameter aesKey) {
if (GUIUtil.isReadyForTxBroadcastOrShowPopup(p2PService, walletsSetup)) {
if (GUIUtil.isReadyForTxBroadcastOrShowPopup(p2PService, connectionService)) {
if (!openOfferManager.getObservableList().isEmpty()) {
UserThread.runAfter(() ->
new Popup().warning(Res.get("emptyWalletWindow.openOffers.warn"))

View file

@ -25,11 +25,10 @@ import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.util.GUIUtil;
import bisq.desktop.util.validation.LengthValidator;
import bisq.desktop.util.validation.PercentageNumberValidator;
import bisq.core.api.CoreMoneroConnectionsService;
import bisq.core.btc.exceptions.TransactionVerificationException;
import bisq.core.btc.exceptions.TxBroadcastException;
import bisq.core.btc.exceptions.WalletException;
import bisq.core.btc.setup.WalletsSetup;
import bisq.core.btc.wallet.TradeWalletService;
import bisq.core.btc.wallet.TxBroadcaster;
import bisq.core.btc.wallet.WalletsManager;
@ -92,7 +91,6 @@ import java.time.Instant;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
@ -111,7 +109,7 @@ public class ManualPayoutTxWindow extends Overlay<ManualPayoutTxWindow> {
private final P2PService p2PService;
private final MediationManager mediationManager;
private final Preferences preferences;
private final WalletsSetup walletsSetup;
private final CoreMoneroConnectionsService connectionService;
private final WalletsManager walletsManager;
GridPane inputsGridPane;
GridPane importTxGridPane;
@ -150,17 +148,18 @@ public class ManualPayoutTxWindow extends Overlay<ManualPayoutTxWindow> {
P2PService p2PService,
MediationManager mediationManager,
Preferences preferences,
WalletsSetup walletsSetup,
CoreMoneroConnectionsService connectionService,
WalletsManager walletsManager) {
this.tradeWalletService = tradeWalletService;
this.p2PService = p2PService;
this.mediationManager = mediationManager;
this.preferences = preferences;
this.walletsSetup = walletsSetup;
this.connectionService = connectionService;
this.walletsManager = walletsManager;
type = Type.Attention;
}
@Override
public void show() {
if (headLine == null)
headLine = "Emergency MultiSig payout tool"; // We dont translate here as it is for dev only purpose
@ -810,7 +809,7 @@ public class ManualPayoutTxWindow extends Overlay<ManualPayoutTxWindow> {
}
};
if (GUIUtil.isReadyForTxBroadcastOrShowPopup(p2PService, walletsSetup)) {
if (GUIUtil.isReadyForTxBroadcastOrShowPopup(p2PService, connectionService)) {
try {
tradeWalletService.emergencyPublishPayoutTxFrom2of2MultiSig(
txIdAndHex.second,

View file

@ -28,12 +28,12 @@ import bisq.desktop.util.Layout;
import bisq.desktop.util.Transitions;
import bisq.core.btc.wallet.WalletsManager;
import bisq.core.crypto.ScryptUtil;
import bisq.core.locale.Res;
import bisq.core.offer.OpenOfferManager;
import bisq.common.UserThread;
import bisq.common.config.Config;
import bisq.common.crypto.ScryptUtil;
import bisq.common.util.Tuple2;
import org.bitcoinj.crypto.KeyCrypterScrypt;

View file

@ -29,7 +29,7 @@ import bisq.desktop.main.support.dispute.client.mediation.MediationClientView;
import bisq.desktop.util.GUIUtil;
import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.btc.setup.WalletsSetup;
import bisq.core.api.CoreMoneroConnectionsService;
import bisq.core.btc.wallet.XmrWalletService;
import bisq.core.locale.Res;
import bisq.core.offer.Offer;
@ -55,6 +55,7 @@ import bisq.core.user.Preferences;
import bisq.network.p2p.P2PService;
import bisq.common.crypto.PubKeyRing;
import bisq.common.crypto.PubKeyRingProvider;
import bisq.common.handlers.ErrorMessageHandler;
import bisq.common.handlers.FaultHandler;
import bisq.common.handlers.ResultHandler;
@ -97,7 +98,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
public final ArbitrationManager arbitrationManager;
public final MediationManager mediationManager;
private final P2PService p2PService;
private final WalletsSetup walletsSetup;
private final CoreMoneroConnectionsService connectionService;
@Getter
private final AccountAgeWitnessService accountAgeWitnessService;
public final Navigation navigation;
@ -120,7 +121,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
private ChangeListener<Trade.State> tradeStateChangeListener;
private Trade selectedTrade;
@Getter
private final PubKeyRing pubKeyRing;
private final PubKeyRingProvider pubKeyRingProvider;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor, initialization
@ -129,13 +130,13 @@ public class PendingTradesDataModel extends ActivatableDataModel {
@Inject
public PendingTradesDataModel(TradeManager tradeManager,
XmrWalletService xmrWalletService,
PubKeyRing pubKeyRing,
PubKeyRingProvider pubKeyRingProvider,
ArbitrationManager arbitrationManager,
MediationManager mediationManager,
TraderChatManager traderChatManager,
Preferences preferences,
P2PService p2PService,
WalletsSetup walletsSetup,
CoreMoneroConnectionsService connectionService,
AccountAgeWitnessService accountAgeWitnessService,
Navigation navigation,
WalletPasswordWindow walletPasswordWindow,
@ -143,13 +144,13 @@ public class PendingTradesDataModel extends ActivatableDataModel {
OfferUtil offerUtil) {
this.tradeManager = tradeManager;
this.xmrWalletService = xmrWalletService;
this.pubKeyRing = pubKeyRing;
this.pubKeyRingProvider = pubKeyRingProvider;
this.arbitrationManager = arbitrationManager;
this.mediationManager = mediationManager;
this.traderChatManager = traderChatManager;
this.preferences = preferences;
this.p2PService = p2PService;
this.walletsSetup = walletsSetup;
this.connectionService = connectionService;
this.accountAgeWitnessService = accountAgeWitnessService;
this.navigation = navigation;
this.walletPasswordWindow = walletPasswordWindow;
@ -513,11 +514,11 @@ public class PendingTradesDataModel extends ActivatableDataModel {
byte[] depositTxSerialized = null; // depositTx.bitcoinSerialize(); // TODO (woodser): no serialized txs in xmr
Dispute dispute = new Dispute(new Date().getTime(),
trade.getId(),
pubKeyRing.hashCode(), // traderId
pubKeyRingProvider.get().hashCode(), // trader id
true,
(offer.getDirection() == OfferPayload.Direction.BUY) == isMaker,
isMaker,
pubKeyRing,
pubKeyRingProvider.get(),
trade.getDate().getTime(),
trade.getMaxTradePeriodDate().getTime(),
trade.getContract(),
@ -549,11 +550,11 @@ public class PendingTradesDataModel extends ActivatableDataModel {
String depositTxHashAsString = null; // depositTx.getHashAsString(); TODO (woodser)
Dispute dispute = new Dispute(new Date().getTime(),
trade.getId(),
pubKeyRing.hashCode(), // traderId,
pubKeyRingProvider.get().hashCode(), // trader id,
true,
(offer.getDirection() == OfferPayload.Direction.BUY) == isMaker,
isMaker,
pubKeyRing,
pubKeyRingProvider.get(),
trade.getDate().getTime(),
trade.getMaxTradePeriodDate().getTime(),
trade.getContract(),
@ -595,7 +596,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
}
public boolean isReadyForTxBroadcast() {
return GUIUtil.isReadyForTxBroadcastOrShowPopup(p2PService, walletsSetup);
return GUIUtil.isReadyForTxBroadcastOrShowPopup(p2PService, connectionService);
}
public boolean isBootstrappedOrShowPopup() {

View file

@ -398,7 +398,7 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
return Res.get("portfolio.pending.failedTrade.missingContract");
}
PubKeyRing myPubKeyRing = model.dataModel.getPubKeyRing();
PubKeyRing myPubKeyRing = model.dataModel.getPubKeyRingProvider().get();
boolean isMyRoleBuyer = contract.isMyRoleBuyer(myPubKeyRing);
boolean isMyRoleMaker = contract.isMyRoleMaker(myPubKeyRing);
@ -411,7 +411,7 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
if (trade.getMakerDepositTx() == null) {
return Res.get("portfolio.pending.failedTrade.missingDepositTx");
}
if (trade.getTakerDepositTx() == null) {
return Res.get("portfolio.pending.failedTrade.missingDepositTx"); // TODO (woodser): use .missingTakerDepositTx, .missingMakerDepositTx
}

View file

@ -409,11 +409,11 @@ public abstract class TradeStepView extends AnchorPane {
private void updateTimeLeft() {
if (timeLeftTextField != null) {
// TODO (woodser): extra TradeStepView created but not deactivated on trade.setState(), so deactivate when model's trade is null
if (model.dataModel.getTrade() == null) {
log.warn("deactivating TradeStepView because model's trade is null");
// schedule deactivation to avoid concurrent modification of clock listeners
Platform.runLater(new Runnable() {
@Override
@ -423,7 +423,7 @@ public abstract class TradeStepView extends AnchorPane {
});
return;
}
String remainingTime = model.getRemainingTradeDurationAsWords();
timeLeftProgressBar.setProgress(model.getRemainingTradeDurationAsPercentage());
if (!remainingTime.isEmpty()) {
@ -675,7 +675,7 @@ public abstract class TradeStepView extends AnchorPane {
DisputeResult disputeResult = optionalDispute.get().getDisputeResultProperty().get();
Contract contract = checkNotNull(trade.getContract(), "contract must not be null");
boolean isMyRoleBuyer = contract.isMyRoleBuyer(model.dataModel.getPubKeyRing());
boolean isMyRoleBuyer = contract.isMyRoleBuyer(model.dataModel.getPubKeyRingProvider().get());
String buyerPayoutAmount = model.btcFormatter.formatCoinWithCode(disputeResult.getBuyerPayoutAmount());
String sellerPayoutAmount = model.btcFormatter.formatCoinWithCode(disputeResult.getSellerPayoutAmount());
String myPayoutAmount = isMyRoleBuyer ? buyerPayoutAmount : sellerPayoutAmount;

View file

@ -28,6 +28,7 @@ import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.overlays.windows.TorNetworkSettingsWindow;
import bisq.desktop.util.GUIUtil;
import bisq.core.api.CoreMoneroConnectionsService;
import bisq.core.btc.nodes.BtcNodes;
import bisq.core.btc.nodes.LocalBitcoinNode;
import bisq.core.btc.setup.WalletsSetup;
@ -38,7 +39,6 @@ import bisq.core.user.Preferences;
import bisq.core.util.FormattingUtils;
import bisq.core.util.validation.RegexValidator;
import bisq.core.util.validation.RegexValidatorFactory;
import bisq.network.p2p.P2PService;
import bisq.network.p2p.network.Statistic;
@ -119,6 +119,7 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
private final ClockWatcher clockWatcher;
private final WalletsSetup walletsSetup;
private final P2PService p2PService;
private final CoreMoneroConnectionsService connectionManager;
private final ObservableList<P2pNetworkListItem> p2pNetworkListItems = FXCollections.observableArrayList();
private final SortedList<P2pNetworkListItem> p2pSortedList = new SortedList<>(p2pNetworkListItems);
@ -139,6 +140,7 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
@Inject
public NetworkSettingsView(WalletsSetup walletsSetup,
P2PService p2PService,
CoreMoneroConnectionsService connectionManager,
Preferences preferences,
BtcNodes btcNodes,
FilterManager filterManager,
@ -148,6 +150,7 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
super();
this.walletsSetup = walletsSetup;
this.p2PService = p2PService;
this.connectionManager = connectionManager;
this.preferences = preferences;
this.btcNodes = btcNodes;
this.filterManager = filterManager;
@ -291,10 +294,10 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
reSyncSPVChainButton.setOnAction(event -> GUIUtil.reSyncSPVChain(preferences));
moneroPeersSubscription = EasyBind.subscribe(walletsSetup.peerConnectionsProperty(),
moneroPeersSubscription = EasyBind.subscribe(connectionManager.peerConnectionsProperty(),
this::updateMoneroPeersTable);
moneroBlockHeightSubscription = EasyBind.subscribe(walletsSetup.chainHeightProperty(),
moneroBlockHeightSubscription = EasyBind.subscribe(connectionManager.chainHeightProperty(),
this::updateChainHeightTextField);
nodeAddressSubscription = EasyBind.subscribe(p2PService.getNetworkNode().nodeAddressProperty(),

View file

@ -30,29 +30,24 @@ import bisq.desktop.main.overlays.popups.Popup;
import bisq.core.account.witness.AccountAgeWitness;
import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.api.CoreMoneroConnectionsService;
import bisq.core.app.HavenoSetup;
import bisq.core.btc.setup.WalletsSetup;
import bisq.core.locale.Country;
import bisq.core.locale.CountryUtil;
import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency;
import bisq.core.monetary.Price;
import bisq.core.monetary.Volume;
import bisq.core.offer.OfferRestrictions;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.PaymentAccountList;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.provider.fee.FeeService;
import bisq.core.provider.price.MarketPrice;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.trade.txproof.AssetTxProofResult;
import bisq.core.user.DontShowAgainLookup;
import bisq.core.user.Preferences;
import bisq.core.user.User;
import bisq.core.util.FormattingUtils;
import bisq.core.util.coin.CoinFormatter;
import bisq.core.util.coin.CoinUtil;
import bisq.network.p2p.P2PService;
@ -63,7 +58,6 @@ import bisq.common.file.CorruptedStorageFileHandler;
import bisq.common.persistence.PersistenceManager;
import bisq.common.proto.persistable.PersistableEnvelope;
import bisq.common.proto.persistable.PersistenceProtoResolver;
import bisq.common.util.MathUtils;
import bisq.common.util.Tuple2;
import bisq.common.util.Tuple3;
import bisq.common.util.Utilities;
@ -72,7 +66,6 @@ import org.bitcoinj.core.Address;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.TransactionConfidence;
import org.bitcoinj.uri.BitcoinURI;
import org.bitcoinj.utils.Fiat;
import com.googlecode.jcsv.CSVStrategy;
import com.googlecode.jcsv.writer.CSVEntryConverter;
@ -757,17 +750,17 @@ public class GUIUtil {
return true;
}
public static boolean isReadyForTxBroadcastOrShowPopup(P2PService p2PService, WalletsSetup walletsSetup) {
public static boolean isReadyForTxBroadcastOrShowPopup(P2PService p2PService, CoreMoneroConnectionsService connectionService) {
if (!GUIUtil.isBootstrappedOrShowPopup(p2PService)) {
return false;
}
if (!walletsSetup.hasSufficientPeersForBroadcast()) {
new Popup().information(Res.get("popup.warning.notSufficientConnectionsToBtcNetwork", walletsSetup.getMinBroadcastConnections())).show();
if (!connectionService.hasSufficientPeersForBroadcast()) {
new Popup().information(Res.get("popup.warning.notSufficientConnectionsToBtcNetwork", connectionService.getMinBroadcastConnections())).show();
return false;
}
if (!walletsSetup.isDownloadComplete()) {
if (!connectionService.isDownloadComplete()) {
new Popup().information(Res.get("popup.warning.downloadNotComplete")).show();
return false;
}
@ -775,8 +768,8 @@ public class GUIUtil {
return true;
}
public static boolean isChainHeightSyncedWithinToleranceOrShowPopup(WalletsSetup walletsSetup) {
if (!walletsSetup.isChainHeightSyncedWithinTolerance()) {
public static boolean isChainHeightSyncedWithinToleranceOrShowPopup(CoreMoneroConnectionsService connectionService) {
if (!connectionService.isChainHeightSyncedWithinTolerance()) {
new Popup().information(Res.get("popup.warning.chainNotSynced")).show();
return false;
}