diff --git a/core/src/main/java/bisq/core/dao/governance/bond/Bond.java b/core/src/main/java/bisq/core/dao/governance/bond/Bond.java index b4d5ed612d5..d2ab83a8dbb 100644 --- a/core/src/main/java/bisq/core/dao/governance/bond/Bond.java +++ b/core/src/main/java/bisq/core/dao/governance/bond/Bond.java @@ -53,10 +53,7 @@ protected Bond(T bondedAsset) { } public boolean isActive() { - return bondState == BondState.LOCKUP_TX_CONFIRMED || - bondState == BondState.UNLOCK_TX_PENDING || - bondState == BondState.UNLOCK_TX_CONFIRMED || - bondState == BondState.UNLOCKING; + return bondState.isActive(); } // Enums must not be used directly for hashCode or equals as it delivers the Object.hashCode (internal address)! diff --git a/core/src/main/java/bisq/core/dao/governance/bond/BondRepository.java b/core/src/main/java/bisq/core/dao/governance/bond/BondRepository.java index e62da9ce404..52608f7ada1 100644 --- a/core/src/main/java/bisq/core/dao/governance/bond/BondRepository.java +++ b/core/src/main/java/bisq/core/dao/governance/bond/BondRepository.java @@ -188,7 +188,7 @@ public boolean isBondedAssetAlreadyInBond(R bondedAsset) { } public List getActiveBonds() { - return bonds.stream().filter(bond -> bond.isActive()).collect(Collectors.toList()); + return bonds.stream().filter(Bond::isActive).collect(Collectors.toList()); } diff --git a/core/src/main/java/bisq/core/dao/governance/bond/BondState.java b/core/src/main/java/bisq/core/dao/governance/bond/BondState.java index 1d74ed19965..86eb4dc2235 100644 --- a/core/src/main/java/bisq/core/dao/governance/bond/BondState.java +++ b/core/src/main/java/bisq/core/dao/governance/bond/BondState.java @@ -29,5 +29,12 @@ public enum BondState { UNLOCK_TX_CONFIRMED, UNLOCKING, // Lock time still not expired UNLOCKED, // Fully unlocked - CONFISCATED // Bond got confiscated by DAO voting + CONFISCATED; // Bond got confiscated by DAO voting + + public boolean isActive() { + return this == BondState.LOCKUP_TX_CONFIRMED || + this == BondState.UNLOCK_TX_PENDING || + this == BondState.UNLOCK_TX_CONFIRMED || + this == BondState.UNLOCKING; + } } diff --git a/core/src/main/java/bisq/core/dao/node/parser/TxParser.java b/core/src/main/java/bisq/core/dao/node/parser/TxParser.java index 3d992105b5b..821ed2bb38d 100644 --- a/core/src/main/java/bisq/core/dao/node/parser/TxParser.java +++ b/core/src/main/java/bisq/core/dao/node/parser/TxParser.java @@ -233,6 +233,7 @@ private void applyTxTypeAndTxOutputType(int blockHeight, TempTx tempTx, long bsq private void processProposal(int blockHeight, TempTx tempTx, long bsqFee) { boolean isFeeAndPhaseValid = isFeeAndPhaseValid(tempTx.getId(), blockHeight, bsqFee, DaoPhase.Phase.PROPOSAL, Param.PROPOSAL_FEE); if (!isFeeAndPhaseValid) { + // TODO don't burn in such cases tempTx.setTxType(TxType.INVALID); } } @@ -250,13 +251,17 @@ private void processIssuance(int blockHeight, TempTx tempTx, long bsqFee) { "As the BSQ fee is set it must be either a buggy tx or an manually crafted invalid tx."); // Even though the request part if invalid the BSQ transfer and change output should still be valid // as long as the BSQ change <= BSQ inputs. - tempTx.setTxType(TxType.UNDEFINED_TX_TYPE); + // TODO do we want to burn in such a case? + tempTx.setTxType(TxType.INVALID); } } else { // This could be a valid compensation request that failed to be included in a block during the // correct phase due to no fault of the user. Better not burn the change as long as the BSQ inputs // cover the value of the outputs. - tempTx.setTxType(TxType.UNDEFINED_TX_TYPE); + // TODO don't burn in such cases + tempTx.setTxType(TxType.INVALID); + + // TODO don't burn in such cases optionalIssuanceCandidate.ifPresent(tempTxOutput -> tempTxOutput.setTxOutputType(TxOutputType.BTC_OUTPUT)); // Empty Optional case is a possible valid case where a random tx matches our opReturn rules but it is not a // valid BSQ tx. @@ -266,7 +271,10 @@ private void processIssuance(int blockHeight, TempTx tempTx, long bsqFee) { private void processBlindVote(int blockHeight, TempTx tempTx, long bsqFee) { boolean isFeeAndPhaseValid = isFeeAndPhaseValid(tempTx.getId(), blockHeight, bsqFee, DaoPhase.Phase.BLIND_VOTE, Param.BLIND_VOTE_FEE); if (!isFeeAndPhaseValid) { + // TODO don't burn in such cases tempTx.setTxType(TxType.INVALID); + + // TODO don't burn in such cases txOutputParser.getOptionalBlindVoteLockStakeOutput().ifPresent(tempTxOutput -> tempTxOutput.setTxOutputType(TxOutputType.BTC_OUTPUT)); // Empty Optional case is a possible valid case where a random tx matches our opReturn rules but it is not a // valid BSQ tx. @@ -388,7 +396,8 @@ static TxType evaluateTxTypeFromOpReturnType(TempTx tempTx, OpReturnType opRetur if (!hasCorrectNumOutputs) { log.warn("Compensation/reimbursement request tx need to have at least 3 outputs"); // This is not an issuance request but it should still not burn the BSQ change - return TxType.UNDEFINED_TX_TYPE; + // TODO do we want to burn in such a case? + return TxType.INVALID; } TempTxOutput issuanceTxOutput = tempTx.getTempTxOutputs().get(1); @@ -397,7 +406,8 @@ static TxType evaluateTxTypeFromOpReturnType(TempTx tempTx, OpReturnType opRetur log.warn("Compensation/reimbursement request txOutput type of output at index 1 need to be ISSUANCE_CANDIDATE_OUTPUT. " + "TxOutputType={}", issuanceTxOutput.getTxOutputType()); // This is not an issuance request but it should still not burn the BSQ change - return TxType.UNDEFINED_TX_TYPE; + // TODO do we want to burn in such a case? + return TxType.INVALID; } return opReturnType == OpReturnType.COMPENSATION_REQUEST ? @@ -415,7 +425,8 @@ static TxType evaluateTxTypeFromOpReturnType(TempTx tempTx, OpReturnType opRetur return TxType.PROOF_OF_BURN; default: log.warn("We got a BSQ tx with an unknown OP_RETURN. tx={}, opReturnType={}", tempTx, opReturnType); - return TxType.UNDEFINED_TX_TYPE; + // TODO do we want to burn in such a case? + return TxType.INVALID; } } } diff --git a/desktop/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxView.java b/desktop/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxView.java index 0cf87dfdea8..25486191ed7 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxView.java @@ -433,13 +433,12 @@ private void addAmountColumn() { column.setMaxWidth(column.getMinWidth()); column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue())); - column.setCellFactory(new Callback, - TableCell>() { + column.setCellFactory(new Callback<>() { @Override public TableCell call(TableColumn column) { - return new TableCell() { + return new TableCell<>() { @Override public void updateItem(final BsqTxListItem item, boolean empty) { @@ -464,13 +463,12 @@ private void addConfidenceColumn() { column.setMaxWidth(column.getMinWidth()); column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue())); - column.setCellFactory(new Callback, - TableCell>() { + column.setCellFactory(new Callback<>() { @Override public TableCell call(TableColumn column) { - return new TableCell() { + return new TableCell<>() { @Override public void updateItem(final BsqTxListItem item, boolean empty) { diff --git a/desktop/src/main/java/bisq/desktop/main/funds/withdrawal/WithdrawalView.java b/desktop/src/main/java/bisq/desktop/main/funds/withdrawal/WithdrawalView.java index 65fafdfb99c..fc8074a3e44 100644 --- a/desktop/src/main/java/bisq/desktop/main/funds/withdrawal/WithdrawalView.java +++ b/desktop/src/main/java/bisq/desktop/main/funds/withdrawal/WithdrawalView.java @@ -38,8 +38,6 @@ import bisq.core.locale.Res; import bisq.core.trade.Trade; import bisq.core.trade.TradeManager; -import bisq.core.trade.closed.ClosedTradableManager; -import bisq.core.trade.failed.FailedTradesManager; import bisq.core.user.Preferences; import bisq.core.util.BSFormatter; import bisq.core.util.CoinUtil; @@ -156,8 +154,6 @@ public class WithdrawalView extends ActivatableView { @Inject private WithdrawalView(BtcWalletService walletService, TradeManager tradeManager, - ClosedTradableManager closedTradableManager, - FailedTradesManager failedTradesManager, P2PService p2PService, WalletsSetup walletsSetup, BSFormatter formatter,