Search in sources :

Example 1 with CompensationAmountException

use of bisq.core.dao.proposal.compensation.CompensationAmountException in project bisq-desktop by bisq-network.

the class MakeProposalView method publishProposal.

private void publishProposal(ProposalType type) {
    try {
        Proposal proposal = createProposal(type);
        Transaction tx = Objects.requireNonNull(proposal).getTx();
        Coin miningFee = Objects.requireNonNull(tx).getFee();
        int txSize = tx.bitcoinSerialize().length;
        validateInputs();
        new Popup<>().headLine(Res.get("dao.proposal.create.confirm")).confirmation(Res.get("dao.proposal.create.confirm.info", bsqFormatter.formatCoinWithCode(ProposalConsensus.getCreateCompensationRequestFee(readableBsqBlockChain)), btcFormatter.formatCoinWithCode(miningFee), CoinUtil.getFeePerByte(miningFee, txSize), (txSize / 1000d))).actionButtonText(Res.get("shared.yes")).onAction(() -> {
            proposalCollectionsService.publishProposal(proposal, new FutureCallback<Transaction>() {

                @Override
                public void onSuccess(@Nullable Transaction transaction) {
                    proposalDisplay.clearForm();
                    proposalTypeComboBox.getSelectionModel().clearSelection();
                    new Popup<>().confirmation(Res.get("dao.tx.published.success")).show();
                }

                @Override
                public void onFailure(@NotNull Throwable t) {
                    log.error(t.toString());
                    new Popup<>().warning(t.toString()).show();
                }
            });
        }).closeButtonText(Res.get("shared.cancel")).show();
    } catch (InsufficientMoneyException e) {
        BSFormatter formatter = e instanceof InsufficientBsqException ? bsqFormatter : btcFormatter;
        new Popup<>().warning(Res.get("dao.proposal.create.missingFunds", formatter.formatCoinWithCode(e.missing))).show();
    } catch (CompensationAmountException e) {
        new Popup<>().warning(Res.get("validation.bsq.amountBelowMinAmount", bsqFormatter.formatCoinWithCode(e.required))).show();
    } catch (TransactionVerificationException | WalletException e) {
        log.error(e.toString());
        e.printStackTrace();
        new Popup<>().warning(e.toString()).show();
    } catch (ChangeBelowDustException e) {
        // TODO
        e.printStackTrace();
    }
}
Also used : WalletException(bisq.core.btc.exceptions.WalletException) TransactionVerificationException(bisq.core.btc.exceptions.TransactionVerificationException) InsufficientMoneyException(org.bitcoinj.core.InsufficientMoneyException) BSFormatter(bisq.desktop.util.BSFormatter) CompensationAmountException(bisq.core.dao.proposal.compensation.CompensationAmountException) ChangeBelowDustException(bisq.core.btc.wallet.ChangeBelowDustException) Coin(org.bitcoinj.core.Coin) Transaction(org.bitcoinj.core.Transaction) InsufficientBsqException(bisq.core.btc.wallet.InsufficientBsqException) Popup(bisq.desktop.main.overlays.popups.Popup) Proposal(bisq.core.dao.proposal.Proposal)

Aggregations

TransactionVerificationException (bisq.core.btc.exceptions.TransactionVerificationException)1 WalletException (bisq.core.btc.exceptions.WalletException)1 ChangeBelowDustException (bisq.core.btc.wallet.ChangeBelowDustException)1 InsufficientBsqException (bisq.core.btc.wallet.InsufficientBsqException)1 Proposal (bisq.core.dao.proposal.Proposal)1 CompensationAmountException (bisq.core.dao.proposal.compensation.CompensationAmountException)1 Popup (bisq.desktop.main.overlays.popups.Popup)1 BSFormatter (bisq.desktop.util.BSFormatter)1 Coin (org.bitcoinj.core.Coin)1 InsufficientMoneyException (org.bitcoinj.core.InsufficientMoneyException)1 Transaction (org.bitcoinj.core.Transaction)1