Search in sources :

Example 1 with ChangeBelowDustException

use of bisq.core.btc.wallet.ChangeBelowDustException in project bisq-desktop by bisq-network.

the class ActiveProposalsView method activate.

@Override
protected void activate() {
    super.activate();
    bsqWalletService.addBsqBalanceListener(this);
    onUpdateBalances(bsqWalletService.getAvailableBalance(), bsqWalletService.getPendingBalance(), bsqWalletService.getLockedForVotingBalance(), bsqWalletService.getLockedInBondsBalance());
    if (voteButton != null) {
        voteButton.setOnAction(e -> {
            Coin stake = bsqFormatter.parseToCoin(stakeInputTextField.getText());
            // TODO show popup
            try {
                voteService.publishBlindVote(stake, new FutureCallback<Transaction>() {

                    @Override
                    public void onSuccess(@Nullable Transaction result) {
                    // TODO
                    }

                    @Override
                    public void onFailure(@NotNull Throwable t) {
                    // TODO
                    }
                });
            } catch (CryptoException e1) {
                // TODO show error popup
                e1.printStackTrace();
            } catch (InsufficientBsqException e1) {
                e1.printStackTrace();
            } catch (WalletException e1) {
                e1.printStackTrace();
            } catch (TransactionVerificationException e1) {
                e1.printStackTrace();
            } catch (InsufficientMoneyException e1) {
                e1.printStackTrace();
            } catch (ChangeBelowDustException e1) {
                e1.printStackTrace();
            } catch (InvalidProtocolBufferException e1) {
                e1.printStackTrace();
            }
        });
    }
}
Also used : WalletException(bisq.core.btc.exceptions.WalletException) Coin(org.bitcoinj.core.Coin) Transaction(org.bitcoinj.core.Transaction) InsufficientBsqException(bisq.core.btc.wallet.InsufficientBsqException) TransactionVerificationException(bisq.core.btc.exceptions.TransactionVerificationException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) InsufficientMoneyException(org.bitcoinj.core.InsufficientMoneyException) CryptoException(bisq.common.crypto.CryptoException) ChangeBelowDustException(bisq.core.btc.wallet.ChangeBelowDustException)

Example 2 with ChangeBelowDustException

use of bisq.core.btc.wallet.ChangeBelowDustException 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)2 WalletException (bisq.core.btc.exceptions.WalletException)2 ChangeBelowDustException (bisq.core.btc.wallet.ChangeBelowDustException)2 InsufficientBsqException (bisq.core.btc.wallet.InsufficientBsqException)2 Coin (org.bitcoinj.core.Coin)2 InsufficientMoneyException (org.bitcoinj.core.InsufficientMoneyException)2 Transaction (org.bitcoinj.core.Transaction)2 CryptoException (bisq.common.crypto.CryptoException)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 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1