mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 06:55:08 +01:00
Add 'confirmpaymentreceived' api method
- Implement confirmpaymentsent on server and cli side - Enable confirmpaymentreceived method tests
This commit is contained in:
parent
3d2b90fb96
commit
ac8ed8dd06
6 changed files with 53 additions and 4 deletions
|
@ -24,7 +24,6 @@ import io.grpc.StatusRuntimeException;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -113,7 +112,6 @@ public class TakeBuyBTCOfferTest extends AbstractTradeTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Disabled
|
||||
@Test
|
||||
@Order(3)
|
||||
public void testBobsConfirmPaymentReceived() {
|
||||
|
|
|
@ -24,7 +24,6 @@ import io.grpc.StatusRuntimeException;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -116,7 +115,6 @@ public class TakeSellBTCOfferTest extends AbstractTradeTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Disabled
|
||||
@Test
|
||||
@Order(3)
|
||||
public void testAlicesConfirmPaymentReceived() {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package bisq.cli;
|
||||
|
||||
import bisq.proto.grpc.ConfirmPaymentReceivedRequest;
|
||||
import bisq.proto.grpc.ConfirmPaymentStartedRequest;
|
||||
import bisq.proto.grpc.CreateOfferRequest;
|
||||
import bisq.proto.grpc.CreatePaymentAccountRequest;
|
||||
|
@ -74,6 +75,7 @@ public class CliMain {
|
|||
getoffers,
|
||||
takeoffer,
|
||||
confirmpaymentstarted,
|
||||
confirmpaymentreceived,
|
||||
createpaymentacct,
|
||||
getpaymentaccts,
|
||||
getversion,
|
||||
|
@ -285,6 +287,18 @@ public class CliMain {
|
|||
out.printf("trade '%s' payment started message sent", tradeId);
|
||||
return;
|
||||
}
|
||||
case confirmpaymentreceived: {
|
||||
if (nonOptionArgs.size() < 2)
|
||||
throw new IllegalArgumentException("incorrect parameter count, expecting trade id");
|
||||
|
||||
var tradeId = nonOptionArgs.get(1);
|
||||
var request = ConfirmPaymentReceivedRequest.newBuilder()
|
||||
.setTradeId(tradeId)
|
||||
.build();
|
||||
tradesService.confirmPaymentReceived(request);
|
||||
out.printf("trade '%s' payment received message sent", tradeId);
|
||||
return;
|
||||
}
|
||||
case createpaymentacct: {
|
||||
if (nonOptionArgs.size() < 5)
|
||||
throw new IllegalArgumentException(
|
||||
|
@ -414,6 +428,7 @@ public class CliMain {
|
|||
stream.format(rowFormat, "getoffers", "buy | sell, currency code", "Get current offers");
|
||||
stream.format(rowFormat, "takeoffer", "offer id", "Take offer with id");
|
||||
stream.format(rowFormat, "confirmpaymentstarted", "trade id", "Confirm payment started");
|
||||
stream.format(rowFormat, "confirmpaymentreceived", "trade id", "Confirm payment received");
|
||||
stream.format(rowFormat, "createpaymentacct", "account name, account number, currency code", "Create PerfectMoney dummy account");
|
||||
stream.format(rowFormat, "getpaymentaccts", "", "Get user payment accounts");
|
||||
stream.format(rowFormat, "lockwallet", "", "Remove wallet password from memory, locking the wallet");
|
||||
|
|
|
@ -185,6 +185,10 @@ public class CoreApi {
|
|||
coreTradesService.confirmPaymentStarted(tradeId);
|
||||
}
|
||||
|
||||
public void confirmPaymentReceived(String tradeId) {
|
||||
coreTradesService.confirmPaymentReceived(tradeId);
|
||||
}
|
||||
|
||||
public Trade getTrade(String tradeId) {
|
||||
return coreTradesService.getTrade(tradeId);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import bisq.core.offer.takeoffer.TakeOfferModel;
|
|||
import bisq.core.trade.Trade;
|
||||
import bisq.core.trade.TradeManager;
|
||||
import bisq.core.trade.protocol.BuyerProtocol;
|
||||
import bisq.core.trade.protocol.SellerProtocol;
|
||||
import bisq.core.user.User;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -96,6 +97,22 @@ class CoreTradesService {
|
|||
}
|
||||
}
|
||||
|
||||
void confirmPaymentReceived(String tradeId) {
|
||||
var trade = getTradeWithId(tradeId);
|
||||
if (isFollowingBuyerProtocol(trade)) {
|
||||
throw new IllegalStateException("you are the buyer, and not receiving payment");
|
||||
} else {
|
||||
var tradeProtocol = tradeManager.getTradeProtocol(trade);
|
||||
((SellerProtocol) tradeProtocol).onPaymentReceived(
|
||||
() -> {
|
||||
},
|
||||
errorMessage -> {
|
||||
throw new IllegalStateException(errorMessage);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Trade getTrade(String tradeId) {
|
||||
return getTradeWithId(tradeId);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import bisq.core.api.CoreApi;
|
|||
import bisq.core.api.model.TradeInfo;
|
||||
import bisq.core.trade.Trade;
|
||||
|
||||
import bisq.proto.grpc.ConfirmPaymentReceivedReply;
|
||||
import bisq.proto.grpc.ConfirmPaymentReceivedRequest;
|
||||
import bisq.proto.grpc.ConfirmPaymentStartedReply;
|
||||
import bisq.proto.grpc.ConfirmPaymentStartedRequest;
|
||||
import bisq.proto.grpc.GetTradeReply;
|
||||
|
@ -101,4 +103,19 @@ class GrpcTradesService extends TradesGrpc.TradesImplBase {
|
|||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirmPaymentReceived(ConfirmPaymentReceivedRequest req,
|
||||
StreamObserver<ConfirmPaymentReceivedReply> responseObserver) {
|
||||
try {
|
||||
coreApi.confirmPaymentReceived(req.getTradeId());
|
||||
var reply = ConfirmPaymentReceivedReply.newBuilder().build();
|
||||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (IllegalStateException | IllegalArgumentException cause) {
|
||||
var ex = new StatusRuntimeException(Status.UNKNOWN.withDescription(cause.getMessage()));
|
||||
responseObserver.onError(ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue