Skip to content

Commit

Permalink
Merge pull request #2576 from ManfredKarrer/mk-fix-get-all-bonds
Browse files Browse the repository at this point in the history
Fix get all bonds not returning not active bonds
  • Loading branch information
ripcurlx committed Mar 25, 2019
2 parents 3491c40 + a9aaef7 commit f65b340
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
9 changes: 8 additions & 1 deletion core/src/main/java/bisq/core/dao/DaoFacade.java
Expand Up @@ -92,6 +92,7 @@

import java.io.IOException;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -548,7 +549,13 @@ public Optional<Integer> getLockTime(String txId) {


public List<Bond> getAllBonds() {
List<Bond> bonds = bondedReputationRepository.getActiveBonds();
List<Bond> bonds = new ArrayList<>(bondedReputationRepository.getBonds());
bonds.addAll(bondedRolesRepository.getBonds());
return bonds;
}

public List<Bond> getAllActiveBonds() {
List<Bond> bonds = new ArrayList<>(bondedReputationRepository.getActiveBonds());
bonds.addAll(bondedRolesRepository.getActiveBonds());
return bonds;
}
Expand Down
Expand Up @@ -69,6 +69,10 @@ public static class ValidationException extends Exception {
super("Validation of vote result failed.", cause);
}

public ValidationException(String message) {
super(message);
}

@Override
public String toString() {
return "VoteResultException{" +
Expand Down
Expand Up @@ -334,7 +334,7 @@ public BondedRoleType fromString(String string) {
comboBoxValueTextFieldIndex = gridRow;
checkNotNull(confiscateBondComboBox, "confiscateBondComboBox must not be null");

confiscateBondComboBox.setItems(FXCollections.observableArrayList(daoFacade.getAllBonds()));
confiscateBondComboBox.setItems(FXCollections.observableArrayList(daoFacade.getAllActiveBonds()));
confiscateBondComboBox.setConverter(new StringConverter<>() {
@Override
public String toString(Bond bond) {
Expand All @@ -347,7 +347,6 @@ public String toString(Bond bond) {
bondType = Res.get("dao.bond.bondedReputation");
bondDetails = Utilities.bytesAsHexString(bond.getBondedAsset().getHash());
}

return bondType + ": " + bondDetails;
}

Expand Down
Expand Up @@ -40,6 +40,7 @@
import bisq.core.dao.governance.proposal.ProposalWithTransaction;
import bisq.core.dao.governance.proposal.TxException;
import bisq.core.dao.governance.proposal.param.ChangeParamValidator;
import bisq.core.dao.governance.voteresult.VoteResultException;
import bisq.core.dao.presentation.DaoUtil;
import bisq.core.dao.state.DaoStateListener;
import bisq.core.dao.state.model.blockchain.Block;
Expand Down Expand Up @@ -310,7 +311,6 @@ private void publishMyProposal(ProposalType type) {
new Popup<>().warning(Res.get("dao.proposal.create.missingMinerFeeFunds",
btcFormatter.formatCoinWithCode(e.missing))).show();
}

} catch (ProposalValidationException e) {
String message;
if (e.getMinRequestAmount() != null) {
Expand All @@ -320,7 +320,7 @@ private void publishMyProposal(ProposalType type) {
message = e.getMessage();
}
new Popup<>().warning(message).show();
} catch (TxException e) {
} catch (Throwable e) {
log.error(e.toString());
e.printStackTrace();
new Popup<>().warning(e.toString()).show();
Expand Down Expand Up @@ -365,7 +365,7 @@ private void doPublishMyProposal(Proposal proposal, Transaction transaction) {

@Nullable
private ProposalWithTransaction getProposalWithTransaction(ProposalType proposalType)
throws InsufficientMoneyException, ProposalValidationException, TxException {
throws InsufficientMoneyException, ProposalValidationException, TxException, VoteResultException.ValidationException {

checkNotNull(proposalDisplay, "proposalDisplay must not be null");

Expand Down Expand Up @@ -421,6 +421,10 @@ private ProposalWithTransaction getProposalWithTransaction(ProposalType proposal
checkNotNull(proposalDisplay.confiscateBondComboBox,
"proposalDisplay.confiscateBondComboBox must not be null");
Bond bond = proposalDisplay.confiscateBondComboBox.getSelectionModel().getSelectedItem();

if (!bond.isActive())
throw new VoteResultException.ValidationException("Bond is not locked and can't be confiscated");

return daoFacade.getConfiscateBondProposalWithTransaction(name, link, bond.getLockupTxId());
case GENERIC:
return daoFacade.getGenericProposalWithTransaction(name, link);
Expand Down

0 comments on commit f65b340

Please sign in to comment.