mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Stub out api methods 'keepfunds', 'withdrawfunds'
This PR adds trade closing method stubs to keep funds in the Bisq wallet or send them to an external BTC wallet. - Add grpc protos - Add new methods to GrpcTradesService, CoreApi - Stub out implementations in CoreTradesService - Add methods to CLI
This commit is contained in:
parent
a2b292318c
commit
a8decafc2f
@ -29,12 +29,14 @@ import bisq.proto.grpc.GetOffersRequest;
|
||||
import bisq.proto.grpc.GetPaymentAccountsRequest;
|
||||
import bisq.proto.grpc.GetTradeRequest;
|
||||
import bisq.proto.grpc.GetVersionRequest;
|
||||
import bisq.proto.grpc.KeepFundsRequest;
|
||||
import bisq.proto.grpc.LockWalletRequest;
|
||||
import bisq.proto.grpc.RegisterDisputeAgentRequest;
|
||||
import bisq.proto.grpc.RemoveWalletPasswordRequest;
|
||||
import bisq.proto.grpc.SetWalletPasswordRequest;
|
||||
import bisq.proto.grpc.TakeOfferRequest;
|
||||
import bisq.proto.grpc.UnlockWalletRequest;
|
||||
import bisq.proto.grpc.WithdrawFundsRequest;
|
||||
|
||||
import io.grpc.StatusRuntimeException;
|
||||
|
||||
@ -78,6 +80,8 @@ public class CliMain {
|
||||
gettrade,
|
||||
confirmpaymentstarted,
|
||||
confirmpaymentreceived,
|
||||
keepfunds,
|
||||
withdrawfunds,
|
||||
createpaymentacct,
|
||||
getpaymentaccts,
|
||||
getversion,
|
||||
@ -320,6 +324,32 @@ public class CliMain {
|
||||
out.printf("trade '%s' payment received message sent", tradeId);
|
||||
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: {
|
||||
if (nonOptionArgs.size() < 5)
|
||||
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, "confirmpaymentstarted", "trade id", "Confirm payment started");
|
||||
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, "getpaymentaccts", "", "Get user payment accounts");
|
||||
stream.format(rowFormat, "lockwallet", "", "Remove wallet password from memory, locking the wallet");
|
||||
|
@ -189,6 +189,14 @@ public class CoreApi {
|
||||
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) {
|
||||
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) {
|
||||
return tradeUtil.getRole(getTrade(tradeId));
|
||||
}
|
||||
|
@ -27,9 +27,13 @@ import bisq.proto.grpc.ConfirmPaymentStartedReply;
|
||||
import bisq.proto.grpc.ConfirmPaymentStartedRequest;
|
||||
import bisq.proto.grpc.GetTradeReply;
|
||||
import bisq.proto.grpc.GetTradeRequest;
|
||||
import bisq.proto.grpc.KeepFundsReply;
|
||||
import bisq.proto.grpc.KeepFundsRequest;
|
||||
import bisq.proto.grpc.TakeOfferReply;
|
||||
import bisq.proto.grpc.TakeOfferRequest;
|
||||
import bisq.proto.grpc.TradesGrpc;
|
||||
import bisq.proto.grpc.WithdrawFundsReply;
|
||||
import bisq.proto.grpc.WithdrawFundsRequest;
|
||||
|
||||
import io.grpc.Status;
|
||||
import io.grpc.StatusRuntimeException;
|
||||
@ -119,4 +123,34 @@ class GrpcTradesService extends TradesGrpc.TradesImplBase {
|
||||
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 KeepFunds (KeepFundsRequest) returns (KeepFundsReply) {
|
||||
}
|
||||
rpc WithdrawFunds (WithdrawFundsRequest) returns (WithdrawFundsReply) {
|
||||
}
|
||||
}
|
||||
|
||||
message TakeOfferRequest {
|
||||
@ -213,6 +217,21 @@ message GetTradeReply {
|
||||
TradeInfo trade = 1;
|
||||
}
|
||||
|
||||
message KeepFundsRequest {
|
||||
string tradeId = 1;
|
||||
}
|
||||
|
||||
message KeepFundsReply {
|
||||
}
|
||||
|
||||
message WithdrawFundsRequest {
|
||||
string tradeId = 1;
|
||||
string address = 2;
|
||||
}
|
||||
|
||||
message WithdrawFundsReply {
|
||||
}
|
||||
|
||||
message TradeInfo {
|
||||
OfferInfo offer = 1;
|
||||
string tradeId = 2;
|
||||
|
Loading…
Reference in New Issue
Block a user