diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index e158cc57986..e23667a3bd9 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -1593,6 +1593,7 @@ dao.proposal.create.phase.inactive=Please wait until the next proposal phase dao.proposal.create.proposalType=Proposal type dao.proposal.create.createNew=Make new proposal dao.proposal.create.create.button=Make proposal +dao.proposal.create.publish=Publish proposal dao.proposal=proposal dao.proposal.display.type=Proposal type dao.proposal.display.name=Name/nickname @@ -1745,6 +1746,11 @@ dao.proposal.create.missingBsqFunds=You don''t have sufficient BSQ funds for cre unconfirmed BSQ transaction you need to wait for a blockchain confirmation because BSQ is validated only if it is \ included in a block.\n\ Missing: {0} + +dao.proposal.create.missingBsqFundsForBond=You don''t have sufficient BSQ funds for this role. You can still \ + publish this proposal, but you''ll need the full BSQ amount required for this role if it gets accepted. \n\ + Missing: {0} + dao.proposal.create.missingMinerFeeFunds=You don''t have sufficient BTC funds for creating the proposal transaction. \ Any BSQ transaction require also a miner fee in BTC.\n\ Missing: {0} diff --git a/desktop/src/main/java/bisq/desktop/main/dao/governance/make/MakeProposalView.java b/desktop/src/main/java/bisq/desktop/main/dao/governance/make/MakeProposalView.java index 360715be1f8..a6817f9310f 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/governance/make/MakeProposalView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/governance/make/MakeProposalView.java @@ -30,6 +30,7 @@ import bisq.core.btc.exceptions.InsufficientBsqException; import bisq.core.btc.setup.WalletsSetup; +import bisq.core.btc.wallet.BsqWalletService; import bisq.core.dao.DaoFacade; import bisq.core.dao.exceptions.ValidationException; import bisq.core.dao.governance.bond.Bond; @@ -100,6 +101,7 @@ public class MakeProposalView extends ActivatableView implements private final BSFormatter btcFormatter; private final BsqFormatter bsqFormatter; private final Navigation navigation; + private final BsqWalletService bsqWalletService; @Nullable private ProposalDisplay proposalDisplay; @@ -127,6 +129,7 @@ public class MakeProposalView extends ActivatableView implements private MakeProposalView(DaoFacade daoFacade, WalletsSetup walletsSetup, P2PService p2PService, + BsqWalletService bsqWalletService, PhasesView phasesView, ChangeParamValidator changeParamValidator, BSFormatter btcFormatter, @@ -135,6 +138,7 @@ private MakeProposalView(DaoFacade daoFacade, this.daoFacade = daoFacade; this.walletsSetup = walletsSetup; this.p2PService = p2PService; + this.bsqWalletService = bsqWalletService; this.phasesView = phasesView; this.changeParamValidator = changeParamValidator; this.btcFormatter = btcFormatter; @@ -268,11 +272,22 @@ private void publishMyProposal(ProposalType type) { int txSize = transaction.bitcoinSerialize().length; Coin fee = daoFacade.getProposalFee(daoFacade.getChainHeight()); - if (!DevEnv.isDevMode()) { - GUIUtil.showBsqFeeInfoPopup(fee, miningFee, txSize, bsqFormatter, btcFormatter, - Res.get("dao.proposal"), () -> doPublishMyProposal(proposal, transaction)); + if (type.equals(ProposalType.BONDED_ROLE)) { + final long requiredBond = proposalDisplay.bondedRoleTypeComboBox.getSelectionModel().getSelectedItem().getRequiredBond(); + final long availableBalance = bsqWalletService.getAvailableBalance().value; + + if (requiredBond > availableBalance) { + final long missing = requiredBond - availableBalance; + new Popup<>().warning(Res.get("dao.proposal.create.missingBsqFundsForBond", + bsqFormatter.formatCoinWithCode(missing))) + .actionButtonText(Res.get("dao.proposal.create.publish")) + .onAction(() -> { + showFeeInfoAndPublishMyProposal(proposal, transaction, miningFee, txSize, fee); + }) + .show(); + } } else { - doPublishMyProposal(proposal, transaction); + showFeeInfoAndPublishMyProposal(proposal, transaction, miningFee, txSize, fee); } } catch (InsufficientMoneyException e) { if (e instanceof InsufficientBsqException) { @@ -299,6 +314,15 @@ private void publishMyProposal(ProposalType type) { } } + private void showFeeInfoAndPublishMyProposal(Proposal proposal, Transaction transaction, Coin miningFee, int txSize, Coin fee) { + if (!DevEnv.isDevMode()) { + GUIUtil.showBsqFeeInfoPopup(fee, miningFee, txSize, bsqFormatter, btcFormatter, + Res.get("dao.proposal"), () -> doPublishMyProposal(proposal, transaction)); + } else { + doPublishMyProposal(proposal, transaction); + } + } + private void doPublishMyProposal(Proposal proposal, Transaction transaction) { daoFacade.publishMyProposal(proposal, transaction,