2021-07-27 14:11:47 +02:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Net.Http;
|
2022-02-02 12:09:08 +01:00
|
|
|
using System.Reflection;
|
2021-07-27 14:11:47 +02:00
|
|
|
using System.Security.Claims;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using BTCPayServer.Abstractions.Contracts;
|
|
|
|
using BTCPayServer.Client;
|
|
|
|
using BTCPayServer.Client.Models;
|
2022-03-11 10:17:40 +01:00
|
|
|
using BTCPayServer.Controllers.GreenField;
|
2021-07-27 14:11:47 +02:00
|
|
|
using BTCPayServer.Data;
|
2022-06-06 15:57:55 +02:00
|
|
|
using BTCPayServer.Security;
|
2022-01-14 05:05:23 +01:00
|
|
|
using BTCPayServer.Security.Greenfield;
|
2022-03-11 10:17:50 +01:00
|
|
|
using BTCPayServer.Services.Mails;
|
2021-07-27 14:11:47 +02:00
|
|
|
using BTCPayServer.Services.Stores;
|
2022-02-02 12:09:08 +01:00
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2021-07-27 14:11:47 +02:00
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2022-02-02 12:09:08 +01:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2021-07-27 14:11:47 +02:00
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
using NBitcoin;
|
2021-07-27 16:53:44 +02:00
|
|
|
using NBXplorer.Models;
|
2022-03-11 10:17:50 +01:00
|
|
|
using Newtonsoft.Json.Linq;
|
2021-07-27 14:11:47 +02:00
|
|
|
using InvoiceData = BTCPayServer.Client.Models.InvoiceData;
|
|
|
|
using Language = BTCPayServer.Client.Models.Language;
|
|
|
|
using NotificationData = BTCPayServer.Client.Models.NotificationData;
|
|
|
|
using PaymentRequestData = BTCPayServer.Client.Models.PaymentRequestData;
|
|
|
|
using PayoutData = BTCPayServer.Client.Models.PayoutData;
|
|
|
|
using PullPaymentData = BTCPayServer.Client.Models.PullPaymentData;
|
|
|
|
using StoreData = BTCPayServer.Client.Models.StoreData;
|
|
|
|
using StoreWebhookData = BTCPayServer.Client.Models.StoreWebhookData;
|
|
|
|
using WebhookDeliveryData = BTCPayServer.Client.Models.WebhookDeliveryData;
|
|
|
|
|
2022-01-14 05:05:23 +01:00
|
|
|
namespace BTCPayServer.Controllers.Greenfield
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
|
|
|
public class BTCPayServerClientFactory : IBTCPayServerClientFactory
|
|
|
|
{
|
|
|
|
private readonly StoreRepository _storeRepository;
|
|
|
|
private readonly IOptionsMonitor<IdentityOptions> _identityOptions;
|
|
|
|
private readonly UserManager<ApplicationUser> _userManager;
|
2022-06-27 03:14:16 +02:00
|
|
|
|
2022-02-02 12:09:08 +01:00
|
|
|
private readonly IServiceProvider _serviceProvider;
|
2021-07-27 14:11:47 +02:00
|
|
|
|
2022-07-19 19:53:14 +02:00
|
|
|
public BTCPayServerClientFactory(
|
|
|
|
StoreRepository storeRepository,
|
2021-07-27 14:11:47 +02:00
|
|
|
IOptionsMonitor<IdentityOptions> identityOptions,
|
|
|
|
UserManager<ApplicationUser> userManager,
|
2022-02-02 12:09:08 +01:00
|
|
|
IServiceProvider serviceProvider)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
|
|
|
_storeRepository = storeRepository;
|
|
|
|
_identityOptions = identityOptions;
|
|
|
|
_userManager = userManager;
|
2022-02-02 12:09:08 +01:00
|
|
|
_serviceProvider = serviceProvider;
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
2022-03-30 15:04:51 +02:00
|
|
|
public Task<BTCPayServerClient> Create(string userId, params string[] storeIds)
|
|
|
|
{
|
|
|
|
return Create(userId, storeIds, new DefaultHttpContext()
|
|
|
|
{
|
|
|
|
Request =
|
|
|
|
{
|
|
|
|
Scheme = "https",
|
|
|
|
Host = new HostString("dummy.com"),
|
|
|
|
Path = new PathString(),
|
|
|
|
PathBase = new PathString(),
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<BTCPayServerClient> Create(string userId, string[] storeIds, HttpContext context)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(userId))
|
|
|
|
{
|
|
|
|
var user = await _userManager.FindByIdAsync(userId);
|
|
|
|
List<Claim> claims = new List<Claim>
|
|
|
|
{
|
|
|
|
new Claim(_identityOptions.CurrentValue.ClaimsIdentity.UserIdClaimType, userId),
|
2022-01-14 05:05:23 +01:00
|
|
|
new Claim(GreenfieldConstants.ClaimTypes.Permission,
|
2021-07-27 14:11:47 +02:00
|
|
|
Permission.Create(Policies.Unrestricted).ToString())
|
|
|
|
};
|
|
|
|
claims.AddRange((await _userManager.GetRolesAsync(user)).Select(s =>
|
|
|
|
new Claim(_identityOptions.CurrentValue.ClaimsIdentity.RoleClaimType, s)));
|
|
|
|
context.User =
|
2022-03-11 10:17:50 +01:00
|
|
|
new ClaimsPrincipal(new ClaimsIdentity(claims,
|
|
|
|
$"Local{GreenfieldConstants.AuthenticationType}WithUser"));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
context.User =
|
2022-08-04 04:38:49 +02:00
|
|
|
new ClaimsPrincipal(new ClaimsIdentity(
|
|
|
|
new List<Claim>()
|
2022-07-01 09:03:32 +02:00
|
|
|
{
|
|
|
|
new(_identityOptions.CurrentValue.ClaimsIdentity.RoleClaimType, Roles.ServerAdmin)
|
|
|
|
},
|
2022-03-11 10:17:50 +01:00
|
|
|
$"Local{GreenfieldConstants.AuthenticationType}"));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (storeIds?.Any() is true)
|
|
|
|
{
|
|
|
|
context.SetStoreData(await _storeRepository.FindStore(storeIds.First()));
|
|
|
|
context.SetStoresData(await _storeRepository.GetStoresByUserId(userId, storeIds));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
context.SetStoresData(await _storeRepository.GetStoresByUserId(userId));
|
|
|
|
}
|
|
|
|
|
2022-07-19 19:53:14 +02:00
|
|
|
return ActivatorUtilities.CreateInstance<LocalBTCPayServerClient>(_serviceProvider,
|
|
|
|
new LocalHttpContextAccessor() {HttpContext = context});
|
|
|
|
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
}
|
2022-07-19 19:53:14 +02:00
|
|
|
|
2021-07-27 14:11:47 +02:00
|
|
|
|
2022-03-11 10:17:50 +01:00
|
|
|
public class LocalHttpContextAccessor : IHttpContextAccessor
|
2022-02-21 11:48:40 +01:00
|
|
|
{
|
2022-04-24 05:19:34 +02:00
|
|
|
public HttpContext HttpContext { get; set; }
|
2022-03-11 10:17:50 +01:00
|
|
|
}
|
2022-02-21 11:48:40 +01:00
|
|
|
|
2021-07-27 14:11:47 +02:00
|
|
|
public class LocalBTCPayServerClient : BTCPayServerClient
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
|
2022-06-27 03:14:16 +02:00
|
|
|
|
2022-02-02 12:09:08 +01:00
|
|
|
public LocalBTCPayServerClient(
|
2022-07-19 19:53:14 +02:00
|
|
|
IHttpContextAccessor httpContextAccessor,
|
|
|
|
IServiceProvider serviceProvider) : base(new Uri("https://dummy.local"), "", "")
|
|
|
|
{
|
|
|
|
_httpContextAccessor = httpContextAccessor;
|
|
|
|
_serviceProvider = serviceProvider;
|
|
|
|
}
|
2022-08-02 07:20:16 +02:00
|
|
|
|
2022-07-19 19:53:14 +02:00
|
|
|
private T GetController<T>() where T : ControllerBase
|
|
|
|
{
|
|
|
|
var authoverride = new AuthorizationService(new GreenfieldAuthorizationHandler(_httpContextAccessor,
|
|
|
|
_serviceProvider.GetService<UserManager<ApplicationUser>>(),
|
2022-08-02 07:20:16 +02:00
|
|
|
_serviceProvider.GetService<StoreRepository>(),
|
|
|
|
_serviceProvider.GetService<IPluginHookService>()));
|
2022-02-02 12:09:08 +01:00
|
|
|
|
2022-07-19 19:53:14 +02:00
|
|
|
var controller = _serviceProvider.GetService<T>();
|
|
|
|
controller.ControllerContext.HttpContext = _httpContextAccessor.HttpContext;
|
|
|
|
var authInterface = typeof(IAuthorizationService);
|
|
|
|
var type = controller.GetType();
|
|
|
|
do
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
foreach (FieldInfo fieldInfo in type.GetFields(BindingFlags.FlattenHierarchy |
|
|
|
|
BindingFlags.Instance |
|
|
|
|
BindingFlags.NonPublic |
|
|
|
|
BindingFlags.Public |
|
|
|
|
BindingFlags.Static)
|
|
|
|
.Where(info =>
|
|
|
|
authInterface == info.FieldType || authInterface.IsAssignableFrom(info.FieldType)))
|
2022-02-02 12:09:08 +01:00
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
fieldInfo.SetValue(controller, authoverride);
|
|
|
|
}
|
2022-06-06 15:57:55 +02:00
|
|
|
|
2022-07-19 19:53:14 +02:00
|
|
|
type = type.BaseType;
|
|
|
|
} while (type is not null);
|
|
|
|
|
|
|
|
return controller;
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
2022-06-06 15:57:55 +02:00
|
|
|
class AuthorizationService : IAuthorizationService
|
2022-02-02 12:09:08 +01:00
|
|
|
{
|
2022-06-06 15:57:55 +02:00
|
|
|
private readonly GreenfieldAuthorizationHandler _greenfieldAuthorizationHandler;
|
2022-02-02 12:09:08 +01:00
|
|
|
|
2022-06-06 15:57:55 +02:00
|
|
|
public AuthorizationService(GreenfieldAuthorizationHandler greenfieldAuthorizationHandler)
|
|
|
|
{
|
|
|
|
_greenfieldAuthorizationHandler = greenfieldAuthorizationHandler;
|
|
|
|
}
|
2022-02-02 12:09:08 +01:00
|
|
|
|
2022-06-06 15:57:55 +02:00
|
|
|
public async Task<AuthorizationResult> AuthorizeAsync(ClaimsPrincipal user, object resource,
|
|
|
|
IEnumerable<IAuthorizationRequirement> requirements)
|
2022-02-02 12:09:08 +01:00
|
|
|
{
|
2022-06-06 15:57:55 +02:00
|
|
|
var withuser = user.Identity?.AuthenticationType ==
|
|
|
|
$"Local{GreenfieldConstants.AuthenticationType}WithUser";
|
|
|
|
if (withuser)
|
|
|
|
{
|
|
|
|
var newUser = new ClaimsPrincipal(new ClaimsIdentity(user.Claims,
|
|
|
|
$"{GreenfieldConstants.AuthenticationType}"));
|
|
|
|
var newContext = new AuthorizationHandlerContext(requirements, newUser, resource);
|
|
|
|
await _greenfieldAuthorizationHandler.HandleAsync(newContext);
|
|
|
|
if (newContext.HasSucceeded)
|
|
|
|
{
|
|
|
|
return AuthorizationResult.Success();
|
|
|
|
}
|
|
|
|
|
|
|
|
return AuthorizationResult.Failed();
|
|
|
|
}
|
|
|
|
|
|
|
|
var succeed = user.Identity.AuthenticationType == $"Local{GreenfieldConstants.AuthenticationType}";
|
|
|
|
|
|
|
|
if (succeed)
|
|
|
|
{
|
|
|
|
return AuthorizationResult.Success();
|
|
|
|
}
|
|
|
|
|
|
|
|
return AuthorizationResult.Failed();
|
2022-02-02 12:09:08 +01:00
|
|
|
}
|
2022-03-11 10:17:50 +01:00
|
|
|
|
2022-06-06 15:57:55 +02:00
|
|
|
public Task<AuthorizationResult> AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName)
|
2022-02-02 12:09:08 +01:00
|
|
|
{
|
2022-06-06 15:57:55 +02:00
|
|
|
return AuthorizeAsync(user, resource,
|
2022-08-04 04:38:49 +02:00
|
|
|
new List<IAuthorizationRequirement>(new[] { new PolicyRequirement(policyName) }));
|
2022-02-02 12:09:08 +01:00
|
|
|
}
|
|
|
|
}
|
2022-03-11 10:17:50 +01:00
|
|
|
|
2021-07-27 14:11:47 +02:00
|
|
|
protected override HttpRequestMessage CreateHttpRequest(string path,
|
|
|
|
Dictionary<string, object> queryPayload = null, HttpMethod method = null)
|
|
|
|
{
|
|
|
|
throw new NotSupportedException("This method is not supported by the LocalBTCPayServerClient.");
|
|
|
|
}
|
|
|
|
|
2022-08-04 04:38:49 +02:00
|
|
|
public override async Task<MarketTradeResponseData> MarketTradeCustodianAccountAsset(string storeId, string accountId,
|
|
|
|
TradeRequestData request, CancellationToken cancellationToken = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<MarketTradeResponseData>(
|
|
|
|
await GetController<GreenfieldCustodianAccountController>().MarketTradeCustodianAccountAsset(storeId, accountId, request, cancellationToken));
|
|
|
|
}
|
|
|
|
|
2022-11-18 16:04:46 +01:00
|
|
|
public override async Task<OnChainWalletObjectData[]> GetOnChainWalletObjects(string storeId, string cryptoCode,
|
|
|
|
GetWalletObjectsRequest query = null,
|
2022-11-16 04:11:17 +01:00
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<OnChainWalletObjectData[]>(
|
2022-11-18 16:04:46 +01:00
|
|
|
await GetController<GreenfieldStoreOnChainWalletsController>().GetOnChainWalletObjects(storeId, cryptoCode, query?.Type, query?.Ids, query?.IncludeNeighbourData));
|
2022-11-16 04:11:17 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 16:04:46 +01:00
|
|
|
public override async Task<OnChainWalletObjectData> GetOnChainWalletObject(string storeId, string cryptoCode, OnChainWalletObjectId objectId, bool? includeNeighbourData = null, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<OnChainWalletObjectData>(
|
|
|
|
await GetController<GreenfieldStoreOnChainWalletsController>().GetOnChainWalletObject(storeId, cryptoCode, objectId.Type, objectId.Id, includeNeighbourData));
|
|
|
|
}
|
|
|
|
public override async Task<OnChainWalletObjectData> AddOrUpdateOnChainWalletObject(string storeId, string cryptoCode, AddOnChainWalletObjectRequest request, CancellationToken token = default)
|
2022-11-16 04:11:17 +01:00
|
|
|
{
|
2022-11-18 16:04:46 +01:00
|
|
|
return GetFromActionResult<OnChainWalletObjectData>(
|
|
|
|
await GetController<GreenfieldStoreOnChainWalletsController>().AddOrUpdateOnChainWalletObject(storeId, cryptoCode, request));
|
2022-11-16 04:11:17 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 16:04:46 +01:00
|
|
|
public override async Task RemoveOnChainWalletLinks(string storeId, string cryptoCode, OnChainWalletObjectId objectId, OnChainWalletObjectId link, CancellationToken token = default)
|
2022-11-16 04:11:17 +01:00
|
|
|
{
|
2022-11-18 16:04:46 +01:00
|
|
|
HandleActionResult(await GetController<GreenfieldStoreOnChainWalletsController>().RemoveOnChainWalletLink(storeId, cryptoCode, objectId.Type, objectId.Id, link.Type, link.Id));
|
2022-11-16 04:11:17 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 16:04:46 +01:00
|
|
|
public override async Task RemoveOnChainWalletObject(string storeId, string cryptoCode, OnChainWalletObjectId objectId, CancellationToken token = default)
|
2022-11-16 04:11:17 +01:00
|
|
|
{
|
2022-11-18 16:04:46 +01:00
|
|
|
HandleActionResult(await GetController<GreenfieldStoreOnChainWalletsController>().RemoveOnChainWalletObject(storeId, cryptoCode, objectId.Type, objectId.Id));
|
2022-11-16 04:11:17 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 16:04:46 +01:00
|
|
|
public override async Task AddOrUpdateOnChainWalletLink(string storeId, string cryptoCode, OnChainWalletObjectId objectId, AddOnChainWalletObjectLinkRequest request = null, CancellationToken token = default)
|
2022-11-16 04:11:17 +01:00
|
|
|
{
|
2022-11-18 16:04:46 +01:00
|
|
|
HandleActionResult(await GetController<GreenfieldStoreOnChainWalletsController>().AddOrUpdateOnChainWalletLinks(storeId, cryptoCode, objectId.Type, objectId.Id, request));
|
2022-11-16 04:11:17 +01:00
|
|
|
}
|
|
|
|
|
2021-07-27 14:11:47 +02:00
|
|
|
public override async Task<StoreWebhookData> CreateWebhook(string storeId, CreateStoreWebhookRequest create,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<StoreWebhookData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreWebhooksController>().CreateWebhook(storeId, create));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<StoreWebhookData> GetWebhook(string storeId, string webhookId,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<StoreWebhookData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreWebhooksController>().ListWebhooks(storeId, webhookId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<StoreWebhookData> UpdateWebhook(string storeId, string webhookId,
|
|
|
|
UpdateStoreWebhookRequest update,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<StoreWebhookData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreWebhooksController>().UpdateWebhook(storeId, webhookId, update));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<bool> DeleteWebhook(string storeId, string webhookId,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldStoreWebhooksController>().DeleteWebhook(storeId, webhookId));
|
2021-07-27 14:11:47 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<StoreWebhookData[]> GetWebhooks(string storeId, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<StoreWebhookData[]>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreWebhooksController>().ListWebhooks(storeId, null));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<WebhookDeliveryData[]> GetWebhookDeliveries(string storeId, string webhookId,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<WebhookDeliveryData[]>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreWebhooksController>().ListDeliveries(storeId, webhookId, null));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<WebhookDeliveryData> GetWebhookDelivery(string storeId, string webhookId,
|
|
|
|
string deliveryId, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<WebhookDeliveryData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreWebhooksController>().ListDeliveries(storeId, webhookId, deliveryId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<string> RedeliverWebhook(string storeId, string webhookId, string deliveryId,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<string>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreWebhooksController>().RedeliverWebhook(storeId, webhookId, deliveryId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<WebhookEvent> GetWebhookDeliveryRequest(string storeId, string webhookId,
|
|
|
|
string deliveryId, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<WebhookEvent>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreWebhooksController>().GetDeliveryRequest(storeId, webhookId, deliveryId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<PullPaymentData> CreatePullPayment(string storeId, CreatePullPaymentRequest request,
|
|
|
|
CancellationToken cancellationToken = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<PullPaymentData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldPullPaymentController>().CreatePullPayment(storeId, request));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<PullPaymentData> GetPullPayment(string pullPaymentId,
|
|
|
|
CancellationToken cancellationToken = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<PullPaymentData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldPullPaymentController>().GetPullPayment(pullPaymentId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<PullPaymentData[]> GetPullPayments(string storeId, bool includeArchived = false,
|
|
|
|
CancellationToken cancellationToken = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<PullPaymentData[]>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldPullPaymentController>().GetPullPayments(storeId, includeArchived));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task ArchivePullPayment(string storeId, string pullPaymentId,
|
|
|
|
CancellationToken cancellationToken = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldPullPaymentController>().ArchivePullPayment(storeId, pullPaymentId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<PayoutData[]> GetPayouts(string pullPaymentId, bool includeCancelled = false,
|
|
|
|
CancellationToken cancellationToken = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<PayoutData[]>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldPullPaymentController>().GetPayouts(pullPaymentId, includeCancelled));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<PayoutData> CreatePayout(string pullPaymentId, CreatePayoutRequest payoutRequest,
|
|
|
|
CancellationToken cancellationToken = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<PayoutData>(
|
2022-11-22 12:17:29 +01:00
|
|
|
await GetController<GreenfieldPullPaymentController>().CreatePayout(pullPaymentId, payoutRequest, cancellationToken));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task CancelPayout(string storeId, string payoutId,
|
|
|
|
CancellationToken cancellationToken = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldPullPaymentController>().CancelPayout(storeId, payoutId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<PayoutData> ApprovePayout(string storeId, string payoutId,
|
2022-04-26 03:29:20 +02:00
|
|
|
ApprovePayoutRequest request, CancellationToken cancellationToken = default)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
|
|
|
return GetFromActionResult<PayoutData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldPullPaymentController>().ApprovePayout(storeId, payoutId, request, cancellationToken));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<LightningNodeInformationData> GetLightningNodeInfo(string storeId, string cryptoCode,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<LightningNodeInformationData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreLightningNodeApiController>().GetInfo(cryptoCode, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
2022-06-23 06:42:28 +02:00
|
|
|
public override async Task<LightningNodeBalanceData> GetLightningNodeBalance(string storeId, string cryptoCode,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<LightningNodeBalanceData>(
|
2022-10-17 09:51:15 +02:00
|
|
|
await GetController<GreenfieldStoreLightningNodeApiController>().GetBalance(cryptoCode, token));
|
2022-06-23 06:42:28 +02:00
|
|
|
}
|
|
|
|
|
2021-07-27 14:11:47 +02:00
|
|
|
public override async Task ConnectToLightningNode(string storeId, string cryptoCode,
|
2022-04-26 03:29:20 +02:00
|
|
|
ConnectToNodeRequest request, CancellationToken token = default)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldStoreLightningNodeApiController>().ConnectToNode(cryptoCode, request, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<IEnumerable<LightningChannelData>> GetLightningNodeChannels(string storeId,
|
|
|
|
string cryptoCode, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<IEnumerable<LightningChannelData>>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreLightningNodeApiController>().GetChannels(cryptoCode, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task OpenLightningChannel(string storeId, string cryptoCode,
|
|
|
|
OpenLightningChannelRequest request,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldStoreLightningNodeApiController>().OpenChannel(cryptoCode, request, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<string> GetLightningDepositAddress(string storeId, string cryptoCode,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<string>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreLightningNodeApiController>().GetDepositAddress(cryptoCode, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
2022-10-27 01:56:24 +02:00
|
|
|
public override async Task<LightningPaymentData> PayLightningInvoice(string storeId, string cryptoCode,
|
2022-04-26 03:29:20 +02:00
|
|
|
PayLightningInvoiceRequest request, CancellationToken token = default)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
2022-10-27 01:56:24 +02:00
|
|
|
return GetFromActionResult<LightningPaymentData>(
|
|
|
|
await GetController<GreenfieldStoreLightningNodeApiController>().PayInvoice(cryptoCode, request, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<LightningInvoiceData> GetLightningInvoice(string storeId, string cryptoCode,
|
|
|
|
string invoiceId, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<LightningInvoiceData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreLightningNodeApiController>().GetInvoice(cryptoCode, invoiceId, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
2022-10-17 09:51:15 +02:00
|
|
|
public override async Task<LightningInvoiceData[]> GetLightningInvoices(string storeId, string cryptoCode,
|
|
|
|
bool? pendingOnly = null, long? offsetIndex = null, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<LightningInvoiceData[]>(
|
|
|
|
await GetController<GreenfieldStoreLightningNodeApiController>().GetInvoices(cryptoCode, pendingOnly, offsetIndex, token));
|
|
|
|
}
|
|
|
|
|
2021-07-27 14:11:47 +02:00
|
|
|
public override async Task<LightningInvoiceData> CreateLightningInvoice(string storeId, string cryptoCode,
|
2022-04-26 03:29:20 +02:00
|
|
|
CreateLightningInvoiceRequest request, CancellationToken token = default)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
|
|
|
return GetFromActionResult<LightningInvoiceData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreLightningNodeApiController>().CreateInvoice(cryptoCode, request, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<LightningNodeInformationData> GetLightningNodeInfo(string cryptoCode,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<LightningNodeInformationData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldInternalLightningNodeApiController>().GetInfo(cryptoCode));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
2022-06-23 06:42:28 +02:00
|
|
|
public override async Task<LightningNodeBalanceData> GetLightningNodeBalance(string cryptoCode,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<LightningNodeBalanceData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldInternalLightningNodeApiController>().GetBalance(cryptoCode));
|
2022-06-23 06:42:28 +02:00
|
|
|
}
|
|
|
|
|
2021-07-27 14:11:47 +02:00
|
|
|
public override async Task ConnectToLightningNode(string cryptoCode, ConnectToNodeRequest request,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldInternalLightningNodeApiController>().ConnectToNode(cryptoCode, request, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<IEnumerable<LightningChannelData>> GetLightningNodeChannels(string cryptoCode,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<IEnumerable<LightningChannelData>>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldInternalLightningNodeApiController>().GetChannels(cryptoCode, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task OpenLightningChannel(string cryptoCode, OpenLightningChannelRequest request,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldInternalLightningNodeApiController>().OpenChannel(cryptoCode, request, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<string> GetLightningDepositAddress(string cryptoCode,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<string>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldInternalLightningNodeApiController>().GetDepositAddress(cryptoCode, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
2022-03-11 10:17:50 +01:00
|
|
|
public override async Task<LightningPaymentData> PayLightningInvoice(string cryptoCode,
|
2022-04-26 03:29:20 +02:00
|
|
|
PayLightningInvoiceRequest request, CancellationToken token = default)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
2022-02-17 10:01:39 +01:00
|
|
|
return GetFromActionResult<LightningPaymentData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldInternalLightningNodeApiController>().PayInvoice(cryptoCode, request, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<LightningInvoiceData> GetLightningInvoice(string cryptoCode, string invoiceId,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<LightningInvoiceData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldInternalLightningNodeApiController>().GetInvoice(cryptoCode, invoiceId, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
2022-10-17 09:51:15 +02:00
|
|
|
public override async Task<LightningInvoiceData[]> GetLightningInvoices(string cryptoCode,
|
|
|
|
bool? pendingOnly = null, long? offsetIndex = null, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<LightningInvoiceData[]>(
|
|
|
|
await GetController<GreenfieldInternalLightningNodeApiController>().GetInvoices(cryptoCode, pendingOnly, offsetIndex, token));
|
|
|
|
}
|
|
|
|
|
2021-07-27 14:11:47 +02:00
|
|
|
public override async Task<LightningInvoiceData> CreateLightningInvoice(string cryptoCode,
|
|
|
|
CreateLightningInvoiceRequest request,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<LightningInvoiceData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldInternalLightningNodeApiController>().CreateInvoice(cryptoCode, request, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private T GetFromActionResult<T>(IActionResult result)
|
|
|
|
{
|
|
|
|
HandleActionResult(result);
|
2022-04-26 03:29:20 +02:00
|
|
|
return result switch
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
2022-04-26 03:29:20 +02:00
|
|
|
JsonResult jsonResult => (T)jsonResult.Value,
|
2022-08-04 04:38:49 +02:00
|
|
|
OkObjectResult { Value: T res } => res,
|
|
|
|
OkObjectResult { Value: JValue res } => res.Value<T>(),
|
2022-04-26 03:29:20 +02:00
|
|
|
_ => default
|
|
|
|
};
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void HandleActionResult(IActionResult result)
|
|
|
|
{
|
|
|
|
switch (result)
|
|
|
|
{
|
2022-08-04 04:38:49 +02:00
|
|
|
case UnprocessableEntityObjectResult { Value: List<GreenfieldValidationError> validationErrors }:
|
2022-01-14 05:05:23 +01:00
|
|
|
throw new GreenfieldValidationException(validationErrors.ToArray());
|
2022-08-04 04:38:49 +02:00
|
|
|
case BadRequestObjectResult { Value: GreenfieldAPIError error }:
|
|
|
|
throw new GreenfieldAPIException(400, error);
|
|
|
|
case ObjectResult { Value: GreenfieldAPIError error }:
|
2022-01-14 05:05:23 +01:00
|
|
|
throw new GreenfieldAPIException(400, error);
|
2021-07-27 14:11:47 +02:00
|
|
|
case NotFoundResult _:
|
2022-01-14 05:05:23 +01:00
|
|
|
throw new GreenfieldAPIException(404, new GreenfieldAPIError("not-found", ""));
|
2021-07-27 14:11:47 +02:00
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private T GetFromActionResult<T>(ActionResult result)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<T>((IActionResult)result);
|
|
|
|
}
|
|
|
|
|
|
|
|
private T GetFromActionResult<T>(ActionResult<T> result)
|
|
|
|
{
|
|
|
|
return result.Value ?? GetFromActionResult<T>(result.Result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override Task<IEnumerable<OnChainPaymentMethodData>> GetStoreOnChainPaymentMethods(string storeId,
|
2022-04-26 03:29:20 +02:00
|
|
|
bool? enabled, CancellationToken token = default)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
2022-03-11 10:17:50 +01:00
|
|
|
return Task.FromResult(
|
2022-07-19 19:53:14 +02:00
|
|
|
GetFromActionResult(GetController<GreenfieldStoreOnChainPaymentMethodsController>().GetOnChainPaymentMethods(storeId, enabled)));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
2021-07-29 13:29:34 +02:00
|
|
|
public override Task<OnChainPaymentMethodData> GetStoreOnChainPaymentMethod(string storeId,
|
2021-07-27 14:11:47 +02:00
|
|
|
string cryptoCode, CancellationToken token = default)
|
|
|
|
{
|
2021-07-29 13:29:34 +02:00
|
|
|
return Task.FromResult(GetFromActionResult(
|
2022-07-19 19:53:14 +02:00
|
|
|
GetController<GreenfieldStoreOnChainPaymentMethodsController>().GetOnChainPaymentMethod(storeId, cryptoCode)));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task RemoveStoreOnChainPaymentMethod(string storeId, string cryptoCode,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldStoreOnChainPaymentMethodsController>().RemoveOnChainPaymentMethod(storeId, cryptoCode));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<OnChainPaymentMethodData> UpdateStoreOnChainPaymentMethod(string storeId,
|
2022-04-26 03:29:20 +02:00
|
|
|
string cryptoCode, UpdateOnChainPaymentMethodRequest paymentMethod, CancellationToken token = default)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
|
|
|
return GetFromActionResult<OnChainPaymentMethodData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreOnChainPaymentMethodsController>().UpdateOnChainPaymentMethod(storeId, cryptoCode,
|
2022-03-11 10:17:50 +01:00
|
|
|
new UpdateOnChainPaymentMethodRequest(
|
|
|
|
enabled: paymentMethod.Enabled,
|
|
|
|
label: paymentMethod.Label,
|
|
|
|
accountKeyPath: paymentMethod.AccountKeyPath,
|
|
|
|
derivationScheme: paymentMethod.DerivationScheme
|
|
|
|
)));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override Task<OnChainPaymentMethodPreviewResultData> PreviewProposedStoreOnChainPaymentMethodAddresses(
|
|
|
|
string storeId, string cryptoCode,
|
2022-03-11 10:17:50 +01:00
|
|
|
UpdateOnChainPaymentMethodRequest paymentMethod, int offset = 0, int amount = 10,
|
|
|
|
CancellationToken token = default)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
|
|
|
return Task.FromResult(GetFromActionResult<OnChainPaymentMethodPreviewResultData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
GetController<GreenfieldStoreOnChainPaymentMethodsController>().GetProposedOnChainPaymentMethodPreview(storeId, cryptoCode,
|
2021-07-27 14:11:47 +02:00
|
|
|
paymentMethod, offset, amount)));
|
|
|
|
}
|
|
|
|
|
2021-07-29 13:29:34 +02:00
|
|
|
public override Task<OnChainPaymentMethodPreviewResultData> PreviewStoreOnChainPaymentMethodAddresses(
|
2022-04-26 03:29:20 +02:00
|
|
|
string storeId, string cryptoCode, int offset = 0, int amount = 10, CancellationToken token = default)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
2021-07-29 13:29:34 +02:00
|
|
|
return Task.FromResult(GetFromActionResult<OnChainPaymentMethodPreviewResultData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
GetController<GreenfieldStoreOnChainPaymentMethodsController>().GetOnChainPaymentMethodPreview(storeId, cryptoCode, offset,
|
2021-07-29 13:29:34 +02:00
|
|
|
amount)));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override Task<ApiHealthData> GetHealth(CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return Task.FromResult(GetFromActionResult<ApiHealthData>(GetController<GreenfieldHealthController>().GetHealth()));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<IEnumerable<PaymentRequestData>> GetPaymentRequests(string storeId,
|
|
|
|
bool includeArchived = false, CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return GetFromActionResult(await GetController<GreenfieldPaymentRequestsController>().GetPaymentRequests(storeId, includeArchived));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<PaymentRequestData> GetPaymentRequest(string storeId, string paymentRequestId,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-03-11 10:17:50 +01:00
|
|
|
return GetFromActionResult<PaymentRequestData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldPaymentRequestsController>().GetPaymentRequest(storeId, paymentRequestId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task ArchivePaymentRequest(string storeId, string paymentRequestId,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldPaymentRequestsController>().ArchivePaymentRequest(storeId, paymentRequestId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
2022-11-02 10:41:19 +01:00
|
|
|
public override async Task<InvoiceData> PayPaymentRequest(string storeId, string paymentRequestId, PayPaymentRequestRequest request, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<InvoiceData>(
|
|
|
|
await GetController<GreenfieldPaymentRequestsController>().PayPaymentRequest(storeId, paymentRequestId, request, token));
|
|
|
|
}
|
|
|
|
|
2021-07-27 14:11:47 +02:00
|
|
|
public override async Task<PaymentRequestData> CreatePaymentRequest(string storeId,
|
|
|
|
CreatePaymentRequestRequest request, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<PaymentRequestData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldPaymentRequestsController>().CreatePaymentRequest(storeId, request));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<PaymentRequestData> UpdatePaymentRequest(string storeId, string paymentRequestId,
|
|
|
|
UpdatePaymentRequestRequest request,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<PaymentRequestData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldPaymentRequestsController>().UpdatePaymentRequest(storeId, paymentRequestId, request));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<ApiKeyData> GetCurrentAPIKeyInfo(CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return GetFromActionResult<ApiKeyData>(await GetController<GreenfieldApiKeysController>().GetKey());
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<ApiKeyData> CreateAPIKey(CreateApiKeyRequest request,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return GetFromActionResult<ApiKeyData>(await GetController<GreenfieldApiKeysController>().CreateKey(request));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task RevokeCurrentAPIKeyInfo(CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldApiKeysController>().RevokeCurrentKey());
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task RevokeAPIKey(string apikey, CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldApiKeysController>().RevokeKey(apikey));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
2021-12-31 08:59:02 +01:00
|
|
|
|
|
|
|
public override async Task<IEnumerable<NotificationData>> GetNotifications(bool? seen = null,
|
2021-11-26 03:55:59 +01:00
|
|
|
int? skip = null, int? take = null, CancellationToken token = default)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
|
|
|
return GetFromActionResult<IEnumerable<NotificationData>>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldNotificationsController>().GetNotifications(seen, skip, take));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<NotificationData> GetNotification(string notificationId,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<NotificationData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldNotificationsController>().GetNotification(notificationId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<NotificationData> UpdateNotification(string notificationId, bool? seen,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<NotificationData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldNotificationsController>().UpdateNotification(notificationId,
|
2022-04-26 14:27:35 +02:00
|
|
|
new UpdateNotification() {Seen = seen}));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task RemoveNotification(string notificationId, CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldNotificationsController>().DeleteNotification(notificationId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<ApplicationUserData> GetCurrentUser(CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return GetFromActionResult(await GetController<GreenfieldUsersController>().GetCurrentUser());
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<ApplicationUserData> CreateUser(CreateApplicationUserRequest request,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return GetFromActionResult<ApplicationUserData>(await GetController<GreenfieldUsersController>().CreateUser(request, token));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<OnChainWalletOverviewData> ShowOnChainWalletOverview(string storeId,
|
|
|
|
string cryptoCode, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<OnChainWalletOverviewData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreOnChainWalletsController>().ShowOnChainWalletOverview(storeId, cryptoCode));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<OnChainWalletAddressData> GetOnChainWalletReceiveAddress(string storeId,
|
|
|
|
string cryptoCode, bool forceGenerate = false,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<OnChainWalletAddressData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreOnChainWalletsController>().GetOnChainWalletReceiveAddress(storeId, cryptoCode,
|
2021-07-27 14:11:47 +02:00
|
|
|
forceGenerate));
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task UnReserveOnChainWalletReceiveAddress(string storeId, string cryptoCode,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
HandleActionResult(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreOnChainWalletsController>().UnReserveOnChainWalletReceiveAddress(storeId, cryptoCode));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<IEnumerable<OnChainWalletTransactionData>> ShowOnChainWalletTransactions(
|
2022-04-18 04:20:15 +02:00
|
|
|
string storeId, string cryptoCode, TransactionStatus[] statusFilter = null, string labelFilter = null,
|
2021-07-27 14:11:47 +02:00
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<IEnumerable<OnChainWalletTransactionData>>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreOnChainWalletsController>().ShowOnChainWalletTransactions(storeId, cryptoCode, statusFilter));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<OnChainWalletTransactionData> GetOnChainWalletTransaction(string storeId,
|
2022-04-26 03:29:20 +02:00
|
|
|
string cryptoCode, string transactionId, CancellationToken token = default)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
|
|
|
return GetFromActionResult<OnChainWalletTransactionData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreOnChainWalletsController>().GetOnChainWalletTransaction(storeId, cryptoCode, transactionId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<IEnumerable<OnChainWalletUTXOData>> GetOnChainWalletUTXOs(string storeId,
|
|
|
|
string cryptoCode, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<IEnumerable<OnChainWalletUTXOData>>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreOnChainWalletsController>().GetOnChainWalletUTXOs(storeId, cryptoCode));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<OnChainWalletTransactionData> CreateOnChainTransaction(string storeId,
|
2022-04-26 03:29:20 +02:00
|
|
|
string cryptoCode, CreateOnChainTransactionRequest request, CancellationToken token = default)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
|
|
|
if (!request.ProceedWithBroadcast)
|
|
|
|
{
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(request.ProceedWithBroadcast),
|
|
|
|
"Please use CreateOnChainTransactionButDoNotBroadcast when wanting to only create the transaction");
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetFromActionResult<OnChainWalletTransactionData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreOnChainWalletsController>().CreateOnChainTransaction(storeId, cryptoCode, request));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<Transaction> CreateOnChainTransactionButDoNotBroadcast(string storeId,
|
|
|
|
string cryptoCode,
|
|
|
|
CreateOnChainTransactionRequest request, Network network, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
if (request.ProceedWithBroadcast)
|
|
|
|
{
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(request.ProceedWithBroadcast),
|
|
|
|
"Please use CreateOnChainTransaction when wanting to also broadcast the transaction");
|
|
|
|
}
|
|
|
|
|
|
|
|
return Transaction.Parse(
|
|
|
|
GetFromActionResult<string>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreOnChainWalletsController>().CreateOnChainTransaction(storeId, cryptoCode, request)),
|
2021-07-27 14:11:47 +02:00
|
|
|
network);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<IEnumerable<StoreData>> GetStores(CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return GetFromActionResult(await GetController<GreenfieldStoresController>().GetStores());
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
2021-12-27 05:46:31 +01:00
|
|
|
public override Task<StoreData> GetStore(string storeId, CancellationToken token = default)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return Task.FromResult(GetFromActionResult<StoreData>(GetController<GreenfieldStoresController>().GetStore(storeId)));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task RemoveStore(string storeId, CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldStoresController>().RemoveStore(storeId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<StoreData> CreateStore(CreateStoreRequest request, CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return GetFromActionResult<StoreData>(await GetController<GreenfieldStoresController>().CreateStore(request));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<StoreData> UpdateStore(string storeId, UpdateStoreRequest request,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return GetFromActionResult<StoreData>(await GetController<GreenfieldStoresController>().UpdateStore(storeId, request));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
2021-12-31 08:59:02 +01:00
|
|
|
|
2021-10-25 08:18:02 +02:00
|
|
|
public override Task<IEnumerable<LNURLPayPaymentMethodData>>
|
|
|
|
GetStoreLNURLPayPaymentMethods(string storeId, bool? enabled,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return Task.FromResult(GetFromActionResult(
|
2022-07-19 19:53:14 +02:00
|
|
|
GetController<GreenfieldStoreLNURLPayPaymentMethodsController>().GetLNURLPayPaymentMethods(storeId, enabled)));
|
2021-10-25 08:18:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override Task<LNURLPayPaymentMethodData> GetStoreLNURLPayPaymentMethod(
|
|
|
|
string storeId, string cryptoCode, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return Task.FromResult(GetFromActionResult<LNURLPayPaymentMethodData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
GetController<GreenfieldStoreLNURLPayPaymentMethodsController>().GetLNURLPayPaymentMethod(storeId, cryptoCode)));
|
2021-10-25 08:18:02 +02:00
|
|
|
}
|
2021-07-27 14:11:47 +02:00
|
|
|
|
2021-10-25 08:18:02 +02:00
|
|
|
public override async Task RemoveStoreLNURLPayPaymentMethod(string storeId, string cryptoCode,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
HandleActionResult(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreLNURLPayPaymentMethodsController>().RemoveLNURLPayPaymentMethod(storeId,
|
2021-10-25 08:18:02 +02:00
|
|
|
cryptoCode));
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<LNURLPayPaymentMethodData> UpdateStoreLNURLPayPaymentMethod(
|
|
|
|
string storeId, string cryptoCode,
|
|
|
|
LNURLPayPaymentMethodData paymentMethod, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<LNURLPayPaymentMethodData>(await
|
2022-07-19 19:53:14 +02:00
|
|
|
GetController<GreenfieldStoreLNURLPayPaymentMethodsController>().UpdateLNURLPayPaymentMethod(storeId, cryptoCode,
|
2021-10-25 08:18:02 +02:00
|
|
|
paymentMethod));
|
|
|
|
}
|
2021-12-31 08:59:02 +01:00
|
|
|
|
2021-07-27 14:11:47 +02:00
|
|
|
public override Task<IEnumerable<LightningNetworkPaymentMethodData>>
|
|
|
|
GetStoreLightningNetworkPaymentMethods(string storeId, bool? enabled,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return Task.FromResult(GetFromActionResult(
|
2022-07-19 19:53:14 +02:00
|
|
|
GetController<GreenfieldStoreLightningNetworkPaymentMethodsController>().GetLightningPaymentMethods(storeId, enabled)));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override Task<LightningNetworkPaymentMethodData> GetStoreLightningNetworkPaymentMethod(
|
|
|
|
string storeId, string cryptoCode, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return Task.FromResult(GetFromActionResult(
|
2022-07-19 19:53:14 +02:00
|
|
|
GetController<GreenfieldStoreLightningNetworkPaymentMethodsController>().GetLightningNetworkPaymentMethod(storeId, cryptoCode)));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task RemoveStoreLightningNetworkPaymentMethod(string storeId, string cryptoCode,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
HandleActionResult(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreLightningNetworkPaymentMethodsController>().RemoveLightningNetworkPaymentMethod(storeId,
|
2021-07-27 14:11:47 +02:00
|
|
|
cryptoCode));
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<LightningNetworkPaymentMethodData> UpdateStoreLightningNetworkPaymentMethod(
|
|
|
|
string storeId, string cryptoCode,
|
2021-09-25 07:04:34 +02:00
|
|
|
UpdateLightningNetworkPaymentMethodRequest paymentMethod, CancellationToken token = default)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
|
|
|
return GetFromActionResult<LightningNetworkPaymentMethodData>(await
|
2022-07-19 19:53:14 +02:00
|
|
|
GetController<GreenfieldStoreLightningNetworkPaymentMethodsController>().UpdateLightningNetworkPaymentMethod(storeId, cryptoCode,
|
2022-03-11 10:17:50 +01:00
|
|
|
new UpdateLightningNetworkPaymentMethodRequest(paymentMethod.ConnectionString,
|
|
|
|
paymentMethod.Enabled)));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<IEnumerable<InvoiceData>> GetInvoices(string storeId, string[] orderId = null,
|
|
|
|
InvoiceStatus[] status = null,
|
|
|
|
DateTimeOffset? startDate = null,
|
|
|
|
DateTimeOffset? endDate = null,
|
|
|
|
string textSearch = null,
|
|
|
|
bool includeArchived = false,
|
2021-10-31 11:47:12 +01:00
|
|
|
int? skip = null,
|
|
|
|
int? take = null,
|
|
|
|
CancellationToken token = default
|
2022-03-11 10:17:50 +01:00
|
|
|
)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
|
|
|
return GetFromActionResult<IEnumerable<InvoiceData>>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldInvoiceController>().GetInvoices(storeId, orderId,
|
2021-07-27 14:11:47 +02:00
|
|
|
status?.Select(invoiceStatus => invoiceStatus.ToString())?.ToArray(), startDate,
|
2021-12-31 08:59:02 +01:00
|
|
|
endDate, textSearch, includeArchived, skip, take));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<InvoiceData> GetInvoice(string storeId, string invoiceId,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return GetFromActionResult<InvoiceData>(await GetController<GreenfieldInvoiceController>().GetInvoice(storeId, invoiceId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<InvoicePaymentMethodDataModel[]> GetInvoicePaymentMethods(string storeId,
|
|
|
|
string invoiceId, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<InvoicePaymentMethodDataModel[]>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldInvoiceController>().GetInvoicePaymentMethods(storeId, invoiceId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task ArchiveInvoice(string storeId, string invoiceId, CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldInvoiceController>().ArchiveInvoice(storeId, invoiceId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<InvoiceData> CreateInvoice(string storeId, CreateInvoiceRequest request,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return GetFromActionResult<InvoiceData>(await GetController<GreenfieldInvoiceController>().CreateInvoice(storeId, request));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<InvoiceData> UpdateInvoice(string storeId, string invoiceId,
|
|
|
|
UpdateInvoiceRequest request, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<InvoiceData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldInvoiceController>().UpdateInvoice(storeId, invoiceId, request));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<InvoiceData> MarkInvoiceStatus(string storeId, string invoiceId,
|
|
|
|
MarkInvoiceStatusRequest request,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<InvoiceData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldInvoiceController>().MarkInvoiceStatus(storeId, invoiceId, request));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<InvoiceData> UnarchiveInvoice(string storeId, string invoiceId,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<InvoiceData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldInvoiceController>().UnarchiveInvoice(storeId, invoiceId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override Task<ServerInfoData> GetServerInfo(CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return Task.FromResult(GetFromActionResult<ServerInfoData>(GetController<GreenfieldServerInfoController>().ServerInfo()));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task ActivateInvoicePaymentMethod(string storeId, string invoiceId, string paymentMethod,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
HandleActionResult(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldInvoiceController>().ActivateInvoicePaymentMethod(storeId, invoiceId, paymentMethod));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<OnChainWalletFeeRateData> GetOnChainFeeRate(string storeId, string cryptoCode,
|
|
|
|
int? blockTarget = null, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<OnChainWalletFeeRateData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreOnChainWalletsController>().GetOnChainFeeRate(storeId, cryptoCode, blockTarget));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task DeleteCurrentUser(CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldUsersController>().DeleteCurrentUser());
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task DeleteUser(string userId, CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldUsersController>().DeleteUser(userId));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override Task<Language[]> GetAvailableLanguages(CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return Task.FromResult(GetController<UIHomeController>().LanguageService.GetLanguages()
|
2022-03-11 10:17:50 +01:00
|
|
|
.Select(language => new Language(language.Code, language.DisplayName)).ToArray());
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override Task<PermissionMetadata[]> GetPermissionMetadata(CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return Task.FromResult(GetFromActionResult<PermissionMetadata[]>(GetController<UIHomeController>().Permissions()));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
|
2022-03-11 10:17:50 +01:00
|
|
|
public override async Task<Dictionary<string, GenericPaymentMethodData>> GetStorePaymentMethods(string storeId,
|
|
|
|
bool? enabled = null, CancellationToken token = default)
|
2021-07-27 14:11:47 +02:00
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return GetFromActionResult(await GetController<GreenfieldStorePaymentMethodsController>().GetStorePaymentMethods(storeId, enabled));
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
2021-07-27 16:53:44 +02:00
|
|
|
|
2022-03-11 10:17:50 +01:00
|
|
|
public override async Task<OnChainPaymentMethodDataWithSensitiveData> GenerateOnChainWallet(string storeId,
|
|
|
|
string cryptoCode, GenerateOnChainWalletRequest request,
|
2021-07-27 16:53:44 +02:00
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-03-11 10:17:50 +01:00
|
|
|
return GetFromActionResult<OnChainPaymentMethodDataWithSensitiveData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreOnChainPaymentMethodsController>().GenerateOnChainWallet(storeId, cryptoCode,
|
2022-03-11 10:17:50 +01:00
|
|
|
new GenerateWalletRequest()
|
|
|
|
{
|
|
|
|
Passphrase = request.Passphrase,
|
|
|
|
AccountNumber = request.AccountNumber,
|
|
|
|
ExistingMnemonic = request.ExistingMnemonic?.ToString(),
|
|
|
|
WordCount = request.WordCount,
|
|
|
|
WordList = request.WordList,
|
|
|
|
SavePrivateKeys = request.SavePrivateKeys,
|
|
|
|
ScriptPubKeyType = request.ScriptPubKeyType,
|
|
|
|
ImportKeysToRPC = request.ImportKeysToRPC
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task SendEmail(string storeId, SendEmailRequest request,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldStoreEmailController>().SendEmailFromStore(storeId, request));
|
2021-07-27 16:53:44 +02:00
|
|
|
}
|
2022-03-11 10:17:40 +01:00
|
|
|
|
2022-03-11 10:17:50 +01:00
|
|
|
public override Task<EmailSettingsData> GetStoreEmailSettings(string storeId, CancellationToken token = default)
|
2022-03-11 10:17:40 +01:00
|
|
|
{
|
2022-03-11 10:17:50 +01:00
|
|
|
return Task.FromResult(
|
2022-07-19 19:53:14 +02:00
|
|
|
GetFromActionResult<EmailSettingsData>(GetController<GreenfieldStoreEmailController>().GetStoreEmailSettings()));
|
2022-03-11 10:17:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<EmailSettingsData> UpdateStoreEmailSettings(string storeId,
|
|
|
|
EmailSettingsData request, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<EmailSettingsData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreEmailController>().UpdateStoreEmailSettings(storeId,
|
2022-03-11 10:17:50 +01:00
|
|
|
JObject.FromObject(request).ToObject<EmailSettings>()));
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<ApplicationUserData[]> GetUsers(CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return GetFromActionResult(await GetController<GreenfieldUsersController>().GetUsers());
|
2022-03-11 10:17:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public override Task<IEnumerable<StoreUserData>> GetStoreUsers(string storeId,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return Task.FromResult(
|
2022-07-19 19:53:14 +02:00
|
|
|
GetFromActionResult<IEnumerable<StoreUserData>>(GetController<GreenfieldStoreUsersController>().GetStoreUsers()));
|
2022-03-11 10:17:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task AddStoreUser(string storeId, StoreUserData request,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldStoreUsersController>().AddStoreUser(storeId, request));
|
2022-03-11 10:17:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task RemoveStoreUser(string storeId, string userId, CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldStoreUsersController>().RemoveStoreUser(storeId, userId));
|
2022-03-11 10:17:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<ApplicationUserData> GetUserByIdOrEmail(string idOrEmail,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
return GetFromActionResult<ApplicationUserData>(await GetController<GreenfieldUsersController>().GetUser(idOrEmail));
|
2022-03-11 10:17:40 +01:00
|
|
|
}
|
2022-06-06 15:57:55 +02:00
|
|
|
|
2022-04-26 14:27:35 +02:00
|
|
|
public override async Task LockUser(string idOrEmail, bool disabled, CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldUsersController>().LockUser(idOrEmail, new LockUserRequest() {Locked = disabled}));
|
2022-04-26 14:27:35 +02:00
|
|
|
}
|
2022-04-24 05:19:34 +02:00
|
|
|
|
2022-06-06 15:57:55 +02:00
|
|
|
public override async Task<OnChainWalletTransactionData> PatchOnChainWalletTransaction(string storeId,
|
|
|
|
string cryptoCode, string transactionId,
|
2022-07-28 15:33:28 +02:00
|
|
|
PatchOnChainTransactionRequest request, bool force = false,CancellationToken token = default)
|
2022-04-26 14:27:35 +02:00
|
|
|
{
|
2022-06-06 15:57:55 +02:00
|
|
|
return GetFromActionResult<OnChainWalletTransactionData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreOnChainWalletsController>().PatchOnChainWalletTransaction(storeId, cryptoCode, transactionId,
|
2022-07-28 15:33:28 +02:00
|
|
|
request, force));
|
2022-04-26 14:27:35 +02:00
|
|
|
}
|
|
|
|
|
2022-06-06 15:57:55 +02:00
|
|
|
public override async Task<LightningPaymentData> GetLightningPayment(string cryptoCode, string paymentHash,
|
|
|
|
CancellationToken token = default)
|
2022-04-26 14:27:35 +02:00
|
|
|
{
|
2022-06-06 15:57:55 +02:00
|
|
|
return GetFromActionResult<LightningPaymentData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldInternalLightningNodeApiController>().GetPayment(cryptoCode, paymentHash, token));
|
2022-04-26 14:27:35 +02:00
|
|
|
}
|
|
|
|
|
2022-06-06 15:57:55 +02:00
|
|
|
public override async Task<LightningPaymentData> GetLightningPayment(string storeId, string cryptoCode,
|
|
|
|
string paymentHash, CancellationToken token = default)
|
2022-04-26 14:27:35 +02:00
|
|
|
{
|
2022-06-06 15:57:55 +02:00
|
|
|
return GetFromActionResult<LightningPaymentData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreLightningNodeApiController>().GetPayment(cryptoCode, paymentHash, token));
|
2022-04-26 14:27:35 +02:00
|
|
|
}
|
2022-06-06 15:57:55 +02:00
|
|
|
|
|
|
|
public override async Task<PayoutData> CreatePayout(string storeId,
|
|
|
|
CreatePayoutThroughStoreRequest payoutRequest,
|
2022-04-24 05:19:34 +02:00
|
|
|
CancellationToken cancellationToken = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<PayoutData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldPullPaymentController>().CreatePayoutThroughStore(storeId, payoutRequest));
|
2022-04-24 05:19:34 +02:00
|
|
|
}
|
|
|
|
|
2022-06-06 15:57:55 +02:00
|
|
|
public override async Task<IEnumerable<PayoutProcessorData>> GetPayoutProcessors(string storeId,
|
|
|
|
CancellationToken token = default)
|
2022-04-24 05:19:34 +02:00
|
|
|
{
|
2022-06-06 15:57:55 +02:00
|
|
|
return GetFromActionResult<IEnumerable<PayoutProcessorData>>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStorePayoutProcessorsController>().GetStorePayoutProcessors(storeId));
|
2022-04-24 05:19:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override Task<IEnumerable<PayoutProcessorData>> GetPayoutProcessors(CancellationToken token = default)
|
|
|
|
{
|
2022-06-06 15:57:55 +02:00
|
|
|
return Task.FromResult(
|
2022-07-19 19:53:14 +02:00
|
|
|
GetFromActionResult<IEnumerable<PayoutProcessorData>>(GetController<GreenfieldPayoutProcessorsController>()
|
2022-06-06 15:57:55 +02:00
|
|
|
.GetPayoutProcessors()));
|
2022-04-24 05:19:34 +02:00
|
|
|
}
|
|
|
|
|
2022-06-06 15:57:55 +02:00
|
|
|
public override async Task RemovePayoutProcessor(string storeId, string processor, string paymentMethod,
|
|
|
|
CancellationToken token = default)
|
2022-04-24 05:19:34 +02:00
|
|
|
{
|
2022-06-06 15:57:55 +02:00
|
|
|
HandleActionResult(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStorePayoutProcessorsController>().RemoveStorePayoutProcessor(storeId, processor,
|
2022-06-06 15:57:55 +02:00
|
|
|
paymentMethod));
|
2022-04-24 05:19:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<IEnumerable<OnChainAutomatedPayoutSettings>>
|
|
|
|
GetStoreOnChainAutomatedPayoutProcessors(string storeId, string paymentMethod = null,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<IEnumerable<OnChainAutomatedPayoutSettings>>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreAutomatedOnChainPayoutProcessorsController>()
|
2022-04-24 05:19:34 +02:00
|
|
|
.GetStoreOnChainAutomatedPayoutProcessors(storeId, paymentMethod));
|
|
|
|
}
|
|
|
|
|
2022-06-06 15:57:55 +02:00
|
|
|
public override async Task<IEnumerable<LightningAutomatedPayoutSettings>>
|
|
|
|
GetStoreLightningAutomatedPayoutProcessors(string storeId, string paymentMethod = null,
|
|
|
|
CancellationToken token = default)
|
2022-04-24 05:19:34 +02:00
|
|
|
{
|
|
|
|
return GetFromActionResult<IEnumerable<LightningAutomatedPayoutSettings>>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreAutomatedLightningPayoutProcessorsController>()
|
2022-04-24 05:19:34 +02:00
|
|
|
.GetStoreLightningAutomatedPayoutProcessors(storeId, paymentMethod));
|
|
|
|
}
|
|
|
|
|
2022-06-06 15:57:55 +02:00
|
|
|
public override async Task<OnChainAutomatedPayoutSettings> UpdateStoreOnChainAutomatedPayoutProcessors(
|
|
|
|
string storeId, string paymentMethod,
|
2022-04-24 05:19:34 +02:00
|
|
|
OnChainAutomatedPayoutSettings request, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<OnChainAutomatedPayoutSettings>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreAutomatedOnChainPayoutProcessorsController>()
|
2022-04-24 05:19:34 +02:00
|
|
|
.UpdateStoreOnchainAutomatedPayoutProcessor(storeId, paymentMethod, request));
|
|
|
|
}
|
|
|
|
|
2022-06-06 15:57:55 +02:00
|
|
|
public override async Task<LightningAutomatedPayoutSettings> UpdateStoreLightningAutomatedPayoutProcessors(
|
|
|
|
string storeId, string paymentMethod,
|
2022-04-24 05:19:34 +02:00
|
|
|
LightningAutomatedPayoutSettings request, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<LightningAutomatedPayoutSettings>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldStoreAutomatedLightningPayoutProcessorsController>()
|
2022-04-24 05:19:34 +02:00
|
|
|
.UpdateStoreLightningAutomatedPayoutProcessor(storeId, paymentMethod, request));
|
|
|
|
}
|
|
|
|
|
2022-06-06 15:57:55 +02:00
|
|
|
public override async Task<PayoutData[]> GetStorePayouts(string storeId, bool includeCancelled = false,
|
|
|
|
CancellationToken cancellationToken = default)
|
2022-04-24 05:19:34 +02:00
|
|
|
{
|
|
|
|
return GetFromActionResult<PayoutData[]>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldPullPaymentController>()
|
2022-06-06 15:57:55 +02:00
|
|
|
.GetStorePayouts(storeId, includeCancelled));
|
2022-04-24 05:19:34 +02:00
|
|
|
}
|
2022-06-27 03:14:16 +02:00
|
|
|
|
|
|
|
public override async Task<PointOfSaleAppData> CreatePointOfSaleApp(
|
2022-08-04 04:38:49 +02:00
|
|
|
string storeId,
|
2022-06-27 03:14:16 +02:00
|
|
|
CreatePointOfSaleAppRequest request, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<PointOfSaleAppData>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldAppsController>().CreatePointOfSaleApp(storeId, request));
|
2022-06-27 03:14:16 +02:00
|
|
|
}
|
|
|
|
|
2022-08-10 06:13:47 +02:00
|
|
|
public override async Task<PointOfSaleAppData> UpdatePointOfSaleApp(
|
2022-07-18 07:23:22 +02:00
|
|
|
string appId,
|
|
|
|
CreatePointOfSaleAppRequest request, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<PointOfSaleAppData>(
|
2022-08-10 06:13:47 +02:00
|
|
|
await GetController<GreenfieldAppsController>().UpdatePointOfSaleApp(appId, request));
|
2022-07-18 07:23:22 +02:00
|
|
|
}
|
|
|
|
|
2022-11-18 06:20:07 +01:00
|
|
|
public override async Task<CrowdfundAppData> CreateCrowdfundApp(
|
|
|
|
string storeId,
|
|
|
|
CreateCrowdfundAppRequest request, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<CrowdfundAppData>(
|
|
|
|
await GetController<GreenfieldAppsController>().CreateCrowdfundApp(storeId, request));
|
|
|
|
}
|
|
|
|
|
2022-06-27 03:14:16 +02:00
|
|
|
public override async Task<AppDataBase> GetApp(string appId, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<AppDataBase>(
|
2022-07-19 19:53:14 +02:00
|
|
|
await GetController<GreenfieldAppsController>().GetApp(appId));
|
2022-06-27 03:14:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task DeleteApp(string appId, CancellationToken token = default)
|
|
|
|
{
|
2022-07-19 19:53:14 +02:00
|
|
|
HandleActionResult(await GetController<GreenfieldAppsController>().DeleteApp(appId));
|
2022-06-27 03:14:16 +02:00
|
|
|
}
|
2022-10-12 15:19:33 +02:00
|
|
|
|
|
|
|
public override Task<List<RateSource>> GetRateSources(CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return Task.FromResult(GetFromActionResult(GetController<GreenfieldStoreRateConfigurationController>().GetRateSources()));
|
|
|
|
}
|
|
|
|
|
|
|
|
public override Task<StoreRateConfiguration> GetStoreRateConfiguration(string storeId, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return Task.FromResult(GetFromActionResult<StoreRateConfiguration>(GetController<GreenfieldStoreRateConfigurationController>().GetStoreRateConfiguration()));
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<List<StoreRatePreviewResult>> PreviewUpdateStoreRateConfiguration(string storeId,
|
|
|
|
StoreRateConfiguration request,
|
|
|
|
string[] currencyPair,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<List<StoreRatePreviewResult>>(
|
|
|
|
await GetController<GreenfieldStoreRateConfigurationController>().PreviewUpdateStoreRateConfiguration(request,
|
|
|
|
currencyPair));
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<StoreRateConfiguration> UpdateStoreRateConfiguration(string storeId, StoreRateConfiguration request, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<StoreRateConfiguration>(await GetController<GreenfieldStoreRateConfigurationController>().UpdateStoreRateConfiguration(request));
|
|
|
|
}
|
2022-11-16 04:11:17 +01:00
|
|
|
|
2022-11-15 10:40:57 +01:00
|
|
|
public override async Task MarkPayoutPaid(string storeId, string payoutId, CancellationToken cancellationToken = default)
|
|
|
|
{
|
|
|
|
HandleActionResult(await GetController<GreenfieldPullPaymentController>().MarkPayoutPaid(storeId, payoutId, cancellationToken));
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task MarkPayout(string storeId, string payoutId, MarkPayoutRequest request,
|
|
|
|
CancellationToken cancellationToken = default)
|
|
|
|
{
|
|
|
|
HandleActionResult(await GetController<GreenfieldPullPaymentController>().MarkPayout(storeId, payoutId, request));
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<PayoutData> GetPullPaymentPayout(string pullPaymentId, string payoutId, CancellationToken cancellationToken = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<PayoutData>(await GetController<GreenfieldPullPaymentController>().GetPayout(pullPaymentId, payoutId));
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<PayoutData> GetStorePayout(string storeId, string payoutId,
|
|
|
|
CancellationToken cancellationToken = default)
|
|
|
|
{
|
|
|
|
return GetFromActionResult<PayoutData>(await GetController<GreenfieldPullPaymentController>().GetStorePayout(storeId, payoutId));
|
|
|
|
}
|
2021-07-27 14:11:47 +02:00
|
|
|
}
|
|
|
|
}
|