Search in sources :

Example 1 with ResultHandler

use of io.bitsquare.common.handlers.ResultHandler in project bitsquare by bitsquare.

the class Offer method checkOfferAvailability.

///////////////////////////////////////////////////////////////////////////////////////////
// Availability
///////////////////////////////////////////////////////////////////////////////////////////
public void checkOfferAvailability(OfferAvailabilityModel model, ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
    availabilityProtocol = new OfferAvailabilityProtocol(model, () -> {
        cancelAvailabilityRequest();
        resultHandler.handleResult();
    }, (errorMessage) -> {
        if (availabilityProtocol != null)
            availabilityProtocol.cancel();
        log.error(errorMessage);
        errorMessageHandler.handleErrorMessage(errorMessage);
    });
    availabilityProtocol.sendOfferAvailabilityRequest();
}
Also used : Version(io.bitsquare.app.Version) MathUtils(io.bitsquare.common.util.MathUtils) PaymentMethod(io.bitsquare.payment.PaymentMethod) PriceFeedService(io.bitsquare.btc.pricefeed.PriceFeedService) PubKeyRing(io.bitsquare.common.crypto.PubKeyRing) MarketPrice(io.bitsquare.btc.pricefeed.MarketPrice) ErrorMessageHandler(io.bitsquare.common.handlers.ErrorMessageHandler) Coin(org.bitcoinj.core.Coin) Date(java.util.Date) Restrictions(io.bitsquare.btc.Restrictions) LoggerFactory(org.slf4j.LoggerFactory) ArrayList(java.util.ArrayList) DevFlags(io.bitsquare.app.DevFlags) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) RequiresOwnerIsOnlinePayload(io.bitsquare.p2p.storage.payload.RequiresOwnerIsOnlinePayload) KeyRing(io.bitsquare.common.crypto.KeyRing) ResultHandler(io.bitsquare.common.handlers.ResultHandler) Nullable(javax.annotation.Nullable) javafx.beans.property(javafx.beans.property) Utilities(io.bitsquare.common.util.Utilities) Logger(org.slf4j.Logger) ExchangeRate(org.bitcoinj.utils.ExchangeRate) OfferAvailabilityProtocol(io.bitsquare.trade.protocol.availability.OfferAvailabilityProtocol) DecimalFormat(java.text.DecimalFormat) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) JsonExclude(io.bitsquare.common.util.JsonExclude) NodeAddress(io.bitsquare.p2p.NodeAddress) Fiat(org.bitcoinj.utils.Fiat) IOException(java.io.IOException) PublicKey(java.security.PublicKey) StoragePayload(io.bitsquare.p2p.storage.payload.StoragePayload) TimeUnit(java.util.concurrent.TimeUnit) MarketPriceNotAvailableException(io.bitsquare.trade.exceptions.MarketPriceNotAvailableException) List(java.util.List) TradePriceOutOfToleranceException(io.bitsquare.trade.exceptions.TradePriceOutOfToleranceException) OfferAvailabilityModel(io.bitsquare.trade.protocol.availability.OfferAvailabilityModel) CurrencyUtil(io.bitsquare.locale.CurrencyUtil) OfferAvailabilityProtocol(io.bitsquare.trade.protocol.availability.OfferAvailabilityProtocol)

Example 2 with ResultHandler

use of io.bitsquare.common.handlers.ResultHandler in project bitsquare by bitsquare.

the class BuyerStep5View method doWithdrawal.

private void doWithdrawal(Coin receiverAmount) {
    String toAddress = withdrawAddressTextField.getText();
    ResultHandler resultHandler = this::handleTradeCompleted;
    FaultHandler faultHandler = (errorMessage, throwable) -> {
        useSavingsWalletButton.setDisable(false);
        withdrawToExternalWalletButton.setDisable(false);
        if (throwable != null && throwable.getMessage() != null)
            new Popup().error(errorMessage + "\n\n" + throwable.getMessage()).show();
        else
            new Popup().error(errorMessage).show();
    };
    if (model.dataModel.walletService.getWallet().isEncrypted()) {
        UserThread.runAfter(() -> model.dataModel.walletPasswordWindow.onAesKey(aesKey -> doWithdrawRequest(toAddress, receiverAmount, aesKey, resultHandler, faultHandler)).show(), 300, TimeUnit.MILLISECONDS);
    } else
        doWithdrawRequest(toAddress, receiverAmount, null, resultHandler, faultHandler);
}
Also used : TradeStepView(io.bitsquare.gui.main.portfolio.pendingtrades.steps.TradeStepView) Button(javafx.scene.control.Button) Popup(io.bitsquare.gui.main.overlays.popups.Popup) MainView(io.bitsquare.gui.main.MainView) Coin(org.bitcoinj.core.Coin) Restrictions(io.bitsquare.btc.Restrictions) Tuple2(io.bitsquare.common.util.Tuple2) FundsView(io.bitsquare.gui.main.funds.FundsView) DevFlags(io.bitsquare.app.DevFlags) PendingTradesViewModel(io.bitsquare.gui.main.portfolio.pendingtrades.PendingTradesViewModel) Insets(javafx.geometry.Insets) WalletService(io.bitsquare.btc.WalletService) Layout(io.bitsquare.gui.util.Layout) ResultHandler(io.bitsquare.common.handlers.ResultHandler) KeyParameter(org.spongycastle.crypto.params.KeyParameter) AddressEntry(io.bitsquare.btc.AddressEntry) GridPane(javafx.scene.layout.GridPane) Log(io.bitsquare.app.Log) BSFormatter(io.bitsquare.gui.util.BSFormatter) HBox(javafx.scene.layout.HBox) AddressFormatException(org.bitcoinj.core.AddressFormatException) InputTextField(io.bitsquare.gui.components.InputTextField) TextField(javafx.scene.control.TextField) Label(javafx.scene.control.Label) UserThread(io.bitsquare.common.UserThread) TimeUnit(java.util.concurrent.TimeUnit) AddressEntryException(io.bitsquare.btc.AddressEntryException) FormBuilder(io.bitsquare.gui.util.FormBuilder) Notification(io.bitsquare.gui.main.overlays.notifications.Notification) FaultHandler(io.bitsquare.common.handlers.FaultHandler) ChangeListener(javafx.beans.value.ChangeListener) TransactionsView(io.bitsquare.gui.main.funds.transactions.TransactionsView) Popup(io.bitsquare.gui.main.overlays.popups.Popup) ResultHandler(io.bitsquare.common.handlers.ResultHandler) FaultHandler(io.bitsquare.common.handlers.FaultHandler)

Aggregations

DevFlags (io.bitsquare.app.DevFlags)2 Restrictions (io.bitsquare.btc.Restrictions)2 ResultHandler (io.bitsquare.common.handlers.ResultHandler)2 TimeUnit (java.util.concurrent.TimeUnit)2 Coin (org.bitcoinj.core.Coin)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Log (io.bitsquare.app.Log)1 Version (io.bitsquare.app.Version)1 AddressEntry (io.bitsquare.btc.AddressEntry)1 AddressEntryException (io.bitsquare.btc.AddressEntryException)1 WalletService (io.bitsquare.btc.WalletService)1 MarketPrice (io.bitsquare.btc.pricefeed.MarketPrice)1 PriceFeedService (io.bitsquare.btc.pricefeed.PriceFeedService)1 UserThread (io.bitsquare.common.UserThread)1 KeyRing (io.bitsquare.common.crypto.KeyRing)1 PubKeyRing (io.bitsquare.common.crypto.PubKeyRing)1 ErrorMessageHandler (io.bitsquare.common.handlers.ErrorMessageHandler)1 FaultHandler (io.bitsquare.common.handlers.FaultHandler)1 JsonExclude (io.bitsquare.common.util.JsonExclude)1