From b39427d594fb79c8064b9f1e0ef10b47ba3f1051 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Sun, 3 Feb 2019 22:46:24 +0100 Subject: [PATCH 1/4] Cleanup --- .../bisq/desktop/main/funds/withdrawal/WithdrawalView.java | 4 ---- 1 file changed, 4 deletions(-) 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, From 282c62a4c6e507c444dea85a548d0d8feb0737fc Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Sun, 3 Feb 2019 22:47:27 +0100 Subject: [PATCH 2/4] Add isActive method to BondState --- .../main/java/bisq/core/dao/governance/bond/Bond.java | 5 +---- .../bisq/core/dao/governance/bond/BondRepository.java | 2 +- .../java/bisq/core/dao/governance/bond/BondState.java | 9 ++++++++- 3 files changed, 10 insertions(+), 6 deletions(-) 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; + } } From 36257314ca0ba3b9828a459eaab2f07a654ef9dd Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Sun, 3 Feb 2019 23:09:13 +0100 Subject: [PATCH 3/4] Add IRREGULAR TxType --- common/src/main/proto/pb.proto | 1 + .../bisq/core/dao/node/parser/TxParser.java | 20 +++++++++++-------- .../dao/state/model/blockchain/TxType.java | 3 ++- .../resources/i18n/displayStrings.properties | 2 ++ .../desktop/main/dao/wallet/tx/BsqTxView.java | 12 ++++++----- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/common/src/main/proto/pb.proto b/common/src/main/proto/pb.proto index 6653b665363..b0b01b52658 100644 --- a/common/src/main/proto/pb.proto +++ b/common/src/main/proto/pb.proto @@ -1379,6 +1379,7 @@ enum TxType { UNLOCK = 13; ASSET_LISTING_FEE = 14; PROOF_OF_BURN = 15; + IRREGULAR = 16; } message TxInput { 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..b1fed023a38 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,7 +233,8 @@ 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) { - tempTx.setTxType(TxType.INVALID); + // We don't want to burn BSQ in that case + tempTx.setTxType(TxType.IRREGULAR); } } @@ -250,13 +251,13 @@ 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); + tempTx.setTxType(TxType.IRREGULAR); } } 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); + tempTx.setTxType(TxType.IRREGULAR); 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,8 +267,11 @@ 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) { - tempTx.setTxType(TxType.INVALID); - txOutputParser.getOptionalBlindVoteLockStakeOutput().ifPresent(tempTxOutput -> tempTxOutput.setTxOutputType(TxOutputType.BTC_OUTPUT)); + // We don't want to burn BSQ in that case + tempTx.setTxType(TxType.IRREGULAR); + + // TODO Do we want to mark that txo as TxOutputType.BTC_OUTPUT? Would lead to burned BSQ... + // 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 +392,7 @@ 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; + return TxType.IRREGULAR; } TempTxOutput issuanceTxOutput = tempTx.getTempTxOutputs().get(1); @@ -397,7 +401,7 @@ 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; + return TxType.IRREGULAR; } return opReturnType == OpReturnType.COMPENSATION_REQUEST ? @@ -415,7 +419,7 @@ 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; + return TxType.IRREGULAR; } } } diff --git a/core/src/main/java/bisq/core/dao/state/model/blockchain/TxType.java b/core/src/main/java/bisq/core/dao/state/model/blockchain/TxType.java index 96d0ef00fbf..53f19e9adc1 100644 --- a/core/src/main/java/bisq/core/dao/state/model/blockchain/TxType.java +++ b/core/src/main/java/bisq/core/dao/state/model/blockchain/TxType.java @@ -44,7 +44,8 @@ public enum TxType implements ImmutableDaoStateModel { LOCKUP(true, false), UNLOCK(true, false), ASSET_LISTING_FEE(true, true), - PROOF_OF_BURN(true, true); + PROOF_OF_BURN(true, true), + IRREGULAR(false, false); // Tx is not rule conform but we don't want to burn the BSQ. hasOpReturn and requiresFee are ignored /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 05da05499fd..fdfe14ba429 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -1713,6 +1713,8 @@ dao.tx.type.enum.UNLOCK=Unlock bond dao.tx.type.enum.ASSET_LISTING_FEE=Asset listing fee # suppress inspection "UnusedProperty" dao.tx.type.enum.PROOF_OF_BURN=Proof of burn +# suppress inspection "UnusedProperty" +dao.tx.type.enum.IRREGULAR=Irregular dao.tx.issuanceFromCompReq=Compensation request/issuance dao.tx.issuanceFromCompReq.tooltip=Compensation request which led to an issuance of new BSQ.\n\ 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..06c9e6ab863 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,8 +463,7 @@ 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 Date: Sun, 3 Feb 2019 23:36:54 +0100 Subject: [PATCH 4/4] Add IRREGULAR TxType to json class Only apply tx type if not irregular --- .../main/java/bisq/core/dao/node/explorer/JsonTxType.java | 3 ++- core/src/main/java/bisq/core/dao/node/parser/TxParser.java | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/bisq/core/dao/node/explorer/JsonTxType.java b/core/src/main/java/bisq/core/dao/node/explorer/JsonTxType.java index b58c2b6723e..57026d9344f 100644 --- a/core/src/main/java/bisq/core/dao/node/explorer/JsonTxType.java +++ b/core/src/main/java/bisq/core/dao/node/explorer/JsonTxType.java @@ -35,7 +35,8 @@ enum JsonTxType { LOCKUP("Lockup"), UNLOCK("Unlock"), ASSET_LISTING_FEE("Asset listing fee"), - PROOF_OF_BURN("Proof of burn"); + PROOF_OF_BURN("Proof of burn"), + IRREGULAR("Irregular"); @Getter private String displayString; 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 b1fed023a38..653c57d35a8 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 @@ -152,8 +152,10 @@ private Optional findTx(RawTx rawTx) { applyTxTypeAndTxOutputType(blockHeight, tempTx, remainingInputValue); - TxType txType = evaluateTxType(tempTx, optionalOpReturnType, hasBurntBsq, unLockInputValid); - tempTx.setTxType(txType); + if (tempTx.getTxType() != TxType.IRREGULAR) { + TxType txType = evaluateTxType(tempTx, optionalOpReturnType, hasBurntBsq, unLockInputValid); + tempTx.setTxType(txType); + } if (isTxInvalid(tempTx, bsqOutputFound, hasBurntBond)) { tempTx.setTxType(TxType.INVALID);