Transfer Processors (#3476)

* Automated Transfer processors

This PR introduces a few things:
* Payouts can now be directly nested under a store instead of through a pull payment.
* The Wallet Send screen now has an option to "schedule" instead of simply creating a transaction. When you click on schedule, all transaction destinations are converted into approved payouts. Any options relating to fees or coin selection are discarded.
* There is a new concept introduced, called "Transfer Processors".  Transfer Processors are services for stores that process payouts that are awaiting payment. Each processor specifies which payment methods it can handle.  BTCPay Server will have some forms of transfer processors baked in but it has been designed to allow the Plugin System to provide additional processors.
* The initial transfer processors provided are "automated processors", for on chain and lightning payment methods. They can be configured to process payouts every X amount of minutes. For  on-chain, this means payments are batched into one transaction, resulting in more efficient and cheaper fees for processing.
*

* fix build

* extract

* remove magic string stuff

* fix error message when scheduling

* Paginate migration

* add payout count to payment method tab

* remove unused var

* add protip

* optimzie payout migration dramatically

* Remove useless double condition

* Fix bunch of warnings

* Remove warning

* Remove warnigns

* Rename to Payout processors

* fix typo

Co-authored-by: Nicolas Dorier <nicolas.dorier@gmail.com>
This commit is contained in:
Andrew Camilleri
2022-04-24 05:19:34 +02:00
committed by GitHub
parent 9ab129ba89
commit 51690b47a3
72 changed files with 3862 additions and 557 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
#nullable enable
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BTCPayServer.Data;
@@ -30,15 +31,17 @@ public class LightningAddressService
query.Usernames = query.Usernames?.Select(NormalizeUsername)?.ToArray();
if (query.Usernames is not null)
{
queryable = queryable.Where(data => query.Usernames.Contains(data.Username));
queryable = queryable.Where(data => query.Usernames.Contains(data!.Username));
}
if (query.StoreIds is not null)
{
queryable = queryable.Where(data => query.StoreIds.Contains(data.StoreDataId));
queryable = queryable.Where(data => query.StoreIds.Contains(data!.StoreDataId));
}
#pragma warning disable CS8619 // Nullability of reference types in value doesn't match target type.
return await queryable.ToListAsync();
#pragma warning restore CS8619 // Nullability of reference types in value doesn't match target type.
}
public async Task<LightningAddressData?> ResolveByAddress(string username)
@@ -77,7 +80,7 @@ public class LightningAddressService
return true;
}
public async Task<bool> Remove(string username, string storeId = null)
public async Task<bool> Remove(string username, string? storeId = null)
{
await using var context = _applicationDbContextFactory.CreateContext();
var x = (await GetCore(context, new LightningAddressQuery() {Usernames = new[] {username}})).FirstOrDefault();