mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-10-01 01:35:48 -04:00
support deleting payment accounts #1136
This commit is contained in:
parent
0a469db8f6
commit
9c359b5e29
@ -496,6 +496,10 @@ public class CoreApi {
|
||||
tradeInstant);
|
||||
}
|
||||
|
||||
public void deletePaymentAccount(String paymentAccountId) {
|
||||
paymentAccountsService.deletePaymentAccount(paymentAccountId);
|
||||
}
|
||||
|
||||
public List<PaymentMethod> getCryptoCurrencyPaymentMethods() {
|
||||
return paymentAccountsService.getCryptoCurrencyPaymentMethods();
|
||||
}
|
||||
|
@ -145,6 +145,16 @@ class CorePaymentAccountsService {
|
||||
return cryptoCurrencyAccount;
|
||||
}
|
||||
|
||||
synchronized void deletePaymentAccount(String paymentAccountId) {
|
||||
accountService.checkAccountOpen();
|
||||
PaymentAccount paymentAccount = getPaymentAccount(paymentAccountId);
|
||||
if (paymentAccount == null) throw new IllegalArgumentException(format("Payment account with id %s not found", paymentAccountId));
|
||||
user.removePaymentAccount(paymentAccount);
|
||||
log.info("Deleted payment account with id {} and payment method {}.",
|
||||
paymentAccount.getId(),
|
||||
paymentAccount.getPaymentAccountPayload().getPaymentMethodId());
|
||||
}
|
||||
|
||||
// TODO Support all alt coin payment methods supported by UI.
|
||||
// The getCryptoCurrencyPaymentMethods method below will be
|
||||
// callable from the CLI when more are supported.
|
||||
|
@ -34,6 +34,8 @@ import haveno.proto.grpc.CreateCryptoCurrencyPaymentAccountReply;
|
||||
import haveno.proto.grpc.CreateCryptoCurrencyPaymentAccountRequest;
|
||||
import haveno.proto.grpc.CreatePaymentAccountReply;
|
||||
import haveno.proto.grpc.CreatePaymentAccountRequest;
|
||||
import haveno.proto.grpc.DeletePaymentAccountReply;
|
||||
import haveno.proto.grpc.DeletePaymentAccountRequest;
|
||||
import haveno.proto.grpc.GetCryptoCurrencyPaymentMethodsReply;
|
||||
import haveno.proto.grpc.GetCryptoCurrencyPaymentMethodsRequest;
|
||||
import haveno.proto.grpc.GetPaymentAccountFormReply;
|
||||
@ -160,6 +162,19 @@ class GrpcPaymentAccountsService extends PaymentAccountsImplBase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePaymentAccount(DeletePaymentAccountRequest req,
|
||||
StreamObserver<DeletePaymentAccountReply> responseObserver) {
|
||||
try {
|
||||
coreApi.deletePaymentAccount(req.getPaymentAccountId());
|
||||
var reply = DeletePaymentAccountReply.newBuilder().build();
|
||||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCryptoCurrencyPaymentMethods(GetCryptoCurrencyPaymentMethodsRequest req,
|
||||
StreamObserver<GetCryptoCurrencyPaymentMethodsReply> responseObserver) {
|
||||
|
@ -586,6 +586,8 @@ service PaymentAccounts {
|
||||
}
|
||||
rpc CreateCryptoCurrencyPaymentAccount (CreateCryptoCurrencyPaymentAccountRequest) returns (CreateCryptoCurrencyPaymentAccountReply) {
|
||||
}
|
||||
rpc DeletePaymentAccount (DeletePaymentAccountRequest) returns (DeletePaymentAccountReply) {
|
||||
}
|
||||
rpc GetCryptoCurrencyPaymentMethods (GetCryptoCurrencyPaymentMethodsRequest) returns (GetCryptoCurrencyPaymentMethodsReply) {
|
||||
}
|
||||
rpc ValidateFormField (ValidateFormFieldRequest) returns (ValidateFormFieldReply) {
|
||||
@ -639,6 +641,13 @@ message CreateCryptoCurrencyPaymentAccountRequest {
|
||||
bool trade_instant = 4;
|
||||
}
|
||||
|
||||
message DeletePaymentAccountRequest {
|
||||
string payment_account_id = 1;
|
||||
}
|
||||
|
||||
message DeletePaymentAccountReply {
|
||||
}
|
||||
|
||||
message CreateCryptoCurrencyPaymentAccountReply {
|
||||
PaymentAccount payment_account = 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user