mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 15:00:30 +01:00
Merge pull request #4709 from ghubstan/9-closetrade-protos
Stub out api methods 'keepfunds', 'withdrawfunds'
This commit is contained in:
commit
c4e2021e37
5 changed files with 103 additions and 0 deletions
|
@ -29,12 +29,14 @@ import bisq.proto.grpc.GetOffersRequest;
|
||||||
import bisq.proto.grpc.GetPaymentAccountsRequest;
|
import bisq.proto.grpc.GetPaymentAccountsRequest;
|
||||||
import bisq.proto.grpc.GetTradeRequest;
|
import bisq.proto.grpc.GetTradeRequest;
|
||||||
import bisq.proto.grpc.GetVersionRequest;
|
import bisq.proto.grpc.GetVersionRequest;
|
||||||
|
import bisq.proto.grpc.KeepFundsRequest;
|
||||||
import bisq.proto.grpc.LockWalletRequest;
|
import bisq.proto.grpc.LockWalletRequest;
|
||||||
import bisq.proto.grpc.RegisterDisputeAgentRequest;
|
import bisq.proto.grpc.RegisterDisputeAgentRequest;
|
||||||
import bisq.proto.grpc.RemoveWalletPasswordRequest;
|
import bisq.proto.grpc.RemoveWalletPasswordRequest;
|
||||||
import bisq.proto.grpc.SetWalletPasswordRequest;
|
import bisq.proto.grpc.SetWalletPasswordRequest;
|
||||||
import bisq.proto.grpc.TakeOfferRequest;
|
import bisq.proto.grpc.TakeOfferRequest;
|
||||||
import bisq.proto.grpc.UnlockWalletRequest;
|
import bisq.proto.grpc.UnlockWalletRequest;
|
||||||
|
import bisq.proto.grpc.WithdrawFundsRequest;
|
||||||
|
|
||||||
import io.grpc.StatusRuntimeException;
|
import io.grpc.StatusRuntimeException;
|
||||||
|
|
||||||
|
@ -78,6 +80,8 @@ public class CliMain {
|
||||||
gettrade,
|
gettrade,
|
||||||
confirmpaymentstarted,
|
confirmpaymentstarted,
|
||||||
confirmpaymentreceived,
|
confirmpaymentreceived,
|
||||||
|
keepfunds,
|
||||||
|
withdrawfunds,
|
||||||
createpaymentacct,
|
createpaymentacct,
|
||||||
getpaymentaccts,
|
getpaymentaccts,
|
||||||
getversion,
|
getversion,
|
||||||
|
@ -320,6 +324,32 @@ public class CliMain {
|
||||||
out.printf("trade '%s' payment received message sent", tradeId);
|
out.printf("trade '%s' payment received message sent", tradeId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
case keepfunds: {
|
||||||
|
if (nonOptionArgs.size() < 2)
|
||||||
|
throw new IllegalArgumentException("incorrect parameter count, expecting trade id");
|
||||||
|
|
||||||
|
var tradeId = nonOptionArgs.get(1);
|
||||||
|
var request = KeepFundsRequest.newBuilder()
|
||||||
|
.setTradeId(tradeId)
|
||||||
|
.build();
|
||||||
|
tradesService.keepFunds(request);
|
||||||
|
out.printf("funds from trade '%s' saved in bisq wallet", tradeId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case withdrawfunds: {
|
||||||
|
if (nonOptionArgs.size() < 3)
|
||||||
|
throw new IllegalArgumentException("incorrect parameter count, expecting trade id, bitcoin wallet address");
|
||||||
|
|
||||||
|
var tradeId = nonOptionArgs.get(1);
|
||||||
|
var address = nonOptionArgs.get(2);
|
||||||
|
var request = WithdrawFundsRequest.newBuilder()
|
||||||
|
.setTradeId(tradeId)
|
||||||
|
.setAddress(address)
|
||||||
|
.build();
|
||||||
|
tradesService.withdrawFunds(request);
|
||||||
|
out.printf("funds from trade '%s' sent to btc address '%s'", tradeId, address);
|
||||||
|
return;
|
||||||
|
}
|
||||||
case createpaymentacct: {
|
case createpaymentacct: {
|
||||||
if (nonOptionArgs.size() < 5)
|
if (nonOptionArgs.size() < 5)
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
@ -451,6 +481,8 @@ public class CliMain {
|
||||||
stream.format(rowFormat, "gettrade", "trade id [,showcontract]", "Get trade summary or full contract");
|
stream.format(rowFormat, "gettrade", "trade id [,showcontract]", "Get trade summary or full contract");
|
||||||
stream.format(rowFormat, "confirmpaymentstarted", "trade id", "Confirm payment started");
|
stream.format(rowFormat, "confirmpaymentstarted", "trade id", "Confirm payment started");
|
||||||
stream.format(rowFormat, "confirmpaymentreceived", "trade id", "Confirm payment received");
|
stream.format(rowFormat, "confirmpaymentreceived", "trade id", "Confirm payment received");
|
||||||
|
stream.format(rowFormat, "keepfunds", "trade id", "Keep received funds in Bisq wallet");
|
||||||
|
stream.format(rowFormat, "withdrawfunds", "trade id, bitcoin wallet address", "Withdraw received funds to external wallet address");
|
||||||
stream.format(rowFormat, "createpaymentacct", "account name, account number, currency code", "Create PerfectMoney dummy account");
|
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, "getpaymentaccts", "", "Get user payment accounts");
|
||||||
stream.format(rowFormat, "lockwallet", "", "Remove wallet password from memory, locking the wallet");
|
stream.format(rowFormat, "lockwallet", "", "Remove wallet password from memory, locking the wallet");
|
||||||
|
|
|
@ -189,6 +189,14 @@ public class CoreApi {
|
||||||
coreTradesService.confirmPaymentReceived(tradeId);
|
coreTradesService.confirmPaymentReceived(tradeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void keepFunds(String tradeId) {
|
||||||
|
coreTradesService.keepFunds(tradeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void withdrawFunds(String tradeId, String address) {
|
||||||
|
coreTradesService.withdrawFunds(tradeId, address);
|
||||||
|
}
|
||||||
|
|
||||||
public Trade getTrade(String tradeId) {
|
public Trade getTrade(String tradeId) {
|
||||||
return coreTradesService.getTrade(tradeId);
|
return coreTradesService.getTrade(tradeId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,16 @@ class CoreTradesService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
void keepFunds(String tradeId) {
|
||||||
|
log.info("TODO");
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
void withdrawFunds(String tradeId, String address) {
|
||||||
|
log.info("TODO");
|
||||||
|
}
|
||||||
|
|
||||||
String getTradeRole(String tradeId) {
|
String getTradeRole(String tradeId) {
|
||||||
return tradeUtil.getRole(getTrade(tradeId));
|
return tradeUtil.getRole(getTrade(tradeId));
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,13 @@ import bisq.proto.grpc.ConfirmPaymentStartedReply;
|
||||||
import bisq.proto.grpc.ConfirmPaymentStartedRequest;
|
import bisq.proto.grpc.ConfirmPaymentStartedRequest;
|
||||||
import bisq.proto.grpc.GetTradeReply;
|
import bisq.proto.grpc.GetTradeReply;
|
||||||
import bisq.proto.grpc.GetTradeRequest;
|
import bisq.proto.grpc.GetTradeRequest;
|
||||||
|
import bisq.proto.grpc.KeepFundsReply;
|
||||||
|
import bisq.proto.grpc.KeepFundsRequest;
|
||||||
import bisq.proto.grpc.TakeOfferReply;
|
import bisq.proto.grpc.TakeOfferReply;
|
||||||
import bisq.proto.grpc.TakeOfferRequest;
|
import bisq.proto.grpc.TakeOfferRequest;
|
||||||
import bisq.proto.grpc.TradesGrpc;
|
import bisq.proto.grpc.TradesGrpc;
|
||||||
|
import bisq.proto.grpc.WithdrawFundsReply;
|
||||||
|
import bisq.proto.grpc.WithdrawFundsRequest;
|
||||||
|
|
||||||
import io.grpc.Status;
|
import io.grpc.Status;
|
||||||
import io.grpc.StatusRuntimeException;
|
import io.grpc.StatusRuntimeException;
|
||||||
|
@ -119,4 +123,34 @@ class GrpcTradesService extends TradesGrpc.TradesImplBase {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keepFunds(KeepFundsRequest req,
|
||||||
|
StreamObserver<KeepFundsReply> responseObserver) {
|
||||||
|
try {
|
||||||
|
coreApi.keepFunds(req.getTradeId());
|
||||||
|
var reply = KeepFundsReply.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void withdrawFunds(WithdrawFundsRequest req,
|
||||||
|
StreamObserver<WithdrawFundsReply> responseObserver) {
|
||||||
|
try {
|
||||||
|
coreApi.withdrawFunds(req.getTradeId(), req.getAddress());
|
||||||
|
var reply = WithdrawFundsReply.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,6 +180,10 @@ service Trades {
|
||||||
}
|
}
|
||||||
rpc ConfirmPaymentReceived (ConfirmPaymentReceivedRequest) returns (ConfirmPaymentReceivedReply) {
|
rpc ConfirmPaymentReceived (ConfirmPaymentReceivedRequest) returns (ConfirmPaymentReceivedReply) {
|
||||||
}
|
}
|
||||||
|
rpc KeepFunds (KeepFundsRequest) returns (KeepFundsReply) {
|
||||||
|
}
|
||||||
|
rpc WithdrawFunds (WithdrawFundsRequest) returns (WithdrawFundsReply) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message TakeOfferRequest {
|
message TakeOfferRequest {
|
||||||
|
@ -213,6 +217,21 @@ message GetTradeReply {
|
||||||
TradeInfo trade = 1;
|
TradeInfo trade = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message KeepFundsRequest {
|
||||||
|
string tradeId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message KeepFundsReply {
|
||||||
|
}
|
||||||
|
|
||||||
|
message WithdrawFundsRequest {
|
||||||
|
string tradeId = 1;
|
||||||
|
string address = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message WithdrawFundsReply {
|
||||||
|
}
|
||||||
|
|
||||||
message TradeInfo {
|
message TradeInfo {
|
||||||
OfferInfo offer = 1;
|
OfferInfo offer = 1;
|
||||||
string tradeId = 2;
|
string tradeId = 2;
|
||||||
|
|
Loading…
Add table
Reference in a new issue