use of bisq.core.trade.protocol.BuyerAsTakerProtocol in project bisq-api by mrosseel.
the class BisqProxy method paymentStarted.
public CompletableFuture<Void> paymentStarted(String tradeId) {
final CompletableFuture<Void> futureResult = new CompletableFuture<>();
Trade trade;
try {
trade = getTrade(tradeId);
} catch (NotFoundException e) {
return failFuture(futureResult, e);
}
if (!Trade.State.DEPOSIT_CONFIRMED_IN_BLOCK_CHAIN.equals(trade.getState())) {
return failFuture(futureResult, new ValidationException("Trade is not in the correct state to start payment: " + trade.getState()));
}
TradeProtocol tradeProtocol = trade.getTradeProtocol();
ResultHandler resultHandler = () -> futureResult.complete(null);
ErrorMessageHandler errorResultHandler = message -> futureResult.completeExceptionally(new RuntimeException(message));
if (trade instanceof BuyerAsMakerTrade) {
((BuyerAsMakerProtocol) tradeProtocol).onFiatPaymentStarted(resultHandler, errorResultHandler);
} else {
((BuyerAsTakerProtocol) tradeProtocol).onFiatPaymentStarted(resultHandler, errorResultHandler);
}
return futureResult;
}
Aggregations