Refactor and decouple Payout logic (#2046)

* Refactor and decouple Payout logic

So that we can support lightning and more complex flows like allowing external payments to payouts.

* fix dropdown align

* switch to simpler buttons

* rebase fixes

add some comments

* rebase fixes

add some comments

* simplify enum caveman logic

* reduce code duplication and db round trips

* Fix pull payment date format

* fix issue with payouts to send page not working correctly

* try fix some style issue

* fix bip21parse
This commit is contained in:
Andrew Camilleri
2021-04-13 10:36:49 +02:00
committed by GitHub
parent 98eee27b93
commit 2e12befb8b
26 changed files with 936 additions and 645 deletions

View File

@@ -1,5 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using BTCPayServer.Client.Models;
using BTCPayServer.Data;
using BTCPayServer.Payments;
namespace BTCPayServer.Models.WalletViewModels
{
@@ -7,6 +11,9 @@ namespace BTCPayServer.Models.WalletViewModels
{
public string PullPaymentId { get; set; }
public string Command { get; set; }
public List<PayoutStateSet> PayoutStateSets{ get; set; }
public PaymentMethodId PaymentMethodId { get; set; }
public class PayoutModel
{
public string PayoutId { get; set; }
@@ -18,7 +25,18 @@ namespace BTCPayServer.Models.WalletViewModels
public string Amount { get; set; }
public string TransactionLink { get; set; }
}
public List<PayoutModel> WaitingForApproval { get; set; } = new List<PayoutModel>();
public List<PayoutModel> Other { get; set; } = new List<PayoutModel>();
public class PayoutStateSet
{
public PayoutState State { get; set; }
public List<PayoutModel> Payouts { get; set; }
}
public string[] GetSelectedPayouts(PayoutState state)
{
return PayoutStateSets.Where(set => set.State == state)
.SelectMany(set => set.Payouts.Where(model => model.Selected).Select(model => model.PayoutId))
.ToArray();
}
}
}