From c777133d369edefe7d9752f6a813ff1988ce4881 Mon Sep 17 00:00:00 2001 From: napoly Date: Sat, 9 Mar 2024 16:36:37 +0100 Subject: [PATCH] Support for open JDK 21 by updating dependencies (#647) --- .github/workflows/build.yml | 8 +- .github/workflows/codacy-code-reporter.yml | 8 +- .github/workflows/codeql-analysis.yml | 17 +- .github/workflows/label.yml | 2 +- build.gradle | 20 +- .../main/java/haveno/common/ClockWatcher.java | 5 +- .../java/haveno/common/crypto/KeyRing.java | 11 +- .../java/haveno/common/crypto/KeyStorage.java | 16 +- .../file/CorruptedStorageFileHandler.java | 7 +- .../persistence/PersistenceManager.java | 16 +- .../account/sign/SignedWitnessService.java | 9 +- .../sign/SignedWitnessStorageService.java | 7 +- .../witness/AccountAgeWitnessService.java | 14 +- .../AccountAgeWitnessStorageService.java | 7 +- .../java/haveno/core/alert/AlertManager.java | 14 +- .../alert/PrivateNotificationManager.java | 24 +- .../haveno/core/api/CoreAccountService.java | 14 +- .../main/java/haveno/core/api/CoreApi.java | 17 +- .../java/haveno/core/api/CoreContext.java | 5 +- .../core/api/CoreDisputeAgentsService.java | 24 +- .../haveno/core/api/CoreDisputesService.java | 12 +- .../java/haveno/core/api/CoreHelpService.java | 10 +- .../core/api/CoreNotificationService.java | 7 +- .../haveno/core/api/CoreOffersService.java | 24 +- .../core/api/CorePaymentAccountsService.java | 16 +- .../haveno/core/api/CorePriceService.java | 7 +- .../haveno/core/api/CoreTradesService.java | 14 +- .../haveno/core/api/CoreWalletsService.java | 26 +- .../haveno/core/api/XmrConnectionService.java | 19 +- .../java/haveno/core/api/XmrLocalNode.java | 16 +- .../java/haveno/core/app/AppStartupState.java | 5 +- .../core/app/AvoidStandbyModeService.java | 19 +- .../haveno/core/app/DomainInitialisation.java | 3 +- .../java/haveno/core/app/HavenoSetup.java | 37 ++- .../java/haveno/core/app/P2PNetworkSetup.java | 9 +- .../main/java/haveno/core/app/TorSetup.java | 14 +- .../java/haveno/core/app/WalletAppSetup.java | 13 +- .../java/haveno/core/app/misc/AppSetup.java | 3 +- .../haveno/core/app/misc/AppSetupWithP2P.java | 5 +- .../haveno/core/filter/FilterManager.java | 22 +- .../haveno/core/network/CoreBanFilter.java | 7 +- .../inventory/GetInventoryRequestHandler.java | 7 +- .../inventory/GetInventoryRequestManager.java | 5 +- .../p2p/seed/DefaultSeedNodeRepository.java | 7 +- .../MobileMessageEncryption.java | 11 +- .../core/notifications/MobileModel.java | 9 +- .../MobileNotificationService.java | 12 +- .../MobileNotificationValidator.java | 5 +- .../alerts/DisputeMsgEvents.java | 7 +- .../alerts/MyOfferTakenEvents.java | 7 +- .../notifications/alerts/TradeEvents.java | 9 +- .../alerts/market/MarketAlerts.java | 7 +- .../alerts/price/PriceAlert.java | 5 +- .../haveno/core/offer/CreateOfferService.java | 7 +- .../haveno/core/offer/OfferBookService.java | 12 +- .../haveno/core/offer/OfferFilterService.java | 13 +- .../java/haveno/core/offer/OfferUtil.java | 38 ++- .../haveno/core/offer/OpenOfferManager.java | 66 +++-- .../core/offer/TriggerPriceService.java | 14 +- .../core/offer/takeoffer/TakeOfferModel.java | 16 +- .../haveno/core/payment/ChargeBackRisk.java | 3 +- .../java/haveno/core/payment/TradeLimits.java | 9 +- .../validation/AdvancedCashValidator.java | 3 +- .../AustraliaPayidAccountNameValidator.java | 3 +- .../payment/validation/CapitualValidator.java | 3 +- .../validation/FiatVolumeValidator.java | 3 +- .../InteracETransferAnswerValidator.java | 3 +- .../InteracETransferQuestionValidator.java | 3 +- .../validation/InteracETransferValidator.java | 3 +- .../JapanBankAccountNameValidator.java | 3 +- .../JapanBankBranchNameValidator.java | 3 +- .../validation/SecurityDepositValidator.java | 3 +- .../validation/TransferwiseValidator.java | 3 +- .../core/payment/validation/XmrValidator.java | 9 +- .../presentation/BalancePresentation.java | 3 +- .../SupportTicketsPresentation.java | 3 +- .../core/presentation/TradePresentation.java | 3 +- .../network/CoreNetworkProtoResolver.java | 7 +- .../CorePersistenceProtoResolver.java | 5 +- .../haveno/core/provider/FeeHttpClient.java | 5 +- .../core/provider/MempoolHttpClient.java | 7 +- .../haveno/core/provider/PriceHttpClient.java | 5 +- .../core/provider/ProvidersRepository.java | 10 +- .../ArbitrationDisputeListService.java | 5 +- .../arbitrator/ArbitratorManager.java | 7 +- .../arbitrator/ArbitratorService.java | 3 +- .../MediationDisputeListService.java | 5 +- .../mediation/mediator/MediatorManager.java | 5 +- .../mediation/mediator/MediatorService.java | 5 +- .../refund/RefundDisputeListService.java | 5 +- .../refundagent/RefundAgentManager.java | 7 +- .../refundagent/RefundAgentService.java | 3 +- .../support/traderchat/TraderChatManager.java | 11 +- .../core/trade/CleanupMailboxMessages.java | 5 +- .../trade/CleanupMailboxMessagesService.java | 5 +- .../core/trade/ClosedTradableFormatter.java | 20 +- .../java/haveno/core/trade/TradeManager.java | 47 ++-- .../java/haveno/core/trade/TradeUtil.java | 22 +- .../protocol/ProcessModelServiceProvider.java | 3 +- .../trade/statistics/ReferralIdService.java | 5 +- .../TradeStatistics3StorageService.java | 9 +- .../statistics/TradeStatisticsManager.java | 13 +- .../java/haveno/core/user/Preferences.java | 34 ++- core/src/main/java/haveno/core/user/User.java | 26 +- .../main/java/haveno/core/util/PriceUtil.java | 14 +- .../util/coin/ImmutableCoinFormatter.java | 3 +- .../validation/AmountValidator4Decimals.java | 2 +- .../validation/AmountValidator8Decimals.java | 2 +- .../util/validation/BtcAddressValidator.java | 3 +- .../util/validation/MonetaryValidator.java | 3 +- .../main/java/haveno/core/xmr/Balances.java | 9 +- .../xmr/model/EncryptedConnectionList.java | 11 +- .../core/xmr/wallet/BtcWalletService.java | 22 +- .../core/xmr/wallet/NonBsqCoinSelector.java | 3 +- .../core/xmr/wallet/TradeWalletService.java | 16 +- .../haveno/core/xmr/wallet/WalletService.java | 28 +-- .../core/xmr/wallet/XmrWalletService.java | 88 ++++--- .../daemon/grpc/GrpcAccountService.java | 26 +- .../daemon/grpc/GrpcDisputeAgentsService.java | 14 +- .../daemon/grpc/GrpcDisputesService.java | 20 +- .../daemon/grpc/GrpcExceptionHandler.java | 16 +- .../grpc/GrpcGetTradeStatisticsService.java | 14 +- .../haveno/daemon/grpc/GrpcHelpService.java | 16 +- .../daemon/grpc/GrpcNotificationsService.java | 16 +- .../haveno/daemon/grpc/GrpcOffersService.java | 26 +- .../grpc/GrpcPaymentAccountsService.java | 22 +- .../haveno/daemon/grpc/GrpcPriceService.java | 8 +- .../java/haveno/daemon/grpc/GrpcServer.java | 10 +- .../daemon/grpc/GrpcShutdownService.java | 6 +- .../haveno/daemon/grpc/GrpcTradesService.java | 22 +- .../daemon/grpc/GrpcVersionService.java | 8 +- .../daemon/grpc/GrpcWalletsService.java | 28 +-- .../daemon/grpc/GrpcXmrConnectionService.java | 26 +- .../daemon/grpc/GrpcXmrNodeService.java | 20 +- .../interceptor/PasswordAuthInterceptor.java | 10 +- desktop/package/package.gradle | 59 +++-- .../main/java/haveno/desktop/Navigation.java | 11 +- .../desktop/common/fxml/FxmlViewLoader.java | 12 +- .../common/view/CachingViewLoader.java | 4 +- .../view/guice/InjectorViewFactory.java | 3 +- .../java/haveno/desktop/main/MainView.java | 45 ++-- .../desktop/main/account/AccountView.java | 5 +- .../account/content/backup/BackupView.java | 24 +- .../cryptoaccounts/CryptoAccountsView.java | 20 +- .../MobileNotificationsView.java | 20 +- .../content/password/PasswordView.java | 14 +- .../content/seedwords/SeedWordsView.java | 31 ++- .../TraditionalAccountsView.java | 28 +-- .../content/walletinfo/WalletInfoView.java | 14 +- .../ArbitratorRegistrationView.java | 5 +- .../mediator/MediatorRegistrationView.java | 5 +- .../RefundAgentRegistrationView.java | 5 +- .../account/register/signing/SigningView.java | 3 +- .../haveno/desktop/main/debug/DebugView.java | 8 +- .../haveno/desktop/main/funds/FundsView.java | 3 +- .../main/funds/deposit/DepositView.java | 28 +-- .../desktop/main/funds/locked/LockedView.java | 15 +- .../main/funds/reserved/ReservedView.java | 15 +- .../DisplayedTransactionsFactory.java | 5 +- .../transactions/TradableRepository.java | 5 +- .../TransactionAwareTradableFactory.java | 5 +- .../TransactionListItemFactory.java | 9 +- .../funds/transactions/TransactionsView.java | 7 +- .../main/funds/withdrawal/WithdrawalView.java | 18 +- .../desktop/main/market/MarketView.java | 9 +- .../market/offerbook/OfferBookChartView.java | 20 +- .../main/market/spread/SpreadView.java | 9 +- .../main/market/spread/SpreadViewModel.java | 17 +- .../spread/SpreadViewPaymentMethod.java | 8 +- .../main/market/trades/TradesChartsView.java | 24 +- .../desktop/main/offer/BuyOfferView.java | 3 +- .../main/offer/MutableOfferDataModel.java | 26 +- .../main/offer/MutableOfferViewModel.java | 22 +- .../desktop/main/offer/SellOfferView.java | 3 +- .../createoffer/CreateOfferDataModel.java | 3 +- .../offer/createoffer/CreateOfferView.java | 7 +- .../createoffer/CreateOfferViewModel.java | 5 +- .../main/offer/offerbook/OfferBook.java | 14 +- .../offer/offerbook/OtherOfferBookView.java | 5 +- .../offerbook/OtherOfferBookViewModel.java | 9 +- .../offerbook/TopCryptoOfferBookView.java | 5 +- .../TopCryptoOfferBookViewModel.java | 7 +- .../offer/offerbook/XmrOfferBookView.java | 5 +- .../offerbook/XmrOfferBookViewModel.java | 7 +- .../offer/signedoffer/SignedOfferView.java | 54 ++-- .../main/offer/takeoffer/TakeOfferView.java | 44 ++-- .../offer/takeoffer/TakeOfferViewModel.java | 12 +- .../notifications/NotificationCenter.java | 15 +- .../windows/ClosedTradesSummaryWindow.java | 12 +- .../main/overlays/windows/ContractWindow.java | 22 +- .../main/overlays/windows/FilterWindow.java | 20 +- .../overlays/windows/OfferDetailsWindow.java | 25 +- .../windows/SelectDepositTxWindow.java | 12 +- .../windows/SendAlertMessageWindow.java | 12 +- .../windows/SignPaymentAccountsWindow.java | 38 ++- .../windows/SignSpecificWitnessWindow.java | 16 +- .../windows/SignUnsignedPubKeysWindow.java | 16 +- .../windows/TorNetworkSettingsWindow.java | 26 +- .../overlays/windows/TradeDetailsWindow.java | 18 +- .../windows/WalletPasswordWindow.java | 30 ++- .../DisplayUpdateDownloadWindow.java | 31 ++- .../desktop/main/portfolio/PortfolioView.java | 5 +- .../closedtrades/ClosedTradesView.java | 12 +- .../DuplicateOfferDataModel.java | 3 +- .../duplicateoffer/DuplicateOfferView.java | 3 +- .../DuplicateOfferViewModel.java | 5 +- .../editoffer/EditOfferDataModel.java | 3 +- .../portfolio/editoffer/EditOfferView.java | 6 +- .../editoffer/EditOfferViewModel.java | 5 +- .../failedtrades/FailedTradesView.java | 7 +- .../failedtrades/FailedTradesViewModel.java | 3 +- .../portfolio/openoffer/OpenOffersView.java | 17 +- .../openoffer/OpenOffersViewModel.java | 6 +- .../pendingtrades/PendingTradesDataModel.java | 16 +- .../pendingtrades/PendingTradesView.java | 11 +- .../pendingtrades/PendingTradesViewModel.java | 26 +- .../pendingtrades/steps/TradeStepView.java | 27 +- .../presentation/AccountPresentation.java | 5 +- .../presentation/MarketPricePresentation.java | 13 +- .../presentation/SettingsPresentation.java | 5 +- .../desktop/main/settings/SettingsView.java | 3 +- .../main/settings/about/AboutView.java | 12 +- .../settings/network/NetworkSettingsView.java | 20 +- .../settings/preferences/PreferencesView.java | 40 ++- .../desktop/main/support/SupportView.java | 5 +- .../agent/arbitration/ArbitratorView.java | 5 +- .../dispute/agent/mediation/MediatorView.java | 5 +- .../dispute/agent/refund/RefundAgentView.java | 5 +- .../arbitration/ArbitrationClientView.java | 5 +- .../client/mediation/MediationClientView.java | 5 +- .../client/refund/RefundClientView.java | 5 +- .../java/haveno/desktop/util/Transitions.java | 5 +- docs/installing.md | 6 +- gradle/verification-metadata.xml | 233 +++++++++--------- gradle/wrapper/gradle-wrapper.properties | 3 +- .../haveno/network/Socks5ProxyProvider.java | 7 +- .../network/crypto/EncryptionService.java | 10 +- .../haveno/network/http/HttpClientImpl.java | 32 ++- .../network/p2p/NetworkNodeProvider.java | 16 +- .../p2p/mailbox/IgnoredMailboxService.java | 5 +- .../p2p/mailbox/MailboxMessageService.java | 18 +- .../network/p2p/network/Connection.java | 56 ++--- .../haveno/network/p2p/peers/Broadcaster.java | 20 +- .../haveno/network/p2p/peers/PeerManager.java | 14 +- .../p2p/peers/getdata/RequestDataManager.java | 12 +- .../p2p/peers/keepalive/KeepAliveManager.java | 7 +- .../peerexchange/PeerExchangeManager.java | 7 +- .../network/p2p/storage/P2PDataStorage.java | 126 +++++----- .../AppendOnlyDataStoreService.java | 11 +- .../ProtectedDataStoreService.java | 5 +- .../persistence/RemovedPayloadsService.java | 5 +- .../persistence/ResourceDataStoreService.java | 5 +- scripts/install_java.bat | 4 +- scripts/install_java.sh | 18 +- 254 files changed, 1616 insertions(+), 1983 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e83778dac3..6c5f6d0445 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,13 +14,13 @@ jobs: fail-fast: false runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: lfs: true - - name: Set up JDK 11 - uses: actions/setup-java@v3 + - name: Set up JDK 21 + uses: actions/setup-java@v4 with: - java-version: '11' + java-version: '21' distribution: 'adopt' cache: gradle - name: Build with Gradle diff --git a/.github/workflows/codacy-code-reporter.yml b/.github/workflows/codacy-code-reporter.yml index 152d2f9b5e..5523d19484 100644 --- a/.github/workflows/codacy-code-reporter.yml +++ b/.github/workflows/codacy-code-reporter.yml @@ -10,12 +10,12 @@ jobs: name: Publish coverage runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Set up JDK 11 - uses: actions/setup-java@v3 + - name: Set up JDK 21 + uses: actions/setup-java@v4 with: - java-version: '11' + java-version: '21' distribution: 'adopt' - name: Build with Gradle diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2cebc57e9e..8b8699ad69 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -33,7 +33,14 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'adopt' + cache: gradle # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL @@ -47,8 +54,8 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). # If this step fails, then you should remove it and run the build manually (see below). - - name: Autobuild - uses: github/codeql-action/autobuild@v2 +# - name: Autobuild +# uses: github/codeql-action/autobuild@v2 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -57,8 +64,8 @@ jobs: # and modify them (or add more) to build your code if your project # uses a compiled language - #- run: | - # ./gradlew build + - name: Build + run: ./gradlew build --stacktrace -x test -x checkstyleMain -x checkstyleTest - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index 66f702c248..a43fe881e7 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Bounty explanation - uses: peter-evans/create-or-update-comment@v2 + uses: peter-evans/create-or-update-comment@v3 if: github.event.label.name == '💰bounty' with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle b/build.gradle index a1de182b40..b6bf4abfba 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { classpath 'com.google.gradle:osdetector-gradle-plugin:1.7.3' classpath 'com.github.johnrengelman:shadow:8.1.1' classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.6.3' - classpath 'com.gradle:gradle-enterprise-gradle-plugin:3.12.4' // added for windows build verification-metadata.xml error + classpath 'com.gradle:gradle-enterprise-gradle-plugin:3.16.1' // added for windows build verification-metadata.xml error } } @@ -31,7 +31,7 @@ configure(subprojects) { apply plugin: 'jacoco-report-aggregation' apply plugin: 'checkstyle' - sourceCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_21 ext { // in alphabetical order bcVersion = '1.63' @@ -47,8 +47,8 @@ configure(subprojects) { fontawesomefxMaterialdesignfontVersion = '2.0.26-9.1.2' grpcVersion = '1.42.1' gsonVersion = '2.8.5' - guavaVersion = '30.1.1-jre' - guiceVersion = '5.1.0' + guavaVersion = '32.1.1-jre' + guiceVersion = '7.0.0' moneroJavaVersion = '0.8.10' httpclient5Version = '5.0' hamcrestVersion = '2.2' @@ -56,7 +56,7 @@ configure(subprojects) { httpcoreVersion = '4.4.13' ioVersion = '2.6' jacksonVersion = '2.12.1' - javafxVersion = '16' + javafxVersion = '21.0.2' javaxAnnotationVersion = '1.2' jcsvVersion = '1.4.0' jetbrainsAnnotationsVersion = '13.0' @@ -69,8 +69,8 @@ configure(subprojects) { langVersion = '3.11' logbackVersion = '1.1.11' loggingVersion = '1.2' - lombokVersion = '1.18.24' - mockitoVersion = '5.2.0' + lombokVersion = '1.18.30' + mockitoVersion = '5.10.0' netlayerVersion = '6797461310f077bbea4f43a3a509c077b0ed8c34' // Netlayer version 0.7.3 with Tor browser version 11.0.14 and tor binary version: 0.4.7.7 protobufVersion = '3.19.1' protocVersion = protobufVersion @@ -174,7 +174,11 @@ configure([project(':cli'), if (applicationName == 'desktop') { def script = file("${rootProject.projectDir}/haveno-$applicationName") script.text = script.text.replace( - 'DEFAULT_JVM_OPTS=""', 'DEFAULT_JVM_OPTS="-XX:MaxRAM=4g"') + 'DEFAULT_JVM_OPTS=""', 'DEFAULT_JVM_OPTS="-XX:MaxRAM=4g ' + + '--add-opens=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED ' + + '--add-opens=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED ' + + '--add-opens=java.base/java.lang.reflect=ALL-UNNAMED ' + + '--add-opens=javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED"') } if (applicationName == 'apitest') { diff --git a/common/src/main/java/haveno/common/ClockWatcher.java b/common/src/main/java/haveno/common/ClockWatcher.java index ac878cb7b1..e962c1c502 100644 --- a/common/src/main/java/haveno/common/ClockWatcher.java +++ b/common/src/main/java/haveno/common/ClockWatcher.java @@ -17,12 +17,11 @@ package haveno.common; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Singleton; +import com.google.inject.Singleton; import java.util.LinkedList; import java.util.List; import java.util.concurrent.TimeUnit; +import lombok.extern.slf4j.Slf4j; // Helps configure listener objects that are run by the `UserThread` each second // and can do per second, per minute and delayed second actions. Also detects when we were in standby, and logs it. diff --git a/common/src/main/java/haveno/common/crypto/KeyRing.java b/common/src/main/java/haveno/common/crypto/KeyRing.java index 9b2e77264e..89552c7c74 100644 --- a/common/src/main/java/haveno/common/crypto/KeyRing.java +++ b/common/src/main/java/haveno/common/crypto/KeyRing.java @@ -17,16 +17,15 @@ package haveno.common.crypto; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import java.security.KeyPair; +import javax.annotation.Nullable; +import javax.crypto.SecretKey; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; -import javax.crypto.SecretKey; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.security.KeyPair; - @Getter @EqualsAndHashCode @Slf4j diff --git a/common/src/main/java/haveno/common/crypto/KeyStorage.java b/common/src/main/java/haveno/common/crypto/KeyStorage.java index 35d1206b6a..05280b8d4a 100644 --- a/common/src/main/java/haveno/common/crypto/KeyStorage.java +++ b/common/src/main/java/haveno/common/crypto/KeyStorage.java @@ -18,15 +18,11 @@ package haveno.common.crypto; import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.common.file.FileUtil; -import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.crypto.SecretKey; -import javax.inject.Named; -import javax.inject.Singleton; +import static haveno.common.util.Preconditions.checkDir; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -48,8 +44,10 @@ import java.security.spec.InvalidKeySpecException; import java.security.spec.KeySpec; import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.RSAPublicKeySpec; - -import static haveno.common.util.Preconditions.checkDir; +import javax.crypto.SecretKey; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * KeyStorage uses password protection to save a symmetric key in PKCS#12 format. diff --git a/common/src/main/java/haveno/common/file/CorruptedStorageFileHandler.java b/common/src/main/java/haveno/common/file/CorruptedStorageFileHandler.java index 061232925c..65d7a07c50 100644 --- a/common/src/main/java/haveno/common/file/CorruptedStorageFileHandler.java +++ b/common/src/main/java/haveno/common/file/CorruptedStorageFileHandler.java @@ -17,13 +17,12 @@ package haveno.common.file; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; +import com.google.inject.Inject; +import com.google.inject.Singleton; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import lombok.extern.slf4j.Slf4j; @Slf4j @Singleton diff --git a/common/src/main/java/haveno/common/persistence/PersistenceManager.java b/common/src/main/java/haveno/common/persistence/PersistenceManager.java index 6824ee15be..b9d38bd82f 100644 --- a/common/src/main/java/haveno/common/persistence/PersistenceManager.java +++ b/common/src/main/java/haveno/common/persistence/PersistenceManager.java @@ -17,7 +17,9 @@ package haveno.common.persistence; +import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.Timer; import haveno.common.UserThread; import haveno.common.app.DevEnv; @@ -30,13 +32,9 @@ import haveno.common.file.FileUtil; import haveno.common.handlers.ResultHandler; import haveno.common.proto.persistable.PersistableEnvelope; import haveno.common.proto.persistable.PersistenceProtoResolver; -import haveno.common.util.SingleThreadExecutorUtils; import haveno.common.util.GcUtil; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; - -import javax.annotation.Nullable; -import javax.inject.Named; +import static haveno.common.util.Preconditions.checkDir; +import haveno.common.util.SingleThreadExecutorUtils; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; @@ -51,9 +49,9 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; - -import static com.google.common.base.Preconditions.checkNotNull; -import static haveno.common.util.Preconditions.checkDir; +import javax.annotation.Nullable; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; /** * Responsible for reading persisted data and writing it on disk. We read usually only at start-up and keep data in RAM. diff --git a/core/src/main/java/haveno/core/account/sign/SignedWitnessService.java b/core/src/main/java/haveno/core/account/sign/SignedWitnessService.java index ec9b37742c..1d7c7607f4 100644 --- a/core/src/main/java/haveno/core/account/sign/SignedWitnessService.java +++ b/core/src/main/java/haveno/core/account/sign/SignedWitnessService.java @@ -19,6 +19,7 @@ package haveno.core.account.sign; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Charsets; +import com.google.inject.Inject; import haveno.common.UserThread; import haveno.common.crypto.CryptoException; import haveno.common.crypto.Hash; @@ -34,11 +35,6 @@ import haveno.network.p2p.BootstrapListener; import haveno.network.p2p.P2PService; import haveno.network.p2p.storage.P2PDataStorage; import haveno.network.p2p.storage.persistence.AppendOnlyDataStoreService; -import lombok.extern.slf4j.Slf4j; -import org.bitcoinj.core.ECKey; -import org.bitcoinj.core.Utils; - -import javax.inject.Inject; import java.math.BigInteger; import java.security.PublicKey; import java.security.SignatureException; @@ -56,6 +52,9 @@ import java.util.Optional; import java.util.Set; import java.util.Stack; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; +import org.bitcoinj.core.ECKey; +import org.bitcoinj.core.Utils; @Slf4j public class SignedWitnessService { diff --git a/core/src/main/java/haveno/core/account/sign/SignedWitnessStorageService.java b/core/src/main/java/haveno/core/account/sign/SignedWitnessStorageService.java index 652b31bab6..a27c55a47a 100644 --- a/core/src/main/java/haveno/core/account/sign/SignedWitnessStorageService.java +++ b/core/src/main/java/haveno/core/account/sign/SignedWitnessStorageService.java @@ -17,17 +17,16 @@ package haveno.core.account.sign; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.common.persistence.PersistenceManager; import haveno.network.p2p.storage.P2PDataStorage; import haveno.network.p2p.storage.payload.PersistableNetworkPayload; import haveno.network.p2p.storage.persistence.MapStoreService; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Named; import java.io.File; import java.util.Map; +import lombok.extern.slf4j.Slf4j; @Slf4j public class SignedWitnessStorageService extends MapStoreService { diff --git a/core/src/main/java/haveno/core/account/witness/AccountAgeWitnessService.java b/core/src/main/java/haveno/core/account/witness/AccountAgeWitnessService.java index 906d42d6ce..ea50e4bea4 100644 --- a/core/src/main/java/haveno/core/account/witness/AccountAgeWitnessService.java +++ b/core/src/main/java/haveno/core/account/witness/AccountAgeWitnessService.java @@ -18,6 +18,8 @@ package haveno.core.account.witness; import com.google.common.annotations.VisibleForTesting; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; import haveno.common.UserThread; import haveno.common.crypto.CryptoException; import haveno.common.crypto.Hash; @@ -51,12 +53,6 @@ import haveno.network.p2p.BootstrapListener; import haveno.network.p2p.P2PService; import haveno.network.p2p.storage.P2PDataStorage; import haveno.network.p2p.storage.persistence.AppendOnlyDataStoreService; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import org.bitcoinj.core.ECKey; -import org.bitcoinj.core.Utils; - -import javax.inject.Inject; import java.math.BigInteger; import java.security.PublicKey; import java.time.Clock; @@ -74,8 +70,10 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.stream.Stream; - -import static com.google.common.base.Preconditions.checkNotNull; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.bitcoinj.core.ECKey; +import org.bitcoinj.core.Utils; @Slf4j public class AccountAgeWitnessService { diff --git a/core/src/main/java/haveno/core/account/witness/AccountAgeWitnessStorageService.java b/core/src/main/java/haveno/core/account/witness/AccountAgeWitnessStorageService.java index 785c83d3da..3a635c0129 100644 --- a/core/src/main/java/haveno/core/account/witness/AccountAgeWitnessStorageService.java +++ b/core/src/main/java/haveno/core/account/witness/AccountAgeWitnessStorageService.java @@ -17,15 +17,14 @@ package haveno.core.account.witness; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.common.persistence.PersistenceManager; import haveno.network.p2p.storage.payload.PersistableNetworkPayload; import haveno.network.p2p.storage.persistence.HistoricalDataStoreService; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Named; import java.io.File; +import lombok.extern.slf4j.Slf4j; @Slf4j public class AccountAgeWitnessStorageService extends HistoricalDataStoreService { diff --git a/core/src/main/java/haveno/core/alert/AlertManager.java b/core/src/main/java/haveno/core/alert/AlertManager.java index 058bd4f4bb..0d5b76618a 100644 --- a/core/src/main/java/haveno/core/alert/AlertManager.java +++ b/core/src/main/java/haveno/core/alert/AlertManager.java @@ -18,6 +18,8 @@ package haveno.core.alert; import com.google.common.base.Charsets; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.app.DevEnv; import haveno.common.config.Config; import haveno.common.crypto.KeyRing; @@ -26,22 +28,18 @@ import haveno.network.p2p.P2PService; import haveno.network.p2p.storage.HashMapChangedListener; import haveno.network.p2p.storage.payload.ProtectedStorageEntry; import haveno.network.p2p.storage.payload.ProtectedStoragePayload; +import java.math.BigInteger; +import java.security.SignatureException; +import java.util.Collection; import javafx.beans.property.ObjectProperty; import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.SimpleObjectProperty; import org.bitcoinj.core.ECKey; import org.bitcoinj.core.Utils; +import static org.bitcoinj.core.Utils.HEX; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Named; -import java.math.BigInteger; -import java.security.SignatureException; -import java.util.Collection; - -import static org.bitcoinj.core.Utils.HEX; - public class AlertManager { private static final Logger log = LoggerFactory.getLogger(AlertManager.class); diff --git a/core/src/main/java/haveno/core/alert/PrivateNotificationManager.java b/core/src/main/java/haveno/core/alert/PrivateNotificationManager.java index b5c25a3d2b..0d3274539e 100644 --- a/core/src/main/java/haveno/core/alert/PrivateNotificationManager.java +++ b/core/src/main/java/haveno/core/alert/PrivateNotificationManager.java @@ -22,6 +22,8 @@ import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.app.DevEnv; import haveno.common.config.Config; import haveno.common.crypto.KeyRing; @@ -37,25 +39,21 @@ import haveno.network.p2p.network.MessageListener; import haveno.network.p2p.network.NetworkNode; import haveno.network.p2p.peers.keepalive.messages.Ping; import haveno.network.p2p.peers.keepalive.messages.Pong; -import javafx.beans.property.ObjectProperty; -import javafx.beans.property.ReadOnlyObjectProperty; -import javafx.beans.property.SimpleObjectProperty; -import org.bitcoinj.core.ECKey; -import org.bitcoinj.core.Utils; -import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Named; import java.math.BigInteger; import java.security.SignatureException; import java.util.Random; import java.util.UUID; import java.util.function.Consumer; - +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.ReadOnlyObjectProperty; +import javafx.beans.property.SimpleObjectProperty; +import javax.annotation.Nullable; +import org.bitcoinj.core.ECKey; +import org.bitcoinj.core.Utils; import static org.bitcoinj.core.Utils.HEX; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivateNotificationManager implements MessageListener { private static final Logger log = LoggerFactory.getLogger(PrivateNotificationManager.class); diff --git a/core/src/main/java/haveno/core/api/CoreAccountService.java b/core/src/main/java/haveno/core/api/CoreAccountService.java index 0089d1a954..0b919bd5ec 100644 --- a/core/src/main/java/haveno/core/api/CoreAccountService.java +++ b/core/src/main/java/haveno/core/api/CoreAccountService.java @@ -17,6 +17,9 @@ package haveno.core.api; +import static com.google.common.base.Preconditions.checkState; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.config.Config; import haveno.common.crypto.IncorrectPasswordException; import haveno.common.crypto.KeyRing; @@ -24,12 +27,6 @@ import haveno.common.crypto.KeyStorage; import haveno.common.file.FileUtil; import haveno.common.persistence.PersistenceManager; import haveno.common.util.ZipUtils; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.io.File; import java.io.InputStream; import java.io.PipedInputStream; @@ -37,8 +34,9 @@ import java.io.PipedOutputStream; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; - -import static com.google.common.base.Preconditions.checkState; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; /** * Manages the account state. A created account must have a password which encrypts diff --git a/core/src/main/java/haveno/core/api/CoreApi.java b/core/src/main/java/haveno/core/api/CoreApi.java index ff96f06b80..a56dc2e5df 100644 --- a/core/src/main/java/haveno/core/api/CoreApi.java +++ b/core/src/main/java/haveno/core/api/CoreApi.java @@ -34,6 +34,8 @@ package haveno.core.api; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.app.Version; import haveno.common.config.Config; import haveno.common.crypto.IncorrectPasswordException; @@ -62,15 +64,6 @@ import haveno.core.trade.statistics.TradeStatistics3; import haveno.core.trade.statistics.TradeStatisticsManager; import haveno.core.xmr.XmrNodeSettings; import haveno.proto.grpc.NotificationMessage; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import monero.common.MoneroRpcConnection; -import monero.wallet.model.MoneroDestination; -import monero.wallet.model.MoneroTxWallet; -import org.bitcoinj.core.Transaction; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; @@ -80,6 +73,12 @@ import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import java.util.function.Consumer; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import monero.common.MoneroRpcConnection; +import monero.wallet.model.MoneroDestination; +import monero.wallet.model.MoneroTxWallet; +import org.bitcoinj.core.Transaction; /** * Provides high level interface to functionality of core Haveno features. diff --git a/core/src/main/java/haveno/core/api/CoreContext.java b/core/src/main/java/haveno/core/api/CoreContext.java index cfa1d267bc..4ff01edf22 100644 --- a/core/src/main/java/haveno/core/api/CoreContext.java +++ b/core/src/main/java/haveno/core/api/CoreContext.java @@ -17,13 +17,12 @@ package haveno.core.api; +import com.google.inject.Inject; +import com.google.inject.Singleton; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; -import javax.inject.Singleton; - @Singleton @Slf4j public class CoreContext { diff --git a/core/src/main/java/haveno/core/api/CoreDisputeAgentsService.java b/core/src/main/java/haveno/core/api/CoreDisputeAgentsService.java index d6118eb617..529a2a8ac1 100644 --- a/core/src/main/java/haveno/core/api/CoreDisputeAgentsService.java +++ b/core/src/main/java/haveno/core/api/CoreDisputeAgentsService.java @@ -17,11 +17,17 @@ package haveno.core.api; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.config.Config; import haveno.common.crypto.KeyRing; import haveno.common.handlers.ErrorMessageHandler; import haveno.common.handlers.ResultHandler; import haveno.core.support.SupportType; +import static haveno.core.support.SupportType.ARBITRATION; +import static haveno.core.support.SupportType.MEDIATION; +import static haveno.core.support.SupportType.REFUND; +import static haveno.core.support.SupportType.TRADE; import haveno.core.support.dispute.arbitration.arbitrator.Arbitrator; import haveno.core.support.dispute.arbitration.arbitrator.ArbitratorManager; import haveno.core.support.dispute.mediation.mediator.Mediator; @@ -32,24 +38,16 @@ import haveno.core.user.User; import haveno.core.xmr.wallet.XmrWalletService; import haveno.network.p2p.NodeAddress; import haveno.network.p2p.P2PService; -import lombok.extern.slf4j.Slf4j; -import org.bitcoinj.core.ECKey; - -import javax.inject.Inject; -import javax.inject.Singleton; +import static java.lang.String.format; +import static java.net.InetAddress.getLoopbackAddress; import java.util.ArrayList; +import static java.util.Arrays.asList; import java.util.Date; import java.util.List; import java.util.Objects; import java.util.Optional; - -import static haveno.core.support.SupportType.ARBITRATION; -import static haveno.core.support.SupportType.MEDIATION; -import static haveno.core.support.SupportType.REFUND; -import static haveno.core.support.SupportType.TRADE; -import static java.lang.String.format; -import static java.net.InetAddress.getLoopbackAddress; -import static java.util.Arrays.asList; +import lombok.extern.slf4j.Slf4j; +import org.bitcoinj.core.ECKey; @Singleton @Slf4j diff --git a/core/src/main/java/haveno/core/api/CoreDisputesService.java b/core/src/main/java/haveno/core/api/CoreDisputesService.java index c665e61430..f94dc983c5 100644 --- a/core/src/main/java/haveno/core/api/CoreDisputesService.java +++ b/core/src/main/java/haveno/core/api/CoreDisputesService.java @@ -17,6 +17,9 @@ package haveno.core.api; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; +import com.google.inject.Singleton; import com.google.inject.name.Named; import haveno.common.ThreadUtils; @@ -43,18 +46,13 @@ import haveno.core.trade.TradeManager; import haveno.core.util.FormattingUtils; import haveno.core.util.coin.CoinFormatter; import haveno.core.xmr.wallet.XmrWalletService; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; +import static java.lang.String.format; import java.math.BigInteger; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Optional; - -import static com.google.common.base.Preconditions.checkNotNull; -import static java.lang.String.format; +import lombok.extern.slf4j.Slf4j; @Singleton diff --git a/core/src/main/java/haveno/core/api/CoreHelpService.java b/core/src/main/java/haveno/core/api/CoreHelpService.java index 8911e2a20e..cc216b9014 100644 --- a/core/src/main/java/haveno/core/api/CoreHelpService.java +++ b/core/src/main/java/haveno/core/api/CoreHelpService.java @@ -17,18 +17,16 @@ package haveno.core.api; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; +import com.google.inject.Inject; +import com.google.inject.Singleton; import java.io.BufferedReader; +import static java.io.File.separator; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; - -import static java.io.File.separator; import static java.lang.String.format; import static java.lang.System.out; +import lombok.extern.slf4j.Slf4j; @Singleton @Slf4j diff --git a/core/src/main/java/haveno/core/api/CoreNotificationService.java b/core/src/main/java/haveno/core/api/CoreNotificationService.java index f7646a5758..fe7d345958 100644 --- a/core/src/main/java/haveno/core/api/CoreNotificationService.java +++ b/core/src/main/java/haveno/core/api/CoreNotificationService.java @@ -1,17 +1,16 @@ package haveno.core.api; +import com.google.inject.Singleton; import haveno.core.api.model.TradeInfo; import haveno.core.support.messages.ChatMessage; import haveno.core.trade.Trade; import haveno.proto.grpc.NotificationMessage; import haveno.proto.grpc.NotificationMessage.NotificationType; -import lombok.NonNull; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Singleton; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import lombok.NonNull; +import lombok.extern.slf4j.Slf4j; @Singleton @Slf4j diff --git a/core/src/main/java/haveno/core/api/CoreOffersService.java b/core/src/main/java/haveno/core/api/CoreOffersService.java index 3807330989..6e32b1e0b3 100644 --- a/core/src/main/java/haveno/core/api/CoreOffersService.java +++ b/core/src/main/java/haveno/core/api/CoreOffersService.java @@ -34,8 +34,13 @@ package haveno.core.api; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.crypto.KeyRing; import haveno.common.handlers.ErrorMessageHandler; +import static haveno.common.util.MathUtils.exactMultiply; +import static haveno.common.util.MathUtils.roundDoubleToLong; +import static haveno.common.util.MathUtils.scaleUpByPowerOf10; import haveno.core.locale.CurrencyUtil; import haveno.core.monetary.CryptoMoney; import haveno.core.monetary.Price; @@ -44,37 +49,30 @@ import haveno.core.offer.CreateOfferService; import haveno.core.offer.Offer; import haveno.core.offer.OfferBookService; import haveno.core.offer.OfferDirection; +import static haveno.core.offer.OfferDirection.BUY; import haveno.core.offer.OfferFilterService; import haveno.core.offer.OfferFilterService.Result; import haveno.core.offer.OfferUtil; import haveno.core.offer.OpenOffer; import haveno.core.offer.OpenOfferManager; import haveno.core.payment.PaymentAccount; +import static haveno.core.payment.PaymentAccountUtil.isPaymentAccountValidForOffer; import haveno.core.user.User; import haveno.core.util.PriceUtil; -import lombok.extern.slf4j.Slf4j; -import org.bitcoinj.core.Transaction; - -import javax.inject.Inject; -import javax.inject.Singleton; +import static java.lang.String.format; import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.Comparator; +import static java.util.Comparator.comparing; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.function.Consumer; import java.util.function.Supplier; import java.util.stream.Collectors; - -import static haveno.common.util.MathUtils.exactMultiply; -import static haveno.common.util.MathUtils.roundDoubleToLong; -import static haveno.common.util.MathUtils.scaleUpByPowerOf10; -import static haveno.core.offer.OfferDirection.BUY; -import static haveno.core.payment.PaymentAccountUtil.isPaymentAccountValidForOffer; -import static java.lang.String.format; -import static java.util.Comparator.comparing; +import lombok.extern.slf4j.Slf4j; +import org.bitcoinj.core.Transaction; @Singleton @Slf4j diff --git a/core/src/main/java/haveno/core/api/CorePaymentAccountsService.java b/core/src/main/java/haveno/core/api/CorePaymentAccountsService.java index 489347b87c..df88d094a2 100644 --- a/core/src/main/java/haveno/core/api/CorePaymentAccountsService.java +++ b/core/src/main/java/haveno/core/api/CorePaymentAccountsService.java @@ -17,13 +17,18 @@ package haveno.core.api; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.asset.Asset; import haveno.asset.AssetRegistry; +import static haveno.common.config.Config.baseCurrencyNetwork; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.api.model.PaymentAccountForm; import haveno.core.api.model.PaymentAccountFormField; import haveno.core.locale.CryptoCurrency; import haveno.core.locale.CurrencyUtil; +import static haveno.core.locale.CurrencyUtil.findAsset; +import static haveno.core.locale.CurrencyUtil.getCryptoCurrency; import haveno.core.locale.TradeCurrency; import haveno.core.payment.AssetAccount; import haveno.core.payment.CryptoCurrencyAccount; @@ -32,21 +37,14 @@ import haveno.core.payment.PaymentAccount; import haveno.core.payment.PaymentAccountFactory; import haveno.core.payment.payload.PaymentMethod; import haveno.core.user.User; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.io.File; +import static java.lang.String.format; import java.util.Comparator; import java.util.List; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; - -import static haveno.common.config.Config.baseCurrencyNetwork; -import static haveno.core.locale.CurrencyUtil.findAsset; -import static haveno.core.locale.CurrencyUtil.getCryptoCurrency; -import static java.lang.String.format; +import lombok.extern.slf4j.Slf4j; @Singleton @Slf4j diff --git a/core/src/main/java/haveno/core/api/CorePriceService.java b/core/src/main/java/haveno/core/api/CorePriceService.java index 41fcce0e0d..453236c5bc 100644 --- a/core/src/main/java/haveno/core/api/CorePriceService.java +++ b/core/src/main/java/haveno/core/api/CorePriceService.java @@ -35,6 +35,8 @@ package haveno.core.api; import com.google.common.math.LongMath; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.core.api.model.MarketDepthInfo; import haveno.core.api.model.MarketPriceInfo; import haveno.core.locale.CurrencyUtil; @@ -44,16 +46,13 @@ import haveno.core.offer.OfferBookService; import haveno.core.offer.OfferDirection; import haveno.core.provider.price.PriceFeedService; import haveno.core.trade.HavenoUtils; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; @Singleton diff --git a/core/src/main/java/haveno/core/api/CoreTradesService.java b/core/src/main/java/haveno/core/api/CoreTradesService.java index 0deff25305..6f709c1ef4 100644 --- a/core/src/main/java/haveno/core/api/CoreTradesService.java +++ b/core/src/main/java/haveno/core/api/CoreTradesService.java @@ -34,6 +34,8 @@ package haveno.core.api; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.handlers.ErrorMessageHandler; import haveno.common.handlers.ResultHandler; import haveno.core.offer.Offer; @@ -55,20 +57,16 @@ import haveno.core.user.User; import haveno.core.util.coin.CoinUtil; import haveno.core.util.validation.BtcAddressValidator; import haveno.core.xmr.model.AddressEntry; +import static haveno.core.xmr.model.AddressEntry.Context.TRADE_PAYOUT; import haveno.core.xmr.wallet.BtcWalletService; -import lombok.extern.slf4j.Slf4j; -import org.bitcoinj.core.Coin; - -import javax.inject.Inject; -import javax.inject.Singleton; +import static java.lang.String.format; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.function.Consumer; - -import static haveno.core.xmr.model.AddressEntry.Context.TRADE_PAYOUT; -import static java.lang.String.format; +import lombok.extern.slf4j.Slf4j; +import org.bitcoinj.core.Coin; @Singleton @Slf4j diff --git a/core/src/main/java/haveno/core/api/CoreWalletsService.java b/core/src/main/java/haveno/core/api/CoreWalletsService.java index 75f6d62c3c..a3713faa72 100644 --- a/core/src/main/java/haveno/core/api/CoreWalletsService.java +++ b/core/src/main/java/haveno/core/api/CoreWalletsService.java @@ -37,6 +37,9 @@ package haveno.core.api; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.google.inject.name.Named; import haveno.common.Timer; import haveno.common.UserThread; import haveno.core.api.model.AddressBalanceInfo; @@ -46,13 +49,22 @@ import haveno.core.api.model.XmrBalanceInfo; import haveno.core.app.AppStartupState; import haveno.core.user.Preferences; import haveno.core.util.FormattingUtils; +import static haveno.core.util.ParsingUtils.parseToCoin; import haveno.core.util.coin.CoinFormatter; import haveno.core.xmr.Balances; import haveno.core.xmr.model.AddressEntry; import haveno.core.xmr.setup.WalletsSetup; import haveno.core.xmr.wallet.BtcWalletService; +import static haveno.core.xmr.wallet.Restrictions.getMinNonDustOutput; import haveno.core.xmr.wallet.WalletsManager; import haveno.core.xmr.wallet.XmrWalletService; +import static java.lang.String.format; +import java.util.List; +import java.util.Optional; +import static java.util.concurrent.TimeUnit.SECONDS; +import java.util.function.Function; +import java.util.stream.Collectors; +import javax.annotation.Nullable; import lombok.extern.slf4j.Slf4j; import monero.wallet.model.MoneroDestination; import monero.wallet.model.MoneroTxWallet; @@ -64,20 +76,6 @@ import org.bitcoinj.core.TransactionConfidence; import org.bitcoinj.crypto.KeyCrypterScrypt; import org.bouncycastle.crypto.params.KeyParameter; -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; -import java.util.List; -import java.util.Optional; -import java.util.function.Function; -import java.util.stream.Collectors; - -import static haveno.core.util.ParsingUtils.parseToCoin; -import static haveno.core.xmr.wallet.Restrictions.getMinNonDustOutput; -import static java.lang.String.format; -import static java.util.concurrent.TimeUnit.SECONDS; - @Singleton @Slf4j class CoreWalletsService { diff --git a/core/src/main/java/haveno/core/api/XmrConnectionService.java b/core/src/main/java/haveno/core/api/XmrConnectionService.java index 0afe6edb96..642eee9a77 100644 --- a/core/src/main/java/haveno/core/api/XmrConnectionService.java +++ b/core/src/main/java/haveno/core/api/XmrConnectionService.java @@ -17,6 +17,8 @@ package haveno.core.api; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.ThreadUtils; import haveno.common.UserThread; import haveno.common.app.DevEnv; @@ -26,13 +28,16 @@ import haveno.core.trade.HavenoUtils; import haveno.core.user.Preferences; import haveno.core.xmr.model.EncryptedConnectionList; import haveno.core.xmr.nodes.XmrNodes; -import haveno.core.xmr.nodes.XmrNodesSetupPreferences; import haveno.core.xmr.nodes.XmrNodes.XmrNode; +import haveno.core.xmr.nodes.XmrNodesSetupPreferences; import haveno.core.xmr.setup.DownloadListener; import haveno.core.xmr.setup.WalletsSetup; import haveno.network.Socks5ProxyProvider; import haveno.network.p2p.P2PService; import haveno.network.p2p.P2PServiceListener; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; import javafx.beans.property.IntegerProperty; import javafx.beans.property.LongProperty; import javafx.beans.property.ObjectProperty; @@ -53,12 +58,6 @@ import monero.daemon.MoneroDaemonRpc; import monero.daemon.model.MoneroDaemonInfo; import monero.daemon.model.MoneroPeer; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - @Slf4j @Singleton public final class XmrConnectionService { @@ -387,7 +386,7 @@ public final class XmrConnectionService { public void onNodeStopped() { log.info("Local monero node stopped"); } - + @Override public void onConnectionChanged(MoneroRpcConnection connection) { log.info("Local monerod connection changed: " + connection); @@ -395,7 +394,7 @@ public final class XmrConnectionService { // skip if ignored if (isShutDownStarted || !connectionManager.getAutoSwitch() || !accountService.isAccountOpen() || !connectionManager.hasConnection(connection.getUri()) || xmrLocalNode.shouldBeIgnored()) return; - + // check connection boolean isConnected = false; if (xmrLocalNode.isConnected()) { @@ -646,7 +645,7 @@ public final class XmrConnectionService { // skip if shut down or connected if (isShutDownStarted || Boolean.TRUE.equals(isConnected())) return; - + // log error message periodically if ((lastErrorTimestamp == null || System.currentTimeMillis() - lastErrorTimestamp > MIN_ERROR_LOG_PERIOD_MS)) { lastErrorTimestamp = System.currentTimeMillis(); diff --git a/core/src/main/java/haveno/core/api/XmrLocalNode.java b/core/src/main/java/haveno/core/api/XmrLocalNode.java index af9b8902d0..6f05cff024 100644 --- a/core/src/main/java/haveno/core/api/XmrLocalNode.java +++ b/core/src/main/java/haveno/core/api/XmrLocalNode.java @@ -14,9 +14,10 @@ * You should have received a copy of the GNU Affero General Public License * along with Haveno. If not, see . */ - package haveno.core.api; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.config.BaseCurrencyNetwork; import haveno.common.config.Config; import haveno.common.util.Utilities; @@ -24,16 +25,15 @@ import haveno.core.trade.HavenoUtils; import haveno.core.user.Preferences; import haveno.core.xmr.XmrNodeSettings; import haveno.core.xmr.nodes.XmrNodes; -import lombok.extern.slf4j.Slf4j; -import monero.common.MoneroConnectionManager; -import monero.common.MoneroUtils; -import monero.daemon.MoneroDaemonRpc; -import javax.inject.Inject; -import javax.inject.Singleton; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import lombok.extern.slf4j.Slf4j; +import monero.common.MoneroConnectionManager; +import monero.common.MoneroUtils; +import monero.daemon.MoneroDaemonRpc; + /** * Start and stop or connect to a local Monero node. @@ -81,7 +81,7 @@ public class XmrLocalNode { this.config = config; this.preferences = preferences; this.daemon = new MoneroDaemonRpc("http://" + HavenoUtils.LOOPBACK_HOST + ":" + rpcPort); - + // initialize connection manager to listen to local connection this.connectionManager = new MoneroConnectionManager().setConnection(daemon.getRpcConnection()); this.connectionManager.setTimeout(REFRESH_PERIOD_LOCAL_MS); diff --git a/core/src/main/java/haveno/core/app/AppStartupState.java b/core/src/main/java/haveno/core/app/AppStartupState.java index caf2e3d965..7e74d81b9d 100644 --- a/core/src/main/java/haveno/core/app/AppStartupState.java +++ b/core/src/main/java/haveno/core/app/AppStartupState.java @@ -17,6 +17,8 @@ package haveno.core.app; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.core.api.XmrConnectionService; import haveno.core.api.CoreNotificationService; import haveno.core.xmr.wallet.XmrWalletService; @@ -29,9 +31,6 @@ import lombok.extern.slf4j.Slf4j; import org.fxmisc.easybind.EasyBind; import org.fxmisc.easybind.monadic.MonadicBinding; -import javax.inject.Inject; -import javax.inject.Singleton; - /** * We often need to wait until network and wallet is ready or other combination of startup states. * To avoid those repeated checks for the state or setting of listeners on different domains we provide here a diff --git a/core/src/main/java/haveno/core/app/AvoidStandbyModeService.java b/core/src/main/java/haveno/core/app/AvoidStandbyModeService.java index 4913074aec..345f556a33 100644 --- a/core/src/main/java/haveno/core/app/AvoidStandbyModeService.java +++ b/core/src/main/java/haveno/core/app/AvoidStandbyModeService.java @@ -17,21 +17,13 @@ package haveno.core.app; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.config.Config; import haveno.common.file.FileUtil; import haveno.common.file.ResourceNotFoundException; import haveno.common.util.Utilities; import haveno.core.user.Preferences; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.sound.sampled.AudioFormat; -import javax.sound.sampled.AudioInputStream; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.DataLine; -import javax.sound.sampled.LineUnavailableException; -import javax.sound.sampled.SourceDataLine; import java.io.File; import java.io.IOException; import java.nio.file.Paths; @@ -43,6 +35,13 @@ import java.util.concurrent.CountDownLatch; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.DataLine; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.SourceDataLine; +import lombok.extern.slf4j.Slf4j; /** * Prevents that Haveno gets hibernated from the OS. On OSX there is a tool called caffeinate but it seems it does not diff --git a/core/src/main/java/haveno/core/app/DomainInitialisation.java b/core/src/main/java/haveno/core/app/DomainInitialisation.java index d121f88a33..91312715a2 100644 --- a/core/src/main/java/haveno/core/app/DomainInitialisation.java +++ b/core/src/main/java/haveno/core/app/DomainInitialisation.java @@ -17,6 +17,7 @@ package haveno.core.app; +import com.google.inject.Inject; import haveno.common.ClockWatcher; import haveno.common.persistence.PersistenceManager; import haveno.core.account.sign.SignedWitnessService; @@ -50,8 +51,6 @@ import haveno.core.user.User; import haveno.core.xmr.Balances; import haveno.network.p2p.P2PService; import haveno.network.p2p.mailbox.MailboxMessageService; - -import javax.inject.Inject; import java.util.List; import java.util.function.Consumer; import java.util.stream.Collectors; diff --git a/core/src/main/java/haveno/core/app/HavenoSetup.java b/core/src/main/java/haveno/core/app/HavenoSetup.java index 3c6122ada0..e44520ec9b 100644 --- a/core/src/main/java/haveno/core/app/HavenoSetup.java +++ b/core/src/main/java/haveno/core/app/HavenoSetup.java @@ -34,6 +34,9 @@ package haveno.core.app; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.google.inject.name.Named; import haveno.common.Timer; import haveno.common.UserThread; import haveno.common.app.DevEnv; @@ -65,8 +68,8 @@ import haveno.core.trade.HavenoUtils; import haveno.core.trade.TradeManager; import haveno.core.trade.TradeTxException; import haveno.core.user.Preferences; -import haveno.core.user.User; import haveno.core.user.Preferences.UseTorForXmr; +import haveno.core.user.User; import haveno.core.util.FormattingUtils; import haveno.core.util.coin.CoinFormatter; import haveno.core.xmr.model.AddressEntry; @@ -79,24 +82,6 @@ import haveno.network.p2p.NodeAddress; import haveno.network.p2p.P2PService; import haveno.network.p2p.storage.payload.PersistableNetworkPayload; import haveno.network.utils.Utils; -import javafx.beans.property.BooleanProperty; -import javafx.beans.property.DoubleProperty; -import javafx.beans.property.ObjectProperty; -import javafx.beans.property.SimpleBooleanProperty; -import javafx.beans.property.StringProperty; -import javafx.beans.value.ChangeListener; -import javafx.collections.SetChangeListener; -import lombok.Getter; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import org.bitcoinj.core.Coin; -import org.fxmisc.easybind.EasyBind; -import org.fxmisc.easybind.monadic.MonadicBinding; - -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; @@ -111,6 +96,20 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; import java.util.function.Consumer; +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.DoubleProperty; +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.beans.property.StringProperty; +import javafx.beans.value.ChangeListener; +import javafx.collections.SetChangeListener; +import javax.annotation.Nullable; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.bitcoinj.core.Coin; +import org.fxmisc.easybind.EasyBind; +import org.fxmisc.easybind.monadic.MonadicBinding; @Slf4j @Singleton diff --git a/core/src/main/java/haveno/core/app/P2PNetworkSetup.java b/core/src/main/java/haveno/core/app/P2PNetworkSetup.java index 43fa23dcb5..4e90faeb55 100644 --- a/core/src/main/java/haveno/core/app/P2PNetworkSetup.java +++ b/core/src/main/java/haveno/core/app/P2PNetworkSetup.java @@ -17,6 +17,8 @@ package haveno.core.app; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.UserThread; import haveno.core.api.XmrConnectionService; import haveno.core.locale.Res; @@ -27,20 +29,17 @@ import haveno.network.p2p.P2PServiceListener; import haveno.network.p2p.network.CloseConnectionReason; import haveno.network.p2p.network.Connection; import haveno.network.p2p.network.ConnectionListener; +import java.util.function.Consumer; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; +import javax.annotation.Nullable; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.fxmisc.easybind.EasyBind; import org.fxmisc.easybind.monadic.MonadicBinding; -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.function.Consumer; - @Singleton @Slf4j public class P2PNetworkSetup { diff --git a/core/src/main/java/haveno/core/app/TorSetup.java b/core/src/main/java/haveno/core/app/TorSetup.java index 06e5330d5d..d878464af2 100644 --- a/core/src/main/java/haveno/core/app/TorSetup.java +++ b/core/src/main/java/haveno/core/app/TorSetup.java @@ -17,20 +17,18 @@ package haveno.core.app; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.common.file.FileUtil; import haveno.common.handlers.ErrorMessageHandler; -import lombok.extern.slf4j.Slf4j; - -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; +import static haveno.common.util.Preconditions.checkDir; import java.io.File; import java.io.IOException; import java.nio.file.Paths; - -import static haveno.common.util.Preconditions.checkDir; +import javax.annotation.Nullable; +import lombok.extern.slf4j.Slf4j; @Slf4j @Singleton diff --git a/core/src/main/java/haveno/core/app/WalletAppSetup.java b/core/src/main/java/haveno/core/app/WalletAppSetup.java index 3a7051e835..0a67640269 100644 --- a/core/src/main/java/haveno/core/app/WalletAppSetup.java +++ b/core/src/main/java/haveno/core/app/WalletAppSetup.java @@ -34,6 +34,8 @@ package haveno.core.app; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.UserThread; import haveno.common.config.Config; import haveno.core.api.CoreContext; @@ -49,12 +51,15 @@ import haveno.core.xmr.exceptions.RejectedTxException; import haveno.core.xmr.setup.WalletsSetup; import haveno.core.xmr.wallet.WalletsManager; import haveno.core.xmr.wallet.XmrWalletService; +import java.util.concurrent.TimeoutException; +import java.util.function.Consumer; import javafx.beans.property.DoubleProperty; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; +import javax.annotation.Nullable; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import monero.common.MoneroUtils; @@ -64,12 +69,6 @@ import org.bitcoinj.store.ChainFileLockedException; import org.fxmisc.easybind.EasyBind; import org.fxmisc.easybind.monadic.MonadicBinding; -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.concurrent.TimeoutException; -import java.util.function.Consumer; - @Slf4j @Singleton public class WalletAppSetup { @@ -135,7 +134,7 @@ public class WalletAppSetup { (numConnectionUpdates, walletDownloadPercentage, walletHeight, exception, errorMsg) -> { String result; if (exception == null && errorMsg == null) { - + // update wallet sync progress double walletDownloadPercentageD = (double) walletDownloadPercentage; xmrWalletSyncProgress.set(walletDownloadPercentageD); diff --git a/core/src/main/java/haveno/core/app/misc/AppSetup.java b/core/src/main/java/haveno/core/app/misc/AppSetup.java index 70e6cf2358..9e10884522 100644 --- a/core/src/main/java/haveno/core/app/misc/AppSetup.java +++ b/core/src/main/java/haveno/core/app/misc/AppSetup.java @@ -17,12 +17,11 @@ package haveno.core.app.misc; +import com.google.inject.Inject; import haveno.common.app.Version; import haveno.common.config.Config; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; - @Slf4j public abstract class AppSetup { protected final Config config; diff --git a/core/src/main/java/haveno/core/app/misc/AppSetupWithP2P.java b/core/src/main/java/haveno/core/app/misc/AppSetupWithP2P.java index a1a7782061..b5553a926f 100644 --- a/core/src/main/java/haveno/core/app/misc/AppSetupWithP2P.java +++ b/core/src/main/java/haveno/core/app/misc/AppSetupWithP2P.java @@ -17,6 +17,7 @@ package haveno.core.app.misc; +import com.google.inject.Inject; import haveno.common.config.Config; import haveno.common.persistence.PersistenceManager; import haveno.common.proto.persistable.PersistedDataHost; @@ -31,13 +32,11 @@ import haveno.network.p2p.network.Connection; import haveno.network.p2p.network.ConnectionListener; import haveno.network.p2p.peers.PeerManager; import haveno.network.p2p.storage.P2PDataStorage; +import java.util.ArrayList; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; -import java.util.ArrayList; - @Slf4j public class AppSetupWithP2P extends AppSetup { protected final P2PService p2PService; diff --git a/core/src/main/java/haveno/core/filter/FilterManager.java b/core/src/main/java/haveno/core/filter/FilterManager.java index 07e1b2ca2f..cb7e0e9b21 100644 --- a/core/src/main/java/haveno/core/filter/FilterManager.java +++ b/core/src/main/java/haveno/core/filter/FilterManager.java @@ -17,6 +17,9 @@ package haveno.core.filter; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.app.DevEnv; import haveno.common.app.Version; import haveno.common.config.Config; @@ -35,16 +38,6 @@ import haveno.network.p2p.P2PServiceListener; import haveno.network.p2p.network.BanFilter; import haveno.network.p2p.storage.HashMapChangedListener; import haveno.network.p2p.storage.payload.ProtectedStorageEntry; -import javafx.beans.property.ObjectProperty; -import javafx.beans.property.SimpleObjectProperty; -import lombok.extern.slf4j.Slf4j; -import org.bitcoinj.core.ECKey; -import org.bitcoinj.core.Sha256Hash; -import org.bouncycastle.util.encoders.Base64; - -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Named; import java.lang.reflect.Method; import java.math.BigInteger; import java.nio.charset.StandardCharsets; @@ -58,9 +51,14 @@ import java.util.List; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import java.util.function.Consumer; - -import static com.google.common.base.Preconditions.checkNotNull; +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleObjectProperty; +import javax.annotation.Nullable; +import lombok.extern.slf4j.Slf4j; +import org.bitcoinj.core.ECKey; +import org.bitcoinj.core.Sha256Hash; import static org.bitcoinj.core.Utils.HEX; +import org.bouncycastle.util.encoders.Base64; /** * We only support one active filter, if we receive multiple we use the one with the more recent creationDate. diff --git a/core/src/main/java/haveno/core/network/CoreBanFilter.java b/core/src/main/java/haveno/core/network/CoreBanFilter.java index f99f3f5c36..f27fdb49b2 100644 --- a/core/src/main/java/haveno/core/network/CoreBanFilter.java +++ b/core/src/main/java/haveno/core/network/CoreBanFilter.java @@ -17,17 +17,16 @@ package haveno.core.network; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.network.p2p.NodeAddress; import haveno.network.p2p.network.BanFilter; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Named; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.function.Predicate; +import lombok.extern.slf4j.Slf4j; @Slf4j public class CoreBanFilter implements BanFilter { diff --git a/core/src/main/java/haveno/core/network/p2p/inventory/GetInventoryRequestHandler.java b/core/src/main/java/haveno/core/network/p2p/inventory/GetInventoryRequestHandler.java index eaefd494af..1e2ad15e7b 100644 --- a/core/src/main/java/haveno/core/network/p2p/inventory/GetInventoryRequestHandler.java +++ b/core/src/main/java/haveno/core/network/p2p/inventory/GetInventoryRequestHandler.java @@ -20,6 +20,8 @@ package haveno.core.network.p2p.inventory; import com.google.common.base.Enums; import com.google.common.base.Joiner; import com.google.common.base.Optional; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.app.Version; import haveno.common.config.Config; import haveno.common.proto.network.NetworkEnvelope; @@ -37,13 +39,10 @@ import haveno.network.p2p.network.Statistic; import haveno.network.p2p.peers.PeerManager; import haveno.network.p2p.storage.P2PDataStorage; import haveno.network.p2p.storage.payload.ProtectedStorageEntry; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Named; import java.lang.management.ManagementFactory; import java.util.HashMap; import java.util.Map; +import lombok.extern.slf4j.Slf4j; @Slf4j public class GetInventoryRequestHandler implements MessageListener { diff --git a/core/src/main/java/haveno/core/network/p2p/inventory/GetInventoryRequestManager.java b/core/src/main/java/haveno/core/network/p2p/inventory/GetInventoryRequestManager.java index 155b41ceac..dc33e8fe53 100644 --- a/core/src/main/java/haveno/core/network/p2p/inventory/GetInventoryRequestManager.java +++ b/core/src/main/java/haveno/core/network/p2p/inventory/GetInventoryRequestManager.java @@ -17,16 +17,15 @@ package haveno.core.network.p2p.inventory; +import com.google.inject.Inject; import haveno.common.handlers.ErrorMessageHandler; import haveno.core.network.p2p.inventory.model.InventoryItem; import haveno.network.p2p.NodeAddress; import haveno.network.p2p.network.NetworkNode; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; +import lombok.extern.slf4j.Slf4j; @Slf4j public class GetInventoryRequestManager { diff --git a/core/src/main/java/haveno/core/network/p2p/seed/DefaultSeedNodeRepository.java b/core/src/main/java/haveno/core/network/p2p/seed/DefaultSeedNodeRepository.java index 9961cbad56..c8d9c33d07 100644 --- a/core/src/main/java/haveno/core/network/p2p/seed/DefaultSeedNodeRepository.java +++ b/core/src/main/java/haveno/core/network/p2p/seed/DefaultSeedNodeRepository.java @@ -17,13 +17,11 @@ package haveno.core.network.p2p.seed; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.config.Config; import haveno.network.p2p.NodeAddress; import haveno.network.p2p.seed.SeedNodeRepository; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; @@ -35,6 +33,7 @@ import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; // If a new BaseCurrencyNetwork type gets added we need to add the resource file for it as well! @Slf4j diff --git a/core/src/main/java/haveno/core/notifications/MobileMessageEncryption.java b/core/src/main/java/haveno/core/notifications/MobileMessageEncryption.java index 4fd364ae4e..02fd428215 100644 --- a/core/src/main/java/haveno/core/notifications/MobileMessageEncryption.java +++ b/core/src/main/java/haveno/core/notifications/MobileMessageEncryption.java @@ -18,16 +18,15 @@ package haveno.core.notifications; import com.google.common.base.Charsets; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.codec.binary.Base64; - +import com.google.inject.Inject; +import com.google.inject.Singleton; +import java.security.NoSuchAlgorithmException; import javax.crypto.Cipher; import javax.crypto.NoSuchPaddingException; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.security.NoSuchAlgorithmException; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.binary.Base64; @Slf4j @Singleton diff --git a/core/src/main/java/haveno/core/notifications/MobileModel.java b/core/src/main/java/haveno/core/notifications/MobileModel.java index e3be49544a..040e260c24 100644 --- a/core/src/main/java/haveno/core/notifications/MobileModel.java +++ b/core/src/main/java/haveno/core/notifications/MobileModel.java @@ -18,15 +18,14 @@ package haveno.core.notifications; import com.google.common.annotations.VisibleForTesting; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import java.util.Arrays; +import javax.annotation.Nullable; import lombok.Data; import lombok.Getter; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.Arrays; - @Data @Slf4j @Singleton diff --git a/core/src/main/java/haveno/core/notifications/MobileNotificationService.java b/core/src/main/java/haveno/core/notifications/MobileNotificationService.java index 65d33476b4..ab80da8b1e 100644 --- a/core/src/main/java/haveno/core/notifications/MobileNotificationService.java +++ b/core/src/main/java/haveno/core/notifications/MobileNotificationService.java @@ -17,6 +17,8 @@ package haveno.core.notifications; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -25,12 +27,15 @@ import com.google.common.util.concurrent.MoreExecutors; import com.google.gson.Gson; import com.google.inject.Inject; import com.google.inject.Singleton; +import com.google.inject.name.Named; import haveno.common.UserThread; import haveno.common.app.Version; import haveno.common.config.Config; import haveno.common.util.Utilities; import haveno.core.user.Preferences; import haveno.network.http.HttpClient; +import java.util.UUID; +import java.util.function.Consumer; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import lombok.Getter; @@ -38,13 +43,6 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.binary.Hex; import org.jetbrains.annotations.NotNull; -import javax.inject.Named; -import java.util.UUID; -import java.util.function.Consumer; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - @Slf4j @Singleton public class MobileNotificationService { diff --git a/core/src/main/java/haveno/core/notifications/MobileNotificationValidator.java b/core/src/main/java/haveno/core/notifications/MobileNotificationValidator.java index 1f48a69d4a..c084b0e42e 100644 --- a/core/src/main/java/haveno/core/notifications/MobileNotificationValidator.java +++ b/core/src/main/java/haveno/core/notifications/MobileNotificationValidator.java @@ -17,11 +17,10 @@ package haveno.core.notifications; +import com.google.inject.Inject; +import com.google.inject.Singleton; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; -import javax.inject.Singleton; - @Slf4j @Singleton public class MobileNotificationValidator { diff --git a/core/src/main/java/haveno/core/notifications/alerts/DisputeMsgEvents.java b/core/src/main/java/haveno/core/notifications/alerts/DisputeMsgEvents.java index 95c36621e8..cade25305a 100644 --- a/core/src/main/java/haveno/core/notifications/alerts/DisputeMsgEvents.java +++ b/core/src/main/java/haveno/core/notifications/alerts/DisputeMsgEvents.java @@ -17,6 +17,8 @@ package haveno.core.notifications.alerts; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.core.locale.Res; import haveno.core.notifications.MobileMessage; import haveno.core.notifications.MobileMessageType; @@ -27,14 +29,11 @@ import haveno.core.support.dispute.mediation.MediationManager; import haveno.core.support.dispute.refund.RefundManager; import haveno.core.support.messages.ChatMessage; import haveno.network.p2p.P2PService; +import java.util.UUID; import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.UUID; - @Slf4j @Singleton public class DisputeMsgEvents { diff --git a/core/src/main/java/haveno/core/notifications/alerts/MyOfferTakenEvents.java b/core/src/main/java/haveno/core/notifications/alerts/MyOfferTakenEvents.java index ff46b7d64d..25886213f1 100644 --- a/core/src/main/java/haveno/core/notifications/alerts/MyOfferTakenEvents.java +++ b/core/src/main/java/haveno/core/notifications/alerts/MyOfferTakenEvents.java @@ -17,19 +17,18 @@ package haveno.core.notifications.alerts; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.core.locale.Res; import haveno.core.notifications.MobileMessage; import haveno.core.notifications.MobileMessageType; import haveno.core.notifications.MobileNotificationService; import haveno.core.offer.OpenOffer; import haveno.core.offer.OpenOfferManager; +import java.util.UUID; import javafx.collections.ListChangeListener; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.UUID; - @Slf4j @Singleton public class MyOfferTakenEvents { diff --git a/core/src/main/java/haveno/core/notifications/alerts/TradeEvents.java b/core/src/main/java/haveno/core/notifications/alerts/TradeEvents.java index f616f68cb1..0dd6fe58ac 100644 --- a/core/src/main/java/haveno/core/notifications/alerts/TradeEvents.java +++ b/core/src/main/java/haveno/core/notifications/alerts/TradeEvents.java @@ -17,6 +17,8 @@ package haveno.core.notifications.alerts; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.crypto.PubKeyRingProvider; import haveno.core.locale.Res; import haveno.core.notifications.MobileMessage; @@ -24,14 +26,11 @@ import haveno.core.notifications.MobileMessageType; import haveno.core.notifications.MobileNotificationService; import haveno.core.trade.Trade; import haveno.core.trade.TradeManager; -import javafx.collections.ListChangeListener; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import javafx.collections.ListChangeListener; +import lombok.extern.slf4j.Slf4j; @Slf4j @Singleton diff --git a/core/src/main/java/haveno/core/notifications/alerts/market/MarketAlerts.java b/core/src/main/java/haveno/core/notifications/alerts/market/MarketAlerts.java index be42496acd..af2434dd22 100644 --- a/core/src/main/java/haveno/core/notifications/alerts/market/MarketAlerts.java +++ b/core/src/main/java/haveno/core/notifications/alerts/market/MarketAlerts.java @@ -17,6 +17,8 @@ package haveno.core.notifications.alerts.market; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.crypto.KeyRing; import haveno.common.util.MathUtils; import haveno.core.locale.CurrencyUtil; @@ -34,12 +36,9 @@ import haveno.core.provider.price.MarketPrice; import haveno.core.provider.price.PriceFeedService; import haveno.core.user.User; import haveno.core.util.FormattingUtils; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.List; import java.util.UUID; +import lombok.extern.slf4j.Slf4j; @Slf4j @Singleton diff --git a/core/src/main/java/haveno/core/notifications/alerts/price/PriceAlert.java b/core/src/main/java/haveno/core/notifications/alerts/price/PriceAlert.java index 535b86675b..afe695b281 100644 --- a/core/src/main/java/haveno/core/notifications/alerts/price/PriceAlert.java +++ b/core/src/main/java/haveno/core/notifications/alerts/price/PriceAlert.java @@ -17,6 +17,8 @@ package haveno.core.notifications.alerts.price; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.util.MathUtils; import haveno.core.locale.CurrencyUtil; import haveno.core.locale.Res; @@ -31,9 +33,6 @@ import haveno.core.user.User; import haveno.core.util.FormattingUtils; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; -import javax.inject.Singleton; - @Slf4j @Singleton public class PriceAlert { diff --git a/core/src/main/java/haveno/core/offer/CreateOfferService.java b/core/src/main/java/haveno/core/offer/CreateOfferService.java index 3847a5c861..59d3790f55 100644 --- a/core/src/main/java/haveno/core/offer/CreateOfferService.java +++ b/core/src/main/java/haveno/core/offer/CreateOfferService.java @@ -17,6 +17,8 @@ package haveno.core.offer; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.app.Version; import haveno.common.crypto.PubKeyRingProvider; import haveno.common.util.Utilities; @@ -38,15 +40,12 @@ import haveno.core.xmr.wallet.Restrictions; import haveno.core.xmr.wallet.XmrWalletService; import haveno.network.p2p.NodeAddress; import haveno.network.p2p.P2PService; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.math.BigInteger; import java.util.Date; import java.util.List; import java.util.Map; import java.util.UUID; +import lombok.extern.slf4j.Slf4j; @Slf4j @Singleton diff --git a/core/src/main/java/haveno/core/offer/OfferBookService.java b/core/src/main/java/haveno/core/offer/OfferBookService.java index 92e504d548..dcea8475d8 100644 --- a/core/src/main/java/haveno/core/offer/OfferBookService.java +++ b/core/src/main/java/haveno/core/offer/OfferBookService.java @@ -34,6 +34,8 @@ package haveno.core.offer; +import com.google.inject.Inject; +import com.google.inject.name.Named; import common.utils.GenUtils; import haveno.common.UserThread; import haveno.common.config.Config; @@ -51,13 +53,6 @@ import haveno.network.p2p.BootstrapListener; import haveno.network.p2p.P2PService; import haveno.network.p2p.storage.HashMapChangedListener; import haveno.network.p2p.storage.payload.ProtectedStorageEntry; -import monero.daemon.model.MoneroKeyImageSpentStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Named; import java.io.File; import java.util.Collection; import java.util.LinkedList; @@ -65,13 +60,14 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; +import javax.annotation.Nullable; +import monero.daemon.model.MoneroKeyImageSpentStatus; /** * Handles storage and retrieval of offers. * Uses an invalidation flag to only request the full offer map in case there was a change (anyone has added or removed an offer). */ public class OfferBookService { - private static final Logger log = LoggerFactory.getLogger(OfferBookService.class); private final P2PService p2PService; private final PriceFeedService priceFeedService; diff --git a/core/src/main/java/haveno/core/offer/OfferFilterService.java b/core/src/main/java/haveno/core/offer/OfferFilterService.java index 45e2dcef5f..bde80b8972 100644 --- a/core/src/main/java/haveno/core/offer/OfferFilterService.java +++ b/core/src/main/java/haveno/core/offer/OfferFilterService.java @@ -17,6 +17,8 @@ package haveno.core.offer; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.app.Version; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.filter.FilterManager; @@ -28,18 +30,15 @@ import haveno.core.user.Preferences; import haveno.core.user.User; import haveno.network.p2p.NodeAddress; import haveno.network.p2p.P2PService; -import javafx.collections.SetChangeListener; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import org.bitcoinj.core.Coin; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; +import javafx.collections.SetChangeListener; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.bitcoinj.core.Coin; @Slf4j @Singleton diff --git a/core/src/main/java/haveno/core/offer/OfferUtil.java b/core/src/main/java/haveno/core/offer/OfferUtil.java index adc2cb41e7..081198770f 100644 --- a/core/src/main/java/haveno/core/offer/OfferUtil.java +++ b/core/src/main/java/haveno/core/offer/OfferUtil.java @@ -17,9 +17,15 @@ package haveno.core.offer; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.app.Capabilities; import haveno.common.app.Version; import haveno.common.util.MathUtils; +import static haveno.common.util.MathUtils.roundDoubleToLong; +import static haveno.common.util.MathUtils.scaleUpByPowerOf10; import haveno.common.util.Utilities; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.filter.FilterManager; @@ -28,8 +34,16 @@ import haveno.core.locale.Res; import haveno.core.monetary.Price; import haveno.core.monetary.TraditionalMoney; import haveno.core.monetary.Volume; -import haveno.core.payment.PayByMailAccount; +import static haveno.core.offer.OfferPayload.ACCOUNT_AGE_WITNESS_HASH; +import static haveno.core.offer.OfferPayload.CAPABILITIES; +import static haveno.core.offer.OfferPayload.F2F_CITY; +import static haveno.core.offer.OfferPayload.F2F_EXTRA_INFO; +import static haveno.core.offer.OfferPayload.PAY_BY_MAIL_EXTRA_INFO; +import static haveno.core.offer.OfferPayload.REFERRAL_ID; +import static haveno.core.offer.OfferPayload.XMR_AUTO_CONF; +import static haveno.core.offer.OfferPayload.XMR_AUTO_CONF_ENABLED_VALUE; import haveno.core.payment.F2FAccount; +import haveno.core.payment.PayByMailAccount; import haveno.core.payment.PaymentAccount; import haveno.core.provider.price.MarketPrice; import haveno.core.provider.price.PriceFeedService; @@ -37,31 +51,15 @@ import haveno.core.trade.statistics.ReferralIdService; import haveno.core.user.AutoConfirmSettings; import haveno.core.user.Preferences; import haveno.core.util.coin.CoinFormatter; +import static haveno.core.xmr.wallet.Restrictions.getMaxBuyerSecurityDepositAsPercent; +import static haveno.core.xmr.wallet.Restrictions.getMinBuyerSecurityDepositAsPercent; import haveno.network.p2p.P2PService; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.math.BigInteger; import java.util.HashMap; import java.util.Map; import java.util.Optional; import java.util.UUID; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static haveno.common.util.MathUtils.roundDoubleToLong; -import static haveno.common.util.MathUtils.scaleUpByPowerOf10; -import static haveno.core.offer.OfferPayload.ACCOUNT_AGE_WITNESS_HASH; -import static haveno.core.offer.OfferPayload.CAPABILITIES; -import static haveno.core.offer.OfferPayload.PAY_BY_MAIL_EXTRA_INFO; -import static haveno.core.offer.OfferPayload.F2F_CITY; -import static haveno.core.offer.OfferPayload.F2F_EXTRA_INFO; -import static haveno.core.offer.OfferPayload.REFERRAL_ID; -import static haveno.core.offer.OfferPayload.XMR_AUTO_CONF; -import static haveno.core.offer.OfferPayload.XMR_AUTO_CONF_ENABLED_VALUE; -import static haveno.core.xmr.wallet.Restrictions.getMaxBuyerSecurityDepositAsPercent; -import static haveno.core.xmr.wallet.Restrictions.getMinBuyerSecurityDepositAsPercent; +import lombok.extern.slf4j.Slf4j; /** * This class holds utility methods for creating, editing and taking an Offer. diff --git a/core/src/main/java/haveno/core/offer/OpenOfferManager.java b/core/src/main/java/haveno/core/offer/OpenOfferManager.java index 2c70814dd3..db47174239 100644 --- a/core/src/main/java/haveno/core/offer/OpenOfferManager.java +++ b/core/src/main/java/haveno/core/offer/OpenOfferManager.java @@ -34,6 +34,8 @@ package haveno.core.offer; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; import common.utils.GenUtils; import haveno.common.ThreadUtils; import haveno.common.Timer; @@ -90,24 +92,6 @@ import haveno.network.p2p.P2PService; import haveno.network.p2p.SendDirectMessageListener; import haveno.network.p2p.peers.Broadcaster; import haveno.network.p2p.peers.PeerManager; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import lombok.Getter; -import monero.daemon.model.MoneroKeyImageSpentStatus; -import monero.daemon.model.MoneroTx; -import monero.wallet.model.MoneroIncomingTransfer; -import monero.wallet.model.MoneroOutputQuery; -import monero.wallet.model.MoneroTransferQuery; -import monero.wallet.model.MoneroTxConfig; -import monero.wallet.model.MoneroTxQuery; -import monero.wallet.model.MoneroTxWallet; -import monero.wallet.model.MoneroWalletListener; -import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.annotation.Nullable; -import javax.inject.Inject; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; @@ -121,8 +105,22 @@ import java.util.UUID; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkNotNull; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javax.annotation.Nullable; +import lombok.Getter; +import monero.daemon.model.MoneroKeyImageSpentStatus; +import monero.daemon.model.MoneroTx; +import monero.wallet.model.MoneroIncomingTransfer; +import monero.wallet.model.MoneroOutputQuery; +import monero.wallet.model.MoneroTransferQuery; +import monero.wallet.model.MoneroTxConfig; +import monero.wallet.model.MoneroTxQuery; +import monero.wallet.model.MoneroTxWallet; +import monero.wallet.model.MoneroWalletListener; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMessageListener, PersistedDataHost { private static final Logger log = LoggerFactory.getLogger(OpenOfferManager.class); @@ -335,7 +333,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe log.info("Remove open offers at shutDown. Number of open offers: {}", size); if (offerBookService.isBootstrapped() && size > 0) { ThreadUtils.execute(() -> { - + // remove offers from offer book synchronized (openOffers) { openOffers.forEach(openOffer -> { @@ -360,9 +358,9 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe // shut down thread pool off main thread ThreadUtils.submitToPool(() -> { shutDownThreadPool(); - + // invoke completion handler - if (completeHandler != null) completeHandler.run(); + if (completeHandler != null) completeHandler.run(); }); } @@ -443,13 +441,13 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe // process open offers on dedicated thread ThreadUtils.execute(() -> { - + // Republish means we send the complete offer object republishOffers(); startPeriodicRepublishOffersTimer(); - + // Refresh is started once we get a success from republish - + // We republish after a bit as it might be that our connected node still has the offer in the data map // but other peers have it already removed because of expired TTL. // Those other not directly connected peers would not get the broadcast of the new offer, as the first @@ -460,19 +458,19 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe if (retryRepublishOffersTimer == null) retryRepublishOffersTimer = UserThread.runAfter(OpenOfferManager.this::republishOffers, REPUBLISH_AGAIN_AT_STARTUP_DELAY_SEC); - + p2PService.getPeerManager().addListener(this); - + // TODO: add to invalid offers on failure // openOffers.stream() // .forEach(openOffer -> OfferUtil.getInvalidMakerFeeTxErrorMessage(openOffer.getOffer(), btcWalletService) // .ifPresent(errorMsg -> invalidOffers.add(new Tuple2<>(openOffer, errorMsg)))); - + // process scheduled offers processScheduledOffers((transaction) -> {}, (errorMessage) -> { log.warn("Error processing unposted offers: " + errorMessage); }); - + // register to process unposted offers when unlocked balance increases if (xmrWalletService.getWallet() != null) lastUnlockedBalance = xmrWalletService.getWallet().getUnlockedBalance(0); xmrWalletService.addWalletListener(new MoneroWalletListener() { @@ -486,10 +484,10 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe lastUnlockedBalance = newUnlockedBalance; } }); - + // initialize key image poller for signed offers maybeInitializeKeyImagePoller(); - + // poll spent status of key images for (SignedOffer signedOffer : signedOffers.getList()) { signedOfferKeyImagePoller.addKeyImages(signedOffer.getReserveTxKeyImages()); @@ -883,7 +881,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe // get offer reserve amount BigInteger offerReserveAmount = openOffer.getOffer().getReserveAmount(); - + // handle split output offer if (openOffer.isReserveExactAmount()) { @@ -1025,7 +1023,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe } private void splitOrSchedule(List openOffers, OpenOffer openOffer, BigInteger offerReserveAmount) { - + // handle sufficient available balance to split output boolean sufficientAvailableBalance = xmrWalletService.getWallet().getUnlockedBalance(0).compareTo(offerReserveAmount) >= 0; if (sufficientAvailableBalance) { diff --git a/core/src/main/java/haveno/core/offer/TriggerPriceService.java b/core/src/main/java/haveno/core/offer/TriggerPriceService.java index 517262cc3d..7cefac2148 100644 --- a/core/src/main/java/haveno/core/offer/TriggerPriceService.java +++ b/core/src/main/java/haveno/core/offer/TriggerPriceService.java @@ -17,7 +17,11 @@ package haveno.core.offer; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.util.MathUtils; +import static haveno.common.util.MathUtils.roundDoubleToLong; +import static haveno.common.util.MathUtils.scaleUpByPowerOf10; import haveno.core.locale.CurrencyUtil; import haveno.core.monetary.CryptoMoney; import haveno.core.monetary.Price; @@ -26,20 +30,14 @@ import haveno.core.provider.price.MarketPrice; import haveno.core.provider.price.PriceFeedService; import haveno.network.p2p.BootstrapListener; import haveno.network.p2p.P2PService; -import javafx.collections.ListChangeListener; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; - -import static haveno.common.util.MathUtils.roundDoubleToLong; -import static haveno.common.util.MathUtils.scaleUpByPowerOf10; +import javafx.collections.ListChangeListener; +import lombok.extern.slf4j.Slf4j; @Slf4j @Singleton diff --git a/core/src/main/java/haveno/core/offer/takeoffer/TakeOfferModel.java b/core/src/main/java/haveno/core/offer/takeoffer/TakeOfferModel.java index febdd1e1f5..bfe3b824d9 100644 --- a/core/src/main/java/haveno/core/offer/takeoffer/TakeOfferModel.java +++ b/core/src/main/java/haveno/core/offer/takeoffer/TakeOfferModel.java @@ -17,31 +17,29 @@ package haveno.core.offer.takeoffer; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; import haveno.common.taskrunner.Model; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.monetary.Price; import haveno.core.monetary.Volume; import haveno.core.offer.Offer; +import static haveno.core.offer.OfferDirection.SELL; import haveno.core.offer.OfferUtil; import haveno.core.payment.PaymentAccount; import haveno.core.provider.price.PriceFeedService; import haveno.core.trade.HavenoUtils; import haveno.core.util.VolumeUtil; import haveno.core.xmr.model.XmrAddressEntry; +import static haveno.core.xmr.model.XmrAddressEntry.Context.OFFER_FUNDING; import haveno.core.xmr.wallet.XmrWalletService; +import java.math.BigInteger; +import java.util.Objects; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; -import javax.inject.Inject; -import java.math.BigInteger; -import java.util.Objects; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static haveno.core.offer.OfferDirection.SELL; -import static haveno.core.xmr.model.XmrAddressEntry.Context.OFFER_FUNDING; - @Slf4j public class TakeOfferModel implements Model { // Immutable diff --git a/core/src/main/java/haveno/core/payment/ChargeBackRisk.java b/core/src/main/java/haveno/core/payment/ChargeBackRisk.java index 0b1f838a2f..29726ac354 100644 --- a/core/src/main/java/haveno/core/payment/ChargeBackRisk.java +++ b/core/src/main/java/haveno/core/payment/ChargeBackRisk.java @@ -17,10 +17,9 @@ package haveno.core.payment; +import com.google.inject.Singleton; import haveno.core.payment.payload.PaymentMethod; -import javax.inject.Singleton; - @Singleton public class ChargeBackRisk { public boolean hasChargebackRisk(String id, String currencyCode) { diff --git a/core/src/main/java/haveno/core/payment/TradeLimits.java b/core/src/main/java/haveno/core/payment/TradeLimits.java index 78c6eb5a5f..e2de303ed5 100644 --- a/core/src/main/java/haveno/core/payment/TradeLimits.java +++ b/core/src/main/java/haveno/core/payment/TradeLimits.java @@ -18,16 +18,15 @@ package haveno.core.payment; import com.google.common.annotations.VisibleForTesting; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.util.MathUtils; import haveno.core.trade.HavenoUtils; +import java.math.BigInteger; +import javax.annotation.Nullable; import lombok.Getter; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.math.BigInteger; - @Slf4j @Singleton public class TradeLimits { diff --git a/core/src/main/java/haveno/core/payment/validation/AdvancedCashValidator.java b/core/src/main/java/haveno/core/payment/validation/AdvancedCashValidator.java index b6504d351c..cce112b189 100644 --- a/core/src/main/java/haveno/core/payment/validation/AdvancedCashValidator.java +++ b/core/src/main/java/haveno/core/payment/validation/AdvancedCashValidator.java @@ -1,11 +1,10 @@ package haveno.core.payment.validation; +import com.google.inject.Inject; import haveno.core.locale.Res; import haveno.core.util.validation.InputValidator; import haveno.core.util.validation.RegexValidator; -import javax.inject.Inject; - public class AdvancedCashValidator extends InputValidator { private EmailValidator emailValidator; private RegexValidator regexValidator; diff --git a/core/src/main/java/haveno/core/payment/validation/AustraliaPayidAccountNameValidator.java b/core/src/main/java/haveno/core/payment/validation/AustraliaPayidAccountNameValidator.java index 02648f9e85..ff4e1300dd 100644 --- a/core/src/main/java/haveno/core/payment/validation/AustraliaPayidAccountNameValidator.java +++ b/core/src/main/java/haveno/core/payment/validation/AustraliaPayidAccountNameValidator.java @@ -18,11 +18,10 @@ package haveno.core.payment.validation; +import com.google.inject.Inject; import haveno.core.util.validation.InputValidator; import haveno.core.util.validation.RegexValidator; -import javax.inject.Inject; - public final class AustraliaPayidAccountNameValidator extends InputValidator { @Override public ValidationResult validate(String input) { diff --git a/core/src/main/java/haveno/core/payment/validation/CapitualValidator.java b/core/src/main/java/haveno/core/payment/validation/CapitualValidator.java index a156193fce..e18ef0f733 100644 --- a/core/src/main/java/haveno/core/payment/validation/CapitualValidator.java +++ b/core/src/main/java/haveno/core/payment/validation/CapitualValidator.java @@ -1,11 +1,10 @@ package haveno.core.payment.validation; +import com.google.inject.Inject; import haveno.core.locale.Res; import haveno.core.util.validation.InputValidator; import haveno.core.util.validation.RegexValidator; -import javax.inject.Inject; - public class CapitualValidator extends InputValidator { private final RegexValidator regexValidator; diff --git a/core/src/main/java/haveno/core/payment/validation/FiatVolumeValidator.java b/core/src/main/java/haveno/core/payment/validation/FiatVolumeValidator.java index 4b3b950f67..d88396db15 100644 --- a/core/src/main/java/haveno/core/payment/validation/FiatVolumeValidator.java +++ b/core/src/main/java/haveno/core/payment/validation/FiatVolumeValidator.java @@ -17,10 +17,9 @@ package haveno.core.payment.validation; +import com.google.inject.Inject; import haveno.core.util.validation.MonetaryValidator; -import javax.inject.Inject; - public class FiatVolumeValidator extends MonetaryValidator { @Override public double getMinValue() { diff --git a/core/src/main/java/haveno/core/payment/validation/InteracETransferAnswerValidator.java b/core/src/main/java/haveno/core/payment/validation/InteracETransferAnswerValidator.java index 47841dcc9b..4bae615941 100644 --- a/core/src/main/java/haveno/core/payment/validation/InteracETransferAnswerValidator.java +++ b/core/src/main/java/haveno/core/payment/validation/InteracETransferAnswerValidator.java @@ -1,11 +1,10 @@ package haveno.core.payment.validation; +import com.google.inject.Inject; import haveno.core.locale.Res; import haveno.core.util.validation.InputValidator; import haveno.core.util.validation.RegexValidator; -import javax.inject.Inject; - public class InteracETransferAnswerValidator extends InputValidator { private LengthValidator lengthValidator; private RegexValidator regexValidator; diff --git a/core/src/main/java/haveno/core/payment/validation/InteracETransferQuestionValidator.java b/core/src/main/java/haveno/core/payment/validation/InteracETransferQuestionValidator.java index 6fd7c865f9..2fa0cf8550 100644 --- a/core/src/main/java/haveno/core/payment/validation/InteracETransferQuestionValidator.java +++ b/core/src/main/java/haveno/core/payment/validation/InteracETransferQuestionValidator.java @@ -1,11 +1,10 @@ package haveno.core.payment.validation; +import com.google.inject.Inject; import haveno.core.locale.Res; import haveno.core.util.validation.InputValidator; import haveno.core.util.validation.RegexValidator; -import javax.inject.Inject; - public class InteracETransferQuestionValidator extends InputValidator { private LengthValidator lengthValidator; private RegexValidator regexValidator; diff --git a/core/src/main/java/haveno/core/payment/validation/InteracETransferValidator.java b/core/src/main/java/haveno/core/payment/validation/InteracETransferValidator.java index 14a6a91f02..f036e0537a 100644 --- a/core/src/main/java/haveno/core/payment/validation/InteracETransferValidator.java +++ b/core/src/main/java/haveno/core/payment/validation/InteracETransferValidator.java @@ -17,12 +17,11 @@ package haveno.core.payment.validation; +import com.google.inject.Inject; import haveno.core.locale.Res; import haveno.core.util.validation.InputValidator; import org.apache.commons.lang3.StringUtils; -import javax.inject.Inject; - /* * Interac e-Transfer requires a mail address or Canadian (mobile) phone number * diff --git a/core/src/main/java/haveno/core/payment/validation/JapanBankAccountNameValidator.java b/core/src/main/java/haveno/core/payment/validation/JapanBankAccountNameValidator.java index 55ff0290ff..7bff62a820 100644 --- a/core/src/main/java/haveno/core/payment/validation/JapanBankAccountNameValidator.java +++ b/core/src/main/java/haveno/core/payment/validation/JapanBankAccountNameValidator.java @@ -17,12 +17,11 @@ package haveno.core.payment.validation; +import com.google.inject.Inject; import haveno.core.payment.JapanBankData; import haveno.core.util.validation.InputValidator; import haveno.core.util.validation.RegexValidator; -import javax.inject.Inject; - public final class JapanBankAccountNameValidator extends InputValidator { @Override diff --git a/core/src/main/java/haveno/core/payment/validation/JapanBankBranchNameValidator.java b/core/src/main/java/haveno/core/payment/validation/JapanBankBranchNameValidator.java index 1359a598cb..6e64658456 100644 --- a/core/src/main/java/haveno/core/payment/validation/JapanBankBranchNameValidator.java +++ b/core/src/main/java/haveno/core/payment/validation/JapanBankBranchNameValidator.java @@ -17,12 +17,11 @@ package haveno.core.payment.validation; +import com.google.inject.Inject; import haveno.core.payment.JapanBankData; import haveno.core.util.validation.InputValidator; import haveno.core.util.validation.RegexValidator; -import javax.inject.Inject; - public final class JapanBankBranchNameValidator extends InputValidator { @Override diff --git a/core/src/main/java/haveno/core/payment/validation/SecurityDepositValidator.java b/core/src/main/java/haveno/core/payment/validation/SecurityDepositValidator.java index a1f8a953db..7bf873ce4f 100644 --- a/core/src/main/java/haveno/core/payment/validation/SecurityDepositValidator.java +++ b/core/src/main/java/haveno/core/payment/validation/SecurityDepositValidator.java @@ -17,6 +17,7 @@ package haveno.core.payment.validation; +import com.google.inject.Inject; import haveno.core.locale.Res; import haveno.core.payment.PaymentAccount; import haveno.core.util.FormattingUtils; @@ -24,8 +25,6 @@ import haveno.core.util.ParsingUtils; import haveno.core.util.validation.NumberValidator; import haveno.core.xmr.wallet.Restrictions; -import javax.inject.Inject; - public class SecurityDepositValidator extends NumberValidator { private PaymentAccount paymentAccount; diff --git a/core/src/main/java/haveno/core/payment/validation/TransferwiseValidator.java b/core/src/main/java/haveno/core/payment/validation/TransferwiseValidator.java index f0fbd94a46..c6438bb85e 100644 --- a/core/src/main/java/haveno/core/payment/validation/TransferwiseValidator.java +++ b/core/src/main/java/haveno/core/payment/validation/TransferwiseValidator.java @@ -17,10 +17,9 @@ package haveno.core.payment.validation; +import com.google.inject.Inject; import haveno.core.util.validation.InputValidator; -import javax.inject.Inject; - public final class TransferwiseValidator extends InputValidator { private final EmailValidator emailValidator; diff --git a/core/src/main/java/haveno/core/payment/validation/XmrValidator.java b/core/src/main/java/haveno/core/payment/validation/XmrValidator.java index e6947e48b2..728e91ebdf 100644 --- a/core/src/main/java/haveno/core/payment/validation/XmrValidator.java +++ b/core/src/main/java/haveno/core/payment/validation/XmrValidator.java @@ -17,16 +17,15 @@ package haveno.core.payment.validation; +import com.google.inject.Inject; import haveno.core.locale.Res; import haveno.core.trade.HavenoUtils; import haveno.core.util.validation.NumberValidator; -import lombok.Getter; -import lombok.Setter; - -import javax.annotation.Nullable; -import javax.inject.Inject; import java.math.BigDecimal; import java.math.BigInteger; +import javax.annotation.Nullable; +import lombok.Getter; +import lombok.Setter; public class XmrValidator extends NumberValidator { diff --git a/core/src/main/java/haveno/core/presentation/BalancePresentation.java b/core/src/main/java/haveno/core/presentation/BalancePresentation.java index 4a125eb86d..5d7f7ff228 100644 --- a/core/src/main/java/haveno/core/presentation/BalancePresentation.java +++ b/core/src/main/java/haveno/core/presentation/BalancePresentation.java @@ -17,6 +17,7 @@ package haveno.core.presentation; +import com.google.inject.Inject; import haveno.common.UserThread; import haveno.core.trade.HavenoUtils; import haveno.core.xmr.Balances; @@ -25,8 +26,6 @@ import javafx.beans.property.StringProperty; import lombok.Getter; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; - @Slf4j public class BalancePresentation { diff --git a/core/src/main/java/haveno/core/presentation/SupportTicketsPresentation.java b/core/src/main/java/haveno/core/presentation/SupportTicketsPresentation.java index fcbabd08ff..30d0d277f1 100644 --- a/core/src/main/java/haveno/core/presentation/SupportTicketsPresentation.java +++ b/core/src/main/java/haveno/core/presentation/SupportTicketsPresentation.java @@ -17,6 +17,7 @@ package haveno.core.presentation; +import com.google.inject.Inject; import haveno.core.support.dispute.arbitration.ArbitrationManager; import haveno.core.support.dispute.mediation.MediationManager; import haveno.core.support.dispute.refund.RefundManager; @@ -26,8 +27,6 @@ import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import lombok.Getter; -import javax.inject.Inject; - public class SupportTicketsPresentation { @Getter private final StringProperty numOpenSupportTickets = new SimpleStringProperty(); diff --git a/core/src/main/java/haveno/core/presentation/TradePresentation.java b/core/src/main/java/haveno/core/presentation/TradePresentation.java index 111bb8d09a..9abd16ca7b 100644 --- a/core/src/main/java/haveno/core/presentation/TradePresentation.java +++ b/core/src/main/java/haveno/core/presentation/TradePresentation.java @@ -17,6 +17,7 @@ package haveno.core.presentation; +import com.google.inject.Inject; import haveno.common.UserThread; import haveno.core.trade.TradeManager; import javafx.beans.property.BooleanProperty; @@ -25,8 +26,6 @@ import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import lombok.Getter; -import javax.inject.Inject; - public class TradePresentation { @Getter private final StringProperty numPendingTrades = new SimpleStringProperty(); diff --git a/core/src/main/java/haveno/core/proto/network/CoreNetworkProtoResolver.java b/core/src/main/java/haveno/core/proto/network/CoreNetworkProtoResolver.java index bfe6cc1bfa..f2be266ddc 100644 --- a/core/src/main/java/haveno/core/proto/network/CoreNetworkProtoResolver.java +++ b/core/src/main/java/haveno/core/proto/network/CoreNetworkProtoResolver.java @@ -17,6 +17,8 @@ package haveno.core.proto.network; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.proto.ProtobufferException; import haveno.common.proto.ProtobufferRuntimeException; import haveno.common.proto.network.NetworkEnvelope; @@ -69,11 +71,8 @@ import haveno.network.p2p.storage.messages.RemoveMailboxDataMessage; import haveno.network.p2p.storage.payload.MailboxStoragePayload; import haveno.network.p2p.storage.payload.ProtectedMailboxStorageEntry; import haveno.network.p2p.storage.payload.ProtectedStorageEntry; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.time.Clock; +import lombok.extern.slf4j.Slf4j; // TODO Use ProtobufferException instead of ProtobufferRuntimeException @Slf4j diff --git a/core/src/main/java/haveno/core/proto/persistable/CorePersistenceProtoResolver.java b/core/src/main/java/haveno/core/proto/persistable/CorePersistenceProtoResolver.java index b4a4dff630..441252d9a1 100644 --- a/core/src/main/java/haveno/core/proto/persistable/CorePersistenceProtoResolver.java +++ b/core/src/main/java/haveno/core/proto/persistable/CorePersistenceProtoResolver.java @@ -17,7 +17,9 @@ package haveno.core.proto.persistable; +import com.google.inject.Inject; import com.google.inject.Provider; +import com.google.inject.Singleton; import haveno.common.proto.ProtobufferRuntimeException; import haveno.common.proto.network.NetworkProtoResolver; import haveno.common.proto.persistable.NavigationPath; @@ -47,9 +49,6 @@ import haveno.network.p2p.storage.persistence.RemovedPayloadsMap; import haveno.network.p2p.storage.persistence.SequenceNumberMap; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; -import javax.inject.Singleton; - // TODO Use ProtobufferException instead of ProtobufferRuntimeException @Slf4j @Singleton diff --git a/core/src/main/java/haveno/core/provider/FeeHttpClient.java b/core/src/main/java/haveno/core/provider/FeeHttpClient.java index 272656649d..02cc02374e 100644 --- a/core/src/main/java/haveno/core/provider/FeeHttpClient.java +++ b/core/src/main/java/haveno/core/provider/FeeHttpClient.java @@ -17,12 +17,11 @@ package haveno.core.provider; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.network.Socks5ProxyProvider; import haveno.network.http.HttpClientImpl; - import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Singleton; @Singleton public class FeeHttpClient extends HttpClientImpl { diff --git a/core/src/main/java/haveno/core/provider/MempoolHttpClient.java b/core/src/main/java/haveno/core/provider/MempoolHttpClient.java index 6a6091ba70..4ef5db8a70 100644 --- a/core/src/main/java/haveno/core/provider/MempoolHttpClient.java +++ b/core/src/main/java/haveno/core/provider/MempoolHttpClient.java @@ -17,14 +17,13 @@ package haveno.core.provider; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.app.Version; import haveno.network.Socks5ProxyProvider; import haveno.network.http.HttpClientImpl; - -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Singleton; import java.io.IOException; +import javax.annotation.Nullable; @Singleton public class MempoolHttpClient extends HttpClientImpl { diff --git a/core/src/main/java/haveno/core/provider/PriceHttpClient.java b/core/src/main/java/haveno/core/provider/PriceHttpClient.java index 7d6a4f7e8e..589a6429be 100644 --- a/core/src/main/java/haveno/core/provider/PriceHttpClient.java +++ b/core/src/main/java/haveno/core/provider/PriceHttpClient.java @@ -17,12 +17,11 @@ package haveno.core.provider; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.network.Socks5ProxyProvider; import haveno.network.http.HttpClientImpl; - import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Singleton; @Singleton public class PriceHttpClient extends HttpClientImpl { diff --git a/core/src/main/java/haveno/core/provider/ProvidersRepository.java b/core/src/main/java/haveno/core/provider/ProvidersRepository.java index b669d06d51..f8c7da06b4 100644 --- a/core/src/main/java/haveno/core/provider/ProvidersRepository.java +++ b/core/src/main/java/haveno/core/provider/ProvidersRepository.java @@ -35,17 +35,15 @@ package haveno.core.provider; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; - -import javax.annotation.Nullable; -import javax.inject.Named; - import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; +import javax.annotation.Nullable; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; @Slf4j public class ProvidersRepository { diff --git a/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationDisputeListService.java b/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationDisputeListService.java index fc6e722bed..4290381f0b 100644 --- a/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationDisputeListService.java +++ b/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationDisputeListService.java @@ -17,12 +17,11 @@ package haveno.core.support.dispute.arbitration; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.persistence.PersistenceManager; import haveno.core.support.dispute.DisputeListService; -import javax.inject.Inject; -import javax.inject.Singleton; - @Singleton public final class ArbitrationDisputeListService extends DisputeListService { diff --git a/core/src/main/java/haveno/core/support/dispute/arbitration/arbitrator/ArbitratorManager.java b/core/src/main/java/haveno/core/support/dispute/arbitration/arbitrator/ArbitratorManager.java index f6fded3185..c200c732c0 100644 --- a/core/src/main/java/haveno/core/support/dispute/arbitration/arbitrator/ArbitratorManager.java +++ b/core/src/main/java/haveno/core/support/dispute/arbitration/arbitrator/ArbitratorManager.java @@ -34,18 +34,17 @@ package haveno.core.support.dispute.arbitration.arbitrator; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.config.Config; import haveno.common.crypto.KeyRing; import haveno.core.filter.FilterManager; import haveno.core.support.dispute.agent.DisputeAgentManager; import haveno.core.user.User; import haveno.network.p2p.storage.payload.ProtectedStorageEntry; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.ArrayList; import java.util.List; +import lombok.extern.slf4j.Slf4j; @Slf4j @Singleton diff --git a/core/src/main/java/haveno/core/support/dispute/arbitration/arbitrator/ArbitratorService.java b/core/src/main/java/haveno/core/support/dispute/arbitration/arbitrator/ArbitratorService.java index 57dc362c78..71d017b7c7 100644 --- a/core/src/main/java/haveno/core/support/dispute/arbitration/arbitrator/ArbitratorService.java +++ b/core/src/main/java/haveno/core/support/dispute/arbitration/arbitrator/ArbitratorService.java @@ -17,13 +17,12 @@ package haveno.core.support.dispute.arbitration.arbitrator; +import com.google.inject.Inject; import com.google.inject.Singleton; import haveno.core.filter.FilterManager; import haveno.core.support.dispute.agent.DisputeAgentService; import haveno.network.p2p.NodeAddress; import haveno.network.p2p.P2PService; - -import javax.inject.Inject; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/core/src/main/java/haveno/core/support/dispute/mediation/MediationDisputeListService.java b/core/src/main/java/haveno/core/support/dispute/mediation/MediationDisputeListService.java index eeb287fd23..b15a3b15fe 100644 --- a/core/src/main/java/haveno/core/support/dispute/mediation/MediationDisputeListService.java +++ b/core/src/main/java/haveno/core/support/dispute/mediation/MediationDisputeListService.java @@ -17,12 +17,11 @@ package haveno.core.support.dispute.mediation; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.persistence.PersistenceManager; import haveno.core.support.dispute.DisputeListService; -import javax.inject.Inject; -import javax.inject.Singleton; - @Singleton public final class MediationDisputeListService extends DisputeListService { diff --git a/core/src/main/java/haveno/core/support/dispute/mediation/mediator/MediatorManager.java b/core/src/main/java/haveno/core/support/dispute/mediation/mediator/MediatorManager.java index c72d4d2e86..62ad2c01b0 100644 --- a/core/src/main/java/haveno/core/support/dispute/mediation/mediator/MediatorManager.java +++ b/core/src/main/java/haveno/core/support/dispute/mediation/mediator/MediatorManager.java @@ -17,14 +17,13 @@ package haveno.core.support.dispute.mediation.mediator; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.crypto.KeyRing; import haveno.core.filter.FilterManager; import haveno.core.support.dispute.agent.DisputeAgentManager; import haveno.core.user.User; import haveno.network.p2p.storage.payload.ProtectedStorageEntry; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.List; @Singleton diff --git a/core/src/main/java/haveno/core/support/dispute/mediation/mediator/MediatorService.java b/core/src/main/java/haveno/core/support/dispute/mediation/mediator/MediatorService.java index 37f9c9d85c..b3f3d793da 100644 --- a/core/src/main/java/haveno/core/support/dispute/mediation/mediator/MediatorService.java +++ b/core/src/main/java/haveno/core/support/dispute/mediation/mediator/MediatorService.java @@ -17,19 +17,18 @@ package haveno.core.support.dispute.mediation.mediator; +import com.google.inject.Inject; import com.google.inject.Singleton; import haveno.core.filter.FilterManager; import haveno.core.support.dispute.agent.DisputeAgentService; import haveno.network.p2p.NodeAddress; import haveno.network.p2p.P2PService; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; @Slf4j diff --git a/core/src/main/java/haveno/core/support/dispute/refund/RefundDisputeListService.java b/core/src/main/java/haveno/core/support/dispute/refund/RefundDisputeListService.java index ffef9f88a4..c4578f49dc 100644 --- a/core/src/main/java/haveno/core/support/dispute/refund/RefundDisputeListService.java +++ b/core/src/main/java/haveno/core/support/dispute/refund/RefundDisputeListService.java @@ -17,12 +17,11 @@ package haveno.core.support.dispute.refund; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.persistence.PersistenceManager; import haveno.core.support.dispute.DisputeListService; -import javax.inject.Inject; -import javax.inject.Singleton; - @Singleton public final class RefundDisputeListService extends DisputeListService { diff --git a/core/src/main/java/haveno/core/support/dispute/refund/refundagent/RefundAgentManager.java b/core/src/main/java/haveno/core/support/dispute/refund/refundagent/RefundAgentManager.java index 323cd5b860..3e31c38ac7 100644 --- a/core/src/main/java/haveno/core/support/dispute/refund/refundagent/RefundAgentManager.java +++ b/core/src/main/java/haveno/core/support/dispute/refund/refundagent/RefundAgentManager.java @@ -17,16 +17,15 @@ package haveno.core.support.dispute.refund.refundagent; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.crypto.KeyRing; import haveno.core.filter.FilterManager; import haveno.core.support.dispute.agent.DisputeAgentManager; import haveno.core.user.User; import haveno.network.p2p.storage.payload.ProtectedStorageEntry; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.List; +import lombok.extern.slf4j.Slf4j; @Slf4j @Singleton diff --git a/core/src/main/java/haveno/core/support/dispute/refund/refundagent/RefundAgentService.java b/core/src/main/java/haveno/core/support/dispute/refund/refundagent/RefundAgentService.java index 7819be2ade..1aa4eed879 100644 --- a/core/src/main/java/haveno/core/support/dispute/refund/refundagent/RefundAgentService.java +++ b/core/src/main/java/haveno/core/support/dispute/refund/refundagent/RefundAgentService.java @@ -17,13 +17,12 @@ package haveno.core.support.dispute.refund.refundagent; +import com.google.inject.Inject; import com.google.inject.Singleton; import haveno.core.filter.FilterManager; import haveno.core.support.dispute.agent.DisputeAgentService; import haveno.network.p2p.NodeAddress; import haveno.network.p2p.P2PService; - -import javax.inject.Inject; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/core/src/main/java/haveno/core/support/traderchat/TraderChatManager.java b/core/src/main/java/haveno/core/support/traderchat/TraderChatManager.java index d5dacf01ba..f462becdf0 100644 --- a/core/src/main/java/haveno/core/support/traderchat/TraderChatManager.java +++ b/core/src/main/java/haveno/core/support/traderchat/TraderChatManager.java @@ -17,10 +17,12 @@ package haveno.core.support.traderchat; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.crypto.PubKeyRing; import haveno.common.crypto.PubKeyRingProvider; -import haveno.core.api.XmrConnectionService; import haveno.core.api.CoreNotificationService; +import haveno.core.api.XmrConnectionService; import haveno.core.locale.Res; import haveno.core.support.SupportManager; import haveno.core.support.SupportType; @@ -32,15 +34,12 @@ import haveno.core.xmr.wallet.XmrWalletService; import haveno.network.p2p.AckMessageSourceType; import haveno.network.p2p.NodeAddress; import haveno.network.p2p.P2PService; +import java.util.List; +import java.util.Optional; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.List; -import java.util.Optional; - @Slf4j @Singleton public class TraderChatManager extends SupportManager { diff --git a/core/src/main/java/haveno/core/trade/CleanupMailboxMessages.java b/core/src/main/java/haveno/core/trade/CleanupMailboxMessages.java index d44ce44dfe..ea809e2710 100644 --- a/core/src/main/java/haveno/core/trade/CleanupMailboxMessages.java +++ b/core/src/main/java/haveno/core/trade/CleanupMailboxMessages.java @@ -17,6 +17,7 @@ package haveno.core.trade; +import com.google.inject.Inject; import haveno.common.crypto.PubKeyRing; import haveno.common.proto.network.NetworkEnvelope; import haveno.core.trade.messages.TradeMessage; @@ -27,10 +28,8 @@ import haveno.network.p2p.DecryptedMessageWithPubKey; import haveno.network.p2p.P2PService; import haveno.network.p2p.mailbox.MailboxMessage; import haveno.network.p2p.mailbox.MailboxMessageService; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; import java.util.List; +import lombok.extern.slf4j.Slf4j; //TODO with the redesign of mailbox messages that is not required anymore. We leave it for now as we want to minimize // changes for the 1.5.0 release but we should clean up afterwards... diff --git a/core/src/main/java/haveno/core/trade/CleanupMailboxMessagesService.java b/core/src/main/java/haveno/core/trade/CleanupMailboxMessagesService.java index 8c5601fdc4..6e2610c0d9 100644 --- a/core/src/main/java/haveno/core/trade/CleanupMailboxMessagesService.java +++ b/core/src/main/java/haveno/core/trade/CleanupMailboxMessagesService.java @@ -17,6 +17,7 @@ package haveno.core.trade; +import com.google.inject.Inject; import haveno.common.proto.network.NetworkEnvelope; import haveno.core.trade.messages.TradeMessage; import haveno.network.p2p.AckMessage; @@ -26,10 +27,8 @@ import haveno.network.p2p.DecryptedMessageWithPubKey; import haveno.network.p2p.P2PService; import haveno.network.p2p.mailbox.MailboxMessage; import haveno.network.p2p.mailbox.MailboxMessageService; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; import java.util.List; +import lombok.extern.slf4j.Slf4j; //TODO with the redesign of mailbox messages that is not required anymore. We leave it for now as we want to minimize // changes for the 1.5.0 release but we should clean up afterwards... diff --git a/core/src/main/java/haveno/core/trade/ClosedTradableFormatter.java b/core/src/main/java/haveno/core/trade/ClosedTradableFormatter.java index fde373904c..db42547d45 100644 --- a/core/src/main/java/haveno/core/trade/ClosedTradableFormatter.java +++ b/core/src/main/java/haveno/core/trade/ClosedTradableFormatter.java @@ -17,23 +17,14 @@ package haveno.core.trade; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.core.locale.CurrencyUtil; import haveno.core.locale.Res; import haveno.core.monetary.CryptoMoney; import haveno.core.monetary.TraditionalMoney; import haveno.core.monetary.Volume; import haveno.core.offer.OpenOffer; -import haveno.core.util.FormattingUtils; -import lombok.extern.slf4j.Slf4j; -import org.bitcoinj.core.Monetary; - -import javax.inject.Inject; -import javax.inject.Singleton; -import java.math.BigInteger; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - import static haveno.core.trade.ClosedTradableUtil.castToTrade; import static haveno.core.trade.ClosedTradableUtil.getTotalTxFee; import static haveno.core.trade.ClosedTradableUtil.getTotalVolumeByCurrency; @@ -42,10 +33,17 @@ import static haveno.core.trade.ClosedTradableUtil.isOpenOffer; import static haveno.core.trade.Trade.DisputeState.DISPUTE_CLOSED; import static haveno.core.trade.Trade.DisputeState.MEDIATION_CLOSED; import static haveno.core.trade.Trade.DisputeState.REFUND_REQUEST_CLOSED; +import haveno.core.util.FormattingUtils; import static haveno.core.util.FormattingUtils.formatPercentagePrice; import static haveno.core.util.FormattingUtils.formatToPercentWithSymbol; import static haveno.core.util.VolumeUtil.formatVolume; import static haveno.core.util.VolumeUtil.formatVolumeWithCode; +import java.math.BigInteger; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; +import org.bitcoinj.core.Monetary; @Slf4j @Singleton diff --git a/core/src/main/java/haveno/core/trade/TradeManager.java b/core/src/main/java/haveno/core/trade/TradeManager.java index 5af9cc076b..06dc5c8a1e 100644 --- a/core/src/main/java/haveno/core/trade/TradeManager.java +++ b/core/src/main/java/haveno/core/trade/TradeManager.java @@ -34,8 +34,10 @@ package haveno.core.trade; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.ImmutableList; - +import com.google.inject.Inject; import common.utils.GenUtils; import haveno.common.ClockWatcher; import haveno.common.ThreadUtils; @@ -105,23 +107,6 @@ import haveno.network.p2p.SendMailboxMessageListener; import haveno.network.p2p.mailbox.MailboxMessage; import haveno.network.p2p.mailbox.MailboxMessageService; import haveno.network.p2p.network.TorNetworkNode; -import javafx.beans.property.BooleanProperty; -import javafx.beans.property.LongProperty; -import javafx.beans.property.SimpleBooleanProperty; -import javafx.beans.property.SimpleLongProperty; -import javafx.collections.ListChangeListener; -import javafx.collections.ObservableList; -import lombok.Getter; -import monero.daemon.model.MoneroTx; -import org.bitcoinj.core.Coin; -import org.bouncycastle.crypto.params.KeyParameter; -import org.fxmisc.easybind.EasyBind; -import org.fxmisc.easybind.Subscription; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.annotation.Nullable; -import javax.inject.Inject; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; @@ -137,9 +122,21 @@ import java.util.UUID; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import java.util.stream.Stream; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.LongProperty; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.beans.property.SimpleLongProperty; +import javafx.collections.ListChangeListener; +import javafx.collections.ObservableList; +import javax.annotation.Nullable; +import lombok.Getter; +import monero.daemon.model.MoneroTx; +import org.bitcoinj.core.Coin; +import org.bouncycastle.crypto.params.KeyParameter; +import org.fxmisc.easybind.EasyBind; +import org.fxmisc.easybind.Subscription; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TradeManager implements PersistedDataHost, DecryptedDirectMessageListener { @@ -442,7 +439,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi for (Trade trade : trades) { tasks.add(() -> { try { - + // check for duplicate uid if (!uids.add(trade.getUid())) { log.warn("Found trade with duplicate uid, skipping. That should never happen. {} {}, uid={}", trade.getClass().getSimpleName(), trade.getId(), trade.getUid()); @@ -477,7 +474,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi for (Trade trade : trades) { if (trade.isIdling()) ThreadUtils.submitToPool(() -> trade.syncAndPollWallet()); } - + // process after all wallets initialized if (!HavenoUtils.isSeedNode()) { @@ -1140,7 +1137,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi /////////////////////////////////////////////////////////////////////////////////////////// public void sendAckMessage(NodeAddress peer, PubKeyRing peersPubKeyRing, TradeMessage message, boolean result, @Nullable String errorMessage) { - + // create ack message String tradeId = message.getTradeId(); String sourceUid = message.getUid(); @@ -1252,7 +1249,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi public Optional getClosedTrade(String tradeId) { return closedTradableManager.getClosedTrades().stream().filter(e -> e.getId().equals(tradeId)).findFirst(); } - + public Optional getFailedTrade(String tradeId) { return failedTradesManager.getTradeById(tradeId); } diff --git a/core/src/main/java/haveno/core/trade/TradeUtil.java b/core/src/main/java/haveno/core/trade/TradeUtil.java index d808ddf5b8..1b55a6b269 100644 --- a/core/src/main/java/haveno/core/trade/TradeUtil.java +++ b/core/src/main/java/haveno/core/trade/TradeUtil.java @@ -17,24 +17,22 @@ package haveno.core.trade; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.crypto.KeyRing; import haveno.common.util.Tuple2; -import haveno.core.locale.Res; -import haveno.core.offer.Offer; -import haveno.core.xmr.wallet.BtcWalletService; -import lombok.extern.slf4j.Slf4j; - -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.Date; -import java.util.Objects; - -import static com.google.common.base.Preconditions.checkNotNull; import static haveno.core.locale.CurrencyUtil.getCurrencyPair; import static haveno.core.locale.CurrencyUtil.isTraditionalCurrency; +import haveno.core.locale.Res; +import haveno.core.offer.Offer; import static haveno.core.util.FormattingUtils.formatDurationAsWords; +import haveno.core.xmr.wallet.BtcWalletService; import static java.lang.String.format; +import java.util.Date; +import java.util.Objects; +import javax.annotation.Nullable; +import lombok.extern.slf4j.Slf4j; /** * This class contains trade utility methods. diff --git a/core/src/main/java/haveno/core/trade/protocol/ProcessModelServiceProvider.java b/core/src/main/java/haveno/core/trade/protocol/ProcessModelServiceProvider.java index ce5103a702..3447d803f2 100644 --- a/core/src/main/java/haveno/core/trade/protocol/ProcessModelServiceProvider.java +++ b/core/src/main/java/haveno/core/trade/protocol/ProcessModelServiceProvider.java @@ -17,6 +17,7 @@ package haveno.core.trade.protocol; +import com.google.inject.Inject; import haveno.common.crypto.KeyRing; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.filter.FilterManager; @@ -33,8 +34,6 @@ import haveno.core.xmr.wallet.XmrWalletService; import haveno.network.p2p.P2PService; import lombok.Getter; -import javax.inject.Inject; - @Getter public class ProcessModelServiceProvider { private final OpenOfferManager openOfferManager; diff --git a/core/src/main/java/haveno/core/trade/statistics/ReferralIdService.java b/core/src/main/java/haveno/core/trade/statistics/ReferralIdService.java index 3cac5a4d95..efe64307fc 100644 --- a/core/src/main/java/haveno/core/trade/statistics/ReferralIdService.java +++ b/core/src/main/java/haveno/core/trade/statistics/ReferralIdService.java @@ -17,12 +17,11 @@ package haveno.core.trade.statistics; +import com.google.inject.Inject; import haveno.core.user.Preferences; - -import javax.annotation.Nullable; -import javax.inject.Inject; import java.util.Arrays; import java.util.Optional; +import javax.annotation.Nullable; public class ReferralIdService { private final Preferences preferences; diff --git a/core/src/main/java/haveno/core/trade/statistics/TradeStatistics3StorageService.java b/core/src/main/java/haveno/core/trade/statistics/TradeStatistics3StorageService.java index b58177db34..2e6fc42d98 100644 --- a/core/src/main/java/haveno/core/trade/statistics/TradeStatistics3StorageService.java +++ b/core/src/main/java/haveno/core/trade/statistics/TradeStatistics3StorageService.java @@ -17,16 +17,15 @@ package haveno.core.trade.statistics; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.common.persistence.PersistenceManager; import haveno.network.p2p.storage.payload.PersistableNetworkPayload; import haveno.network.p2p.storage.persistence.HistoricalDataStoreService; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import java.io.File; +import lombok.extern.slf4j.Slf4j; @Singleton @Slf4j diff --git a/core/src/main/java/haveno/core/trade/statistics/TradeStatisticsManager.java b/core/src/main/java/haveno/core/trade/statistics/TradeStatisticsManager.java index 7c84e9d0e9..723149ce4a 100644 --- a/core/src/main/java/haveno/core/trade/statistics/TradeStatisticsManager.java +++ b/core/src/main/java/haveno/core/trade/statistics/TradeStatisticsManager.java @@ -18,6 +18,8 @@ package haveno.core.trade.statistics; import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.common.file.JsonFileManager; import haveno.core.locale.CurrencyTuple; @@ -30,13 +32,6 @@ import haveno.core.util.JsonUtil; import haveno.network.p2p.P2PService; import haveno.network.p2p.storage.P2PDataStorage; import haveno.network.p2p.storage.persistence.AppendOnlyDataStoreService; -import javafx.collections.FXCollections; -import javafx.collections.ObservableSet; -import lombok.extern.slf4j.Slf4j; - -import javax.annotation.Nullable; -import javax.inject.Named; -import javax.inject.Singleton; import java.io.File; import java.time.Instant; import java.util.ArrayList; @@ -44,6 +39,10 @@ import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import javafx.collections.FXCollections; +import javafx.collections.ObservableSet; +import javax.annotation.Nullable; +import lombok.extern.slf4j.Slf4j; @Singleton @Slf4j diff --git a/core/src/main/java/haveno/core/user/Preferences.java b/core/src/main/java/haveno/core/user/Preferences.java index bfb10aa472..97e7fc67d6 100644 --- a/core/src/main/java/haveno/core/user/Preferences.java +++ b/core/src/main/java/haveno/core/user/Preferences.java @@ -17,6 +17,10 @@ package haveno.core.user; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.google.inject.name.Named; import haveno.common.config.BaseCurrencyNetwork; import haveno.common.config.Config; import haveno.common.persistence.PersistenceManager; @@ -26,9 +30,9 @@ import haveno.core.locale.Country; import haveno.core.locale.CountryUtil; import haveno.core.locale.CryptoCurrency; import haveno.core.locale.CurrencyUtil; -import haveno.core.locale.TraditionalCurrency; import haveno.core.locale.GlobalSettings; import haveno.core.locale.TradeCurrency; +import haveno.core.locale.TraditionalCurrency; import haveno.core.payment.PaymentAccount; import haveno.core.payment.PaymentAccountUtil; import haveno.core.xmr.XmrNodeSettings; @@ -36,6 +40,13 @@ import haveno.core.xmr.nodes.XmrNodes; import haveno.core.xmr.nodes.XmrNodes.MoneroNodesOption; import haveno.core.xmr.wallet.Restrictions; import haveno.network.p2p.network.BridgeAddressProvider; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; import javafx.beans.property.BooleanProperty; import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleBooleanProperty; @@ -44,30 +55,17 @@ import javafx.collections.FXCollections; import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; import javafx.collections.ObservableMap; +import javax.annotation.Nullable; import lombok.Getter; import lombok.Setter; import lombok.experimental.Delegate; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkNotNull; - @Slf4j @Singleton public final class Preferences implements PersistedDataHost, BridgeAddressProvider { - + public enum UseTorForXmr { AFTER_SYNC, OFF, @@ -654,7 +652,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid prefPayload.setCustomBridges(customBridges); persistenceManager.forcePersistNow(); } - + public void setUseTorForXmrOrdinal(int useTorForXmrOrdinal) { prefPayload.setUseTorForXmrOrdinal(useTorForXmrOrdinal); requestPersistence(); @@ -925,7 +923,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid void setTorTransportOrdinal(int torTransportOrdinal); void setCustomBridges(String customBridges); - + void setUseTorForXmrOrdinal(int useTorForXmrOrdinal); void setMoneroNodesOptionOrdinal(int bitcoinNodesOption); diff --git a/core/src/main/java/haveno/core/user/User.java b/core/src/main/java/haveno/core/user/User.java index bcd7676edd..13eace6281 100644 --- a/core/src/main/java/haveno/core/user/User.java +++ b/core/src/main/java/haveno/core/user/User.java @@ -17,6 +17,9 @@ package haveno.core.user; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.crypto.KeyRing; import haveno.common.persistence.PersistenceManager; import haveno.common.proto.persistable.PersistedDataHost; @@ -31,26 +34,21 @@ import haveno.core.support.dispute.arbitration.arbitrator.Arbitrator; import haveno.core.support.dispute.mediation.mediator.Mediator; import haveno.core.support.dispute.refund.refundagent.RefundAgent; import haveno.network.p2p.NodeAddress; -import javafx.beans.property.ObjectProperty; -import javafx.beans.property.ReadOnlyObjectProperty; -import javafx.beans.property.SimpleObjectProperty; -import javafx.collections.FXCollections; -import javafx.collections.ObservableSet; -import javafx.collections.SetChangeListener; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkNotNull; +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.ReadOnlyObjectProperty; +import javafx.beans.property.SimpleObjectProperty; +import javafx.collections.FXCollections; +import javafx.collections.ObservableSet; +import javafx.collections.SetChangeListener; +import javax.annotation.Nullable; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; /** * The User is persisted locally. diff --git a/core/src/main/java/haveno/core/util/PriceUtil.java b/core/src/main/java/haveno/core/util/PriceUtil.java index f1b6a9c791..35a6b0bec8 100644 --- a/core/src/main/java/haveno/core/util/PriceUtil.java +++ b/core/src/main/java/haveno/core/util/PriceUtil.java @@ -17,6 +17,9 @@ package haveno.core.util; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.util.MathUtils; import haveno.core.locale.CurrencyUtil; import haveno.core.locale.Res; @@ -29,17 +32,12 @@ import haveno.core.provider.price.MarketPrice; import haveno.core.provider.price.PriceFeedService; import haveno.core.trade.statistics.TradeStatisticsManager; import haveno.core.user.Preferences; -import haveno.core.util.validation.AmountValidator8Decimals; import haveno.core.util.validation.AmountValidator4Decimals; +import haveno.core.util.validation.AmountValidator8Decimals; import haveno.core.util.validation.InputValidator; import haveno.core.util.validation.MonetaryValidator; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.Optional; - -import static com.google.common.base.Preconditions.checkNotNull; +import lombok.extern.slf4j.Slf4j; @Slf4j @Singleton @@ -205,4 +203,4 @@ public class PriceUtil { return CurrencyUtil.isTraditionalCurrency(currencyCode) ? TraditionalMoney.SMALLEST_UNIT_EXPONENT : CryptoMoney.SMALLEST_UNIT_EXPONENT; } -} \ No newline at end of file +} diff --git a/core/src/main/java/haveno/core/util/coin/ImmutableCoinFormatter.java b/core/src/main/java/haveno/core/util/coin/ImmutableCoinFormatter.java index 24da3148b5..17ba9a7bc4 100644 --- a/core/src/main/java/haveno/core/util/coin/ImmutableCoinFormatter.java +++ b/core/src/main/java/haveno/core/util/coin/ImmutableCoinFormatter.java @@ -17,14 +17,13 @@ package haveno.core.util.coin; +import com.google.inject.Inject; import haveno.core.util.FormattingUtils; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.bitcoinj.core.Coin; import org.bitcoinj.utils.MonetaryFormat; -import javax.inject.Inject; - @Slf4j public class ImmutableCoinFormatter implements CoinFormatter { diff --git a/core/src/main/java/haveno/core/util/validation/AmountValidator4Decimals.java b/core/src/main/java/haveno/core/util/validation/AmountValidator4Decimals.java index 11f6e43ee9..2cedb5673c 100644 --- a/core/src/main/java/haveno/core/util/validation/AmountValidator4Decimals.java +++ b/core/src/main/java/haveno/core/util/validation/AmountValidator4Decimals.java @@ -17,7 +17,7 @@ package haveno.core.util.validation; -import javax.inject.Inject; +import com.google.inject.Inject; public class AmountValidator4Decimals extends MonetaryValidator { @Override diff --git a/core/src/main/java/haveno/core/util/validation/AmountValidator8Decimals.java b/core/src/main/java/haveno/core/util/validation/AmountValidator8Decimals.java index 7a8afc12eb..6ed489c205 100644 --- a/core/src/main/java/haveno/core/util/validation/AmountValidator8Decimals.java +++ b/core/src/main/java/haveno/core/util/validation/AmountValidator8Decimals.java @@ -17,7 +17,7 @@ package haveno.core.util.validation; -import javax.inject.Inject; +import com.google.inject.Inject; public class AmountValidator8Decimals extends MonetaryValidator { @Override diff --git a/core/src/main/java/haveno/core/util/validation/BtcAddressValidator.java b/core/src/main/java/haveno/core/util/validation/BtcAddressValidator.java index 7424a5e72d..119351eb1f 100644 --- a/core/src/main/java/haveno/core/util/validation/BtcAddressValidator.java +++ b/core/src/main/java/haveno/core/util/validation/BtcAddressValidator.java @@ -17,13 +17,12 @@ package haveno.core.util.validation; +import com.google.inject.Inject; import haveno.common.config.Config; import haveno.core.locale.Res; import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; -import javax.inject.Inject; - public final class BtcAddressValidator extends InputValidator { @Inject diff --git a/core/src/main/java/haveno/core/util/validation/MonetaryValidator.java b/core/src/main/java/haveno/core/util/validation/MonetaryValidator.java index 3dc69a0816..e8e1c1e9a6 100644 --- a/core/src/main/java/haveno/core/util/validation/MonetaryValidator.java +++ b/core/src/main/java/haveno/core/util/validation/MonetaryValidator.java @@ -17,10 +17,9 @@ package haveno.core.util.validation; +import com.google.inject.Inject; import haveno.core.locale.Res; -import javax.inject.Inject; - public abstract class MonetaryValidator extends NumberValidator { public abstract double getMinValue(); diff --git a/core/src/main/java/haveno/core/xmr/Balances.java b/core/src/main/java/haveno/core/xmr/Balances.java index ab03803070..287060246b 100644 --- a/core/src/main/java/haveno/core/xmr/Balances.java +++ b/core/src/main/java/haveno/core/xmr/Balances.java @@ -34,6 +34,7 @@ package haveno.core.xmr; +import com.google.inject.Inject; import haveno.common.ThreadUtils; import haveno.common.UserThread; import haveno.core.offer.OpenOffer; @@ -47,6 +48,9 @@ import haveno.core.trade.TradeManager; import haveno.core.trade.failed.FailedTradesManager; import haveno.core.xmr.listeners.XmrBalanceListener; import haveno.core.xmr.wallet.XmrWalletService; +import java.math.BigInteger; +import java.util.List; +import java.util.stream.Collectors; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.collections.ListChangeListener; @@ -55,11 +59,6 @@ import lombok.extern.slf4j.Slf4j; import monero.wallet.model.MoneroOutputQuery; import monero.wallet.model.MoneroOutputWallet; -import javax.inject.Inject; -import java.math.BigInteger; -import java.util.List; -import java.util.stream.Collectors; - @Slf4j public class Balances { private final TradeManager tradeManager; diff --git a/core/src/main/java/haveno/core/xmr/model/EncryptedConnectionList.java b/core/src/main/java/haveno/core/xmr/model/EncryptedConnectionList.java index b5bd7e916f..9b49e3e96f 100644 --- a/core/src/main/java/haveno/core/xmr/model/EncryptedConnectionList.java +++ b/core/src/main/java/haveno/core/xmr/model/EncryptedConnectionList.java @@ -1,5 +1,6 @@ package haveno.core.xmr.model; +import com.google.inject.Inject; import com.google.protobuf.ByteString; import com.google.protobuf.Message; import haveno.common.crypto.CryptoException; @@ -10,12 +11,6 @@ import haveno.common.proto.persistable.PersistableEnvelope; import haveno.common.proto.persistable.PersistedDataHost; import haveno.core.api.CoreAccountService; import haveno.core.api.model.EncryptedConnection; -import lombok.NonNull; -import monero.common.MoneroRpcConnection; -import org.bitcoinj.crypto.KeyCrypterScrypt; - -import javax.crypto.SecretKey; -import javax.inject.Inject; import java.nio.charset.StandardCharsets; import java.security.SecureRandom; import java.util.HashMap; @@ -28,6 +23,10 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.function.Function; import java.util.stream.Collectors; +import javax.crypto.SecretKey; +import lombok.NonNull; +import monero.common.MoneroRpcConnection; +import org.bitcoinj.crypto.KeyCrypterScrypt; /** diff --git a/core/src/main/java/haveno/core/xmr/wallet/BtcWalletService.java b/core/src/main/java/haveno/core/xmr/wallet/BtcWalletService.java index 1116d0ad1d..f92df7dbbc 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/BtcWalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/BtcWalletService.java @@ -18,6 +18,9 @@ package haveno.core.xmr.wallet; import com.google.common.base.Preconditions; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; import haveno.common.util.Tuple2; import haveno.core.user.Preferences; import haveno.core.xmr.exceptions.AddressEntryException; @@ -27,6 +30,13 @@ import haveno.core.xmr.exceptions.WalletException; import haveno.core.xmr.model.AddressEntry; import haveno.core.xmr.model.AddressEntryList; import haveno.core.xmr.setup.WalletsSetup; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.annotation.Nullable; import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; import org.bitcoinj.core.Coin; @@ -46,18 +56,6 @@ import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.Nullable; -import javax.inject.Inject; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - public class BtcWalletService extends WalletService { private static final Logger log = LoggerFactory.getLogger(BtcWalletService.class); diff --git a/core/src/main/java/haveno/core/xmr/wallet/NonBsqCoinSelector.java b/core/src/main/java/haveno/core/xmr/wallet/NonBsqCoinSelector.java index d256460567..19b833e4bf 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/NonBsqCoinSelector.java +++ b/core/src/main/java/haveno/core/xmr/wallet/NonBsqCoinSelector.java @@ -17,6 +17,7 @@ package haveno.core.xmr.wallet; +import com.google.inject.Inject; import haveno.core.user.Preferences; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -24,8 +25,6 @@ import org.bitcoinj.core.Transaction; import org.bitcoinj.core.TransactionConfidence; import org.bitcoinj.core.TransactionOutput; -import javax.inject.Inject; - /** * We use a specialized version of the CoinSelector based on the DefaultCoinSelector implementation. * We lookup for spendable outputs which matches our address of our address. diff --git a/core/src/main/java/haveno/core/xmr/wallet/TradeWalletService.java b/core/src/main/java/haveno/core/xmr/wallet/TradeWalletService.java index 42516b9f16..55f94ddc1c 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/TradeWalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/TradeWalletService.java @@ -17,7 +17,10 @@ package haveno.core.xmr.wallet; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.ImmutableList; +import com.google.inject.Inject; import haveno.common.config.Config; import haveno.common.util.Tuple2; import haveno.core.user.Preferences; @@ -29,6 +32,10 @@ import haveno.core.xmr.model.PreparedDepositTxAndMakerInputs; import haveno.core.xmr.model.RawTransactionInput; import haveno.core.xmr.setup.WalletConfig; import haveno.core.xmr.setup.WalletsSetup; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import javax.annotation.Nullable; import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; import org.bitcoinj.core.Coin; @@ -55,15 +62,6 @@ import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.Nullable; -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - public class TradeWalletService { diff --git a/core/src/main/java/haveno/core/xmr/wallet/WalletService.java b/core/src/main/java/haveno/core/xmr/wallet/WalletService.java index ba56cc701e..bfd66c0723 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/WalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/WalletService.java @@ -17,10 +17,13 @@ package haveno.core.xmr.wallet; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; import com.google.common.collect.ImmutableMultiset; import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.Multiset; import com.google.common.collect.SetMultimap; +import com.google.inject.Inject; import haveno.common.config.Config; import haveno.core.user.Preferences; import haveno.core.xmr.exceptions.TransactionVerificationException; @@ -29,8 +32,18 @@ import haveno.core.xmr.listeners.AddressConfidenceListener; import haveno.core.xmr.listeners.BalanceListener; import haveno.core.xmr.listeners.TxConfidenceListener; import haveno.core.xmr.setup.WalletsSetup; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.CopyOnWriteArraySet; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; +import javax.annotation.Nullable; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import monero.wallet.MoneroWallet; @@ -73,21 +86,6 @@ import org.bitcoinj.wallet.listeners.WalletReorganizeEventListener; import org.bouncycastle.crypto.params.KeyParameter; import org.jetbrains.annotations.NotNull; -import javax.annotation.Nullable; -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Set; -import java.util.concurrent.CopyOnWriteArraySet; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - /** * Abstract base class for BTC wallet. Provides all non-trade specific functionality. */ diff --git a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java index 2404cb33a3..fd71f2b723 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java @@ -17,9 +17,10 @@ package haveno.core.xmr.wallet; +import static com.google.common.base.Preconditions.checkState; import com.google.common.util.concurrent.Service.State; +import com.google.inject.Inject; import com.google.inject.name.Named; - import common.utils.JsonUtils; import haveno.common.ThreadUtils; import haveno.common.UserThread; @@ -44,38 +45,6 @@ import haveno.core.xmr.model.XmrAddressEntryList; import haveno.core.xmr.setup.DownloadListener; import haveno.core.xmr.setup.MoneroWalletRpcManager; import haveno.core.xmr.setup.WalletsSetup; -import monero.common.MoneroError; -import monero.common.MoneroRpcConnection; -import monero.common.MoneroRpcError; -import monero.common.MoneroUtils; -import monero.common.TaskLooper; -import monero.daemon.MoneroDaemonRpc; -import monero.daemon.model.MoneroFeeEstimate; -import monero.daemon.model.MoneroNetworkType; -import monero.daemon.model.MoneroOutput; -import monero.daemon.model.MoneroSubmitTxResult; -import monero.daemon.model.MoneroTx; -import monero.wallet.MoneroWallet; -import monero.wallet.MoneroWalletRpc; -import monero.wallet.model.MoneroCheckTx; -import monero.wallet.model.MoneroDestination; -import monero.wallet.model.MoneroIncomingTransfer; -import monero.wallet.model.MoneroOutputQuery; -import monero.wallet.model.MoneroOutputWallet; -import monero.wallet.model.MoneroSubaddress; -import monero.wallet.model.MoneroSyncResult; -import monero.wallet.model.MoneroTxConfig; -import monero.wallet.model.MoneroTxPriority; -import monero.wallet.model.MoneroTxQuery; -import monero.wallet.model.MoneroTxWallet; -import monero.wallet.model.MoneroWalletConfig; -import monero.wallet.model.MoneroWalletListener; -import monero.wallet.model.MoneroWalletListenerI; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import javax.inject.Inject; import java.io.File; import java.math.BigInteger; import java.time.LocalDate; @@ -104,8 +73,37 @@ import javafx.beans.property.LongProperty; import javafx.beans.property.ReadOnlyDoubleProperty; import javafx.beans.property.SimpleLongProperty; import javafx.beans.value.ChangeListener; +import monero.common.MoneroError; +import monero.common.MoneroRpcConnection; +import monero.common.MoneroRpcError; +import monero.common.MoneroUtils; +import monero.common.TaskLooper; +import monero.daemon.MoneroDaemonRpc; +import monero.daemon.model.MoneroFeeEstimate; +import monero.daemon.model.MoneroNetworkType; +import monero.daemon.model.MoneroOutput; +import monero.daemon.model.MoneroSubmitTxResult; +import monero.daemon.model.MoneroTx; +import monero.wallet.MoneroWallet; +import monero.wallet.MoneroWalletRpc; +import monero.wallet.model.MoneroCheckTx; +import monero.wallet.model.MoneroDestination; +import monero.wallet.model.MoneroIncomingTransfer; +import monero.wallet.model.MoneroOutputQuery; +import monero.wallet.model.MoneroOutputWallet; +import monero.wallet.model.MoneroSubaddress; +import monero.wallet.model.MoneroSyncResult; +import monero.wallet.model.MoneroTxConfig; +import monero.wallet.model.MoneroTxPriority; +import monero.wallet.model.MoneroTxQuery; +import monero.wallet.model.MoneroTxWallet; +import monero.wallet.model.MoneroWalletConfig; +import monero.wallet.model.MoneroWalletListener; +import monero.wallet.model.MoneroWalletListenerI; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import static com.google.common.base.Preconditions.checkState; public class XmrWalletService { private static final Logger log = LoggerFactory.getLogger(XmrWalletService.class); @@ -295,7 +293,7 @@ public class XmrWalletService { public boolean isProxyApplied() { return isProxyApplied(wasWalletSynced); } - + public boolean isProxyApplied(boolean wasWalletSynced) { return preferences.isProxyApplied(wasWalletSynced); } @@ -449,7 +447,7 @@ public class XmrWalletService { /** * Freeze the given outputs with a lock on the wallet. - * + * * @param keyImages the key images to freeze */ public void freezeOutputs(Collection keyImages) { @@ -771,7 +769,7 @@ public class XmrWalletService { public void shutDown() { log.info("Shutting down {}", getClass().getSimpleName()); - + // remove listeners which stops polling wallet // TODO monero-java: wallet.stopPolling()? synchronized (walletLock) { @@ -860,18 +858,18 @@ public class XmrWalletService { BigInteger unlockedBalance = getAvailableBalance(); log.info("Monero wallet unlocked balance={}, pending balance={}, total balance={}", unlockedBalance, balance.subtract(unlockedBalance), balance); } - + // reapply connection after wallet synced onConnectionChanged(xmrConnectionService.getConnection()); // signal that main wallet is synced doneDownload(); - + // notify setup that main wallet is initialized // TODO: app fully initializes after this is set to true, even though wallet might not be initialized if unconnected. wallet will be created when connection detected // refactor startup to call this and sync off main thread? but the calls to e.g. getBalance() fail with 'wallet and network is not yet initialized' HavenoUtils.havenoSetup.getWalletInitialized().set(true); - + // save but skip backup on initialization saveMainWallet(false); } catch (Exception e) { @@ -955,10 +953,10 @@ public class XmrWalletService { // start monero-wallet-rpc instance walletRpc = startWalletRpcInstance(port, isProxyApplied(false)); walletRpc.getRpcConnection().setPrintStackTrace(PRINT_STACK_TRACE); - + // prevent wallet rpc from syncing walletRpc.stopSyncing(); - + // create wallet log.info("Creating wallet " + config.getPath() + " connected to daemon " + connection.getUri()); long time = System.currentTimeMillis(); @@ -980,14 +978,14 @@ public class XmrWalletService { // start monero-wallet-rpc instance walletRpc = startWalletRpcInstance(port, applyProxyUri); walletRpc.getRpcConnection().setPrintStackTrace(PRINT_STACK_TRACE); - + // prevent wallet rpc from syncing walletRpc.stopSyncing(); // configure connection MoneroRpcConnection connection = new MoneroRpcConnection(xmrConnectionService.getConnection()); if (!applyProxyUri) connection.setProxyUri(null); - + // open wallet walletRpc.openWallet(config.setServer(connection)); if (walletRpc.getDaemonConnection() != null) walletRpc.getDaemonConnection().setPrintStackTrace(PRINT_STACK_TRACE); @@ -1132,7 +1130,7 @@ public class XmrWalletService { log.warn("Error getting new address entry based on incoming transactions"); e.printStackTrace(); } - + // create new entry return getNewAddressEntryAux(offerId, context); } diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcAccountService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcAccountService.java index 387d52a45b..d994f500c6 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcAccountService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcAccountService.java @@ -18,14 +18,25 @@ package haveno.daemon.grpc; import com.google.common.annotations.VisibleForTesting; +import com.google.inject.Inject; import com.google.protobuf.ByteString; import haveno.common.crypto.IncorrectPasswordException; import haveno.core.api.CoreApi; import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor; import haveno.daemon.grpc.interceptor.GrpcCallRateMeter; +import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import haveno.proto.grpc.AccountExistsReply; import haveno.proto.grpc.AccountExistsRequest; import haveno.proto.grpc.AccountGrpc.AccountImplBase; +import static haveno.proto.grpc.AccountGrpc.getAccountExistsMethod; +import static haveno.proto.grpc.AccountGrpc.getBackupAccountMethod; +import static haveno.proto.grpc.AccountGrpc.getChangePasswordMethod; +import static haveno.proto.grpc.AccountGrpc.getCloseAccountMethod; +import static haveno.proto.grpc.AccountGrpc.getCreateAccountMethod; +import static haveno.proto.grpc.AccountGrpc.getDeleteAccountMethod; +import static haveno.proto.grpc.AccountGrpc.getIsAccountOpenMethod; +import static haveno.proto.grpc.AccountGrpc.getOpenAccountMethod; +import static haveno.proto.grpc.AccountGrpc.getRestoreAccountMethod; import haveno.proto.grpc.BackupAccountReply; import haveno.proto.grpc.BackupAccountRequest; import haveno.proto.grpc.ChangePasswordReply; @@ -46,25 +57,12 @@ import haveno.proto.grpc.RestoreAccountReply; import haveno.proto.grpc.RestoreAccountRequest; import io.grpc.ServerInterceptor; import io.grpc.stub.StreamObserver; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.HashMap; import java.util.Optional; - -import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; -import static haveno.proto.grpc.AccountGrpc.getAccountExistsMethod; -import static haveno.proto.grpc.AccountGrpc.getBackupAccountMethod; -import static haveno.proto.grpc.AccountGrpc.getChangePasswordMethod; -import static haveno.proto.grpc.AccountGrpc.getCloseAccountMethod; -import static haveno.proto.grpc.AccountGrpc.getCreateAccountMethod; -import static haveno.proto.grpc.AccountGrpc.getDeleteAccountMethod; -import static haveno.proto.grpc.AccountGrpc.getIsAccountOpenMethod; -import static haveno.proto.grpc.AccountGrpc.getOpenAccountMethod; -import static haveno.proto.grpc.AccountGrpc.getRestoreAccountMethod; import static java.util.concurrent.TimeUnit.SECONDS; +import lombok.extern.slf4j.Slf4j; @VisibleForTesting @Slf4j diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcDisputeAgentsService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcDisputeAgentsService.java index 99ca4fa868..75d1eef40c 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcDisputeAgentsService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcDisputeAgentsService.java @@ -1,25 +1,23 @@ package haveno.daemon.grpc; +import com.google.inject.Inject; import haveno.core.api.CoreApi; import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor; import haveno.daemon.grpc.interceptor.GrpcCallRateMeter; +import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; +import static haveno.proto.grpc.DisputeAgentsGrpc.DisputeAgentsImplBase; +import static haveno.proto.grpc.DisputeAgentsGrpc.getRegisterDisputeAgentMethod; +import static haveno.proto.grpc.DisputeAgentsGrpc.getUnregisterDisputeAgentMethod; import haveno.proto.grpc.RegisterDisputeAgentReply; import haveno.proto.grpc.RegisterDisputeAgentRequest; import haveno.proto.grpc.UnregisterDisputeAgentReply; import haveno.proto.grpc.UnregisterDisputeAgentRequest; import io.grpc.ServerInterceptor; import io.grpc.stub.StreamObserver; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; import java.util.HashMap; import java.util.Optional; - -import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; -import static haveno.proto.grpc.DisputeAgentsGrpc.DisputeAgentsImplBase; -import static haveno.proto.grpc.DisputeAgentsGrpc.getRegisterDisputeAgentMethod; -import static haveno.proto.grpc.DisputeAgentsGrpc.getUnregisterDisputeAgentMethod; import static java.util.concurrent.TimeUnit.SECONDS; +import lombok.extern.slf4j.Slf4j; @Slf4j class GrpcDisputeAgentsService extends DisputeAgentsImplBase { diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcDisputesService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcDisputesService.java index a5dd0978fa..29d0f3cda9 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcDisputesService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcDisputesService.java @@ -1,5 +1,6 @@ package haveno.daemon.grpc; +import com.google.inject.Inject; import haveno.common.config.Config; import haveno.common.proto.ProtoUtil; import haveno.core.api.CoreApi; @@ -7,7 +8,13 @@ import haveno.core.support.dispute.Attachment; import haveno.core.support.dispute.DisputeResult; import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor; import haveno.daemon.grpc.interceptor.GrpcCallRateMeter; +import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import haveno.proto.grpc.DisputesGrpc.DisputesImplBase; +import static haveno.proto.grpc.DisputesGrpc.getGetDisputeMethod; +import static haveno.proto.grpc.DisputesGrpc.getGetDisputesMethod; +import static haveno.proto.grpc.DisputesGrpc.getOpenDisputeMethod; +import static haveno.proto.grpc.DisputesGrpc.getResolveDisputeMethod; +import static haveno.proto.grpc.DisputesGrpc.getSendDisputeChatMessageMethod; import haveno.proto.grpc.GetDisputeReply; import haveno.proto.grpc.GetDisputeRequest; import haveno.proto.grpc.GetDisputesReply; @@ -20,21 +27,12 @@ import haveno.proto.grpc.SendDisputeChatMessageReply; import haveno.proto.grpc.SendDisputeChatMessageRequest; import io.grpc.ServerInterceptor; import io.grpc.stub.StreamObserver; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; import java.util.ArrayList; import java.util.HashMap; import java.util.Optional; -import java.util.stream.Collectors; - -import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; -import static haveno.proto.grpc.DisputesGrpc.getGetDisputeMethod; -import static haveno.proto.grpc.DisputesGrpc.getGetDisputesMethod; -import static haveno.proto.grpc.DisputesGrpc.getOpenDisputeMethod; -import static haveno.proto.grpc.DisputesGrpc.getResolveDisputeMethod; -import static haveno.proto.grpc.DisputesGrpc.getSendDisputeChatMessageMethod; import static java.util.concurrent.TimeUnit.SECONDS; +import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; @Slf4j public class GrpcDisputesService extends DisputesImplBase { diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcExceptionHandler.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcExceptionHandler.java index 0056f5b0a8..1d3e4bf17c 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcExceptionHandler.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcExceptionHandler.java @@ -17,18 +17,16 @@ package haveno.daemon.grpc; +import com.google.inject.Inject; +import com.google.inject.Singleton; import io.grpc.Status; -import io.grpc.StatusRuntimeException; -import io.grpc.stub.StreamObserver; -import org.slf4j.Logger; - -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.function.Function; -import java.util.function.Predicate; - import static io.grpc.Status.INVALID_ARGUMENT; import static io.grpc.Status.UNKNOWN; +import io.grpc.StatusRuntimeException; +import io.grpc.stub.StreamObserver; +import java.util.function.Function; +import java.util.function.Predicate; +import org.slf4j.Logger; /** * The singleton instance of this class handles any expected core api Throwable by diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcGetTradeStatisticsService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcGetTradeStatisticsService.java index 459f59f37e..04aefc0872 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcGetTradeStatisticsService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcGetTradeStatisticsService.java @@ -1,24 +1,22 @@ package haveno.daemon.grpc; +import com.google.inject.Inject; import haveno.core.api.CoreApi; import haveno.core.trade.statistics.TradeStatistics3; import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor; import haveno.daemon.grpc.interceptor.GrpcCallRateMeter; +import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; +import static haveno.proto.grpc.GetTradeStatisticsGrpc.GetTradeStatisticsImplBase; +import static haveno.proto.grpc.GetTradeStatisticsGrpc.getGetTradeStatisticsMethod; import haveno.proto.grpc.GetTradeStatisticsReply; import haveno.proto.grpc.GetTradeStatisticsRequest; import io.grpc.ServerInterceptor; import io.grpc.stub.StreamObserver; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; import java.util.HashMap; import java.util.Optional; -import java.util.stream.Collectors; - -import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; -import static haveno.proto.grpc.GetTradeStatisticsGrpc.GetTradeStatisticsImplBase; -import static haveno.proto.grpc.GetTradeStatisticsGrpc.getGetTradeStatisticsMethod; import static java.util.concurrent.TimeUnit.SECONDS; +import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; @Slf4j class GrpcGetTradeStatisticsService extends GetTradeStatisticsImplBase { diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcHelpService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcHelpService.java index 86fc6e1d21..1a2b880ec1 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcHelpService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcHelpService.java @@ -17,23 +17,21 @@ package haveno.daemon.grpc; +import com.google.inject.Inject; import haveno.core.api.CoreApi; import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor; import haveno.daemon.grpc.interceptor.GrpcCallRateMeter; +import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import haveno.proto.grpc.GetMethodHelpReply; import haveno.proto.grpc.GetMethodHelpRequest; -import io.grpc.ServerInterceptor; -import io.grpc.stub.StreamObserver; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import java.util.HashMap; -import java.util.Optional; - -import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import static haveno.proto.grpc.HelpGrpc.HelpImplBase; import static haveno.proto.grpc.HelpGrpc.getGetMethodHelpMethod; +import io.grpc.ServerInterceptor; +import io.grpc.stub.StreamObserver; +import java.util.HashMap; +import java.util.Optional; import static java.util.concurrent.TimeUnit.SECONDS; +import lombok.extern.slf4j.Slf4j; @Slf4j class GrpcHelpService extends HelpImplBase { diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcNotificationsService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcNotificationsService.java index 23082d0364..410ac270ce 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcNotificationsService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcNotificationsService.java @@ -1,11 +1,15 @@ package haveno.daemon.grpc; +import com.google.inject.Inject; import haveno.core.api.CoreApi; import haveno.core.api.NotificationListener; import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor; import haveno.daemon.grpc.interceptor.GrpcCallRateMeter; +import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import haveno.proto.grpc.NotificationMessage; import haveno.proto.grpc.NotificationsGrpc.NotificationsImplBase; +import static haveno.proto.grpc.NotificationsGrpc.getRegisterNotificationListenerMethod; +import static haveno.proto.grpc.NotificationsGrpc.getSendNotificationMethod; import haveno.proto.grpc.RegisterNotificationListenerRequest; import haveno.proto.grpc.SendNotificationReply; import haveno.proto.grpc.SendNotificationRequest; @@ -13,19 +17,13 @@ import io.grpc.Context; import io.grpc.ServerInterceptor; import io.grpc.stub.ServerCallStreamObserver; import io.grpc.stub.StreamObserver; +import java.util.HashMap; +import java.util.Optional; +import static java.util.concurrent.TimeUnit.SECONDS; import lombok.NonNull; import lombok.Value; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; -import java.util.HashMap; -import java.util.Optional; - -import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; -import static haveno.proto.grpc.NotificationsGrpc.getRegisterNotificationListenerMethod; -import static haveno.proto.grpc.NotificationsGrpc.getSendNotificationMethod; -import static java.util.concurrent.TimeUnit.SECONDS; - @Slf4j class GrpcNotificationsService extends NotificationsImplBase { diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcOffersService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcOffersService.java index 5f2bb84b6d..6b1ccbf270 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcOffersService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcOffersService.java @@ -17,6 +17,7 @@ package haveno.daemon.grpc; +import com.google.inject.Inject; import haveno.common.config.Config; import haveno.core.api.CoreApi; import haveno.core.api.model.OfferInfo; @@ -24,6 +25,7 @@ import haveno.core.offer.Offer; import haveno.core.offer.OpenOffer; import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor; import haveno.daemon.grpc.interceptor.GrpcCallRateMeter; +import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import haveno.proto.grpc.CancelOfferReply; import haveno.proto.grpc.CancelOfferRequest; import haveno.proto.grpc.GetMyOfferReply; @@ -34,20 +36,6 @@ import haveno.proto.grpc.GetOfferReply; import haveno.proto.grpc.GetOfferRequest; import haveno.proto.grpc.GetOffersReply; import haveno.proto.grpc.GetOffersRequest; -import haveno.proto.grpc.PostOfferReply; -import haveno.proto.grpc.PostOfferRequest; -import io.grpc.ServerInterceptor; -import io.grpc.stub.StreamObserver; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import static haveno.proto.grpc.OffersGrpc.OffersImplBase; import static haveno.proto.grpc.OffersGrpc.getCancelOfferMethod; import static haveno.proto.grpc.OffersGrpc.getGetMyOfferMethod; @@ -55,8 +43,18 @@ import static haveno.proto.grpc.OffersGrpc.getGetMyOffersMethod; import static haveno.proto.grpc.OffersGrpc.getGetOfferMethod; import static haveno.proto.grpc.OffersGrpc.getGetOffersMethod; import static haveno.proto.grpc.OffersGrpc.getPostOfferMethod; +import haveno.proto.grpc.PostOfferReply; +import haveno.proto.grpc.PostOfferRequest; +import io.grpc.ServerInterceptor; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.SECONDS; +import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; @Slf4j class GrpcOffersService extends OffersImplBase { diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcPaymentAccountsService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcPaymentAccountsService.java index 82f619afe8..e29b448f83 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcPaymentAccountsService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcPaymentAccountsService.java @@ -17,6 +17,7 @@ package haveno.daemon.grpc; +import com.google.inject.Inject; import haveno.common.config.Config; import haveno.core.api.CoreApi; import haveno.core.api.model.PaymentAccountForm; @@ -28,6 +29,7 @@ import haveno.core.payment.payload.PaymentMethod; import haveno.core.proto.CoreProtoResolver; import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor; import haveno.daemon.grpc.interceptor.GrpcCallRateMeter; +import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import haveno.proto.grpc.CreateCryptoCurrencyPaymentAccountReply; import haveno.proto.grpc.CreateCryptoCurrencyPaymentAccountRequest; import haveno.proto.grpc.CreatePaymentAccountReply; @@ -41,25 +43,21 @@ import haveno.proto.grpc.GetPaymentAccountsRequest; import haveno.proto.grpc.GetPaymentMethodsReply; import haveno.proto.grpc.GetPaymentMethodsRequest; import haveno.proto.grpc.PaymentAccountsGrpc.PaymentAccountsImplBase; -import haveno.proto.grpc.ValidateFormFieldReply; -import haveno.proto.grpc.ValidateFormFieldRequest; -import io.grpc.ServerInterceptor; -import io.grpc.stub.StreamObserver; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import java.util.HashMap; -import java.util.Optional; -import java.util.stream.Collectors; - -import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import static haveno.proto.grpc.PaymentAccountsGrpc.getCreateCryptoCurrencyPaymentAccountMethod; import static haveno.proto.grpc.PaymentAccountsGrpc.getCreatePaymentAccountMethod; import static haveno.proto.grpc.PaymentAccountsGrpc.getGetPaymentAccountFormMethod; import static haveno.proto.grpc.PaymentAccountsGrpc.getGetPaymentAccountsMethod; import static haveno.proto.grpc.PaymentAccountsGrpc.getGetPaymentMethodsMethod; +import haveno.proto.grpc.ValidateFormFieldReply; +import haveno.proto.grpc.ValidateFormFieldRequest; +import io.grpc.ServerInterceptor; +import io.grpc.stub.StreamObserver; +import java.util.HashMap; +import java.util.Optional; import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.SECONDS; +import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; @Slf4j class GrpcPaymentAccountsService extends PaymentAccountsImplBase { diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcPriceService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcPriceService.java index b91497d641..223b1f2874 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcPriceService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcPriceService.java @@ -35,23 +35,24 @@ package haveno.daemon.grpc; import haveno.common.config.Config; +import com.google.inject.Inject; import haveno.core.api.CoreApi; import haveno.core.api.model.MarketDepthInfo; import haveno.core.api.model.MarketPriceInfo; import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor; import haveno.daemon.grpc.interceptor.GrpcCallRateMeter; +import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import haveno.proto.grpc.MarketDepthReply; import haveno.proto.grpc.MarketDepthRequest; import haveno.proto.grpc.MarketPriceReply; import haveno.proto.grpc.MarketPriceRequest; import haveno.proto.grpc.MarketPricesReply; import haveno.proto.grpc.MarketPricesRequest; +import static haveno.proto.grpc.PriceGrpc.PriceImplBase; +import static haveno.proto.grpc.PriceGrpc.getGetMarketPriceMethod; import haveno.proto.grpc.PriceGrpc.PriceImplBase; import io.grpc.ServerInterceptor; import io.grpc.stub.StreamObserver; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; import java.util.HashMap; import java.util.List; import java.util.Optional; @@ -59,6 +60,7 @@ import java.util.Optional; import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import static haveno.proto.grpc.PriceGrpc.getGetMarketPriceMethod; import static java.util.concurrent.TimeUnit.SECONDS; +import lombok.extern.slf4j.Slf4j; @Slf4j class GrpcPriceService extends PriceImplBase { diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcServer.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcServer.java index 9b56975835..1de4580038 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcServer.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcServer.java @@ -17,19 +17,17 @@ package haveno.daemon.grpc; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.config.Config; import haveno.core.api.CoreContext; import haveno.daemon.grpc.interceptor.PasswordAuthInterceptor; import io.grpc.Server; import io.grpc.ServerBuilder; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; +import static io.grpc.ServerInterceptors.interceptForward; import java.io.IOException; import java.io.UncheckedIOException; - -import static io.grpc.ServerInterceptors.interceptForward; +import lombok.extern.slf4j.Slf4j; @Singleton @Slf4j diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcShutdownService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcShutdownService.java index 94cd0c41c5..8956ce8f8e 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcShutdownService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcShutdownService.java @@ -17,17 +17,15 @@ package haveno.daemon.grpc; +import com.google.inject.Inject; import haveno.common.UserThread; import haveno.core.app.HavenoHeadlessApp; import haveno.proto.grpc.ShutdownServerGrpc; import haveno.proto.grpc.StopReply; import haveno.proto.grpc.StopRequest; import io.grpc.stub.StreamObserver; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; - import static java.util.concurrent.TimeUnit.MILLISECONDS; +import lombok.extern.slf4j.Slf4j; @Slf4j class GrpcShutdownService extends ShutdownServerGrpc.ShutdownServerImplBase { diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcTradesService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcTradesService.java index 782eb28664..70c2c355fd 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcTradesService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcTradesService.java @@ -34,12 +34,15 @@ package haveno.daemon.grpc; +import com.google.inject.Inject; import haveno.common.config.Config; import haveno.core.api.CoreApi; import haveno.core.api.model.TradeInfo; +import static haveno.core.api.model.TradeInfo.toTradeInfo; import haveno.core.trade.Trade; import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor; import haveno.daemon.grpc.interceptor.GrpcCallRateMeter; +import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import haveno.proto.grpc.CompleteTradeReply; import haveno.proto.grpc.CompleteTradeRequest; import haveno.proto.grpc.ConfirmPaymentReceivedReply; @@ -57,18 +60,6 @@ import haveno.proto.grpc.SendChatMessageRequest; import haveno.proto.grpc.TakeOfferReply; import haveno.proto.grpc.TakeOfferRequest; import haveno.proto.grpc.TradesGrpc.TradesImplBase; -import io.grpc.ServerInterceptor; -import io.grpc.stub.StreamObserver; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import static haveno.core.api.model.TradeInfo.toTradeInfo; -import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import static haveno.proto.grpc.TradesGrpc.getCompleteTradeMethod; import static haveno.proto.grpc.TradesGrpc.getConfirmPaymentReceivedMethod; import static haveno.proto.grpc.TradesGrpc.getConfirmPaymentSentMethod; @@ -78,8 +69,15 @@ import static haveno.proto.grpc.TradesGrpc.getGetTradesMethod; import static haveno.proto.grpc.TradesGrpc.getSendChatMessageMethod; import static haveno.proto.grpc.TradesGrpc.getTakeOfferMethod; import static haveno.proto.grpc.TradesGrpc.getWithdrawFundsMethod; +import io.grpc.ServerInterceptor; +import io.grpc.stub.StreamObserver; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.SECONDS; +import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; @Slf4j class GrpcTradesService extends TradesImplBase { diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcVersionService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcVersionService.java index f6abaffb33..a2897d5267 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcVersionService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcVersionService.java @@ -20,23 +20,25 @@ package haveno.daemon.grpc; import com.google.common.annotations.VisibleForTesting; import haveno.common.config.Config; +import com.google.inject.Inject; import haveno.core.api.CoreApi; import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor; import haveno.daemon.grpc.interceptor.GrpcCallRateMeter; +import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; +import static haveno.proto.grpc.GetVersionGrpc.GetVersionImplBase; +import static haveno.proto.grpc.GetVersionGrpc.getGetVersionMethod; import haveno.proto.grpc.GetVersionGrpc.GetVersionImplBase; import haveno.proto.grpc.GetVersionReply; import haveno.proto.grpc.GetVersionRequest; import io.grpc.ServerInterceptor; import io.grpc.stub.StreamObserver; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; import java.util.HashMap; import java.util.Optional; import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import static haveno.proto.grpc.GetVersionGrpc.getGetVersionMethod; import static java.util.concurrent.TimeUnit.SECONDS; +import lombok.extern.slf4j.Slf4j; @VisibleForTesting @Slf4j diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcWalletsService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcWalletsService.java index d430afa39e..7c3ca22e3b 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcWalletsService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcWalletsService.java @@ -34,12 +34,15 @@ package haveno.daemon.grpc; +import com.google.inject.Inject; import haveno.common.UserThread; import haveno.common.config.Config; import haveno.core.api.CoreApi; import haveno.core.api.model.AddressBalanceInfo; +import static haveno.core.api.model.XmrTx.toXmrTx; import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor; import haveno.daemon.grpc.interceptor.GrpcCallRateMeter; +import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import haveno.proto.grpc.CreateXmrTxReply; import haveno.proto.grpc.CreateXmrTxRequest; import haveno.proto.grpc.GetAddressBalanceReply; @@ -67,21 +70,6 @@ import haveno.proto.grpc.SetWalletPasswordRequest; import haveno.proto.grpc.UnlockWalletReply; import haveno.proto.grpc.UnlockWalletRequest; import haveno.proto.grpc.WalletsGrpc.WalletsImplBase; -import io.grpc.ServerInterceptor; -import io.grpc.stub.StreamObserver; -import lombok.extern.slf4j.Slf4j; -import monero.wallet.model.MoneroDestination; -import monero.wallet.model.MoneroTxWallet; - -import javax.inject.Inject; -import java.math.BigInteger; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import static haveno.core.api.model.XmrTx.toXmrTx; -import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import static haveno.proto.grpc.WalletsGrpc.getGetAddressBalanceMethod; import static haveno.proto.grpc.WalletsGrpc.getGetBalancesMethod; import static haveno.proto.grpc.WalletsGrpc.getGetFundingAddressesMethod; @@ -89,7 +77,17 @@ import static haveno.proto.grpc.WalletsGrpc.getLockWalletMethod; import static haveno.proto.grpc.WalletsGrpc.getRemoveWalletPasswordMethod; import static haveno.proto.grpc.WalletsGrpc.getSetWalletPasswordMethod; import static haveno.proto.grpc.WalletsGrpc.getUnlockWalletMethod; +import io.grpc.ServerInterceptor; +import io.grpc.stub.StreamObserver; +import java.math.BigInteger; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; import static java.util.concurrent.TimeUnit.SECONDS; +import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; +import monero.wallet.model.MoneroDestination; +import monero.wallet.model.MoneroTxWallet; @Slf4j class GrpcWalletsService extends WalletsImplBase { diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrConnectionService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrConnectionService.java index 9d293ba2cb..741704eff5 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrConnectionService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrConnectionService.java @@ -34,9 +34,11 @@ package haveno.daemon.grpc; +import com.google.inject.Inject; import haveno.core.api.CoreApi; import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor; import haveno.daemon.grpc.interceptor.GrpcCallRateMeter; +import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import haveno.proto.grpc.AddConnectionReply; import haveno.proto.grpc.AddConnectionRequest; import haveno.proto.grpc.CheckConnectionReply; @@ -60,20 +62,6 @@ import haveno.proto.grpc.StartCheckingConnectionsRequest; import haveno.proto.grpc.StopCheckingConnectionsReply; import haveno.proto.grpc.StopCheckingConnectionsRequest; import haveno.proto.grpc.UrlConnection; -import io.grpc.ServerInterceptor; -import io.grpc.stub.StreamObserver; -import lombok.extern.slf4j.Slf4j; -import monero.common.MoneroRpcConnection; - -import javax.inject.Inject; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import static haveno.proto.grpc.XmrConnectionsGrpc.XmrConnectionsImplBase; import static haveno.proto.grpc.XmrConnectionsGrpc.getAddConnectionMethod; import static haveno.proto.grpc.XmrConnectionsGrpc.getCheckConnectionMethod; @@ -86,7 +74,17 @@ import static haveno.proto.grpc.XmrConnectionsGrpc.getSetAutoSwitchMethod; import static haveno.proto.grpc.XmrConnectionsGrpc.getSetConnectionMethod; import static haveno.proto.grpc.XmrConnectionsGrpc.getStartCheckingConnectionsMethod; import static haveno.proto.grpc.XmrConnectionsGrpc.getStopCheckingConnectionsMethod; +import io.grpc.ServerInterceptor; +import io.grpc.stub.StreamObserver; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; import static java.util.concurrent.TimeUnit.SECONDS; +import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; +import monero.common.MoneroRpcConnection; @Slf4j class GrpcXmrConnectionService extends XmrConnectionsImplBase { diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrNodeService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrNodeService.java index 24a1053c14..7df9ae4602 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrNodeService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrNodeService.java @@ -17,34 +17,32 @@ package haveno.daemon.grpc; +import com.google.inject.Inject; import haveno.core.api.CoreApi; import haveno.core.xmr.XmrNodeSettings; import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor; import haveno.daemon.grpc.interceptor.GrpcCallRateMeter; +import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import haveno.proto.grpc.GetXmrNodeSettingsReply; import haveno.proto.grpc.GetXmrNodeSettingsRequest; import haveno.proto.grpc.IsXmrNodeOnlineReply; import haveno.proto.grpc.IsXmrNodeOnlineRequest; -import haveno.proto.grpc.XmrNodeGrpc.XmrNodeImplBase; import haveno.proto.grpc.StartXmrNodeReply; import haveno.proto.grpc.StartXmrNodeRequest; import haveno.proto.grpc.StopXmrNodeReply; import haveno.proto.grpc.StopXmrNodeRequest; -import io.grpc.ServerInterceptor; -import io.grpc.stub.StreamObserver; -import lombok.extern.slf4j.Slf4j; -import monero.common.MoneroError; - -import javax.inject.Inject; -import java.util.HashMap; -import java.util.Optional; - -import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; +import haveno.proto.grpc.XmrNodeGrpc.XmrNodeImplBase; import static haveno.proto.grpc.XmrNodeGrpc.getGetXmrNodeSettingsMethod; import static haveno.proto.grpc.XmrNodeGrpc.getIsXmrNodeOnlineMethod; import static haveno.proto.grpc.XmrNodeGrpc.getStartXmrNodeMethod; import static haveno.proto.grpc.XmrNodeGrpc.getStopXmrNodeMethod; +import io.grpc.ServerInterceptor; +import io.grpc.stub.StreamObserver; +import java.util.HashMap; +import java.util.Optional; import static java.util.concurrent.TimeUnit.SECONDS; +import lombok.extern.slf4j.Slf4j; +import monero.common.MoneroError; @Slf4j public class GrpcXmrNodeService extends XmrNodeImplBase { diff --git a/daemon/src/main/java/haveno/daemon/grpc/interceptor/PasswordAuthInterceptor.java b/daemon/src/main/java/haveno/daemon/grpc/interceptor/PasswordAuthInterceptor.java index c9a7bb03b7..d47b8c83c4 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/interceptor/PasswordAuthInterceptor.java +++ b/daemon/src/main/java/haveno/daemon/grpc/interceptor/PasswordAuthInterceptor.java @@ -17,18 +17,16 @@ package haveno.daemon.grpc.interceptor; +import com.google.inject.Inject; import haveno.common.config.Config; import io.grpc.Metadata; +import static io.grpc.Metadata.ASCII_STRING_MARSHALLER; +import static io.grpc.Metadata.Key; import io.grpc.ServerCall; import io.grpc.ServerCallHandler; import io.grpc.ServerInterceptor; -import io.grpc.StatusRuntimeException; - -import javax.inject.Inject; - -import static io.grpc.Metadata.ASCII_STRING_MARSHALLER; -import static io.grpc.Metadata.Key; import static io.grpc.Status.UNAUTHENTICATED; +import io.grpc.StatusRuntimeException; import static java.lang.String.format; /** diff --git a/desktop/package/package.gradle b/desktop/package/package.gradle index d5cd9fc2c2..d6c1820305 100644 --- a/desktop/package/package.gradle +++ b/desktop/package/package.gradle @@ -55,9 +55,6 @@ task getJavaBinariesDownloadURLs { binariesFolderPath.mkdirs() ext.binariesFolderPath = binariesFolderPath - // TODO Extend script logic to alternatively allow a local (separate, v14+) JDK for jpackage - // TODO Another option is to use the local JDK for everything: build jars and use jpackage (but then it has to be v14+) - // Define the download URLs (and associated binary hashes) for the JDK used to package the installers // These JDKs are independent of what is installed on the building system // @@ -71,28 +68,46 @@ task getJavaBinariesDownloadURLs { // -- linux ( -> use the tar.gz JDK link) // -- macOS ( -> use the tar.gz JDK link) // -- windows ( -> use the .zip JDK link) - Map jdk15Binaries = [ - 'linux' : 'https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.2%2B7/OpenJDK15U-jdk_x64_linux_hotspot_15.0.2_7.tar.gz', - 'linux-sha256' : '94f20ca8ea97773571492e622563883b8869438a015d02df6028180dd9acc24d', - 'mac' : 'https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.2%2B7/OpenJDK15U-jdk_x64_mac_hotspot_15.0.2_7.tar.gz', - 'mac-sha256' : 'd358a7ff03905282348c6c80562a4da2e04eb377b60ad2152be4c90f8d580b7f', - 'windows' : 'https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.2%2B7/OpenJDK15U-jdk_x64_windows_hotspot_15.0.2_7.zip', - 'windows-sha256': 'b80dde2b7f8374eff0f1726c1cbdb48fb095fdde21489046d92f7144baff5741' - - // TODO For some reason, using "--runtime-image jdk-11" does NOT work with a v15 jpackage, but works with v14 + Map jdk21Binaries = [ + 'linux' : 'https://download.bell-sw.com/java/21.0.2+14/bellsoft-jdk21.0.2+14-linux-amd64-full.tar.gz', + 'linux-sha256' : '7eda80851fba1da023e03446c77100f19e7c770491b0d5bc9f893044e1b2b69b', + 'linux-aarch64' : 'https://download.bell-sw.com/java/21.0.2+14/bellsoft-jdk21.0.2+14-linux-aarch64-full.tar.gz', + 'linux-aarch64-sha256' : 'a477fc72085f30b03bf71fbed47923cea3b6f33b5b6a5a74718623b772a3a043', + 'mac' : 'https://download.bell-sw.com/java/21.0.2+14/bellsoft-jdk21.0.2+14-macos-amd64-full.tar.gz', + 'mac-sha256' : '42b528206595e559803b6f9f6bdbbf236ec6d10684058f46bc5261f5498d345c', + 'mac-aarch64' : 'https://download.bell-sw.com/java/21.0.2+14/bellsoft-jdk21.0.2+14-macos-aarch64-full.tar.gz', + 'mac-aarch64-sha256' : 'eba73a9bff7234220dc9a1da7f44b3d7ed2a562663eadc1c53bd74b355839a55', + 'windows' : 'https://download.bell-sw.com/java/21.0.2+14/bellsoft-jdk21.0.2+14-windows-amd64-full.zip', + 'windows-sha256' : 'f823eff0234af5bef095e53e5431191dbee8c2e42ca321eda23148a15cbf8d5b', + 'windows-aarch64' : 'https://download.bell-sw.com/java/21.0.2+14/bellsoft-jdk21.0.2+14-windows-aarch64-full.zip', + 'windows-aarch64-sha256': 'a2e9edecaf9637f83ef1cddab3a74f39ac55f8e1a479f10f3584ad939dfadd0a' ] String osKey + String architecture = System.getProperty("os.arch").toLowerCase() + if (Os.isFamily(Os.FAMILY_WINDOWS)) { - osKey = 'windows' + if (architecture.contains("aarch64") || architecture.contains("arm")) { + osKey = "windows-aarch64" + } else { + osKey = "windows" + } } else if (Os.isFamily(Os.FAMILY_MAC)) { - osKey = 'mac' + if (architecture.contains("aarch64") || architecture.contains("arm")) { + osKey = "mac-aarch64" + } else { + osKey = "mac" + } } else { - osKey = 'linux' + if (architecture.contains("aarch64") || architecture.contains("arm")) { + osKey = "linux-aarch64" + } else { + osKey = "linux" + } } - ext.jdk15Binary_DownloadURL = jdk15Binaries[osKey] - ext.jdk15Binary_SHA256Hash = jdk15Binaries[osKey + '-sha256'] + ext.jdk21Binary_DownloadURL = jdk21Binaries[osKey] + ext.jdk21Binary_SHA256Hash = jdk21Binaries[osKey + '-sha256'] } } @@ -108,8 +123,8 @@ task retrieveAndExtractJavaBinaries { File jdkForJpackageDir = new File(tempRootDir, jdkForJpackageDirName) jdkForJpackageDir.mkdirs() - String jdkForJpackageArchiveURL = getJavaBinariesDownloadURLs.property('jdk15Binary_DownloadURL') - String jdkForJpackageArchiveHash = getJavaBinariesDownloadURLs.property('jdk15Binary_SHA256Hash') + String jdkForJpackageArchiveURL = getJavaBinariesDownloadURLs.property('jdk21Binary_DownloadURL') + String jdkForJpackageArchiveHash = getJavaBinariesDownloadURLs.property('jdk21Binary_SHA256Hash') String jdkForJpackageArchiveFileName = jdkForJpackageArchiveURL.tokenize('/').last() File jdkForJpackageFile = new File(jdkForJpackageDir, jdkForJpackageArchiveFileName) @@ -248,6 +263,10 @@ task packageInstallers { " --main-class haveno.desktop.app.HavenoAppMain" + " --java-options -Xss1280k" + " --java-options -XX:MaxRAM=4g" + + " --java-options --add-opens=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED" + + " --java-options --add-opens=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED" + + " --java-options --add-opens=java.base/java.lang.reflect=ALL-UNNAMED" + + " --java-options --add-opens=javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED" + " --java-options -Djava.net.preferIPv4Stack=true" + " --arguments --baseCurrencyNetwork=XMR_STAGENET" // Warning: this will cause guice reflection exceptions and lead to issues with the guice internal cache @@ -265,7 +284,7 @@ task packageInstallers { " --win-shortcut" ) - executeCmd(jPackageFilePath + commonOpts + windowsOpts + " --type exe") + executeCmd(jPackageFilePath + commonOpts + windowsOpts + " --win-console --type exe") } else if (Os.isFamily(Os.FAMILY_MAC)) { // See https://docs.oracle.com/en/java/javase/14/jpackage/override-jpackage-resources.html // for details of "--resource-dir" diff --git a/desktop/src/main/java/haveno/desktop/Navigation.java b/desktop/src/main/java/haveno/desktop/Navigation.java index ded1945234..b917f5cb06 100644 --- a/desktop/src/main/java/haveno/desktop/Navigation.java +++ b/desktop/src/main/java/haveno/desktop/Navigation.java @@ -18,6 +18,7 @@ package haveno.desktop; import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.persistence.PersistenceManager; import haveno.common.proto.persistable.NavigationPath; import haveno.common.proto.persistable.PersistedDataHost; @@ -25,17 +26,15 @@ import haveno.desktop.common.view.View; import haveno.desktop.common.view.ViewPath; import haveno.desktop.main.MainView; import haveno.desktop.main.market.MarketView; -import lombok.Getter; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; - -import javax.annotation.Nullable; -import javax.inject.Singleton; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.concurrent.CopyOnWriteArraySet; import java.util.stream.Collectors; +import javax.annotation.Nullable; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; @Slf4j @Singleton diff --git a/desktop/src/main/java/haveno/desktop/common/fxml/FxmlViewLoader.java b/desktop/src/main/java/haveno/desktop/common/fxml/FxmlViewLoader.java index f7d76beff2..0679677fa7 100644 --- a/desktop/src/main/java/haveno/desktop/common/fxml/FxmlViewLoader.java +++ b/desktop/src/main/java/haveno/desktop/common/fxml/FxmlViewLoader.java @@ -18,23 +18,21 @@ package haveno.desktop.common.fxml; import com.google.common.base.Joiner; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.util.Utilities; import haveno.desktop.common.ViewfxException; import haveno.desktop.common.view.FxmlView; import haveno.desktop.common.view.View; import haveno.desktop.common.view.ViewFactory; import haveno.desktop.common.view.ViewLoader; -import javafx.fxml.FXMLLoader; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.io.IOException; import java.lang.annotation.Annotation; import java.net.URL; import java.util.ResourceBundle; - -import static com.google.common.base.Preconditions.checkNotNull; +import javafx.fxml.FXMLLoader; +import lombok.extern.slf4j.Slf4j; @Slf4j @Singleton diff --git a/desktop/src/main/java/haveno/desktop/common/view/CachingViewLoader.java b/desktop/src/main/java/haveno/desktop/common/view/CachingViewLoader.java index 998dc3ee60..1dbd5412f1 100644 --- a/desktop/src/main/java/haveno/desktop/common/view/CachingViewLoader.java +++ b/desktop/src/main/java/haveno/desktop/common/view/CachingViewLoader.java @@ -17,8 +17,8 @@ package haveno.desktop.common.view; -import javax.inject.Inject; -import javax.inject.Singleton; +import com.google.inject.Inject; +import com.google.inject.Singleton; import java.util.HashMap; import java.util.Map; diff --git a/desktop/src/main/java/haveno/desktop/common/view/guice/InjectorViewFactory.java b/desktop/src/main/java/haveno/desktop/common/view/guice/InjectorViewFactory.java index c7c3565ca1..4ab0ddee74 100644 --- a/desktop/src/main/java/haveno/desktop/common/view/guice/InjectorViewFactory.java +++ b/desktop/src/main/java/haveno/desktop/common/view/guice/InjectorViewFactory.java @@ -19,10 +19,9 @@ package haveno.desktop.common.view.guice; import com.google.common.base.Preconditions; import com.google.inject.Injector; +import com.google.inject.Singleton; import haveno.desktop.common.view.ViewFactory; -import javax.inject.Singleton; - @Singleton public class InjectorViewFactory implements ViewFactory { diff --git a/desktop/src/main/java/haveno/desktop/main/MainView.java b/desktop/src/main/java/haveno/desktop/main/MainView.java index b22d923e47..07a2648661 100644 --- a/desktop/src/main/java/haveno/desktop/main/MainView.java +++ b/desktop/src/main/java/haveno/desktop/main/MainView.java @@ -17,9 +17,9 @@ package haveno.desktop.main; +import com.google.inject.Inject; import com.jfoenix.controls.JFXBadge; import com.jfoenix.controls.JFXComboBox; -import com.jfoenix.controls.JFXProgressBar; import haveno.common.HavenoException; import haveno.common.Timer; import haveno.common.UserThread; @@ -55,6 +55,10 @@ import haveno.desktop.main.shared.PriceFeedComboBoxItem; import haveno.desktop.main.support.SupportView; import haveno.desktop.util.DisplayUtils; import haveno.desktop.util.Transitions; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.Date; +import java.util.Locale; import javafx.animation.Animation; import javafx.animation.KeyFrame; import javafx.animation.Timeline; @@ -81,6 +85,10 @@ import javafx.scene.image.ImageView; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.layout.AnchorPane; +import static javafx.scene.layout.AnchorPane.setBottomAnchor; +import static javafx.scene.layout.AnchorPane.setLeftAnchor; +import static javafx.scene.layout.AnchorPane.setRightAnchor; +import static javafx.scene.layout.AnchorPane.setTopAnchor; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; @@ -93,17 +101,6 @@ import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; -import javax.inject.Inject; -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.util.Date; -import java.util.Locale; - -import static javafx.scene.layout.AnchorPane.setBottomAnchor; -import static javafx.scene.layout.AnchorPane.setLeftAnchor; -import static javafx.scene.layout.AnchorPane.setRightAnchor; -import static javafx.scene.layout.AnchorPane.setTopAnchor; - @FxmlView @Slf4j public class MainView extends InitializableView { @@ -521,7 +518,7 @@ public class MainView extends InitializableView { }; model.getWalletServiceErrorMsg().addListener(walletServiceErrorMsgListener); - xmrSyncIndicator = new JFXProgressBar(); + xmrSyncIndicator = new ProgressBar(); xmrSyncIndicator.setPrefWidth(305); xmrSyncIndicator.progressProperty().bind(model.getCombinedSyncProgress()); @@ -770,14 +767,12 @@ public class MainView extends InitializableView { } }); - model.getUpdatedDataReceived().addListener((observable, oldValue, newValue) -> { - UserThread.execute(() -> { - p2PNetworkIcon.setOpacity(1); - p2pNetworkProgressBar.setProgress(0); - }); - }); + model.getUpdatedDataReceived().addListener((observable, oldValue, newValue) -> UserThread.execute(() -> { + p2PNetworkIcon.setOpacity(1); + p2pNetworkProgressBar.setProgress(0); + })); - p2pNetworkProgressBar = new JFXProgressBar(-1); + p2pNetworkProgressBar = new ProgressBar(-1); p2pNetworkProgressBar.setMaxHeight(2); p2pNetworkProgressBar.prefWidthProperty().bind(p2PNetworkLabel.widthProperty()); @@ -797,12 +792,10 @@ public class MainView extends InitializableView { private void setupBadge(JFXBadge buttonWithBadge, StringProperty badgeNumber, BooleanProperty badgeEnabled) { buttonWithBadge.textProperty().bind(badgeNumber); buttonWithBadge.setEnabled(badgeEnabled.get()); - badgeEnabled.addListener((observable, oldValue, newValue) -> { - UserThread.execute(() -> { - buttonWithBadge.setEnabled(newValue); - buttonWithBadge.refreshBadge(); - }); - }); + badgeEnabled.addListener((observable, oldValue, newValue) -> UserThread.execute(() -> { + buttonWithBadge.setEnabled(newValue); + buttonWithBadge.refreshBadge(); + })); buttonWithBadge.setPosition(Pos.TOP_RIGHT); buttonWithBadge.setMinHeight(34); diff --git a/desktop/src/main/java/haveno/desktop/main/account/AccountView.java b/desktop/src/main/java/haveno/desktop/main/account/AccountView.java index 522140619f..30c434cccd 100644 --- a/desktop/src/main/java/haveno/desktop/main/account/AccountView.java +++ b/desktop/src/main/java/haveno/desktop/main/account/AccountView.java @@ -17,6 +17,7 @@ package haveno.desktop.main.account; +import com.google.inject.Inject; import haveno.common.util.Utilities; import haveno.core.locale.Res; import haveno.core.user.DontShowAgainLookup; @@ -38,6 +39,7 @@ import haveno.desktop.main.account.register.mediator.MediatorRegistrationView; import haveno.desktop.main.account.register.refundagent.RefundAgentRegistrationView; import haveno.desktop.main.account.register.signing.SigningView; import haveno.desktop.main.presentation.AccountPresentation; +import java.util.List; import javafx.beans.value.ChangeListener; import javafx.collections.ListChangeListener; import javafx.event.EventHandler; @@ -49,9 +51,6 @@ import javafx.scene.control.TabPane; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; -import javax.inject.Inject; -import java.util.List; - @FxmlView public class AccountView extends ActivatableView { diff --git a/desktop/src/main/java/haveno/desktop/main/account/content/backup/BackupView.java b/desktop/src/main/java/haveno/desktop/main/account/content/backup/BackupView.java index aa4ee0811f..56a3b3553b 100644 --- a/desktop/src/main/java/haveno/desktop/main/account/content/backup/BackupView.java +++ b/desktop/src/main/java/haveno/desktop/main/account/content/backup/BackupView.java @@ -17,6 +17,7 @@ package haveno.desktop.main.account.content.backup; +import com.google.inject.Inject; import haveno.common.config.Config; import haveno.common.file.FileUtil; import haveno.common.persistence.PersistenceManager; @@ -27,25 +28,22 @@ import haveno.core.user.Preferences; import haveno.desktop.common.view.ActivatableView; import haveno.desktop.common.view.FxmlView; import haveno.desktop.main.overlays.popups.Popup; +import static haveno.desktop.util.FormBuilder.add2Buttons; +import static haveno.desktop.util.FormBuilder.add2ButtonsAfterGroup; +import static haveno.desktop.util.FormBuilder.addInputTextField; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; import haveno.desktop.util.Layout; -import javafx.beans.value.ChangeListener; -import javafx.scene.control.Button; -import javafx.scene.control.TextField; -import javafx.scene.layout.GridPane; -import javafx.stage.DirectoryChooser; - -import javax.annotation.Nullable; -import javax.inject.Inject; import java.io.File; import java.io.IOException; import java.nio.file.Paths; import java.text.SimpleDateFormat; import java.util.Date; - -import static haveno.desktop.util.FormBuilder.add2Buttons; -import static haveno.desktop.util.FormBuilder.add2ButtonsAfterGroup; -import static haveno.desktop.util.FormBuilder.addInputTextField; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; +import javafx.beans.value.ChangeListener; +import javafx.scene.control.Button; +import javafx.scene.control.TextField; +import javafx.scene.layout.GridPane; +import javafx.stage.DirectoryChooser; +import javax.annotation.Nullable; @FxmlView public class BackupView extends ActivatableView { diff --git a/desktop/src/main/java/haveno/desktop/main/account/content/cryptoaccounts/CryptoAccountsView.java b/desktop/src/main/java/haveno/desktop/main/account/content/cryptoaccounts/CryptoAccountsView.java index 04136bab68..8abcd98a9d 100644 --- a/desktop/src/main/java/haveno/desktop/main/account/content/cryptoaccounts/CryptoAccountsView.java +++ b/desktop/src/main/java/haveno/desktop/main/account/content/cryptoaccounts/CryptoAccountsView.java @@ -17,8 +17,10 @@ package haveno.desktop.main.account.content.cryptoaccounts; -import haveno.asset.CryptoAccountDisclaimer; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.asset.Asset; +import haveno.asset.CryptoAccountDisclaimer; import haveno.asset.coins.Monero; import haveno.common.util.Tuple2; import haveno.common.util.Tuple3; @@ -39,11 +41,17 @@ import haveno.core.util.validation.InputValidator; import haveno.desktop.common.view.FxmlView; import haveno.desktop.components.TitledGroupBg; import haveno.desktop.components.paymentmethods.AssetsForm; +import static haveno.desktop.components.paymentmethods.AssetsForm.INSTANT_TRADE_NEWS; import haveno.desktop.components.paymentmethods.PaymentMethodForm; import haveno.desktop.main.account.content.PaymentAccountsView; import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.util.FormBuilder; +import static haveno.desktop.util.FormBuilder.add2ButtonsAfterGroup; +import static haveno.desktop.util.FormBuilder.add3ButtonsAfterGroup; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; +import static haveno.desktop.util.FormBuilder.addTopLabelListView; import haveno.desktop.util.Layout; +import java.util.Optional; import javafx.collections.ObservableList; import javafx.scene.control.Button; import javafx.scene.control.Label; @@ -52,16 +60,6 @@ import javafx.scene.layout.GridPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; -import javax.inject.Inject; -import javax.inject.Named; -import java.util.Optional; - -import static haveno.desktop.components.paymentmethods.AssetsForm.INSTANT_TRADE_NEWS; -import static haveno.desktop.util.FormBuilder.add2ButtonsAfterGroup; -import static haveno.desktop.util.FormBuilder.add3ButtonsAfterGroup; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; -import static haveno.desktop.util.FormBuilder.addTopLabelListView; - @FxmlView public class CryptoAccountsView extends PaymentAccountsView { diff --git a/desktop/src/main/java/haveno/desktop/main/account/content/notifications/MobileNotificationsView.java b/desktop/src/main/java/haveno/desktop/main/account/content/notifications/MobileNotificationsView.java index b7e5de4a88..255558ab22 100644 --- a/desktop/src/main/java/haveno/desktop/main/account/content/notifications/MobileNotificationsView.java +++ b/desktop/src/main/java/haveno/desktop/main/account/content/notifications/MobileNotificationsView.java @@ -17,6 +17,7 @@ package haveno.desktop.main.account.content.notifications; +import com.google.inject.Inject; import haveno.common.UserThread; import haveno.common.util.Tuple2; import haveno.common.util.Tuple3; @@ -47,8 +48,16 @@ import haveno.desktop.components.InfoInputTextField; import haveno.desktop.components.InputTextField; import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.util.FormBuilder; +import static haveno.desktop.util.FormBuilder.addButton; +import static haveno.desktop.util.FormBuilder.addInputTextField; +import static haveno.desktop.util.FormBuilder.addSlideToggleButton; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; +import static haveno.desktop.util.FormBuilder.addTopLabelButton; import haveno.desktop.util.GUIUtil; import haveno.desktop.util.Layout; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; import javafx.beans.value.ChangeListener; import javafx.collections.FXCollections; import javafx.collections.SetChangeListener; @@ -64,17 +73,6 @@ import javafx.scene.control.ToggleGroup; import javafx.scene.layout.GridPane; import javafx.util.StringConverter; -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import static haveno.desktop.util.FormBuilder.addButton; -import static haveno.desktop.util.FormBuilder.addInputTextField; -import static haveno.desktop.util.FormBuilder.addSlideToggleButton; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; -import static haveno.desktop.util.FormBuilder.addTopLabelButton; - @FxmlView public class MobileNotificationsView extends ActivatableView { private final Preferences preferences; diff --git a/desktop/src/main/java/haveno/desktop/main/account/content/password/PasswordView.java b/desktop/src/main/java/haveno/desktop/main/account/content/password/PasswordView.java index 2c3cee548b..8c8891fb08 100644 --- a/desktop/src/main/java/haveno/desktop/main/account/content/password/PasswordView.java +++ b/desktop/src/main/java/haveno/desktop/main/account/content/password/PasswordView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.account.content.password; +import static com.google.common.base.Preconditions.checkArgument; +import com.google.inject.Inject; import com.jfoenix.validation.RequiredFieldValidator; import haveno.common.util.Tuple4; import haveno.core.api.CoreAccountService; @@ -33,6 +35,10 @@ import haveno.desktop.main.MainView; import haveno.desktop.main.account.AccountView; import haveno.desktop.main.account.content.backup.BackupView; import haveno.desktop.main.overlays.popups.Popup; +import static haveno.desktop.util.FormBuilder.addButtonBusyAnimationLabel; +import static haveno.desktop.util.FormBuilder.addMultilineLabel; +import static haveno.desktop.util.FormBuilder.addPasswordTextField; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; import haveno.desktop.util.Layout; import haveno.desktop.util.validation.PasswordValidator; import javafx.beans.value.ChangeListener; @@ -41,14 +47,6 @@ import javafx.scene.control.Label; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; -import javax.inject.Inject; - -import static com.google.common.base.Preconditions.checkArgument; -import static haveno.desktop.util.FormBuilder.addButtonBusyAnimationLabel; -import static haveno.desktop.util.FormBuilder.addMultilineLabel; -import static haveno.desktop.util.FormBuilder.addPasswordTextField; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; - @FxmlView public class PasswordView extends ActivatableView { diff --git a/desktop/src/main/java/haveno/desktop/main/account/content/seedwords/SeedWordsView.java b/desktop/src/main/java/haveno/desktop/main/account/content/seedwords/SeedWordsView.java index cb6e6a3d52..9d90994029 100644 --- a/desktop/src/main/java/haveno/desktop/main/account/content/seedwords/SeedWordsView.java +++ b/desktop/src/main/java/haveno/desktop/main/account/content/seedwords/SeedWordsView.java @@ -35,6 +35,8 @@ package haveno.desktop.main.account.content.seedwords; import com.google.common.base.Splitter; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.core.locale.Res; import haveno.core.offer.OpenOfferManager; @@ -46,7 +48,19 @@ import haveno.desktop.common.view.FxmlView; import haveno.desktop.main.SharedPresentation; import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.main.overlays.windows.WalletPasswordWindow; +import static haveno.desktop.util.FormBuilder.addMultilineLabel; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; +import static haveno.desktop.util.FormBuilder.addTopLabelDatePicker; +import static haveno.desktop.util.FormBuilder.addTopLabelTextArea; import haveno.desktop.util.Layout; +import java.io.File; +import java.io.IOException; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.util.TimeZone; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.value.ChangeListener; @@ -57,23 +71,6 @@ import javafx.scene.layout.GridPane; import org.bitcoinj.crypto.MnemonicCode; import org.bitcoinj.crypto.MnemonicException; import org.bitcoinj.wallet.DeterministicSeed; - -import javax.inject.Inject; -import javax.inject.Named; -import java.io.File; -import java.io.IOException; -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.util.TimeZone; - -import static haveno.desktop.util.FormBuilder.addMultilineLabel; -//import static haveno.desktop.util.FormBuilder.addPrimaryActionButtonAFterGroup; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; -import static haveno.desktop.util.FormBuilder.addTopLabelDatePicker; -import static haveno.desktop.util.FormBuilder.addTopLabelTextArea; //import static javafx.beans.binding.Bindings.createBooleanBinding; @FxmlView diff --git a/desktop/src/main/java/haveno/desktop/main/account/content/traditionalaccounts/TraditionalAccountsView.java b/desktop/src/main/java/haveno/desktop/main/account/content/traditionalaccounts/TraditionalAccountsView.java index b7d6f58b6f..4636065766 100644 --- a/desktop/src/main/java/haveno/desktop/main/account/content/traditionalaccounts/TraditionalAccountsView.java +++ b/desktop/src/main/java/haveno/desktop/main/account/content/traditionalaccounts/TraditionalAccountsView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.account.content.traditionalaccounts; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.common.util.Tuple2; import haveno.common.util.Tuple3; @@ -27,17 +29,17 @@ import haveno.core.offer.OfferRestrictions; import haveno.core.payment.AmazonGiftCardAccount; import haveno.core.payment.AustraliaPayidAccount; import haveno.core.payment.CashAtAtmAccount; -import haveno.core.payment.PayByMailAccount; import haveno.core.payment.CashDepositAccount; -import haveno.core.payment.ZelleAccount; import haveno.core.payment.F2FAccount; import haveno.core.payment.HalCashAccount; import haveno.core.payment.MoneyGramAccount; +import haveno.core.payment.PayByMailAccount; import haveno.core.payment.PaymentAccount; import haveno.core.payment.PaymentAccountFactory; import haveno.core.payment.RevolutAccount; import haveno.core.payment.USPostalMoneyOrderAccount; import haveno.core.payment.WesternUnionAccount; +import haveno.core.payment.ZelleAccount; import haveno.core.payment.payload.PaymentMethod; import haveno.core.payment.validation.AdvancedCashValidator; import haveno.core.payment.validation.AliPayValidator; @@ -74,11 +76,9 @@ import haveno.desktop.components.paymentmethods.AustraliaPayidForm; import haveno.desktop.components.paymentmethods.BizumForm; import haveno.desktop.components.paymentmethods.CapitualForm; import haveno.desktop.components.paymentmethods.CashAtAtmForm; -import haveno.desktop.components.paymentmethods.PayByMailForm; import haveno.desktop.components.paymentmethods.CashDepositForm; import haveno.desktop.components.paymentmethods.CelPayForm; import haveno.desktop.components.paymentmethods.ChaseQuickPayForm; -import haveno.desktop.components.paymentmethods.ZelleForm; import haveno.desktop.components.paymentmethods.DomesticWireTransferForm; import haveno.desktop.components.paymentmethods.F2FForm; import haveno.desktop.components.paymentmethods.FasterPaymentsForm; @@ -93,6 +93,7 @@ import haveno.desktop.components.paymentmethods.NationalBankForm; import haveno.desktop.components.paymentmethods.NeftForm; import haveno.desktop.components.paymentmethods.NequiForm; import haveno.desktop.components.paymentmethods.PaxumForm; +import haveno.desktop.components.paymentmethods.PayByMailForm; import haveno.desktop.components.paymentmethods.PaymentMethodForm; import haveno.desktop.components.paymentmethods.PayseraForm; import haveno.desktop.components.paymentmethods.PaytmForm; @@ -119,11 +120,19 @@ import haveno.desktop.components.paymentmethods.UpiForm; import haveno.desktop.components.paymentmethods.VerseForm; import haveno.desktop.components.paymentmethods.WeChatPayForm; import haveno.desktop.components.paymentmethods.WesternUnionForm; +import haveno.desktop.components.paymentmethods.ZelleForm; import haveno.desktop.main.account.content.PaymentAccountsView; import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.util.FormBuilder; +import static haveno.desktop.util.FormBuilder.add2ButtonsAfterGroup; +import static haveno.desktop.util.FormBuilder.add3ButtonsAfterGroup; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; +import static haveno.desktop.util.FormBuilder.addTopLabelListView; import haveno.desktop.util.GUIUtil; import haveno.desktop.util.Layout; +import java.math.BigInteger; +import java.util.List; +import java.util.stream.Collectors; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.scene.control.Button; @@ -135,17 +144,6 @@ import javafx.scene.layout.VBox; import javafx.stage.Stage; import javafx.util.StringConverter; -import javax.inject.Inject; -import javax.inject.Named; -import java.math.BigInteger; -import java.util.List; -import java.util.stream.Collectors; - -import static haveno.desktop.util.FormBuilder.add2ButtonsAfterGroup; -import static haveno.desktop.util.FormBuilder.add3ButtonsAfterGroup; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; -import static haveno.desktop.util.FormBuilder.addTopLabelListView; - @FxmlView public class TraditionalAccountsView extends PaymentAccountsView { diff --git a/desktop/src/main/java/haveno/desktop/main/account/content/walletinfo/WalletInfoView.java b/desktop/src/main/java/haveno/desktop/main/account/content/walletinfo/WalletInfoView.java index 83deb0c4c3..d761ffec51 100644 --- a/desktop/src/main/java/haveno/desktop/main/account/content/walletinfo/WalletInfoView.java +++ b/desktop/src/main/java/haveno/desktop/main/account/content/walletinfo/WalletInfoView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.account.content.walletinfo; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.core.locale.Res; import haveno.core.util.FormattingUtils; @@ -29,6 +31,10 @@ import haveno.desktop.common.view.ActivatableView; import haveno.desktop.common.view.FxmlView; import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.main.overlays.windows.ShowWalletDataWindow; +import static haveno.desktop.util.FormBuilder.addButtonAfterGroup; +import static haveno.desktop.util.FormBuilder.addMultilineLabel; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; +import static haveno.desktop.util.FormBuilder.addTopLabelTextField; import haveno.desktop.util.Layout; import javafx.scene.control.Button; import javafx.scene.control.TextField; @@ -37,14 +43,6 @@ import org.bitcoinj.core.Coin; import org.bitcoinj.core.Transaction; import org.bitcoinj.script.Script; import org.bitcoinj.wallet.DeterministicKeyChain; - -import javax.inject.Inject; -import javax.inject.Named; - -import static haveno.desktop.util.FormBuilder.addButtonAfterGroup; -import static haveno.desktop.util.FormBuilder.addMultilineLabel; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; -import static haveno.desktop.util.FormBuilder.addTopLabelTextField; import static org.bitcoinj.wallet.Wallet.BalanceType.ESTIMATED_SPENDABLE; @FxmlView diff --git a/desktop/src/main/java/haveno/desktop/main/account/register/arbitrator/ArbitratorRegistrationView.java b/desktop/src/main/java/haveno/desktop/main/account/register/arbitrator/ArbitratorRegistrationView.java index f18bf04273..8a0350762f 100644 --- a/desktop/src/main/java/haveno/desktop/main/account/register/arbitrator/ArbitratorRegistrationView.java +++ b/desktop/src/main/java/haveno/desktop/main/account/register/arbitrator/ArbitratorRegistrationView.java @@ -18,15 +18,14 @@ package haveno.desktop.main.account.register.arbitrator; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.core.locale.Res; import haveno.core.support.dispute.arbitration.arbitrator.Arbitrator; import haveno.desktop.common.view.FxmlView; import haveno.desktop.main.account.register.AgentRegistrationView; -import javax.inject.Inject; -import javax.inject.Named; - @FxmlView public class ArbitratorRegistrationView extends AgentRegistrationView { diff --git a/desktop/src/main/java/haveno/desktop/main/account/register/mediator/MediatorRegistrationView.java b/desktop/src/main/java/haveno/desktop/main/account/register/mediator/MediatorRegistrationView.java index c58bcdea5d..b2fe9b8908 100644 --- a/desktop/src/main/java/haveno/desktop/main/account/register/mediator/MediatorRegistrationView.java +++ b/desktop/src/main/java/haveno/desktop/main/account/register/mediator/MediatorRegistrationView.java @@ -18,15 +18,14 @@ package haveno.desktop.main.account.register.mediator; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.core.locale.Res; import haveno.core.support.dispute.mediation.mediator.Mediator; import haveno.desktop.common.view.FxmlView; import haveno.desktop.main.account.register.AgentRegistrationView; -import javax.inject.Inject; -import javax.inject.Named; - @FxmlView public class MediatorRegistrationView extends AgentRegistrationView { diff --git a/desktop/src/main/java/haveno/desktop/main/account/register/refundagent/RefundAgentRegistrationView.java b/desktop/src/main/java/haveno/desktop/main/account/register/refundagent/RefundAgentRegistrationView.java index a45fe22222..80a445f60b 100644 --- a/desktop/src/main/java/haveno/desktop/main/account/register/refundagent/RefundAgentRegistrationView.java +++ b/desktop/src/main/java/haveno/desktop/main/account/register/refundagent/RefundAgentRegistrationView.java @@ -18,15 +18,14 @@ package haveno.desktop.main.account.register.refundagent; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.core.locale.Res; import haveno.core.support.dispute.refund.refundagent.RefundAgent; import haveno.desktop.common.view.FxmlView; import haveno.desktop.main.account.register.AgentRegistrationView; -import javax.inject.Inject; -import javax.inject.Named; - @FxmlView public class RefundAgentRegistrationView extends AgentRegistrationView { diff --git a/desktop/src/main/java/haveno/desktop/main/account/register/signing/SigningView.java b/desktop/src/main/java/haveno/desktop/main/account/register/signing/SigningView.java index d2c1fb2c19..f127975bc5 100644 --- a/desktop/src/main/java/haveno/desktop/main/account/register/signing/SigningView.java +++ b/desktop/src/main/java/haveno/desktop/main/account/register/signing/SigningView.java @@ -18,6 +18,7 @@ package haveno.desktop.main.account.register.signing; +import com.google.inject.Inject; import haveno.common.util.Utilities; import haveno.desktop.common.view.ActivatableView; import haveno.desktop.common.view.FxmlView; @@ -30,8 +31,6 @@ import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.layout.AnchorPane; -import javax.inject.Inject; - @FxmlView public class SigningView extends ActivatableView { diff --git a/desktop/src/main/java/haveno/desktop/main/debug/DebugView.java b/desktop/src/main/java/haveno/desktop/main/debug/DebugView.java index ec1277d34a..1d447b69af 100644 --- a/desktop/src/main/java/haveno/desktop/main/debug/DebugView.java +++ b/desktop/src/main/java/haveno/desktop/main/debug/DebugView.java @@ -17,6 +17,7 @@ package haveno.desktop.main.debug; +import com.google.inject.Inject; import haveno.common.taskrunner.Task; import haveno.common.util.Tuple2; import haveno.core.offer.availability.tasks.ProcessOfferAvailabilityResponse; @@ -39,6 +40,8 @@ import haveno.core.trade.protocol.tasks.VerifyPeersAccountAgeWitness; import haveno.desktop.common.view.FxmlView; import haveno.desktop.common.view.InitializableView; import haveno.desktop.components.TitledGroupBg; +import static haveno.desktop.util.FormBuilder.addTopLabelComboBox; +import java.util.Arrays; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.fxml.FXML; @@ -47,11 +50,6 @@ import javafx.scene.control.Label; import javafx.scene.layout.GridPane; import javafx.util.StringConverter; -import javax.inject.Inject; -import java.util.Arrays; - -import static haveno.desktop.util.FormBuilder.addTopLabelComboBox; - // Not maintained anymore with new trade protocol, but leave it...If used needs to be adopted to current protocol. @FxmlView public class DebugView extends InitializableView { diff --git a/desktop/src/main/java/haveno/desktop/main/funds/FundsView.java b/desktop/src/main/java/haveno/desktop/main/funds/FundsView.java index 8e705cc81a..588f3eb299 100644 --- a/desktop/src/main/java/haveno/desktop/main/funds/FundsView.java +++ b/desktop/src/main/java/haveno/desktop/main/funds/FundsView.java @@ -17,6 +17,7 @@ package haveno.desktop.main.funds; +import com.google.inject.Inject; import haveno.core.locale.Res; import haveno.desktop.Navigation; import haveno.desktop.common.view.ActivatableView; @@ -33,8 +34,6 @@ import javafx.fxml.FXML; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; -import javax.inject.Inject; - @FxmlView public class FundsView extends ActivatableView { diff --git a/desktop/src/main/java/haveno/desktop/main/funds/deposit/DepositView.java b/desktop/src/main/java/haveno/desktop/main/funds/deposit/DepositView.java index b4a99627e8..7d6cd6a13f 100644 --- a/desktop/src/main/java/haveno/desktop/main/funds/deposit/DepositView.java +++ b/desktop/src/main/java/haveno/desktop/main/funds/deposit/DepositView.java @@ -34,6 +34,8 @@ package haveno.desktop.main.funds.deposit; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.UserThread; import haveno.common.app.DevEnv; import haveno.common.util.Tuple3; @@ -55,8 +57,18 @@ import haveno.desktop.components.InputTextField; import haveno.desktop.components.TitledGroupBg; import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.main.overlays.windows.QRCodeWindow; +import static haveno.desktop.util.FormBuilder.addAddressTextField; +import static haveno.desktop.util.FormBuilder.addButtonCheckBoxWithBox; +import static haveno.desktop.util.FormBuilder.addInputTextField; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; import haveno.desktop.util.GUIUtil; import haveno.desktop.util.Layout; +import java.io.ByteArrayInputStream; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.concurrent.TimeUnit; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.value.ChangeListener; import javafx.collections.FXCollections; @@ -85,20 +97,6 @@ import org.fxmisc.easybind.EasyBind; import org.fxmisc.easybind.Subscription; import org.jetbrains.annotations.NotNull; -import javax.inject.Inject; -import javax.inject.Named; -import java.io.ByteArrayInputStream; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import static haveno.desktop.util.FormBuilder.addAddressTextField; -import static haveno.desktop.util.FormBuilder.addButtonCheckBoxWithBox; -import static haveno.desktop.util.FormBuilder.addInputTextField; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; - @FxmlView public class DepositView extends ActivatableView { @@ -325,7 +323,7 @@ public class DepositView extends ActivatableView { /////////////////////////////////////////////////////////////////////////////////////////// private void updateList() { - + // create deposit list items List addressEntries = xmrWalletService.getAddressEntries(); List items = new ArrayList<>(); diff --git a/desktop/src/main/java/haveno/desktop/main/funds/locked/LockedView.java b/desktop/src/main/java/haveno/desktop/main/funds/locked/LockedView.java index e8cd2a0ce2..0a986b5505 100644 --- a/desktop/src/main/java/haveno/desktop/main/funds/locked/LockedView.java +++ b/desktop/src/main/java/haveno/desktop/main/funds/locked/LockedView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.funds.locked; +import com.google.inject.Inject; +import com.google.inject.name.Named; import com.googlecode.jcsv.writer.CSVEntryConverter; import de.jensd.fx.fontawesome.AwesomeIcon; import haveno.core.locale.Res; @@ -39,6 +41,11 @@ import haveno.desktop.components.HyperlinkWithIcon; import haveno.desktop.main.overlays.windows.OfferDetailsWindow; import haveno.desktop.main.overlays.windows.TradeDetailsWindow; import haveno.desktop.util.GUIUtil; +import java.util.Comparator; +import java.util.Date; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.collections.FXCollections; import javafx.collections.ListChangeListener; @@ -60,14 +67,6 @@ import javafx.util.Callback; import org.bitcoinj.core.Coin; import org.bitcoinj.core.Transaction; -import javax.inject.Inject; -import javax.inject.Named; -import java.util.Comparator; -import java.util.Date; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Collectors; - @FxmlView public class LockedView extends ActivatableView { @FXML diff --git a/desktop/src/main/java/haveno/desktop/main/funds/reserved/ReservedView.java b/desktop/src/main/java/haveno/desktop/main/funds/reserved/ReservedView.java index b946338943..bfa8bd26b0 100644 --- a/desktop/src/main/java/haveno/desktop/main/funds/reserved/ReservedView.java +++ b/desktop/src/main/java/haveno/desktop/main/funds/reserved/ReservedView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.funds.reserved; +import com.google.inject.Inject; +import com.google.inject.name.Named; import com.googlecode.jcsv.writer.CSVEntryConverter; import de.jensd.fx.fontawesome.AwesomeIcon; import haveno.core.locale.Res; @@ -39,6 +41,11 @@ import haveno.desktop.components.HyperlinkWithIcon; import haveno.desktop.main.overlays.windows.OfferDetailsWindow; import haveno.desktop.main.overlays.windows.TradeDetailsWindow; import haveno.desktop.util.GUIUtil; +import java.util.Comparator; +import java.util.Date; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.collections.FXCollections; import javafx.collections.ListChangeListener; @@ -60,14 +67,6 @@ import javafx.util.Callback; import org.bitcoinj.core.Coin; import org.bitcoinj.core.Transaction; -import javax.inject.Inject; -import javax.inject.Named; -import java.util.Comparator; -import java.util.Date; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Collectors; - @FxmlView public class ReservedView extends ActivatableView { @FXML diff --git a/desktop/src/main/java/haveno/desktop/main/funds/transactions/DisplayedTransactionsFactory.java b/desktop/src/main/java/haveno/desktop/main/funds/transactions/DisplayedTransactionsFactory.java index 4a4a0a34c3..7b83bbb157 100644 --- a/desktop/src/main/java/haveno/desktop/main/funds/transactions/DisplayedTransactionsFactory.java +++ b/desktop/src/main/java/haveno/desktop/main/funds/transactions/DisplayedTransactionsFactory.java @@ -17,11 +17,10 @@ package haveno.desktop.main.funds.transactions; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.core.xmr.wallet.XmrWalletService; -import javax.inject.Inject; -import javax.inject.Singleton; - @Singleton public class DisplayedTransactionsFactory { private final XmrWalletService xmrWalletService; diff --git a/desktop/src/main/java/haveno/desktop/main/funds/transactions/TradableRepository.java b/desktop/src/main/java/haveno/desktop/main/funds/transactions/TradableRepository.java index e729b970d9..a46a18f624 100644 --- a/desktop/src/main/java/haveno/desktop/main/funds/transactions/TradableRepository.java +++ b/desktop/src/main/java/haveno/desktop/main/funds/transactions/TradableRepository.java @@ -18,14 +18,13 @@ package haveno.desktop.main.funds.transactions; import com.google.common.collect.ImmutableSet; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.core.offer.OpenOfferManager; import haveno.core.trade.ClosedTradableManager; import haveno.core.trade.Tradable; import haveno.core.trade.TradeManager; import haveno.core.trade.failed.FailedTradesManager; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.Set; @Singleton diff --git a/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionAwareTradableFactory.java b/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionAwareTradableFactory.java index c5db2d0852..c07e548032 100644 --- a/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionAwareTradableFactory.java +++ b/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionAwareTradableFactory.java @@ -17,6 +17,8 @@ package haveno.desktop.main.funds.transactions; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.crypto.PubKeyRingProvider; import haveno.core.offer.OpenOffer; import haveno.core.support.dispute.arbitration.ArbitrationManager; @@ -25,9 +27,6 @@ import haveno.core.trade.Tradable; import haveno.core.trade.Trade; import haveno.core.xmr.wallet.XmrWalletService; -import javax.inject.Inject; -import javax.inject.Singleton; - @Singleton public class TransactionAwareTradableFactory { diff --git a/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionListItemFactory.java b/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionListItemFactory.java index c1aad38a1e..996a9f7a73 100644 --- a/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionListItemFactory.java +++ b/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionListItemFactory.java @@ -17,16 +17,15 @@ package haveno.desktop.main.funds.transactions; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.google.inject.name.Named; import haveno.core.user.Preferences; import haveno.core.util.FormattingUtils; import haveno.core.util.coin.CoinFormatter; import haveno.core.xmr.wallet.XmrWalletService; -import monero.wallet.model.MoneroTxWallet; - import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; +import monero.wallet.model.MoneroTxWallet; @Singleton diff --git a/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionsView.java b/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionsView.java index 4edeefb572..f5cca952d6 100644 --- a/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionsView.java +++ b/desktop/src/main/java/haveno/desktop/main/funds/transactions/TransactionsView.java @@ -17,6 +17,7 @@ package haveno.desktop.main.funds.transactions; +import com.google.inject.Inject; import com.googlecode.jcsv.writer.CSVEntryConverter; import de.jensd.fx.fontawesome.AwesomeIcon; import haveno.common.util.Utilities; @@ -37,6 +38,8 @@ import haveno.desktop.main.overlays.windows.OfferDetailsWindow; import haveno.desktop.main.overlays.windows.TradeDetailsWindow; import haveno.desktop.util.GUIUtil; import haveno.network.p2p.P2PService; +import java.math.BigInteger; +import java.util.Comparator; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.collections.ObservableList; import javafx.collections.transformation.SortedList; @@ -60,10 +63,6 @@ import javafx.stage.Stage; import javafx.util.Callback; import monero.wallet.model.MoneroWalletListener; -import javax.inject.Inject; -import java.math.BigInteger; -import java.util.Comparator; - @FxmlView public class TransactionsView extends ActivatableView { diff --git a/desktop/src/main/java/haveno/desktop/main/funds/withdrawal/WithdrawalView.java b/desktop/src/main/java/haveno/desktop/main/funds/withdrawal/WithdrawalView.java index cacc215f31..bb62831afd 100644 --- a/desktop/src/main/java/haveno/desktop/main/funds/withdrawal/WithdrawalView.java +++ b/desktop/src/main/java/haveno/desktop/main/funds/withdrawal/WithdrawalView.java @@ -34,6 +34,7 @@ package haveno.desktop.main.funds.withdrawal; +import com.google.inject.Inject; import haveno.common.util.Tuple4; import haveno.core.locale.Res; import haveno.core.trade.HavenoUtils; @@ -52,8 +53,15 @@ import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.main.overlays.windows.TxDetails; import haveno.desktop.main.overlays.windows.WalletPasswordWindow; import haveno.desktop.util.FormBuilder; +import static haveno.desktop.util.FormBuilder.addButton; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; +import static haveno.desktop.util.FormBuilder.addTopLabelInputTextField; import haveno.desktop.util.GUIUtil; import haveno.network.p2p.P2PService; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import javafx.beans.value.ChangeListener; import javafx.fxml.FXML; import javafx.scene.control.Button; @@ -67,16 +75,6 @@ import javafx.scene.layout.VBox; import monero.wallet.model.MoneroTxConfig; import monero.wallet.model.MoneroTxWallet; -import javax.inject.Inject; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static haveno.desktop.util.FormBuilder.addButton; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; -import static haveno.desktop.util.FormBuilder.addTopLabelInputTextField; - @FxmlView public class WithdrawalView extends ActivatableView { diff --git a/desktop/src/main/java/haveno/desktop/main/market/MarketView.java b/desktop/src/main/java/haveno/desktop/main/market/MarketView.java index 72de57fd1d..3fb91650c4 100644 --- a/desktop/src/main/java/haveno/desktop/main/market/MarketView.java +++ b/desktop/src/main/java/haveno/desktop/main/market/MarketView.java @@ -18,6 +18,8 @@ package haveno.desktop.main.market; import com.google.common.base.Joiner; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.util.Utilities; import haveno.core.locale.CurrencyUtil; import haveno.core.locale.Res; @@ -43,6 +45,8 @@ import haveno.desktop.main.offer.offerbook.OfferBook; import haveno.desktop.main.offer.offerbook.OfferBookListItem; import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.util.DisplayUtils; +import java.util.List; +import java.util.stream.Collectors; import javafx.beans.value.ChangeListener; import javafx.event.EventHandler; import javafx.fxml.FXML; @@ -54,11 +58,6 @@ import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import org.apache.commons.lang3.StringUtils; -import javax.inject.Inject; -import javax.inject.Named; -import java.util.List; -import java.util.stream.Collectors; - @FxmlView public class MarketView extends ActivatableView { @FXML diff --git a/desktop/src/main/java/haveno/desktop/main/market/offerbook/OfferBookChartView.java b/desktop/src/main/java/haveno/desktop/main/market/offerbook/OfferBookChartView.java index 90ad518d3d..ac57c22bce 100644 --- a/desktop/src/main/java/haveno/desktop/main/market/offerbook/OfferBookChartView.java +++ b/desktop/src/main/java/haveno/desktop/main/market/offerbook/OfferBookChartView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.market.offerbook; +import com.google.inject.Inject; +import com.google.inject.name.Named; import com.jfoenix.controls.JFXTabPane; import haveno.common.UserThread; import haveno.common.config.Config; @@ -40,8 +42,15 @@ import haveno.desktop.components.PeerInfoIconSmall; import haveno.desktop.main.offer.offerbook.OfferBookListItem; import haveno.desktop.util.CurrencyListItem; import haveno.desktop.util.DisplayUtils; +import static haveno.desktop.util.FormBuilder.addTopLabelAutocompleteComboBox; import haveno.desktop.util.GUIUtil; +import static haveno.desktop.util.Layout.INITIAL_WINDOW_HEIGHT; import haveno.network.p2p.NodeAddress; +import java.text.DecimalFormat; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; +import java.util.stream.Collectors; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; @@ -73,17 +82,6 @@ import javafx.util.StringConverter; import org.fxmisc.easybind.EasyBind; import org.fxmisc.easybind.Subscription; -import javax.inject.Inject; -import javax.inject.Named; -import java.text.DecimalFormat; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.function.Function; -import java.util.stream.Collectors; - -import static haveno.desktop.util.FormBuilder.addTopLabelAutocompleteComboBox; -import static haveno.desktop.util.Layout.INITIAL_WINDOW_HEIGHT; - @FxmlView public class OfferBookChartView extends ActivatableViewAndModel { private final boolean useDevPrivilegeKeys; diff --git a/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadView.java b/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadView.java index e1ceb4a6ef..9adf595ad4 100644 --- a/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadView.java +++ b/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.market.spread; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.UserThread; import haveno.core.locale.CurrencyUtil; import haveno.core.locale.Res; @@ -29,6 +31,8 @@ import haveno.desktop.components.AutoTooltipLabel; import haveno.desktop.components.AutoTooltipTableColumn; import haveno.desktop.components.ColoredDecimalPlacesWithZerosText; import haveno.desktop.util.GUIUtil; +import java.math.BigInteger; +import java.util.Comparator; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.collections.ListChangeListener; import javafx.collections.transformation.SortedList; @@ -40,11 +44,6 @@ import javafx.scene.layout.GridPane; import javafx.scene.layout.Priority; import javafx.util.Callback; -import javax.inject.Inject; -import javax.inject.Named; -import java.math.BigInteger; -import java.util.Comparator; - @FxmlView public class SpreadView extends ActivatableViewAndModel { private final CoinFormatter formatter; diff --git a/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadViewModel.java b/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadViewModel.java index 7efba12b9c..ec30ebef97 100644 --- a/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadViewModel.java @@ -18,6 +18,7 @@ package haveno.desktop.main.market.spread; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.UserThread; import haveno.core.locale.Res; import haveno.core.monetary.CryptoMoney; @@ -35,15 +36,6 @@ import haveno.desktop.main.offer.offerbook.OfferBook; import haveno.desktop.main.offer.offerbook.OfferBookListItem; import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.util.GUIUtil; -import javafx.beans.property.IntegerProperty; -import javafx.beans.property.SimpleIntegerProperty; -import javafx.collections.FXCollections; -import javafx.collections.ListChangeListener; -import javafx.collections.ObservableList; -import lombok.Getter; -import lombok.Setter; - -import javax.inject.Named; import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; @@ -56,6 +48,13 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; +import javafx.beans.property.IntegerProperty; +import javafx.beans.property.SimpleIntegerProperty; +import javafx.collections.FXCollections; +import javafx.collections.ListChangeListener; +import javafx.collections.ObservableList; +import lombok.Getter; +import lombok.Setter; class SpreadViewModel extends ActivatableViewModel { diff --git a/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadViewPaymentMethod.java b/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadViewPaymentMethod.java index baa598f9be..39933c24c7 100644 --- a/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadViewPaymentMethod.java +++ b/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadViewPaymentMethod.java @@ -17,16 +17,14 @@ package haveno.desktop.main.market.spread; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.core.locale.Res; import haveno.core.util.FormattingUtils; import haveno.core.util.coin.CoinFormatter; import haveno.desktop.common.view.FxmlView; -import javafx.scene.control.ToggleButton; - -import javax.inject.Inject; -import javax.inject.Named; - import static haveno.desktop.util.FormBuilder.addSlideToggleButton; +import javafx.scene.control.ToggleButton; @FxmlView public class SpreadViewPaymentMethod extends SpreadView { diff --git a/desktop/src/main/java/haveno/desktop/main/market/trades/TradesChartsView.java b/desktop/src/main/java/haveno/desktop/main/market/trades/TradesChartsView.java index 98b08912de..dee3591bc8 100644 --- a/desktop/src/main/java/haveno/desktop/main/market/trades/TradesChartsView.java +++ b/desktop/src/main/java/haveno/desktop/main/market/trades/TradesChartsView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.market.trades; +import com.google.inject.Inject; +import com.google.inject.name.Named; import com.googlecode.jcsv.writer.CSVEntryConverter; import com.jfoenix.controls.JFXTabPane; import haveno.common.UserThread; @@ -41,11 +43,20 @@ import haveno.desktop.components.AutoTooltipTableColumn; import haveno.desktop.components.AutoTooltipToggleButton; import haveno.desktop.components.AutocompleteComboBox; import haveno.desktop.components.ColoredDecimalPlacesWithZerosText; +import static haveno.desktop.main.market.trades.TradesChartsViewModel.MAX_TICKS; import haveno.desktop.main.market.trades.charts.price.CandleStickChart; import haveno.desktop.main.market.trades.charts.volume.VolumeChart; import haveno.desktop.util.CurrencyListItem; import haveno.desktop.util.DisplayUtils; +import static haveno.desktop.util.FormBuilder.addTopLabelAutocompleteComboBox; +import static haveno.desktop.util.FormBuilder.getTopLabelWithVBox; import haveno.desktop.util.GUIUtil; +import java.text.DecimalFormat; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; @@ -84,19 +95,6 @@ import org.fxmisc.easybind.Subscription; import org.fxmisc.easybind.monadic.MonadicBinding; import org.jetbrains.annotations.NotNull; -import javax.inject.Inject; -import javax.inject.Named; -import java.text.DecimalFormat; -import java.util.Comparator; -import java.util.Date; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.stream.Collectors; - -import static haveno.desktop.main.market.trades.TradesChartsViewModel.MAX_TICKS; -import static haveno.desktop.util.FormBuilder.addTopLabelAutocompleteComboBox; -import static haveno.desktop.util.FormBuilder.getTopLabelWithVBox; - @FxmlView public class TradesChartsView extends ActivatableViewAndModel { private static final int SHOW_ALL = 0; diff --git a/desktop/src/main/java/haveno/desktop/main/offer/BuyOfferView.java b/desktop/src/main/java/haveno/desktop/main/offer/BuyOfferView.java index 45a0dc7442..c5def765e9 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/BuyOfferView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/BuyOfferView.java @@ -17,6 +17,7 @@ package haveno.desktop.main.offer; +import com.google.inject.Inject; import haveno.core.offer.OfferDirection; import haveno.core.user.Preferences; import haveno.core.user.User; @@ -25,8 +26,6 @@ import haveno.desktop.common.view.FxmlView; import haveno.desktop.common.view.ViewLoader; import haveno.network.p2p.P2PService; -import javax.inject.Inject; - @FxmlView public class BuyOfferView extends OfferView { diff --git a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferDataModel.java b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferDataModel.java index cdd74c1a4b..3d8f00f1b8 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferDataModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferDataModel.java @@ -17,7 +17,9 @@ package haveno.desktop.main.offer; +import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.handlers.ErrorMessageHandler; import haveno.common.util.MathUtils; import haveno.common.util.Utilities; @@ -50,6 +52,16 @@ import haveno.core.xmr.wallet.XmrWalletService; import haveno.desktop.Navigation; import haveno.desktop.util.GUIUtil; import haveno.network.p2p.P2PService; +import java.math.BigInteger; +import java.util.Comparator; +import static java.util.Comparator.comparing; +import java.util.Date; +import java.util.HashSet; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Collectors; import javafx.beans.property.BooleanProperty; import javafx.beans.property.DoubleProperty; import javafx.beans.property.ObjectProperty; @@ -68,20 +80,6 @@ import javafx.collections.SetChangeListener; import lombok.Getter; import org.jetbrains.annotations.NotNull; -import javax.inject.Named; -import java.math.BigInteger; -import java.util.Comparator; -import java.util.Date; -import java.util.HashSet; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkNotNull; -import static java.util.Comparator.comparing; - public abstract class MutableOfferDataModel extends OfferDataModel { private final CreateOfferService createOfferService; protected final OpenOfferManager openOfferManager; diff --git a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java index 51fe0dc44f..e221341078 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java @@ -17,6 +17,8 @@ package haveno.desktop.main.offer; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.UserThread; import haveno.common.app.DevEnv; import haveno.common.util.MathUtils; @@ -47,8 +49,8 @@ import haveno.core.util.PriceUtil; import haveno.core.util.VolumeUtil; import haveno.core.util.coin.CoinFormatter; import haveno.core.util.coin.CoinUtil; -import haveno.core.util.validation.AmountValidator8Decimals; import haveno.core.util.validation.AmountValidator4Decimals; +import haveno.core.util.validation.AmountValidator8Decimals; import haveno.core.util.validation.InputValidator; import haveno.core.util.validation.MonetaryValidator; import haveno.core.xmr.wallet.Restrictions; @@ -62,6 +64,12 @@ import haveno.desktop.main.settings.SettingsView; import haveno.desktop.main.settings.preferences.PreferencesView; import haveno.desktop.util.DisplayUtils; import haveno.desktop.util.GUIUtil; +import java.math.BigInteger; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.concurrent.TimeUnit; +import static javafx.beans.binding.Bindings.createStringBinding; import javafx.beans.property.BooleanProperty; import javafx.beans.property.IntegerProperty; import javafx.beans.property.ObjectProperty; @@ -78,16 +86,6 @@ import javafx.util.Callback; import lombok.extern.slf4j.Slf4j; import org.bitcoinj.core.Coin; -import javax.inject.Inject; -import javax.inject.Named; -import java.math.BigInteger; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.concurrent.TimeUnit; - -import static javafx.beans.binding.Bindings.createStringBinding; - @Slf4j public abstract class MutableOfferViewModel extends ActivatableWithDataModel { private final XmrValidator xmrValidator; @@ -697,7 +695,7 @@ public abstract class MutableOfferViewModel ext boolean isBuy = dataModel.getDirection() == OfferDirection.BUY; boolean isSellerWithinReleaseWindow = !isBuy && HavenoUtils.isReleasedWithinDays(HavenoUtils.RELEASE_LIMIT_DAYS); if (isSellerWithinReleaseWindow) { - + // format release date plus days Date releaseDate = HavenoUtils.getReleaseDate(); Calendar c = Calendar.getInstance(); diff --git a/desktop/src/main/java/haveno/desktop/main/offer/SellOfferView.java b/desktop/src/main/java/haveno/desktop/main/offer/SellOfferView.java index 8c3d391683..931f70ac66 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/SellOfferView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/SellOfferView.java @@ -17,6 +17,7 @@ package haveno.desktop.main.offer; +import com.google.inject.Inject; import haveno.core.offer.OfferDirection; import haveno.core.user.Preferences; import haveno.core.user.User; @@ -25,8 +26,6 @@ import haveno.desktop.common.view.FxmlView; import haveno.desktop.common.view.ViewLoader; import haveno.network.p2p.P2PService; -import javax.inject.Inject; - @FxmlView public class SellOfferView extends OfferView { diff --git a/desktop/src/main/java/haveno/desktop/main/offer/createoffer/CreateOfferDataModel.java b/desktop/src/main/java/haveno/desktop/main/offer/createoffer/CreateOfferDataModel.java index 53524d2f51..c511cabe4e 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/createoffer/CreateOfferDataModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/createoffer/CreateOfferDataModel.java @@ -18,6 +18,7 @@ package haveno.desktop.main.offer.createoffer; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.offer.CreateOfferService; import haveno.core.offer.OfferUtil; @@ -33,8 +34,6 @@ import haveno.core.xmr.wallet.XmrWalletService; import haveno.desktop.Navigation; import haveno.desktop.main.offer.MutableOfferDataModel; import haveno.network.p2p.P2PService; - -import javax.inject.Named; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; diff --git a/desktop/src/main/java/haveno/desktop/main/offer/createoffer/CreateOfferView.java b/desktop/src/main/java/haveno/desktop/main/offer/createoffer/CreateOfferView.java index 8065e82dcd..e30d53fdc1 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/createoffer/CreateOfferView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/createoffer/CreateOfferView.java @@ -18,6 +18,7 @@ package haveno.desktop.main.offer.createoffer; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.core.locale.CurrencyUtil; import haveno.core.locale.TradeCurrency; import haveno.core.offer.OfferDirection; @@ -31,12 +32,10 @@ import haveno.desktop.main.offer.MutableOfferView; import haveno.desktop.main.offer.OfferView; import haveno.desktop.main.overlays.windows.OfferDetailsWindow; import haveno.desktop.util.GUIUtil; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; - -import javax.inject.Named; import java.util.Objects; import java.util.stream.Collectors; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; @FxmlView public class CreateOfferView extends MutableOfferView { diff --git a/desktop/src/main/java/haveno/desktop/main/offer/createoffer/CreateOfferViewModel.java b/desktop/src/main/java/haveno/desktop/main/offer/createoffer/CreateOfferViewModel.java index f3d6865958..7f9de4c88a 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/createoffer/CreateOfferViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/createoffer/CreateOfferViewModel.java @@ -18,6 +18,7 @@ package haveno.desktop.main.offer.createoffer; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.offer.OfferUtil; import haveno.core.payment.validation.FiatVolumeValidator; @@ -27,14 +28,12 @@ import haveno.core.provider.price.PriceFeedService; import haveno.core.user.Preferences; import haveno.core.util.FormattingUtils; import haveno.core.util.coin.CoinFormatter; -import haveno.core.util.validation.AmountValidator8Decimals; import haveno.core.util.validation.AmountValidator4Decimals; +import haveno.core.util.validation.AmountValidator8Decimals; import haveno.desktop.Navigation; import haveno.desktop.common.model.ViewModel; import haveno.desktop.main.offer.MutableOfferViewModel; -import javax.inject.Named; - class CreateOfferViewModel extends MutableOfferViewModel implements ViewModel { @Inject diff --git a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBook.java b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBook.java index b1bf077935..2367f51c8d 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBook.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBook.java @@ -17,25 +17,23 @@ package haveno.desktop.main.offer.offerbook; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.core.filter.FilterManager; import haveno.core.offer.Offer; import haveno.core.offer.OfferBookService; +import static haveno.core.offer.OfferDirection.BUY; import haveno.core.offer.OfferRestrictions; import haveno.network.p2p.storage.P2PDataStorage; import haveno.network.utils.Utils; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; - -import static haveno.core.offer.OfferDirection.BUY; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import lombok.extern.slf4j.Slf4j; /** * Holds and manages the unsorted and unfiltered offerbook list (except for banned offers) of both buy and sell offers. diff --git a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OtherOfferBookView.java b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OtherOfferBookView.java index 67979aac07..71d18d50ed 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OtherOfferBookView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OtherOfferBookView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.offer.offerbook; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.core.account.sign.SignedWitnessService; import haveno.core.account.witness.AccountAgeWitnessService; @@ -30,9 +32,6 @@ import haveno.desktop.common.view.FxmlView; import haveno.desktop.main.overlays.windows.OfferDetailsWindow; import javafx.scene.layout.GridPane; -import javax.inject.Inject; -import javax.inject.Named; - @FxmlView public class OtherOfferBookView extends OfferBookView { diff --git a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OtherOfferBookViewModel.java b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OtherOfferBookViewModel.java index 3ee2576307..36ca017b8c 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OtherOfferBookViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OtherOfferBookViewModel.java @@ -18,6 +18,7 @@ package haveno.desktop.main.offer.offerbook; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.api.CoreApi; import haveno.core.locale.CryptoCurrency; @@ -42,14 +43,12 @@ import haveno.desktop.Navigation; import haveno.desktop.main.offer.OfferViewUtil; import haveno.desktop.util.GUIUtil; import haveno.network.p2p.P2PService; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import org.jetbrains.annotations.NotNull; - -import javax.inject.Named; import java.util.List; import java.util.function.Predicate; import java.util.stream.Collectors; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import org.jetbrains.annotations.NotNull; public class OtherOfferBookViewModel extends OfferBookViewModel { diff --git a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/TopCryptoOfferBookView.java b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/TopCryptoOfferBookView.java index eb982da646..a6904d9635 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/TopCryptoOfferBookView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/TopCryptoOfferBookView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.offer.offerbook; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.core.account.sign.SignedWitnessService; import haveno.core.account.witness.AccountAgeWitnessService; @@ -30,9 +32,6 @@ import haveno.desktop.common.view.FxmlView; import haveno.desktop.main.overlays.windows.OfferDetailsWindow; import javafx.scene.layout.GridPane; -import javax.inject.Inject; -import javax.inject.Named; - @FxmlView public class TopCryptoOfferBookView extends OfferBookView { diff --git a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/TopCryptoOfferBookViewModel.java b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/TopCryptoOfferBookViewModel.java index 3ebb1fd987..37cdaa129a 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/TopCryptoOfferBookViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/TopCryptoOfferBookViewModel.java @@ -18,6 +18,7 @@ package haveno.desktop.main.offer.offerbook; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.api.CoreApi; import haveno.core.locale.TradeCurrency; @@ -37,12 +38,10 @@ import haveno.core.xmr.setup.WalletsSetup; import haveno.desktop.Navigation; import haveno.desktop.util.GUIUtil; import haveno.network.p2p.P2PService; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; - -import javax.inject.Named; import java.util.function.Predicate; import java.util.stream.Collectors; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; public class TopCryptoOfferBookViewModel extends OfferBookViewModel { diff --git a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/XmrOfferBookView.java b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/XmrOfferBookView.java index 0a100890a1..07b4c5610d 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/XmrOfferBookView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/XmrOfferBookView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.offer.offerbook; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.core.account.sign.SignedWitnessService; import haveno.core.account.witness.AccountAgeWitnessService; @@ -30,9 +32,6 @@ import haveno.desktop.common.view.FxmlView; import haveno.desktop.main.overlays.windows.OfferDetailsWindow; import javafx.scene.layout.GridPane; -import javax.inject.Inject; -import javax.inject.Named; - @FxmlView public class XmrOfferBookView extends OfferBookView { diff --git a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/XmrOfferBookViewModel.java b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/XmrOfferBookViewModel.java index fa95062ac7..38702cde90 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/XmrOfferBookViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/XmrOfferBookViewModel.java @@ -18,6 +18,7 @@ package haveno.desktop.main.offer.offerbook; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.api.CoreApi; import haveno.core.locale.CryptoCurrency; @@ -42,13 +43,11 @@ import haveno.core.xmr.setup.WalletsSetup; import haveno.desktop.Navigation; import haveno.desktop.util.GUIUtil; import haveno.network.p2p.P2PService; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; - -import javax.inject.Named; import java.util.List; import java.util.function.Predicate; import java.util.stream.Collectors; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; public class XmrOfferBookViewModel extends OfferBookViewModel { diff --git a/desktop/src/main/java/haveno/desktop/main/offer/signedoffer/SignedOfferView.java b/desktop/src/main/java/haveno/desktop/main/offer/signedoffer/SignedOfferView.java index 934a4b0585..f241797fc7 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/signedoffer/SignedOfferView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/signedoffer/SignedOfferView.java @@ -17,38 +17,7 @@ package haveno.desktop.main.offer.signedoffer; -import javax.inject.Inject; - -import javafx.fxml.FXML; - -import javafx.scene.control.ContextMenu; -import javafx.scene.control.Label; -import javafx.scene.control.MenuItem; -import javafx.scene.control.TableCell; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableRow; -import javafx.scene.control.TableView; -import javafx.scene.control.Tooltip; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Priority; -import javafx.scene.layout.Region; -import javafx.scene.layout.VBox; - -import javafx.geometry.Insets; - -import javafx.beans.property.ReadOnlyObjectWrapper; - -import javafx.collections.transformation.FilteredList; -import javafx.collections.transformation.SortedList; - -import javafx.util.Callback; -import javafx.util.Duration; - -import java.util.Comparator; -import java.util.Date; - - - +import com.google.inject.Inject; import haveno.common.util.Utilities; import haveno.core.locale.Res; import haveno.core.offer.SignedOffer; @@ -65,6 +34,27 @@ import haveno.desktop.main.offer.OfferViewUtil; import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.util.DisplayUtils; import haveno.desktop.util.GUIUtil; +import java.util.Comparator; +import java.util.Date; +import javafx.beans.property.ReadOnlyObjectWrapper; +import javafx.collections.transformation.FilteredList; +import javafx.collections.transformation.SortedList; +import javafx.fxml.FXML; +import javafx.geometry.Insets; +import javafx.scene.control.ContextMenu; +import javafx.scene.control.Label; +import javafx.scene.control.MenuItem; +import javafx.scene.control.TableCell; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableRow; +import javafx.scene.control.TableView; +import javafx.scene.control.Tooltip; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; +import javafx.scene.layout.Region; +import javafx.scene.layout.VBox; +import javafx.util.Callback; +import javafx.util.Duration; @FxmlView public class SignedOfferView extends ActivatableViewAndModel { diff --git a/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java b/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java index da41c381e0..7599faad7e 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.offer.takeoffer; +import com.google.inject.Inject; +import com.google.inject.name.Named; import com.jfoenix.controls.JFXTextField; import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon; import haveno.common.UserThread; @@ -54,6 +56,7 @@ import haveno.desktop.main.offer.ClosableView; import haveno.desktop.main.offer.InitializableViewWithTakeOfferData; import haveno.desktop.main.offer.OfferView; import haveno.desktop.main.offer.OfferViewUtil; +import static haveno.desktop.main.offer.OfferViewUtil.addPayInfoEntry; import haveno.desktop.main.offer.SelectableView; import haveno.desktop.main.overlays.notifications.Notification; import haveno.desktop.main.overlays.popups.Popup; @@ -62,9 +65,27 @@ import haveno.desktop.main.overlays.windows.OfferDetailsWindow; import haveno.desktop.main.overlays.windows.QRCodeWindow; import haveno.desktop.main.portfolio.PortfolioView; import haveno.desktop.main.portfolio.pendingtrades.PendingTradesView; +import static haveno.desktop.util.FormBuilder.add2ButtonsWithBox; +import static haveno.desktop.util.FormBuilder.addAddressTextField; +import static haveno.desktop.util.FormBuilder.addBalanceTextField; +import static haveno.desktop.util.FormBuilder.addComboBoxTopLabelTextField; +import static haveno.desktop.util.FormBuilder.addFundsTextfield; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; +import static haveno.desktop.util.FormBuilder.getEditableValueBox; +import static haveno.desktop.util.FormBuilder.getIconForLabel; +import static haveno.desktop.util.FormBuilder.getNonEditableValueBox; +import static haveno.desktop.util.FormBuilder.getNonEditableValueBoxWithInfo; +import static haveno.desktop.util.FormBuilder.getSmallIconForLabel; +import static haveno.desktop.util.FormBuilder.getTopLabelWithVBox; import haveno.desktop.util.GUIUtil; import haveno.desktop.util.Layout; import haveno.desktop.util.Transitions; +import java.io.ByteArrayInputStream; +import java.math.BigInteger; +import java.net.URI; +import java.util.HashMap; +import java.util.concurrent.TimeUnit; +import static javafx.beans.binding.Bindings.createStringBinding; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.value.ChangeListener; import javafx.geometry.HPos; @@ -93,29 +114,6 @@ import org.fxmisc.easybind.EasyBind; import org.fxmisc.easybind.Subscription; import org.jetbrains.annotations.NotNull; -import javax.inject.Inject; -import javax.inject.Named; -import java.io.ByteArrayInputStream; -import java.math.BigInteger; -import java.net.URI; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; - -import static haveno.desktop.main.offer.OfferViewUtil.addPayInfoEntry; -import static haveno.desktop.util.FormBuilder.add2ButtonsWithBox; -import static haveno.desktop.util.FormBuilder.addAddressTextField; -import static haveno.desktop.util.FormBuilder.addBalanceTextField; -import static haveno.desktop.util.FormBuilder.addComboBoxTopLabelTextField; -import static haveno.desktop.util.FormBuilder.addFundsTextfield; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; -import static haveno.desktop.util.FormBuilder.getEditableValueBox; -import static haveno.desktop.util.FormBuilder.getIconForLabel; -import static haveno.desktop.util.FormBuilder.getNonEditableValueBox; -import static haveno.desktop.util.FormBuilder.getNonEditableValueBoxWithInfo; -import static haveno.desktop.util.FormBuilder.getSmallIconForLabel; -import static haveno.desktop.util.FormBuilder.getTopLabelWithVBox; -import static javafx.beans.binding.Bindings.createStringBinding; - @FxmlView public class TakeOfferView extends ActivatableViewAndModel implements ClosableView, InitializableViewWithTakeOfferData, SelectableView { private final Navigation navigation; diff --git a/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferViewModel.java b/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferViewModel.java index 6b83669c2c..742dddb619 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferViewModel.java @@ -17,6 +17,9 @@ package haveno.desktop.main.offer.takeoffer; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.UserThread; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.locale.Res; @@ -50,6 +53,8 @@ import haveno.network.p2p.P2PService; import haveno.network.p2p.network.CloseConnectionReason; import haveno.network.p2p.network.Connection; import haveno.network.p2p.network.ConnectionListener; +import java.math.BigInteger; +import static javafx.beans.binding.Bindings.createStringBinding; import javafx.beans.property.BooleanProperty; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleBooleanProperty; @@ -62,14 +67,7 @@ import javafx.scene.control.ComboBox; import javafx.scene.control.ListCell; import javafx.scene.control.ListView; import javafx.util.Callback; - import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Named; -import java.math.BigInteger; - -import static com.google.common.base.Preconditions.checkNotNull; -import static javafx.beans.binding.Bindings.createStringBinding; class TakeOfferViewModel extends ActivatableWithDataModel implements ViewModel { final TakeOfferDataModel dataModel; diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/notifications/NotificationCenter.java b/desktop/src/main/java/haveno/desktop/main/overlays/notifications/NotificationCenter.java index 8c54802669..829a0640d5 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/notifications/NotificationCenter.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/notifications/NotificationCenter.java @@ -18,6 +18,7 @@ package haveno.desktop.main.overlays.notifications; import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.UserThread; import haveno.core.api.NotificationListener; import haveno.core.locale.Res; @@ -45,19 +46,17 @@ import haveno.desktop.main.support.dispute.client.mediation.MediationClientView; import haveno.desktop.main.support.dispute.client.refund.RefundClientView; import haveno.proto.grpc.NotificationMessage; import haveno.proto.grpc.NotificationMessage.NotificationType; -import javafx.collections.ListChangeListener; -import lombok.NonNull; -import lombok.extern.slf4j.Slf4j; -import org.fxmisc.easybind.EasyBind; -import org.fxmisc.easybind.Subscription; - -import javax.annotation.Nullable; -import javax.inject.Singleton; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Consumer; +import javafx.collections.ListChangeListener; +import javax.annotation.Nullable; +import lombok.NonNull; +import lombok.extern.slf4j.Slf4j; +import org.fxmisc.easybind.EasyBind; +import org.fxmisc.easybind.Subscription; @Slf4j @Singleton diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/ClosedTradesSummaryWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/ClosedTradesSummaryWindow.java index 1bc6da7284..cce9c01663 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/ClosedTradesSummaryWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/ClosedTradesSummaryWindow.java @@ -17,18 +17,16 @@ package haveno.desktop.main.overlays.windows; +import com.google.inject.Inject; import haveno.core.locale.Res; import haveno.desktop.main.overlays.Overlay; import haveno.desktop.main.portfolio.closedtrades.ClosedTradesViewModel; -import haveno.desktop.util.Layout; -import javafx.geometry.Insets; - -import javax.inject.Inject; -import java.math.BigInteger; -import java.util.Map; - import static haveno.desktop.util.FormBuilder.addConfirmationLabelLabel; import static haveno.desktop.util.FormBuilder.addTitledGroupBg; +import haveno.desktop.util.Layout; +import java.math.BigInteger; +import java.util.Map; +import javafx.geometry.Insets; public class ClosedTradesSummaryWindow extends Overlay { private final ClosedTradesViewModel model; diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/ContractWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/ContractWindow.java index 96e10a8022..262ec5efea 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/ContractWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/ContractWindow.java @@ -18,6 +18,7 @@ package haveno.desktop.main.overlays.windows; import com.google.common.base.Joiner; +import com.google.inject.Inject; import haveno.common.UserThread; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.locale.CountryUtil; @@ -38,8 +39,17 @@ import haveno.desktop.components.HavenoTextArea; import haveno.desktop.main.MainView; import haveno.desktop.main.overlays.Overlay; import haveno.desktop.util.DisplayUtils; +import static haveno.desktop.util.DisplayUtils.getAccountWitnessDescription; +import static haveno.desktop.util.FormBuilder.addButtonAfterGroup; +import static haveno.desktop.util.FormBuilder.addConfirmationLabelButton; +import static haveno.desktop.util.FormBuilder.addConfirmationLabelTextField; +import static haveno.desktop.util.FormBuilder.addConfirmationLabelTextFieldWithCopyIcon; +import static haveno.desktop.util.FormBuilder.addLabelExplorerAddressTextField; +import static haveno.desktop.util.FormBuilder.addLabelTxIdTextField; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; import haveno.desktop.util.Layout; import haveno.network.p2p.NodeAddress; +import java.util.List; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Button; @@ -54,18 +64,6 @@ import javafx.stage.Window; import lombok.extern.slf4j.Slf4j; import org.bitcoinj.core.Utils; -import javax.inject.Inject; -import java.util.List; - -import static haveno.desktop.util.DisplayUtils.getAccountWitnessDescription; -import static haveno.desktop.util.FormBuilder.addButtonAfterGroup; -import static haveno.desktop.util.FormBuilder.addConfirmationLabelButton; -import static haveno.desktop.util.FormBuilder.addConfirmationLabelTextField; -import static haveno.desktop.util.FormBuilder.addConfirmationLabelTextFieldWithCopyIcon; -import static haveno.desktop.util.FormBuilder.addLabelExplorerAddressTextField; -import static haveno.desktop.util.FormBuilder.addLabelTxIdTextField; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; - @Slf4j public class ContractWindow extends Overlay { private final ArbitrationManager arbitrationManager; diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/FilterWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/FilterWindow.java index 27de13eafb..f3a6338005 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/FilterWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/FilterWindow.java @@ -18,6 +18,7 @@ package haveno.desktop.main.overlays.windows; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.UserThread; import haveno.common.app.DevEnv; import haveno.common.config.Config; @@ -29,6 +30,14 @@ import haveno.desktop.components.AutoTooltipButton; import haveno.desktop.components.InputTextField; import haveno.desktop.main.overlays.Overlay; import haveno.desktop.main.overlays.popups.Popup; +import static haveno.desktop.util.FormBuilder.addInputTextField; +import static haveno.desktop.util.FormBuilder.addLabelCheckBox; +import static haveno.desktop.util.FormBuilder.addTopLabelInputTextField; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.stream.Collectors; import javafx.collections.FXCollections; import javafx.geometry.HPos; import javafx.geometry.Insets; @@ -42,17 +51,6 @@ import javafx.scene.layout.HBox; import javafx.scene.layout.Region; import org.apache.commons.lang3.StringUtils; -import javax.inject.Named; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.stream.Collectors; - -import static haveno.desktop.util.FormBuilder.addInputTextField; -import static haveno.desktop.util.FormBuilder.addLabelCheckBox; -import static haveno.desktop.util.FormBuilder.addTopLabelInputTextField; - public class FilterWindow extends Overlay { private final FilterManager filterManager; private final boolean useDevPrivilegeKeys; diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java index f52ffd06eb..8e0a0c099b 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java @@ -18,7 +18,8 @@ package haveno.desktop.main.overlays.windows; import com.google.common.base.Joiner; - +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.UserThread; import haveno.common.crypto.KeyRing; import haveno.common.util.Tuple2; @@ -42,8 +43,17 @@ import haveno.desktop.components.AutoTooltipButton; import haveno.desktop.components.BusyAnimation; import haveno.desktop.main.overlays.Overlay; import haveno.desktop.util.DisplayUtils; +import static haveno.desktop.util.FormBuilder.addButtonAfterGroup; +import static haveno.desktop.util.FormBuilder.addButtonBusyAnimationLabelAfterGroup; +import static haveno.desktop.util.FormBuilder.addConfirmationLabelLabel; +import static haveno.desktop.util.FormBuilder.addConfirmationLabelTextArea; +import static haveno.desktop.util.FormBuilder.addConfirmationLabelTextFieldWithCopyIcon; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; import haveno.desktop.util.GUIUtil; import haveno.desktop.util.Layout; +import java.math.BigInteger; +import java.util.List; +import java.util.Optional; import javafx.geometry.HPos; import javafx.geometry.Insets; import javafx.scene.control.Button; @@ -58,19 +68,6 @@ import org.fxmisc.easybind.Subscription; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Named; -import java.math.BigInteger; -import java.util.List; -import java.util.Optional; - -import static haveno.desktop.util.FormBuilder.addButtonAfterGroup; -import static haveno.desktop.util.FormBuilder.addButtonBusyAnimationLabelAfterGroup; -import static haveno.desktop.util.FormBuilder.addConfirmationLabelLabel; -import static haveno.desktop.util.FormBuilder.addConfirmationLabelTextArea; -import static haveno.desktop.util.FormBuilder.addConfirmationLabelTextFieldWithCopyIcon; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; - public class OfferDetailsWindow extends Overlay { protected static final Logger log = LoggerFactory.getLogger(OfferDetailsWindow.class); diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/SelectDepositTxWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/SelectDepositTxWindow.java index 53c14c453f..a0ce3fb9b8 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/SelectDepositTxWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/SelectDepositTxWindow.java @@ -17,9 +17,14 @@ package haveno.desktop.main.overlays.windows; +import com.google.inject.Inject; import haveno.core.locale.Res; import haveno.desktop.main.overlays.Overlay; import haveno.desktop.util.FormBuilder; +import static haveno.desktop.util.FormBuilder.addMultilineLabel; +import java.util.List; +import java.util.Optional; +import java.util.function.Consumer; import javafx.collections.FXCollections; import javafx.geometry.Insets; import javafx.scene.control.ComboBox; @@ -28,13 +33,6 @@ import javafx.scene.layout.GridPane; import javafx.util.StringConverter; import org.bitcoinj.core.Transaction; -import javax.inject.Inject; -import java.util.List; -import java.util.Optional; -import java.util.function.Consumer; - -import static haveno.desktop.util.FormBuilder.addMultilineLabel; - //TODO might be removed, but leave it for now until sure we will not use it anymore. public class SelectDepositTxWindow extends Overlay { private ComboBox transactionsComboBox; diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/SendAlertMessageWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/SendAlertMessageWindow.java index 59cc133223..a03e7e111f 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/SendAlertMessageWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/SendAlertMessageWindow.java @@ -18,6 +18,7 @@ package haveno.desktop.main.overlays.windows; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.app.DevEnv; import haveno.common.config.Config; import haveno.common.util.Tuple2; @@ -29,6 +30,10 @@ import haveno.desktop.components.InputTextField; import haveno.desktop.main.overlays.Overlay; import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.util.FormBuilder; +import static haveno.desktop.util.FormBuilder.addInputTextField; +import static haveno.desktop.util.FormBuilder.addLabelCheckBox; +import static haveno.desktop.util.FormBuilder.addRadioButton; +import static haveno.desktop.util.FormBuilder.addTopLabelTextArea; import javafx.geometry.HPos; import javafx.geometry.Insets; import javafx.scene.Scene; @@ -42,13 +47,6 @@ import javafx.scene.input.KeyCode; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; -import javax.inject.Named; - -import static haveno.desktop.util.FormBuilder.addInputTextField; -import static haveno.desktop.util.FormBuilder.addLabelCheckBox; -import static haveno.desktop.util.FormBuilder.addRadioButton; -import static haveno.desktop.util.FormBuilder.addTopLabelTextArea; - public class SendAlertMessageWindow extends Overlay { private final AlertManager alertManager; private final boolean useDevPrivilegeKeys; diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/SignPaymentAccountsWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/SignPaymentAccountsWindow.java index 783f824d6a..fe8b8c9009 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/SignPaymentAccountsWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/SignPaymentAccountsWindow.java @@ -17,6 +17,8 @@ package haveno.desktop.main.overlays.windows; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.common.util.Tuple2; import haveno.common.util.Tuple3; @@ -34,6 +36,22 @@ import haveno.desktop.components.AutoTooltipButton; import haveno.desktop.components.InputTextField; import haveno.desktop.main.overlays.Overlay; import haveno.desktop.main.overlays.popups.Popup; +import static haveno.desktop.util.FormBuilder.add2ButtonsAfterGroup; +import static haveno.desktop.util.FormBuilder.addComboBox; +import static haveno.desktop.util.FormBuilder.addInputTextField; +import static haveno.desktop.util.FormBuilder.addLabelCheckBox; +import static haveno.desktop.util.FormBuilder.addMultilineLabel; +import static haveno.desktop.util.FormBuilder.addTopLabelDatePicker; +import static haveno.desktop.util.FormBuilder.addTopLabelListView; +import static haveno.desktop.util.FormBuilder.removeRowsFromGridPane; +import java.time.Instant; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.geometry.HPos; @@ -54,26 +72,6 @@ import lombok.extern.slf4j.Slf4j; import org.bitcoinj.core.ECKey; import org.bitcoinj.core.Utils; -import javax.inject.Inject; -import javax.inject.Named; -import java.time.Instant; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; - -import static haveno.desktop.util.FormBuilder.add2ButtonsAfterGroup; -import static haveno.desktop.util.FormBuilder.addComboBox; -import static haveno.desktop.util.FormBuilder.addInputTextField; -import static haveno.desktop.util.FormBuilder.addLabelCheckBox; -import static haveno.desktop.util.FormBuilder.addMultilineLabel; -import static haveno.desktop.util.FormBuilder.addTopLabelDatePicker; -import static haveno.desktop.util.FormBuilder.addTopLabelListView; -import static haveno.desktop.util.FormBuilder.removeRowsFromGridPane; - @Slf4j public class SignPaymentAccountsWindow extends Overlay { diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/SignSpecificWitnessWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/SignSpecificWitnessWindow.java index b76507b385..f008dd7b9e 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/SignSpecificWitnessWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/SignSpecificWitnessWindow.java @@ -17,6 +17,7 @@ package haveno.desktop.main.overlays.windows; +import com.google.inject.Inject; import haveno.common.util.Tuple2; import haveno.common.util.Utilities; import haveno.core.account.witness.AccountAgeWitness; @@ -28,6 +29,12 @@ import haveno.desktop.components.HavenoTextArea; import haveno.desktop.components.InputTextField; import haveno.desktop.main.overlays.Overlay; import haveno.desktop.main.overlays.popups.Popup; +import static haveno.desktop.util.FormBuilder.add2ButtonsAfterGroup; +import static haveno.desktop.util.FormBuilder.addInputTextField; +import static haveno.desktop.util.FormBuilder.addMultilineLabel; +import static haveno.desktop.util.FormBuilder.addTopLabelTextField; +import static haveno.desktop.util.FormBuilder.removeRowsFromGridPane; +import java.util.Date; import javafx.geometry.VPos; import javafx.scene.control.TextArea; import javafx.scene.layout.GridPane; @@ -36,15 +43,6 @@ import lombok.extern.slf4j.Slf4j; import org.bitcoinj.core.ECKey; import org.bitcoinj.core.Utils; -import javax.inject.Inject; -import java.util.Date; - -import static haveno.desktop.util.FormBuilder.add2ButtonsAfterGroup; -import static haveno.desktop.util.FormBuilder.addInputTextField; -import static haveno.desktop.util.FormBuilder.addMultilineLabel; -import static haveno.desktop.util.FormBuilder.addTopLabelTextField; -import static haveno.desktop.util.FormBuilder.removeRowsFromGridPane; - @Slf4j public class SignSpecificWitnessWindow extends Overlay { diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/SignUnsignedPubKeysWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/SignUnsignedPubKeysWindow.java index aa1277ced6..6b618adf68 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/SignUnsignedPubKeysWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/SignUnsignedPubKeysWindow.java @@ -17,6 +17,7 @@ package haveno.desktop.main.overlays.windows; +import com.google.inject.Inject; import haveno.common.crypto.Hash; import haveno.common.util.Tuple3; import haveno.common.util.Utilities; @@ -28,6 +29,12 @@ import haveno.desktop.components.AutoTooltipButton; import haveno.desktop.components.InputTextField; import haveno.desktop.main.overlays.Overlay; import haveno.desktop.main.overlays.popups.Popup; +import static haveno.desktop.util.FormBuilder.add2ButtonsAfterGroup; +import static haveno.desktop.util.FormBuilder.addInputTextField; +import static haveno.desktop.util.FormBuilder.addTopLabelListView; +import static haveno.desktop.util.FormBuilder.removeRowsFromGridPane; +import java.util.ArrayList; +import java.util.List; import javafx.collections.FXCollections; import javafx.geometry.VPos; import javafx.scene.control.Label; @@ -40,15 +47,6 @@ import javafx.util.Callback; import lombok.extern.slf4j.Slf4j; import org.bitcoinj.core.Utils; -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.List; - -import static haveno.desktop.util.FormBuilder.add2ButtonsAfterGroup; -import static haveno.desktop.util.FormBuilder.addInputTextField; -import static haveno.desktop.util.FormBuilder.addTopLabelListView; -import static haveno.desktop.util.FormBuilder.removeRowsFromGridPane; - @Slf4j public class SignUnsignedPubKeysWindow extends Overlay { diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/TorNetworkSettingsWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/TorNetworkSettingsWindow.java index 607efb2006..3d65d0e9c7 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/TorNetworkSettingsWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/TorNetworkSettingsWindow.java @@ -18,6 +18,8 @@ package haveno.desktop.main.overlays.windows; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.UserThread; import haveno.common.util.Tuple2; import haveno.common.util.Tuple4; @@ -30,9 +32,19 @@ import haveno.desktop.components.BusyAnimation; import haveno.desktop.components.TitledGroupBg; import haveno.desktop.main.overlays.Overlay; import haveno.desktop.main.overlays.popups.Popup; +import static haveno.desktop.util.FormBuilder.addButtonBusyAnimationLabelAfterGroup; +import static haveno.desktop.util.FormBuilder.addComboBox; +import static haveno.desktop.util.FormBuilder.addLabel; +import static haveno.desktop.util.FormBuilder.addRadioButton; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; +import static haveno.desktop.util.FormBuilder.addTopLabelTextArea; import haveno.desktop.util.Layout; import haveno.network.p2p.network.DefaultPluggableTransports; import haveno.network.p2p.network.NetworkNode; +import java.io.IOException; +import java.net.URI; +import java.util.Arrays; +import java.util.concurrent.TimeUnit; import javafx.collections.FXCollections; import javafx.geometry.HPos; import javafx.geometry.Insets; @@ -52,20 +64,6 @@ import javafx.scene.layout.Priority; import javafx.util.StringConverter; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.io.IOException; -import java.net.URI; -import java.util.Arrays; -import java.util.concurrent.TimeUnit; - -import static haveno.desktop.util.FormBuilder.addButtonBusyAnimationLabelAfterGroup; -import static haveno.desktop.util.FormBuilder.addComboBox; -import static haveno.desktop.util.FormBuilder.addLabel; -import static haveno.desktop.util.FormBuilder.addRadioButton; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; -import static haveno.desktop.util.FormBuilder.addTopLabelTextArea; - @Slf4j @Singleton public class TorNetworkSettingsWindow extends Overlay { diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/TradeDetailsWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/TradeDetailsWindow.java index 2087e09348..6575769db3 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/TradeDetailsWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/TradeDetailsWindow.java @@ -17,6 +17,8 @@ package haveno.desktop.main.overlays.windows; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.UserThread; import haveno.common.util.Tuple3; import haveno.common.util.Utilities; @@ -37,6 +39,12 @@ import haveno.desktop.components.HavenoTextArea; import haveno.desktop.main.MainView; import haveno.desktop.main.overlays.Overlay; import haveno.desktop.util.DisplayUtils; +import static haveno.desktop.util.DisplayUtils.getAccountWitnessDescription; +import static haveno.desktop.util.FormBuilder.add2ButtonsWithBox; +import static haveno.desktop.util.FormBuilder.addConfirmationLabelTextArea; +import static haveno.desktop.util.FormBuilder.addConfirmationLabelTextField; +import static haveno.desktop.util.FormBuilder.addLabelTxIdTextField; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; import haveno.desktop.util.Layout; import haveno.network.p2p.NodeAddress; import javafx.beans.property.IntegerProperty; @@ -59,16 +67,6 @@ import javafx.stage.Window; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Named; - -import static haveno.desktop.util.DisplayUtils.getAccountWitnessDescription; -import static haveno.desktop.util.FormBuilder.add2ButtonsWithBox; -import static haveno.desktop.util.FormBuilder.addConfirmationLabelTextArea; -import static haveno.desktop.util.FormBuilder.addConfirmationLabelTextField; -import static haveno.desktop.util.FormBuilder.addLabelTxIdTextField; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; - public class TradeDetailsWindow extends Overlay { protected static final Logger log = LoggerFactory.getLogger(TradeDetailsWindow.class); diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/WalletPasswordWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/WalletPasswordWindow.java index 04fff8ecf6..dbdc6696d2 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/WalletPasswordWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/WalletPasswordWindow.java @@ -17,7 +17,10 @@ package haveno.desktop.main.overlays.windows; +import static com.google.common.base.Preconditions.checkArgument; import com.google.common.base.Splitter; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.common.crypto.IncorrectPasswordException; import haveno.common.util.Tuple2; @@ -32,7 +35,18 @@ import haveno.desktop.components.PasswordTextField; import haveno.desktop.main.SharedPresentation; import haveno.desktop.main.overlays.Overlay; import haveno.desktop.main.overlays.popups.Popup; +import static haveno.desktop.util.FormBuilder.addPasswordTextField; +import static haveno.desktop.util.FormBuilder.addPrimaryActionButton; +import static haveno.desktop.util.FormBuilder.addTextArea; +import static haveno.desktop.util.FormBuilder.addTopLabelDatePicker; import haveno.desktop.util.Layout; +import java.io.File; +import java.io.IOException; +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.ZoneOffset; +import static javafx.beans.binding.Bindings.createBooleanBinding; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.value.ChangeListener; @@ -54,22 +68,6 @@ import org.bitcoinj.crypto.MnemonicCode; import org.bitcoinj.crypto.MnemonicException; import org.bitcoinj.wallet.DeterministicSeed; -import javax.inject.Inject; -import javax.inject.Named; -import java.io.File; -import java.io.IOException; -import java.time.Instant; -import java.time.LocalDate; -import java.time.ZoneId; -import java.time.ZoneOffset; - -import static com.google.common.base.Preconditions.checkArgument; -import static haveno.desktop.util.FormBuilder.addPasswordTextField; -import static haveno.desktop.util.FormBuilder.addPrimaryActionButton; -import static haveno.desktop.util.FormBuilder.addTextArea; -import static haveno.desktop.util.FormBuilder.addTopLabelDatePicker; -import static javafx.beans.binding.Bindings.createBooleanBinding; - @Slf4j public class WalletPasswordWindow extends Overlay { private final CoreAccountService accountService; diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/downloadupdate/DisplayUpdateDownloadWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/downloadupdate/DisplayUpdateDownloadWindow.java index 9092502ef1..12974cb6f3 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/downloadupdate/DisplayUpdateDownloadWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/downloadupdate/DisplayUpdateDownloadWindow.java @@ -18,7 +18,7 @@ package haveno.desktop.main.overlays.windows.downloadupdate; import com.google.common.base.Joiner; -import com.jfoenix.controls.JFXProgressBar; +import static com.google.common.base.Preconditions.checkNotNull; import haveno.common.config.Config; import haveno.common.util.Utilities; import haveno.core.alert.Alert; @@ -28,6 +28,18 @@ import haveno.desktop.components.AutoTooltipLabel; import haveno.desktop.components.BusyAnimation; import haveno.desktop.main.overlays.Overlay; import haveno.desktop.main.overlays.popups.Popup; +import static haveno.desktop.util.FormBuilder.addLabel; +import static haveno.desktop.util.FormBuilder.addMultilineLabel; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.Scanner; import javafx.beans.value.ChangeListener; import javafx.geometry.HPos; import javafx.geometry.Insets; @@ -43,21 +55,6 @@ import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import lombok.extern.slf4j.Slf4j; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.PrintWriter; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.Scanner; - -import static com.google.common.base.Preconditions.checkNotNull; -import static haveno.desktop.util.FormBuilder.addLabel; -import static haveno.desktop.util.FormBuilder.addMultilineLabel; - @Slf4j public class DisplayUpdateDownloadWindow extends Overlay { private final Alert alert; @@ -134,7 +131,7 @@ public class DisplayUpdateDownloadWindow extends Overlay { diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesView.java b/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesView.java index b04a86eb17..056da477f2 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesView.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.portfolio.closedtrades; +import com.google.inject.Inject; +import com.google.inject.name.Named; import com.googlecode.jcsv.writer.CSVEntryConverter; import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon; import haveno.common.config.Config; @@ -43,8 +45,11 @@ import haveno.desktop.main.overlays.windows.ClosedTradesSummaryWindow; import haveno.desktop.main.overlays.windows.OfferDetailsWindow; import haveno.desktop.main.overlays.windows.TradeDetailsWindow; import haveno.desktop.main.portfolio.presentation.PortfolioUtil; +import static haveno.desktop.util.FormBuilder.getRegularIconButton; import haveno.desktop.util.GUIUtil; import haveno.network.p2p.NodeAddress; +import java.util.Comparator; +import java.util.function.Function; import javafx.beans.binding.Bindings; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.value.ChangeListener; @@ -70,13 +75,6 @@ import javafx.scene.layout.VBox; import javafx.stage.Stage; import javafx.util.Callback; -import javax.inject.Inject; -import javax.inject.Named; -import java.util.Comparator; -import java.util.function.Function; - -import static haveno.desktop.util.FormBuilder.getRegularIconButton; - @FxmlView public class ClosedTradesView extends ActivatableViewAndModel { private final boolean useDevPrivilegeKeys; diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/duplicateoffer/DuplicateOfferDataModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/duplicateoffer/DuplicateOfferDataModel.java index 6c6b06b9e4..75514e4300 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/duplicateoffer/DuplicateOfferDataModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/duplicateoffer/DuplicateOfferDataModel.java @@ -19,6 +19,7 @@ package haveno.desktop.main.portfolio.duplicateoffer; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.locale.CurrencyUtil; import haveno.core.locale.TradeCurrency; @@ -39,8 +40,6 @@ import haveno.core.xmr.wallet.XmrWalletService; import haveno.desktop.Navigation; import haveno.desktop.main.offer.MutableOfferDataModel; import haveno.network.p2p.P2PService; - -import javax.inject.Named; import java.math.BigInteger; import java.util.Objects; import java.util.Optional; diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/duplicateoffer/DuplicateOfferView.java b/desktop/src/main/java/haveno/desktop/main/portfolio/duplicateoffer/DuplicateOfferView.java index 65de9c746d..33285e7c32 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/duplicateoffer/DuplicateOfferView.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/duplicateoffer/DuplicateOfferView.java @@ -18,6 +18,7 @@ package haveno.desktop.main.portfolio.duplicateoffer; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.core.locale.CurrencyUtil; import haveno.core.offer.OfferPayload; import haveno.core.payment.PaymentAccount; @@ -31,8 +32,6 @@ import haveno.desktop.main.overlays.windows.OfferDetailsWindow; import javafx.collections.ObservableList; import javafx.geometry.Insets; -import javax.inject.Named; - @FxmlView public class DuplicateOfferView extends MutableOfferView { diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/duplicateoffer/DuplicateOfferViewModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/duplicateoffer/DuplicateOfferViewModel.java index f9c2788d2e..08c5e18f9e 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/duplicateoffer/DuplicateOfferViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/duplicateoffer/DuplicateOfferViewModel.java @@ -18,6 +18,7 @@ package haveno.desktop.main.portfolio.duplicateoffer; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.offer.Offer; import haveno.core.offer.OfferPayload; @@ -29,14 +30,12 @@ import haveno.core.provider.price.PriceFeedService; import haveno.core.user.Preferences; import haveno.core.util.FormattingUtils; import haveno.core.util.coin.CoinFormatter; -import haveno.core.util.validation.AmountValidator8Decimals; import haveno.core.util.validation.AmountValidator4Decimals; +import haveno.core.util.validation.AmountValidator8Decimals; import haveno.desktop.Navigation; import haveno.desktop.main.offer.MutableOfferViewModel; import lombok.extern.slf4j.Slf4j; -import javax.inject.Named; - @Slf4j class DuplicateOfferViewModel extends MutableOfferViewModel { diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferDataModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferDataModel.java index bd0eedab6e..64e68ce9f2 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferDataModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferDataModel.java @@ -19,6 +19,7 @@ package haveno.desktop.main.portfolio.editoffer; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.handlers.ErrorMessageHandler; import haveno.common.handlers.ResultHandler; import haveno.core.account.witness.AccountAgeWitnessService; @@ -45,8 +46,6 @@ import haveno.core.xmr.wallet.XmrWalletService; import haveno.desktop.Navigation; import haveno.desktop.main.offer.MutableOfferDataModel; import haveno.network.p2p.P2PService; - -import javax.inject.Named; import java.util.Optional; import java.util.Set; diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferView.java b/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferView.java index ba9a17372f..60aa3c4dec 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferView.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferView.java @@ -18,6 +18,7 @@ package haveno.desktop.main.portfolio.editoffer; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.util.Tuple4; import haveno.core.locale.CurrencyUtil; import haveno.core.locale.Res; @@ -34,6 +35,7 @@ import haveno.desktop.components.BusyAnimation; import haveno.desktop.main.offer.MutableOfferView; import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.main.overlays.windows.OfferDetailsWindow; +import static haveno.desktop.util.FormBuilder.addButtonBusyAnimationLabelAfterGroup; import javafx.collections.ObservableList; import javafx.geometry.HPos; import javafx.geometry.Insets; @@ -44,10 +46,6 @@ import javafx.scene.image.ImageView; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; -import javax.inject.Named; - -import static haveno.desktop.util.FormBuilder.addButtonBusyAnimationLabelAfterGroup; - @FxmlView public class EditOfferView extends MutableOfferView { diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferViewModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferViewModel.java index cab90c96ce..8f121359c7 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferViewModel.java @@ -18,6 +18,7 @@ package haveno.desktop.main.portfolio.editoffer; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.handlers.ErrorMessageHandler; import haveno.common.handlers.ResultHandler; import haveno.core.account.witness.AccountAgeWitnessService; @@ -31,13 +32,11 @@ import haveno.core.user.Preferences; import haveno.core.util.FormattingUtils; import haveno.core.util.PriceUtil; import haveno.core.util.coin.CoinFormatter; -import haveno.core.util.validation.AmountValidator8Decimals; import haveno.core.util.validation.AmountValidator4Decimals; +import haveno.core.util.validation.AmountValidator8Decimals; import haveno.desktop.Navigation; import haveno.desktop.main.offer.MutableOfferViewModel; -import javax.inject.Named; - class EditOfferViewModel extends MutableOfferViewModel { @Inject diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/failedtrades/FailedTradesView.java b/desktop/src/main/java/haveno/desktop/main/portfolio/failedtrades/FailedTradesView.java index 027c9128db..3449ea5650 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/failedtrades/FailedTradesView.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/failedtrades/FailedTradesView.java @@ -17,6 +17,7 @@ package haveno.desktop.main.portfolio.failedtrades; +import com.google.inject.Inject; import com.googlecode.jcsv.writer.CSVEntryConverter; import com.jfoenix.controls.JFXButton; import de.jensd.fx.fontawesome.AwesomeIcon; @@ -38,6 +39,8 @@ import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.main.overlays.windows.TradeDetailsWindow; import haveno.desktop.util.FormBuilder; import haveno.desktop.util.GUIUtil; +import java.math.BigInteger; +import java.util.Comparator; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.value.ChangeListener; import javafx.collections.ObservableList; @@ -65,10 +68,6 @@ import javafx.scene.layout.VBox; import javafx.stage.Stage; import javafx.util.Callback; -import javax.inject.Inject; -import java.math.BigInteger; -import java.util.Comparator; - @FxmlView public class FailedTradesView extends ActivatableViewAndModel { diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/failedtrades/FailedTradesViewModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/failedtrades/FailedTradesViewModel.java index 064ac7b9d3..eef2ffa444 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/failedtrades/FailedTradesViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/failedtrades/FailedTradesViewModel.java @@ -18,6 +18,7 @@ package haveno.desktop.main.portfolio.failedtrades; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.core.locale.CurrencyUtil; import haveno.core.locale.Res; import haveno.core.trade.HavenoUtils; @@ -29,8 +30,6 @@ import haveno.desktop.common.model.ViewModel; import haveno.desktop.util.DisplayUtils; import javafx.collections.ObservableList; -import javax.inject.Named; - class FailedTradesViewModel extends ActivatableWithDataModel implements ViewModel { private final CoinFormatter formatter; diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersView.java b/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersView.java index 009ae82772..f0b1f1fc28 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersView.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersView.java @@ -17,6 +17,7 @@ package haveno.desktop.main.portfolio.openoffer; +import com.google.inject.Inject; import com.googlecode.jcsv.writer.CSVEntryConverter; import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon; import haveno.core.locale.Res; @@ -40,7 +41,13 @@ import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.main.overlays.windows.OfferDetailsWindow; import haveno.desktop.main.portfolio.PortfolioView; import haveno.desktop.main.portfolio.duplicateoffer.DuplicateOfferView; +import static haveno.desktop.util.FormBuilder.getRegularIconButton; import haveno.desktop.util.GUIUtil; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import javafx.beans.binding.Bindings; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.value.ChangeListener; @@ -68,20 +75,10 @@ import javafx.scene.layout.Region; import javafx.scene.layout.VBox; import javafx.stage.Stage; import javafx.util.Callback; - import org.fxmisc.easybind.EasyBind; import org.fxmisc.easybind.Subscription; import org.jetbrains.annotations.NotNull; -import javax.inject.Inject; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static haveno.desktop.util.FormBuilder.getRegularIconButton; - @FxmlView public class OpenOffersView extends ActivatableViewAndModel { diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersViewModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersViewModel.java index d560891890..3c5eaf325a 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersViewModel.java @@ -17,7 +17,9 @@ package haveno.desktop.main.portfolio.openoffer; +import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.handlers.ErrorMessageHandler; import haveno.common.handlers.ResultHandler; import haveno.core.locale.CurrencyUtil; @@ -37,10 +39,6 @@ import haveno.desktop.util.GUIUtil; import haveno.network.p2p.P2PService; import javafx.collections.ObservableList; -import javax.inject.Named; - -import static com.google.common.base.Preconditions.checkNotNull; - class OpenOffersViewModel extends ActivatableWithDataModel implements ViewModel { private final P2PService p2PService; private final PriceUtil priceUtil; diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java index c699b70494..62cf805ee0 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java @@ -17,7 +17,10 @@ package haveno.desktop.main.portfolio.pendingtrades; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.UserThread; import haveno.common.crypto.PubKeyRing; import haveno.common.crypto.PubKeyRingProvider; @@ -61,6 +64,9 @@ import haveno.desktop.main.support.dispute.client.arbitration.ArbitrationClientV import haveno.desktop.main.support.dispute.client.mediation.MediationClientView; import haveno.desktop.util.GUIUtil; import haveno.network.p2p.P2PService; +import java.math.BigInteger; +import java.util.Date; +import java.util.stream.Collectors; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleStringProperty; @@ -69,19 +75,11 @@ import javafx.beans.value.ChangeListener; import javafx.collections.FXCollections; import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; +import javax.annotation.Nullable; import lombok.Getter; import org.bitcoinj.core.Coin; import org.bouncycastle.crypto.params.KeyParameter; -import javax.annotation.Nullable; -import javax.inject.Named; -import java.math.BigInteger; -import java.util.Date; -import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - public class PendingTradesDataModel extends ActivatableDataModel { @Getter public final TradeManager tradeManager; diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesView.java b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesView.java index b32bb77139..5e3b643d70 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesView.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.portfolio.pendingtrades; +import com.google.inject.Inject; +import com.google.inject.name.Named; import com.jfoenix.controls.JFXBadge; import com.jfoenix.controls.JFXButton; import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon; @@ -54,6 +56,9 @@ import haveno.desktop.util.CssTheme; import haveno.desktop.util.DisplayUtils; import haveno.desktop.util.FormBuilder; import haveno.network.p2p.NodeAddress; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; import javafx.beans.binding.Bindings; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.value.ChangeListener; @@ -91,12 +96,6 @@ import javafx.util.Callback; import org.fxmisc.easybind.EasyBind; import org.fxmisc.easybind.Subscription; -import javax.inject.Inject; -import javax.inject.Named; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; - @FxmlView public class PendingTradesView extends ActivatableViewAndModel { public interface ChatCallback { diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java index a6afd46a6c..d6bc9b8024 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java @@ -17,7 +17,9 @@ package haveno.desktop.main.portfolio.pendingtrades; +import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.ClockWatcher; import haveno.common.app.DevEnv; import haveno.core.account.witness.AccountAgeWitnessService; @@ -40,27 +42,23 @@ import haveno.core.xmr.wallet.Restrictions; import haveno.desktop.Navigation; import haveno.desktop.common.model.ActivatableWithDataModel; import haveno.desktop.common.model.ViewModel; +import static haveno.desktop.main.portfolio.pendingtrades.PendingTradesViewModel.SellerState.UNDEFINED; import haveno.desktop.util.DisplayUtils; import haveno.desktop.util.GUIUtil; import haveno.network.p2p.P2PService; +import java.math.BigInteger; +import java.util.Date; +import java.util.stream.Collectors; import javafx.beans.property.IntegerProperty; import javafx.beans.property.ObjectProperty; import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleObjectProperty; +import javax.annotation.Nullable; import lombok.Getter; import org.fxmisc.easybind.EasyBind; import org.fxmisc.easybind.Subscription; -import javax.annotation.Nullable; -import javax.inject.Named; -import java.math.BigInteger; -import java.util.Date; -import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkNotNull; -import static haveno.desktop.main.portfolio.pendingtrades.PendingTradesViewModel.SellerState.UNDEFINED; - public class PendingTradesViewModel extends ActivatableWithDataModel implements ViewModel { @Getter @@ -148,12 +146,12 @@ public class PendingTradesViewModel extends ActivatableWithDataModel { diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java index d40a09f2f2..b3ba0aed6b 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java @@ -17,7 +17,7 @@ package haveno.desktop.main.portfolio.pendingtrades.steps; -import com.jfoenix.controls.JFXProgressBar; +import static com.google.common.base.Preconditions.checkNotNull; import de.jensd.fx.fontawesome.AwesomeDude; import de.jensd.fx.fontawesome.AwesomeIcon; import haveno.common.ClockWatcher; @@ -39,12 +39,22 @@ import haveno.core.user.Preferences; import haveno.desktop.components.InfoTextField; import haveno.desktop.components.TitledGroupBg; import haveno.desktop.components.TxIdTextField; +import static haveno.desktop.components.paymentmethods.PaymentMethodForm.addOpenTradeDuration; import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.main.portfolio.pendingtrades.PendingTradesViewModel; import haveno.desktop.main.portfolio.pendingtrades.TradeStepInfo; import haveno.desktop.main.portfolio.pendingtrades.TradeSubView; +import static haveno.desktop.util.FormBuilder.addCompactTopLabelTextField; +import static haveno.desktop.util.FormBuilder.addMultilineLabel; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; +import static haveno.desktop.util.FormBuilder.addTopLabelTxIdTextField; import haveno.desktop.util.Layout; import haveno.network.p2p.BootstrapListener; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; import javafx.application.Platform; import javafx.beans.property.BooleanProperty; import javafx.beans.value.ChangeListener; @@ -64,19 +74,6 @@ import org.fxmisc.easybind.Subscription; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.time.Duration; -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import static com.google.common.base.Preconditions.checkNotNull; -import static haveno.desktop.components.paymentmethods.PaymentMethodForm.addOpenTradeDuration; -import static haveno.desktop.util.FormBuilder.addCompactTopLabelTextField; -import static haveno.desktop.util.FormBuilder.addMultilineLabel; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; -import static haveno.desktop.util.FormBuilder.addTopLabelTxIdTextField; - public abstract class TradeStepView extends AnchorPane { protected final Logger log = LoggerFactory.getLogger(this.getClass()); @@ -384,7 +381,7 @@ public abstract class TradeStepView extends AnchorPane { timeLeftTextField = labelTextFieldVBoxTuple3.second; timeLeftTextField.setMinWidth(400); - timeLeftProgressBar = new JFXProgressBar(0); + timeLeftProgressBar = new ProgressBar(0); timeLeftProgressBar.setOpacity(0.7); timeLeftProgressBar.setMinHeight(9); timeLeftProgressBar.setMaxHeight(9); diff --git a/desktop/src/main/java/haveno/desktop/main/presentation/AccountPresentation.java b/desktop/src/main/java/haveno/desktop/main/presentation/AccountPresentation.java index 3dc117ae5d..61b785439b 100644 --- a/desktop/src/main/java/haveno/desktop/main/presentation/AccountPresentation.java +++ b/desktop/src/main/java/haveno/desktop/main/presentation/AccountPresentation.java @@ -17,6 +17,8 @@ package haveno.desktop.main.presentation; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.app.DevEnv; import haveno.core.locale.Res; import haveno.core.user.DontShowAgainLookup; @@ -26,9 +28,6 @@ import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.collections.MapChangeListener; -import javax.inject.Inject; -import javax.inject.Singleton; - @Singleton public class AccountPresentation { diff --git a/desktop/src/main/java/haveno/desktop/main/presentation/MarketPricePresentation.java b/desktop/src/main/java/haveno/desktop/main/presentation/MarketPricePresentation.java index 18f30743c9..ab77b5e00d 100644 --- a/desktop/src/main/java/haveno/desktop/main/presentation/MarketPricePresentation.java +++ b/desktop/src/main/java/haveno/desktop/main/presentation/MarketPricePresentation.java @@ -17,6 +17,8 @@ package haveno.desktop.main.presentation; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.UserThread; import haveno.core.locale.CurrencyUtil; import haveno.core.locale.Res; @@ -28,6 +30,10 @@ import haveno.core.util.FormattingUtils; import haveno.core.xmr.wallet.XmrWalletService; import haveno.desktop.components.TxIdTextField; import haveno.desktop.main.shared.PriceFeedComboBoxItem; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import javafx.beans.property.BooleanProperty; import javafx.beans.property.IntegerProperty; import javafx.beans.property.ObjectProperty; @@ -44,13 +50,6 @@ import org.fxmisc.easybind.EasyBind; import org.fxmisc.easybind.Subscription; import org.fxmisc.easybind.monadic.MonadicBinding; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; - @Singleton public class MarketPricePresentation { private final Preferences preferences; diff --git a/desktop/src/main/java/haveno/desktop/main/presentation/SettingsPresentation.java b/desktop/src/main/java/haveno/desktop/main/presentation/SettingsPresentation.java index ed70cd7135..df2ca2665d 100644 --- a/desktop/src/main/java/haveno/desktop/main/presentation/SettingsPresentation.java +++ b/desktop/src/main/java/haveno/desktop/main/presentation/SettingsPresentation.java @@ -17,14 +17,13 @@ package haveno.desktop.main.presentation; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.core.user.Preferences; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.collections.MapChangeListener; -import javax.inject.Inject; -import javax.inject.Singleton; - @Singleton public class SettingsPresentation { diff --git a/desktop/src/main/java/haveno/desktop/main/settings/SettingsView.java b/desktop/src/main/java/haveno/desktop/main/settings/SettingsView.java index 1c040d8cc5..ee147ad376 100644 --- a/desktop/src/main/java/haveno/desktop/main/settings/SettingsView.java +++ b/desktop/src/main/java/haveno/desktop/main/settings/SettingsView.java @@ -17,6 +17,7 @@ package haveno.desktop.main.settings; +import com.google.inject.Inject; import haveno.core.locale.Res; import haveno.core.user.Preferences; import haveno.desktop.Navigation; @@ -36,8 +37,6 @@ import javafx.scene.control.ScrollPane; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; -import javax.inject.Inject; - @FxmlView public class SettingsView extends ActivatableView { @FXML diff --git a/desktop/src/main/java/haveno/desktop/main/settings/about/AboutView.java b/desktop/src/main/java/haveno/desktop/main/settings/about/AboutView.java index 84e80fac09..e543837f5d 100644 --- a/desktop/src/main/java/haveno/desktop/main/settings/about/AboutView.java +++ b/desktop/src/main/java/haveno/desktop/main/settings/about/AboutView.java @@ -17,22 +17,20 @@ package haveno.desktop.main.settings.about; +import com.google.inject.Inject; import haveno.common.app.Version; import haveno.core.locale.Res; import haveno.desktop.common.view.ActivatableView; import haveno.desktop.common.view.FxmlView; import haveno.desktop.components.HyperlinkWithIcon; -import haveno.desktop.util.Layout; -import javafx.geometry.HPos; -import javafx.scene.control.Label; -import javafx.scene.layout.GridPane; - -import javax.inject.Inject; - import static haveno.desktop.util.FormBuilder.addCompactTopLabelTextField; import static haveno.desktop.util.FormBuilder.addHyperlinkWithIcon; import static haveno.desktop.util.FormBuilder.addLabel; import static haveno.desktop.util.FormBuilder.addTitledGroupBg; +import haveno.desktop.util.Layout; +import javafx.geometry.HPos; +import javafx.scene.control.Label; +import javafx.scene.layout.GridPane; @FxmlView public class AboutView extends ActivatableView { diff --git a/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.java b/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.java index dbe77dfef4..c3226ec9ba 100644 --- a/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.java +++ b/desktop/src/main/java/haveno/desktop/main/settings/network/NetworkSettingsView.java @@ -17,6 +17,7 @@ package haveno.desktop.main.settings.network; +import com.google.inject.Inject; import haveno.common.ClockWatcher; import haveno.common.UserThread; import haveno.core.api.XmrConnectionService; @@ -42,6 +43,10 @@ import haveno.desktop.main.overlays.windows.TorNetworkSettingsWindow; import haveno.desktop.util.GUIUtil; import haveno.network.p2p.P2PService; import haveno.network.p2p.network.Statistic; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; +import static javafx.beans.binding.Bindings.createStringBinding; import javafx.beans.value.ChangeListener; import javafx.collections.FXCollections; import javafx.collections.ObservableList; @@ -61,13 +66,6 @@ import monero.daemon.model.MoneroPeer; import org.fxmisc.easybind.EasyBind; import org.fxmisc.easybind.Subscription; -import javax.inject.Inject; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; - -import static javafx.beans.binding.Bindings.createStringBinding; - @FxmlView public class NetworkSettingsView extends ActivatableView { @@ -213,7 +211,7 @@ public class NetworkSettingsView extends ActivatableView { p2pPeersTableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData"))); p2pPeersTableView.getSortOrder().add(creationDateColumn); creationDateColumn.setSortType(TableColumn.SortType.ASCENDING); - + // use tor for xmr radio buttons useTorForXmrToggleGroup = new ToggleGroup(); @@ -236,7 +234,7 @@ public class NetworkSettingsView extends ActivatableView { onUseTorForXmrToggleSelected(true); } }; - + // monero nodes radio buttons moneroPeersToggleGroup = new ToggleGroup(); @@ -374,7 +372,7 @@ public class NetworkSettingsView extends ActivatableView { return filterManager.getFilter() != null && filterManager.getFilter().isPreventPublicXmrNetwork(); } - + private void selectUseTorForXmrToggle() { switch (selectedUseTorForXmr) { case OFF: @@ -412,7 +410,7 @@ public class NetworkSettingsView extends ActivatableView { .useShutDownButton() .show(); } - + private void onUseTorForXmrToggleSelected(boolean calledFromUser) { Preferences.UseTorForXmr currentUseTorForXmr = Preferences.UseTorForXmr.values()[preferences.getUseTorForXmrOrdinal()]; if (currentUseTorForXmr != selectedUseTorForXmr) { diff --git a/desktop/src/main/java/haveno/desktop/main/settings/preferences/PreferencesView.java b/desktop/src/main/java/haveno/desktop/main/settings/preferences/PreferencesView.java index fc89f1afa4..08e6a083b6 100644 --- a/desktop/src/main/java/haveno/desktop/main/settings/preferences/PreferencesView.java +++ b/desktop/src/main/java/haveno/desktop/main/settings/preferences/PreferencesView.java @@ -17,6 +17,9 @@ package haveno.desktop.main.settings.preferences; +import static com.google.common.base.Preconditions.checkArgument; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.UserThread; import haveno.common.app.DevEnv; import haveno.common.config.Config; @@ -29,10 +32,10 @@ import haveno.core.locale.Country; import haveno.core.locale.CountryUtil; import haveno.core.locale.CryptoCurrency; import haveno.core.locale.CurrencyUtil; -import haveno.core.locale.TraditionalCurrency; import haveno.core.locale.LanguageUtil; import haveno.core.locale.Res; import haveno.core.locale.TradeCurrency; +import haveno.core.locale.TraditionalCurrency; import haveno.core.payment.PaymentAccount; import haveno.core.payment.payload.PaymentMethod; import haveno.core.payment.validation.XmrValidator; @@ -54,9 +57,24 @@ import haveno.desktop.components.PasswordTextField; import haveno.desktop.components.TitledGroupBg; import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.main.overlays.windows.EditCustomExplorerWindow; +import static haveno.desktop.util.FormBuilder.addButton; +import static haveno.desktop.util.FormBuilder.addComboBox; +import static haveno.desktop.util.FormBuilder.addInputTextField; +import static haveno.desktop.util.FormBuilder.addSlideToggleButton; +import static haveno.desktop.util.FormBuilder.addTextFieldWithEditButton; +import static haveno.desktop.util.FormBuilder.addTitledGroupBg; +import static haveno.desktop.util.FormBuilder.addTopLabelListView; import haveno.desktop.util.GUIUtil; import haveno.desktop.util.ImageUtil; import haveno.desktop.util.Layout; +import java.io.File; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import javafx.beans.value.ChangeListener; import javafx.collections.FXCollections; import javafx.collections.ObservableList; @@ -81,26 +99,6 @@ import javafx.util.Callback; import javafx.util.StringConverter; import org.apache.commons.lang3.StringUtils; -import javax.inject.Inject; -import javax.inject.Named; -import java.io.File; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkArgument; -import static haveno.desktop.util.FormBuilder.addButton; -import static haveno.desktop.util.FormBuilder.addComboBox; -import static haveno.desktop.util.FormBuilder.addInputTextField; -import static haveno.desktop.util.FormBuilder.addSlideToggleButton; -import static haveno.desktop.util.FormBuilder.addTextFieldWithEditButton; -import static haveno.desktop.util.FormBuilder.addTitledGroupBg; -import static haveno.desktop.util.FormBuilder.addTopLabelListView; - @FxmlView public class PreferencesView extends ActivatableViewAndModel { private final User user; diff --git a/desktop/src/main/java/haveno/desktop/main/support/SupportView.java b/desktop/src/main/java/haveno/desktop/main/support/SupportView.java index 034b32921b..76935be60d 100644 --- a/desktop/src/main/java/haveno/desktop/main/support/SupportView.java +++ b/desktop/src/main/java/haveno/desktop/main/support/SupportView.java @@ -34,6 +34,7 @@ package haveno.desktop.main.support; +import com.google.inject.Inject; import haveno.common.app.DevEnv; import haveno.common.crypto.KeyRing; import haveno.common.crypto.PubKeyRing; @@ -54,8 +55,8 @@ import haveno.desktop.common.view.FxmlView; import haveno.desktop.common.view.View; import haveno.desktop.common.view.ViewLoader; import haveno.desktop.main.MainView; -import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.main.offer.signedoffer.SignedOfferView; +import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.main.support.dispute.agent.arbitration.ArbitratorView; import haveno.desktop.main.support.dispute.agent.mediation.MediatorView; import haveno.desktop.main.support.dispute.agent.refund.RefundAgentView; @@ -67,9 +68,7 @@ import javafx.beans.value.ChangeListener; import javafx.collections.MapChangeListener; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; - import javax.annotation.Nullable; -import javax.inject.Inject; @FxmlView public class SupportView extends ActivatableView { diff --git a/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java b/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java index 5da0fda6da..c5d122cffa 100644 --- a/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java +++ b/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.support.dispute.agent.arbitration; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.common.crypto.KeyRing; import haveno.core.account.witness.AccountAgeWitnessService; @@ -37,9 +39,6 @@ import haveno.desktop.main.overlays.windows.DisputeSummaryWindow; import haveno.desktop.main.overlays.windows.TradeDetailsWindow; import haveno.desktop.main.support.dispute.agent.DisputeAgentView; -import javax.inject.Inject; -import javax.inject.Named; - @FxmlView public class ArbitratorView extends DisputeAgentView { diff --git a/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/mediation/MediatorView.java b/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/mediation/MediatorView.java index c8069b34ca..e8e3f9d6ac 100644 --- a/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/mediation/MediatorView.java +++ b/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/mediation/MediatorView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.support.dispute.agent.mediation; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.common.crypto.KeyRing; import haveno.core.account.witness.AccountAgeWitnessService; @@ -37,9 +39,6 @@ import haveno.desktop.main.overlays.windows.DisputeSummaryWindow; import haveno.desktop.main.overlays.windows.TradeDetailsWindow; import haveno.desktop.main.support.dispute.agent.DisputeAgentView; -import javax.inject.Inject; -import javax.inject.Named; - @FxmlView public class MediatorView extends DisputeAgentView { diff --git a/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/refund/RefundAgentView.java b/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/refund/RefundAgentView.java index 39ed2a6941..c7e1705d58 100644 --- a/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/refund/RefundAgentView.java +++ b/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/refund/RefundAgentView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.support.dispute.agent.refund; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.common.crypto.KeyRing; import haveno.core.account.witness.AccountAgeWitnessService; @@ -39,9 +41,6 @@ import haveno.desktop.main.overlays.windows.DisputeSummaryWindow; import haveno.desktop.main.overlays.windows.TradeDetailsWindow; import haveno.desktop.main.support.dispute.agent.DisputeAgentView; -import javax.inject.Inject; -import javax.inject.Named; - @FxmlView public class RefundAgentView extends DisputeAgentView { diff --git a/desktop/src/main/java/haveno/desktop/main/support/dispute/client/arbitration/ArbitrationClientView.java b/desktop/src/main/java/haveno/desktop/main/support/dispute/client/arbitration/ArbitrationClientView.java index 5470f32e5d..182bd815ae 100644 --- a/desktop/src/main/java/haveno/desktop/main/support/dispute/client/arbitration/ArbitrationClientView.java +++ b/desktop/src/main/java/haveno/desktop/main/support/dispute/client/arbitration/ArbitrationClientView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.support.dispute.client.arbitration; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.common.crypto.KeyRing; import haveno.core.account.witness.AccountAgeWitnessService; @@ -37,9 +39,6 @@ import haveno.desktop.main.overlays.windows.DisputeSummaryWindow; import haveno.desktop.main.overlays.windows.TradeDetailsWindow; import haveno.desktop.main.support.dispute.client.DisputeClientView; -import javax.inject.Inject; -import javax.inject.Named; - @FxmlView public class ArbitrationClientView extends DisputeClientView { @Inject diff --git a/desktop/src/main/java/haveno/desktop/main/support/dispute/client/mediation/MediationClientView.java b/desktop/src/main/java/haveno/desktop/main/support/dispute/client/mediation/MediationClientView.java index 0b4771a894..63eed5ff64 100644 --- a/desktop/src/main/java/haveno/desktop/main/support/dispute/client/mediation/MediationClientView.java +++ b/desktop/src/main/java/haveno/desktop/main/support/dispute/client/mediation/MediationClientView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.support.dispute.client.mediation; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.common.crypto.KeyRing; import haveno.core.account.witness.AccountAgeWitnessService; @@ -41,9 +43,6 @@ import haveno.desktop.main.overlays.windows.TradeDetailsWindow; import haveno.desktop.main.support.dispute.client.DisputeClientView; import haveno.network.p2p.NodeAddress; -import javax.inject.Inject; -import javax.inject.Named; - @FxmlView public class MediationClientView extends DisputeClientView { @Inject diff --git a/desktop/src/main/java/haveno/desktop/main/support/dispute/client/refund/RefundClientView.java b/desktop/src/main/java/haveno/desktop/main/support/dispute/client/refund/RefundClientView.java index 4aeab412c5..52d77038e3 100644 --- a/desktop/src/main/java/haveno/desktop/main/support/dispute/client/refund/RefundClientView.java +++ b/desktop/src/main/java/haveno/desktop/main/support/dispute/client/refund/RefundClientView.java @@ -17,6 +17,8 @@ package haveno.desktop.main.support.dispute.client.refund; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.config.Config; import haveno.common.crypto.KeyRing; import haveno.core.account.witness.AccountAgeWitnessService; @@ -39,9 +41,6 @@ import haveno.desktop.main.overlays.windows.TradeDetailsWindow; import haveno.desktop.main.support.dispute.client.DisputeClientView; import haveno.network.p2p.NodeAddress; -import javax.inject.Inject; -import javax.inject.Named; - @FxmlView public class RefundClientView extends DisputeClientView { @Inject diff --git a/desktop/src/main/java/haveno/desktop/util/Transitions.java b/desktop/src/main/java/haveno/desktop/util/Transitions.java index 0241990c08..300524ccce 100644 --- a/desktop/src/main/java/haveno/desktop/util/Transitions.java +++ b/desktop/src/main/java/haveno/desktop/util/Transitions.java @@ -17,6 +17,8 @@ package haveno.desktop.util; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.UserThread; import haveno.core.user.Preferences; import javafx.animation.FadeTransition; @@ -32,9 +34,6 @@ import javafx.scene.effect.GaussianBlur; import javafx.scene.layout.Pane; import javafx.util.Duration; -import javax.inject.Inject; -import javax.inject.Singleton; - @Singleton public class Transitions { diff --git a/docs/installing.md b/docs/installing.md index ac684a3b1d..63bd1dcde1 100644 --- a/docs/installing.md +++ b/docs/installing.md @@ -6,8 +6,8 @@ These are the steps needed to build Haveno and test it on our test network or lo On Ubuntu: - 1. `sudo apt install make wget git openjdk-11-jdk`. - 2. If `echo $JAVA_HOME` does not print the path to JDK 11, then `export JAVA_HOME=/path/to/jdk` (e.g. `export JAVA_HOME=/usr/lib/jvm/java-11-openjdk`). + 1. `sudo apt install make wget git openjdk-17-jdk`. + 2. If `echo $JAVA_HOME` does not print the path to JDK 17, then `export JAVA_HOME=/path/to/jdk` (e.g. `export JAVA_HOME=/usr/lib/jvm/java-17-openjdk`). On Mac: 1. Download and install [Java JDK 11](https://adoptium.net/temurin/archive/?version=11). @@ -15,7 +15,7 @@ On Mac: On Windows: - 1. Download [Java JDK 11](https://adoptium.net/temurin/archive/?version=11). During installation, enable the option to set the $JAVA_HOME environment variable. + 1. Download [Java JDK 17](https://adoptium.net/temurin/archive/?version=17). During installation, enable the option to set the $JAVA_HOME environment variable. 2. Install [MSYS2](https://www.msys2.org/). 3. Start MSYS2 MINGW64 or MSYS MINGW32 depending on your system. Use MSYS2 for all commands throughout this document. 4. Update pacman: `pacman -Syy` diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index d5c644257f..33ae03fee6 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -1,5 +1,5 @@ - + false false @@ -678,6 +678,11 @@ + + + + + @@ -778,6 +783,11 @@ + + + + + @@ -831,9 +841,9 @@ - - - + + + @@ -849,6 +859,11 @@ + + + + + @@ -956,14 +971,9 @@ - - - - - - - - + + + @@ -1111,6 +1121,11 @@ + + + + + @@ -1554,6 +1569,11 @@ + + + + + @@ -1669,66 +1689,14 @@ - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + @@ -2201,6 +2169,11 @@ + + + + + @@ -3000,6 +2973,11 @@ + + + + + @@ -3036,79 +3014,83 @@ - - - + + + + + + + + + + + + + + + - - - + + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - + + - - + + - - - + + + - - + + - - + + + + + + + + - - - + + + - - + + - - + + - - - - - - - - - - - - - - - - + + @@ -3175,6 +3157,11 @@ + + + + + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a6f7c3a890..a80b22ce5c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha256Sum=7c3ad722e9b0ce8205b91560fd6ce8296ac3eadf065672242fd73c06b8eeb6ee -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/p2p/src/main/java/haveno/network/Socks5ProxyProvider.java b/p2p/src/main/java/haveno/network/Socks5ProxyProvider.java index 951dc984cb..8bb3e1d418 100644 --- a/p2p/src/main/java/haveno/network/Socks5ProxyProvider.java +++ b/p2p/src/main/java/haveno/network/Socks5ProxyProvider.java @@ -18,16 +18,15 @@ package haveno.network; import com.google.inject.Inject; +import com.google.inject.name.Named; import com.runjva.sourceforge.jsocks.protocol.Socks5Proxy; import haveno.common.config.Config; import haveno.network.p2p.network.NetworkNode; +import java.net.UnknownHostException; +import javax.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.Nullable; -import javax.inject.Named; -import java.net.UnknownHostException; - /** * Provides Socks5Proxies for the monero network and http requests *

diff --git a/p2p/src/main/java/haveno/network/crypto/EncryptionService.java b/p2p/src/main/java/haveno/network/crypto/EncryptionService.java index 16cb322c37..994111dec0 100644 --- a/p2p/src/main/java/haveno/network/crypto/EncryptionService.java +++ b/p2p/src/main/java/haveno/network/crypto/EncryptionService.java @@ -17,9 +17,11 @@ package haveno.network.crypto; +import com.google.inject.Inject; import com.google.protobuf.InvalidProtocolBufferException; import haveno.common.crypto.CryptoException; import haveno.common.crypto.Encryption; +import static haveno.common.crypto.Encryption.decryptSecretKey; import haveno.common.crypto.Hash; import haveno.common.crypto.KeyRing; import haveno.common.crypto.PubKeyRing; @@ -29,15 +31,11 @@ import haveno.common.proto.ProtobufferException; import haveno.common.proto.network.NetworkEnvelope; import haveno.common.proto.network.NetworkProtoResolver; import haveno.network.p2p.DecryptedMessageWithPubKey; -import lombok.extern.slf4j.Slf4j; - -import javax.crypto.SecretKey; -import javax.inject.Inject; import java.security.KeyPair; import java.security.PrivateKey; import java.security.PublicKey; - -import static haveno.common.crypto.Encryption.decryptSecretKey; +import javax.crypto.SecretKey; +import lombok.extern.slf4j.Slf4j; @Slf4j public class EncryptionService { diff --git a/p2p/src/main/java/haveno/network/http/HttpClientImpl.java b/p2p/src/main/java/haveno/network/http/HttpClientImpl.java index 23a0a9983b..62f9fca581 100644 --- a/p2p/src/main/java/haveno/network/http/HttpClientImpl.java +++ b/p2p/src/main/java/haveno/network/http/HttpClientImpl.java @@ -17,12 +17,27 @@ package haveno.network.http; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; import com.runjva.sourceforge.jsocks.protocol.Socks5Proxy; import haveno.common.ThreadUtils; import haveno.common.app.Version; import haveno.common.util.Utilities; import haveno.network.Socks5ProxyProvider; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; +import java.net.InetSocketAddress; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import javax.annotation.Nullable; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -41,23 +56,6 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.ssl.SSLContexts; -import javax.annotation.Nullable; -import javax.inject.Inject; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.InetSocketAddress; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.util.UUID; -import java.util.concurrent.TimeUnit; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - // TODO close connection if failing @Slf4j public class HttpClientImpl implements HttpClient { diff --git a/p2p/src/main/java/haveno/network/p2p/NetworkNodeProvider.java b/p2p/src/main/java/haveno/network/p2p/NetworkNodeProvider.java index 36fd984ef7..4027abb2e2 100644 --- a/p2p/src/main/java/haveno/network/p2p/NetworkNodeProvider.java +++ b/p2p/src/main/java/haveno/network/p2p/NetworkNodeProvider.java @@ -17,24 +17,20 @@ package haveno.network.p2p; +import com.google.inject.Inject; +import com.google.inject.Provider; +import com.google.inject.name.Named; +import haveno.common.config.Config; +import haveno.common.proto.network.NetworkProtoResolver; +import haveno.network.p2p.network.BanFilter; import haveno.network.p2p.network.BridgeAddressProvider; import haveno.network.p2p.network.LocalhostNetworkNode; -import haveno.network.p2p.network.BanFilter; import haveno.network.p2p.network.NetworkNode; import haveno.network.p2p.network.NewTor; import haveno.network.p2p.network.RunningTor; import haveno.network.p2p.network.TorMode; import haveno.network.p2p.network.TorNetworkNode; - -import haveno.common.config.Config; -import haveno.common.proto.network.NetworkProtoResolver; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; - import java.io.File; - import javax.annotation.Nullable; public class NetworkNodeProvider implements Provider { diff --git a/p2p/src/main/java/haveno/network/p2p/mailbox/IgnoredMailboxService.java b/p2p/src/main/java/haveno/network/p2p/mailbox/IgnoredMailboxService.java index c3b4e6842f..45f5eaed7a 100644 --- a/p2p/src/main/java/haveno/network/p2p/mailbox/IgnoredMailboxService.java +++ b/p2p/src/main/java/haveno/network/p2p/mailbox/IgnoredMailboxService.java @@ -17,13 +17,12 @@ package haveno.network.p2p.mailbox; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.persistence.PersistenceManager; import haveno.common.proto.persistable.PersistedDataHost; import haveno.network.p2p.storage.payload.MailboxStoragePayload; -import javax.inject.Inject; -import javax.inject.Singleton; - /** * We persist failed attempts to decrypt mailbox messages (expected if mailbox message was not addressed to us). * This improves performance at processing mailbox messages. diff --git a/p2p/src/main/java/haveno/network/p2p/mailbox/MailboxMessageService.java b/p2p/src/main/java/haveno/network/p2p/mailbox/MailboxMessageService.java index 231c1dd935..131b537217 100644 --- a/p2p/src/main/java/haveno/network/p2p/mailbox/MailboxMessageService.java +++ b/p2p/src/main/java/haveno/network/p2p/mailbox/MailboxMessageService.java @@ -35,10 +35,15 @@ package haveno.network.p2p.mailbox; import com.google.common.base.Joiner; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.google.inject.name.Named; import haveno.common.UserThread; import haveno.common.config.Config; import haveno.common.crypto.CryptoException; @@ -70,13 +75,6 @@ import haveno.network.p2p.storage.payload.MailboxStoragePayload; import haveno.network.p2p.storage.payload.ProtectedMailboxStorageEntry; import haveno.network.p2p.storage.payload.ProtectedStorageEntry; import haveno.network.utils.CapabilityUtils; -import lombok.extern.slf4j.Slf4j; -import org.jetbrains.annotations.NotNull; - -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import java.security.PublicKey; import java.time.Clock; import java.util.ArrayDeque; @@ -95,9 +93,9 @@ import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; +import javax.annotation.Nullable; +import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; /** * Responsible for handling of mailbox messages. diff --git a/p2p/src/main/java/haveno/network/p2p/network/Connection.java b/p2p/src/main/java/haveno/network/p2p/network/Connection.java index f82d4ef6ed..137e84a5ac 100644 --- a/p2p/src/main/java/haveno/network/p2p/network/Connection.java +++ b/p2p/src/main/java/haveno/network/p2p/network/Connection.java @@ -34,6 +34,22 @@ package haveno.network.p2p.network; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.util.concurrent.Uninterruptibles; +import com.google.inject.Inject; +import com.google.protobuf.InvalidProtocolBufferException; +import haveno.common.Proto; +import haveno.common.ThreadUtils; +import haveno.common.app.Capabilities; +import haveno.common.app.HasCapabilities; +import haveno.common.app.Version; +import haveno.common.config.Config; +import haveno.common.proto.ProtobufferException; +import haveno.common.proto.network.NetworkEnvelope; +import haveno.common.proto.network.NetworkProtoResolver; +import haveno.common.util.SingleThreadExecutorUtils; +import haveno.common.util.Utilities; import haveno.network.p2p.BundleOfEnvelopes; import haveno.network.p2p.CloseConnectionMessage; import haveno.network.p2p.ExtendedDataSizePermission; @@ -47,39 +63,16 @@ import haveno.network.p2p.storage.messages.AddPersistableNetworkPayloadMessage; import haveno.network.p2p.storage.messages.RemoveDataMessage; import haveno.network.p2p.storage.payload.CapabilityRequiringPayload; import haveno.network.p2p.storage.payload.PersistableNetworkPayload; - -import haveno.common.Proto; -import haveno.common.ThreadUtils; -import haveno.common.app.Capabilities; -import haveno.common.app.HasCapabilities; -import haveno.common.app.Version; -import haveno.common.config.Config; -import haveno.common.proto.ProtobufferException; -import haveno.common.proto.network.NetworkEnvelope; -import haveno.common.proto.network.NetworkProtoResolver; -import haveno.common.util.SingleThreadExecutorUtils; -import haveno.common.util.Utilities; - -import com.google.protobuf.InvalidProtocolBufferException; - -import javax.inject.Inject; - -import com.google.common.util.concurrent.Uninterruptibles; - -import javafx.beans.property.ObjectProperty; -import javafx.beans.property.SimpleObjectProperty; - -import java.net.Socket; -import java.net.SocketException; -import java.net.SocketTimeoutException; - import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.InvalidClassException; import java.io.OptionalDataException; import java.io.StreamCorruptedException; - +import java.lang.ref.WeakReference; +import java.net.Socket; +import java.net.SocketException; +import java.net.SocketTimeoutException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -94,17 +87,12 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; - -import java.lang.ref.WeakReference; - +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleObjectProperty; import lombok.Getter; import lombok.extern.slf4j.Slf4j; - import org.jetbrains.annotations.Nullable; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - /** * Connection is created by the server thread or by sendMessage from NetworkNode. * All handlers are called on User thread. diff --git a/p2p/src/main/java/haveno/network/p2p/peers/Broadcaster.java b/p2p/src/main/java/haveno/network/p2p/peers/Broadcaster.java index b639938a33..2aa255b81a 100644 --- a/p2p/src/main/java/haveno/network/p2p/peers/Broadcaster.java +++ b/p2p/src/main/java/haveno/network/p2p/peers/Broadcaster.java @@ -17,31 +17,25 @@ package haveno.network.p2p.peers; -import haveno.network.p2p.NodeAddress; -import haveno.network.p2p.network.NetworkNode; -import haveno.network.p2p.storage.messages.BroadcastMessage; - +import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.Timer; import haveno.common.UserThread; import haveno.common.config.Config; import haveno.common.util.Utilities; - -import javax.inject.Inject; -import javax.inject.Named; - -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; - +import haveno.network.p2p.NodeAddress; +import haveno.network.p2p.network.NetworkNode; +import haveno.network.p2p.storage.messages.BroadcastMessage; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; - import lombok.Value; import lombok.extern.slf4j.Slf4j; - import org.jetbrains.annotations.Nullable; @Slf4j diff --git a/p2p/src/main/java/haveno/network/p2p/peers/PeerManager.java b/p2p/src/main/java/haveno/network/p2p/peers/PeerManager.java index c7b2619a8a..2e361b75a4 100644 --- a/p2p/src/main/java/haveno/network/p2p/peers/PeerManager.java +++ b/p2p/src/main/java/haveno/network/p2p/peers/PeerManager.java @@ -18,6 +18,9 @@ package haveno.network.p2p.peers; import com.google.common.annotations.VisibleForTesting; +import static com.google.common.base.Preconditions.checkArgument; +import com.google.inject.Inject; +import com.google.inject.name.Named; import haveno.common.ClockWatcher; import haveno.common.Timer; import haveno.common.UserThread; @@ -37,12 +40,6 @@ import haveno.network.p2p.network.RuleViolation; import haveno.network.p2p.peers.peerexchange.Peer; import haveno.network.p2p.peers.peerexchange.PeerList; import haveno.network.p2p.seed.SeedNodeRepository; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; - -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Named; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; @@ -56,8 +53,9 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkArgument; +import javax.annotation.Nullable; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; @Slf4j public final class PeerManager implements ConnectionListener, PersistedDataHost { diff --git a/p2p/src/main/java/haveno/network/p2p/peers/getdata/RequestDataManager.java b/p2p/src/main/java/haveno/network/p2p/peers/getdata/RequestDataManager.java index 84fdbd98d7..98cffc7c1d 100644 --- a/p2p/src/main/java/haveno/network/p2p/peers/getdata/RequestDataManager.java +++ b/p2p/src/main/java/haveno/network/p2p/peers/getdata/RequestDataManager.java @@ -17,6 +17,9 @@ package haveno.network.p2p.peers.getdata; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; import haveno.common.Timer; import haveno.common.UserThread; import haveno.common.app.Version; @@ -32,10 +35,6 @@ import haveno.network.p2p.peers.getdata.messages.GetDataRequest; import haveno.network.p2p.peers.peerexchange.Peer; import haveno.network.p2p.seed.SeedNodeRepository; import haveno.network.p2p.storage.P2PDataStorage; -import lombok.extern.slf4j.Slf4j; -import org.jetbrains.annotations.Nullable; - -import javax.inject.Inject; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -45,9 +44,8 @@ import java.util.Map; import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; +import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.Nullable; @Slf4j public class RequestDataManager implements MessageListener, ConnectionListener, PeerManager.Listener { diff --git a/p2p/src/main/java/haveno/network/p2p/peers/keepalive/KeepAliveManager.java b/p2p/src/main/java/haveno/network/p2p/peers/keepalive/KeepAliveManager.java index d143990aae..5a80a67a94 100644 --- a/p2p/src/main/java/haveno/network/p2p/peers/keepalive/KeepAliveManager.java +++ b/p2p/src/main/java/haveno/network/p2p/peers/keepalive/KeepAliveManager.java @@ -20,6 +20,7 @@ package haveno.network.p2p.peers.keepalive; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; +import com.google.inject.Inject; import haveno.common.Timer; import haveno.common.UserThread; import haveno.common.proto.network.NetworkEnvelope; @@ -33,13 +34,11 @@ import haveno.network.p2p.network.OutboundConnection; import haveno.network.p2p.peers.PeerManager; import haveno.network.p2p.peers.keepalive.messages.Ping; import haveno.network.p2p.peers.keepalive.messages.Pong; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.inject.Inject; import java.util.HashMap; import java.util.Map; import java.util.Random; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class KeepAliveManager implements MessageListener, ConnectionListener, PeerManager.Listener { private static final Logger log = LoggerFactory.getLogger(KeepAliveManager.class); diff --git a/p2p/src/main/java/haveno/network/p2p/peers/peerexchange/PeerExchangeManager.java b/p2p/src/main/java/haveno/network/p2p/peers/peerexchange/PeerExchangeManager.java index ca55c9edaf..ccc52e6930 100644 --- a/p2p/src/main/java/haveno/network/p2p/peers/peerexchange/PeerExchangeManager.java +++ b/p2p/src/main/java/haveno/network/p2p/peers/peerexchange/PeerExchangeManager.java @@ -18,6 +18,7 @@ package haveno.network.p2p.peers.peerexchange; import com.google.common.base.Preconditions; +import com.google.inject.Inject; import haveno.common.Timer; import haveno.common.UserThread; import haveno.common.proto.network.NetworkEnvelope; @@ -30,10 +31,6 @@ import haveno.network.p2p.network.NetworkNode; import haveno.network.p2p.peers.PeerManager; import haveno.network.p2p.peers.peerexchange.messages.GetPeersRequest; import haveno.network.p2p.seed.SeedNodeRepository; -import lombok.extern.slf4j.Slf4j; - -import javax.annotation.Nullable; -import javax.inject.Inject; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -46,6 +43,8 @@ import java.util.Random; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import javax.annotation.Nullable; +import lombok.extern.slf4j.Slf4j; @Slf4j public class PeerExchangeManager implements MessageListener, ConnectionListener, PeerManager.Listener { diff --git a/p2p/src/main/java/haveno/network/p2p/storage/P2PDataStorage.java b/p2p/src/main/java/haveno/network/p2p/storage/P2PDataStorage.java index 8d20b333c8..a9c0f6ad16 100644 --- a/p2p/src/main/java/haveno/network/p2p/storage/P2PDataStorage.java +++ b/p2p/src/main/java/haveno/network/p2p/storage/P2PDataStorage.java @@ -17,6 +17,26 @@ package haveno.network.p2p.storage; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.Maps; +import com.google.inject.Inject; +import com.google.inject.name.Named; +import com.google.protobuf.ByteString; +import haveno.common.Timer; +import haveno.common.UserThread; +import haveno.common.app.Capabilities; +import haveno.common.crypto.CryptoException; +import haveno.common.crypto.Hash; +import haveno.common.crypto.Sig; +import haveno.common.persistence.PersistenceManager; +import haveno.common.proto.network.GetDataResponsePriority; +import haveno.common.proto.network.NetworkEnvelope; +import haveno.common.proto.network.NetworkPayload; +import haveno.common.proto.persistable.PersistablePayload; +import haveno.common.proto.persistable.PersistedDataHost; +import haveno.common.util.Hex; +import haveno.common.util.Tuple2; +import haveno.common.util.Utilities; import haveno.network.p2p.NodeAddress; import haveno.network.p2p.network.CloseConnectionReason; import haveno.network.p2p.network.Connection; @@ -54,43 +74,9 @@ import haveno.network.p2p.storage.persistence.ProtectedDataStoreService; import haveno.network.p2p.storage.persistence.RemovedPayloadsService; import haveno.network.p2p.storage.persistence.ResourceDataStoreService; import haveno.network.p2p.storage.persistence.SequenceNumberMap; - -import haveno.common.Timer; -import haveno.common.UserThread; -import haveno.common.app.Capabilities; -import haveno.common.crypto.CryptoException; -import haveno.common.crypto.Hash; -import haveno.common.crypto.Sig; -import haveno.common.persistence.PersistenceManager; -import haveno.common.proto.network.GetDataResponsePriority; -import haveno.common.proto.network.NetworkEnvelope; -import haveno.common.proto.network.NetworkPayload; -import haveno.common.proto.persistable.PersistablePayload; -import haveno.common.proto.persistable.PersistedDataHost; -import haveno.common.util.Hex; -import haveno.common.util.Tuple2; -import haveno.common.util.Utilities; - -import com.google.protobuf.ByteString; - -import com.google.inject.name.Named; - -import javax.inject.Inject; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.Maps; - -import org.fxmisc.easybind.EasyBind; -import org.fxmisc.easybind.monadic.MonadicBinding; - -import javafx.beans.property.BooleanProperty; -import javafx.beans.property.SimpleBooleanProperty; - import java.security.KeyPair; import java.security.PublicKey; - import java.time.Clock; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -111,14 +97,16 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; - +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.SimpleBooleanProperty; +import javax.annotation.Nullable; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.ToString; import lombok.extern.slf4j.Slf4j; - -import javax.annotation.Nullable; +import org.fxmisc.easybind.EasyBind; +import org.fxmisc.easybind.monadic.MonadicBinding; @Slf4j public class P2PDataStorage implements MessageListener, ConnectionListener, PersistedDataHost { @@ -247,7 +235,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers appendOnlyDataStoreService.readFromResourcesSync(postFix); protectedDataStoreService.readFromResourcesSync(postFix); resourceDataStoreService.readFromResourcesSync(postFix); - + map.putAll(protectedDataStoreService.getMap()); } } @@ -831,9 +819,9 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers synchronized (map) { ProtectedStoragePayload protectedStoragePayload = protectedStorageEntry.getProtectedStoragePayload(); ByteArray hashOfPayload = get32ByteHashAsByteArray(protectedStoragePayload); - + //log.trace("## call addProtectedStorageEntry hash={}, map={}", hashOfPayload, printMap()); - + // We do that check early as it is a very common case for returning, so we return early // If we have seen a more recent operation for this payload and we have a payload locally, ignore it ProtectedStorageEntry storedEntry = map.get(hashOfPayload); @@ -841,13 +829,13 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers log.trace("## hasSequenceNrIncreased is false. hash={}", hashOfPayload); return false; } - + if (hasAlreadyRemovedAddOncePayload(protectedStoragePayload, hashOfPayload)) { log.trace("## We have already removed that AddOncePayload by a previous removeDataMessage. " + "We ignore that message. ProtectedStoragePayload: {}", protectedStoragePayload.toString()); return false; } - + // To avoid that expired data get stored and broadcast we check for expire date. if (protectedStorageEntry.isExpired(clock)) { String peer = sender != null ? sender.getFullAddress() : "sender is null"; @@ -855,7 +843,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers peer, protectedStorageEntry.getProtectedStoragePayload().getClass().getSimpleName()); return false; } - + // We want to allow add operations for equal sequence numbers if we don't have the payload locally. This is // the case for non-persistent Payloads that need to be reconstructed from peer and seed nodes each startup. MapValue sequenceNumberMapValue = sequenceNumberMap.get(hashOfPayload); @@ -864,36 +852,36 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers log.trace("## sequenceNr too low hash={}", hashOfPayload); return false; } - + // Verify the ProtectedStorageEntry is well formed and valid for the add operation if (!protectedStorageEntry.isValidForAddOperation()) { log.trace("## !isValidForAddOperation hash={}", hashOfPayload); return false; } - + // If we have already seen an Entry with the same hash, verify the metadata is equal if (storedEntry != null && !protectedStorageEntry.matchesRelevantPubKey(storedEntry)) { log.trace("## !matchesRelevantPubKey hash={}", hashOfPayload); return false; } - + // Test against filterPredicate set from FilterManager if (filterPredicate != null && !filterPredicate.test(protectedStorageEntry.getProtectedStoragePayload())) { log.debug("filterPredicate test failed. hashOfPayload={}", hashOfPayload); return false; } - + // This is an updated entry. Record it and signal listeners. map.put(hashOfPayload, protectedStorageEntry); hashMapChangedListeners.forEach(e -> e.onAdded(Collections.singletonList(protectedStorageEntry))); - + // Record the updated sequence number and persist it. Higher delay so we can batch more items. sequenceNumberMap.put(hashOfPayload, new MapValue(protectedStorageEntry.getSequenceNumber(), this.clock.millis())); requestPersistence(); - + //log.trace("## ProtectedStorageEntry added to map. hash={}, map={}", hashOfPayload, printMap()); - + // Optionally, broadcast the add/update depending on the calling environment if (allowBroadcast) { broadcaster.broadcast(new AddDataMessage(protectedStorageEntry), sender, listener); @@ -902,7 +890,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers // Persist ProtectedStorageEntries carrying PersistablePayload payloads if (protectedStoragePayload instanceof PersistablePayload) protectedDataStoreService.put(hashOfPayload, protectedStorageEntry); - + return true; } } @@ -951,13 +939,13 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers try { ByteArray hashOfPayload = new ByteArray(refreshTTLMessage.getHashOfPayload()); ProtectedStorageEntry storedData = map.get(hashOfPayload); - + if (storedData == null) { log.debug("We don't have data for that refresh message in our map. That is expected if we missed the data publishing."); - + return false; } - + ProtectedStorageEntry storedEntry = map.get(hashOfPayload); ProtectedStorageEntry updatedEntry = new ProtectedStorageEntry( storedEntry.getProtectedStoragePayload(), @@ -965,26 +953,26 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers refreshTTLMessage.getSequenceNumber(), refreshTTLMessage.getSignature(), this.clock); - - + + // If we have seen a more recent operation for this payload, we ignore the current one if (!hasSequenceNrIncreased(updatedEntry.getSequenceNumber(), hashOfPayload)) return false; - + // Verify the updated ProtectedStorageEntry is well formed and valid for update if (!updatedEntry.isValidForAddOperation()) return false; - + // Update the hash map with the updated entry map.put(hashOfPayload, updatedEntry); - + // Record the latest sequence number and persist it sequenceNumberMap.put(hashOfPayload, new MapValue(updatedEntry.getSequenceNumber(), this.clock.millis())); requestPersistence(); - + // Always broadcast refreshes broadcaster.broadcast(refreshTTLMessage, sender); - + } catch (IllegalArgumentException e) { log.error("refreshTTL failed, missing data: {}", e.toString()); e.printStackTrace(); @@ -1007,29 +995,29 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers synchronized (map) { ProtectedStoragePayload protectedStoragePayload = protectedStorageEntry.getProtectedStoragePayload(); ByteArray hashOfPayload = get32ByteHashAsByteArray(protectedStoragePayload); - + // If we have seen a more recent operation for this payload, ignore this one if (!hasSequenceNrIncreased(protectedStorageEntry.getSequenceNumber(), hashOfPayload)) return false; - + // Verify the ProtectedStorageEntry is well formed and valid for the remove operation if (!protectedStorageEntry.isValidForRemoveOperation()) return false; - + // If we have already seen an Entry with the same hash, verify the metadata is the same ProtectedStorageEntry storedEntry = map.get(hashOfPayload); if (storedEntry != null && !protectedStorageEntry.matchesRelevantPubKey(storedEntry)) return false; - + // Record the latest sequence number and persist it sequenceNumberMap.put(hashOfPayload, new MapValue(protectedStorageEntry.getSequenceNumber(), this.clock.millis())); requestPersistence(); - + // Update that we have seen this AddOncePayload so the next time it is seen it fails verification if (protectedStoragePayload instanceof AddOncePayload) { removedPayloadsService.addHash(hashOfPayload); } - + if (storedEntry != null) { // Valid remove entry, do the remove and signal listeners removeFromMapAndDataStore(protectedStorageEntry, hashOfPayload); @@ -1039,13 +1027,13 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers // broadcast the remove to peers so they can update their state appropriately } */ printData("after remove"); - + if (protectedStorageEntry instanceof ProtectedMailboxStorageEntry) { broadcaster.broadcast(new RemoveMailboxDataMessage((ProtectedMailboxStorageEntry) protectedStorageEntry), sender); } else { broadcaster.broadcast(new RemoveDataMessage(protectedStorageEntry), sender); } - + return true; } } diff --git a/p2p/src/main/java/haveno/network/p2p/storage/persistence/AppendOnlyDataStoreService.java b/p2p/src/main/java/haveno/network/p2p/storage/persistence/AppendOnlyDataStoreService.java index c3edd7019b..ee44123bdd 100644 --- a/p2p/src/main/java/haveno/network/p2p/storage/persistence/AppendOnlyDataStoreService.java +++ b/p2p/src/main/java/haveno/network/p2p/storage/persistence/AppendOnlyDataStoreService.java @@ -18,21 +18,18 @@ package haveno.network.p2p.storage.persistence; import com.google.common.annotations.VisibleForTesting; +import com.google.inject.Inject; import haveno.network.p2p.storage.P2PDataStorage; import haveno.network.p2p.storage.payload.PersistableNetworkPayload; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; - -import org.jetbrains.annotations.NotNull; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; /** * Used for PersistableNetworkPayload data which gets appended to a map storage. diff --git a/p2p/src/main/java/haveno/network/p2p/storage/persistence/ProtectedDataStoreService.java b/p2p/src/main/java/haveno/network/p2p/storage/persistence/ProtectedDataStoreService.java index 1f3b7435dc..a26c2be2c5 100644 --- a/p2p/src/main/java/haveno/network/p2p/storage/persistence/ProtectedDataStoreService.java +++ b/p2p/src/main/java/haveno/network/p2p/storage/persistence/ProtectedDataStoreService.java @@ -18,18 +18,17 @@ package haveno.network.p2p.storage.persistence; import com.google.common.annotations.VisibleForTesting; +import com.google.inject.Inject; import haveno.common.proto.persistable.PersistableEnvelope; import haveno.network.p2p.storage.P2PDataStorage; import haveno.network.p2p.storage.payload.ProtectedStorageEntry; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; /** * Used for data which can be added and removed. ProtectedStorageEntry is used for verifying ownership. diff --git a/p2p/src/main/java/haveno/network/p2p/storage/persistence/RemovedPayloadsService.java b/p2p/src/main/java/haveno/network/p2p/storage/persistence/RemovedPayloadsService.java index 7bb9f46510..6908696c13 100644 --- a/p2p/src/main/java/haveno/network/p2p/storage/persistence/RemovedPayloadsService.java +++ b/p2p/src/main/java/haveno/network/p2p/storage/persistence/RemovedPayloadsService.java @@ -17,15 +17,14 @@ package haveno.network.p2p.storage.persistence; +import com.google.inject.Inject; +import com.google.inject.Singleton; import haveno.common.persistence.PersistenceManager; import haveno.common.proto.persistable.PersistedDataHost; import haveno.network.p2p.storage.P2PDataStorage; import haveno.network.p2p.storage.payload.MailboxStoragePayload; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; -import javax.inject.Singleton; - /** * We persist the hashes and timestamp when a AddOncePayload payload got removed. This protects that it could be * added again for instance if the sequence number map would be inconsistent/deleted or when we receive data from diff --git a/p2p/src/main/java/haveno/network/p2p/storage/persistence/ResourceDataStoreService.java b/p2p/src/main/java/haveno/network/p2p/storage/persistence/ResourceDataStoreService.java index b316c6bc8b..c5cbc90f93 100644 --- a/p2p/src/main/java/haveno/network/p2p/storage/persistence/ResourceDataStoreService.java +++ b/p2p/src/main/java/haveno/network/p2p/storage/persistence/ResourceDataStoreService.java @@ -18,13 +18,12 @@ package haveno.network.p2p.storage.persistence; import com.google.common.annotations.VisibleForTesting; +import com.google.inject.Inject; import haveno.common.proto.persistable.PersistableEnvelope; -import lombok.extern.slf4j.Slf4j; - -import javax.inject.Inject; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import lombok.extern.slf4j.Slf4j; /** * Used for handling data from resource files. diff --git a/scripts/install_java.bat b/scripts/install_java.bat index b53b087917..28224d2d9c 100644 --- a/scripts/install_java.bat +++ b/scripts/install_java.bat @@ -25,9 +25,9 @@ cd /D "%~dp0" title Install Java -set jdk_version=11.0.2 +set jdk_version=21.0.2 set jdk_filename=openjdk-%jdk_version%_windows-x64_bin -set jdk_url=https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_windows-x64_bin.zip +set jdk_url=https://download.java.net/java/GA/jdk21.0.2/f2283984656d49d69e91c558476027ac/13/GPL/openjdk-21.0.2_windows-x64_bin.zip if exist "%PROGRAMFILES%\Java\openjdk\jdk-%jdk_version%" ( echo %PROGRAMFILES%\Java\openjdk\jdk-%jdk_version% already exists, skipping install diff --git a/scripts/install_java.sh b/scripts/install_java.sh index d14214b9f7..e52fb5f918 100755 --- a/scripts/install_java.sh +++ b/scripts/install_java.sh @@ -15,9 +15,9 @@ set -e unameOut="$(uname -s)" case "${unameOut}" in Linux*) - JAVA_HOME=/usr/lib/jvm/openjdk-11.0.2 - JDK_FILENAME=openjdk-11.0.2_linux-x64_bin.tar.gz - JDK_URL=https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz + JAVA_HOME=/usr/lib/jvm/openjdk-21.0.2 + JDK_FILENAME=openjdk-21.0.2_linux-x64_bin.tar.gz + JDK_URL=https://download.java.net/java/GA/jdk21.0.2/f2283984656d49d69e91c558476027ac/13/GPL/openjdk-21.0.2_linux-x64_bin.tar.gz # Determine which package manager to use depending on the distribution declare -A osInfo; @@ -52,9 +52,9 @@ case "${unameOut}" in update-alternatives --set javac $JAVA_HOME/bin/javac ;; Darwin*) - JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home - JDK_FILENAME=openjdk-11.0.2_osx-x64_bin.tar.gz - JDK_URL=https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_osx-x64_bin.tar.gz + JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-21.0.2.jdk/Contents/Home + JDK_FILENAME=openjdk-21.0.2_macos-x64_bin.tar.gz + JDK_URL=https://download.java.net/java/GA/jdk21.0.2/f2283984656d49d69e91c558476027ac/13/GPL/openjdk-21.0.2_macos-x64_bin.tar.gz if [ ! -d "$JAVA_HOME" ]; then if [[ $(command -v brew) == "" ]]; then echo "Installing Homebrew" @@ -66,10 +66,10 @@ case "${unameOut}" in brew install curl curl -L -O $JDK_URL - sudo mkdir /Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk | sudo bash + sudo mkdir /Library/Java/JavaVirtualMachines/openjdk-21.0.2.jdk | sudo bash gunzip -c $JDK_FILENAME | tar xopf - - sudo mv jdk-11.0.2.jdk/* /Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk - sudo rmdir jdk-11.0.2.jdk + sudo mv jdk-21.0.2.jdk/* /Library/Java/JavaVirtualMachines/openjdk-21.0.2.jdk + sudo rmdir jdk-21.0.2.jdk rm $JDK_FILENAME fi