use of org.bitcoinj.core.Coin in project bitsquare by bitsquare.
the class TakeOfferDataModel method wouldCreateDustForOfferer.
boolean wouldCreateDustForOfferer() {
//noinspection SimplifiableIfStatement
if (amountAsCoin.get() != null && offer != null) {
Coin customAmount = offer.getAmount().subtract(amountAsCoin.get());
Coin dustAndFee = FeePolicy.getFixedTxFeeForTrades().add(Transaction.MIN_NONDUST_OUTPUT);
return customAmount.isPositive() && customAmount.isLessThan(dustAndFee);
} else {
return true;
}
}
use of org.bitcoinj.core.Coin in project bitsquare by bitsquare.
the class TakeOfferDataModel method updateBalance.
void updateBalance() {
Coin tradeWalletBalance = walletService.getBalanceForAddress(addressEntry.getAddress());
if (useSavingsWallet) {
Coin savingWalletBalance = walletService.getSavingWalletBalance();
totalAvailableBalance = savingWalletBalance.add(tradeWalletBalance);
if (totalToPayAsCoin.get() != null) {
if (totalAvailableBalance.compareTo(totalToPayAsCoin.get()) > 0)
balance.set(totalToPayAsCoin.get());
else
balance.set(totalAvailableBalance);
}
} else {
balance.set(tradeWalletBalance);
}
if (totalToPayAsCoin.get() != null) {
missingCoin.set(totalToPayAsCoin.get().subtract(balance.get()));
if (missingCoin.get().isNegative())
missingCoin.set(Coin.ZERO);
}
log.debug("missingCoin " + missingCoin.get().toFriendlyString());
isWalletFunded.set(isBalanceSufficient(balance.get()));
if (totalToPayAsCoin.get() != null && isWalletFunded.get() && walletFundedNotification == null && !DevFlags.DEV_MODE) {
walletFundedNotification = new Notification().headLine("Trading wallet update").notification("Your trading wallet is sufficiently funded.\n" + "Amount: " + formatter.formatCoinWithCode(totalToPayAsCoin.get())).autoClose();
walletFundedNotification.show();
}
}
use of org.bitcoinj.core.Coin in project bitsquare by bitsquare.
the class DisputeSummaryWindow method calculatePayoutAmounts.
private void calculatePayoutAmounts(DisputeResult.DisputeFeePolicy feePayment) {
Contract contract = dispute.getContract();
Coin refund = FeePolicy.getSecurityDeposit(dispute.getContract().offer);
Coin winnerRefund;
Coin loserRefund;
switch(feePayment) {
case SPLIT:
winnerRefund = refund.divide(2L);
loserRefund = winnerRefund;
arbitratorPayoutAmount = refund;
break;
case WAIVE:
winnerRefund = refund;
loserRefund = refund;
arbitratorPayoutAmount = Coin.ZERO;
break;
case LOSER:
default:
winnerRefund = refund;
loserRefund = Coin.ZERO;
arbitratorPayoutAmount = refund;
break;
}
winnerPayoutAmount = contract.getTradeAmount().add(winnerRefund);
loserPayoutAmount = loserRefund;
stalematePayoutAmount = contract.getTradeAmount().divide(2L).add(winnerRefund);
}
use of org.bitcoinj.core.Coin in project bitsquare by bitsquare.
the class DisputeSummaryWindow method applyTradeAmountRadioButtonStates.
private void applyTradeAmountRadioButtonStates() {
Coin buyerPayoutAmount = disputeResult.getBuyerPayoutAmount();
Coin sellerPayoutAmount = disputeResult.getSellerPayoutAmount();
buyerPayoutAmountInputTextField.setText(formatter.formatCoin(buyerPayoutAmount));
sellerPayoutAmountInputTextField.setText(formatter.formatCoin(sellerPayoutAmount));
arbitratorPayoutAmountInputTextField.setText(formatter.formatCoin(disputeResult.getArbitratorPayoutAmount()));
if (buyerPayoutAmount.equals(winnerPayoutAmount) && sellerPayoutAmount.equals(loserPayoutAmount)) {
buyerIsWinnerRadioButton.setSelected(true);
} else if (sellerPayoutAmount.equals(winnerPayoutAmount) && buyerPayoutAmount.equals(loserPayoutAmount)) {
sellerIsWinnerRadioButton.setSelected(true);
} else if (sellerPayoutAmount.equals(buyerPayoutAmount)) {
shareRadioButton.setSelected(true);
} else {
customRadioButton.setSelected(true);
}
}
use of org.bitcoinj.core.Coin in project bitsquare by bitsquare.
the class DisputeSummaryWindow method isPayoutAmountValid.
private boolean isPayoutAmountValid() {
Coin buyerAmount = formatter.parseToCoin(buyerPayoutAmountInputTextField.getText());
Coin sellerAmount = formatter.parseToCoin(sellerPayoutAmountInputTextField.getText());
Coin arbitratorAmount = formatter.parseToCoin(arbitratorPayoutAmountInputTextField.getText());
Coin securityDeposit = FeePolicy.getSecurityDeposit(dispute.getContract().offer);
Coin tradeAmount = dispute.getContract().getTradeAmount();
Coin available = tradeAmount.add(securityDeposit).add(securityDeposit);
Coin totalAmount = buyerAmount.add(sellerAmount).add(arbitratorAmount);
return (totalAmount.compareTo(available) == 0);
}
Aggregations