Pluginify BTCPayNetworkProvider (#5331)

This commit is contained in:
Nicolas Dorier
2023-11-29 18:51:40 +09:00
committed by GitHub
parent 1081eab9db
commit 04292d09e1
139 changed files with 1251 additions and 1075 deletions

View File

@@ -66,6 +66,7 @@ namespace BTCPayServer.Controllers
private readonly DelayedTransactionBroadcaster _broadcaster;
private readonly PayjoinClient _payjoinClient;
private readonly LabelService _labelService;
private readonly TransactionLinkProviders _transactionLinkProviders;
private readonly PullPaymentHostedService _pullPaymentHostedService;
private readonly WalletHistogramService _walletHistogramService;
@@ -89,10 +90,12 @@ namespace BTCPayServer.Controllers
PayjoinClient payjoinClient,
IServiceProvider serviceProvider,
PullPaymentHostedService pullPaymentHostedService,
LabelService labelService)
LabelService labelService,
TransactionLinkProviders transactionLinkProviders)
{
_currencyTable = currencyTable;
_labelService = labelService;
_transactionLinkProviders = transactionLinkProviders;
Repository = repo;
WalletRepository = walletRepository;
RateFetcher = rateProvider;
@@ -248,12 +251,12 @@ namespace BTCPayServer.Controllers
}
else
{
var pmi = new PaymentMethodId(walletId.CryptoCode, PaymentTypes.BTCLike);
foreach (var tx in transactions)
{
var vm = new ListTransactionsViewModel.TransactionViewModel();
vm.Id = tx.TransactionId.ToString();
vm.Link = string.Format(CultureInfo.InvariantCulture, paymentMethod.Network.BlockExplorerLink,
vm.Id);
vm.Link = _transactionLinkProviders.GetTransactionLink(pmi, vm.Id);
vm.Timestamp = tx.SeenAt;
vm.Positive = tx.BalanceChange.GetValue(wallet.Network) >= 0;
vm.Balance = tx.BalanceChange.ShowMoney(wallet.Network);
@@ -590,7 +593,7 @@ namespace BTCPayServer.Controllers
var utxos = await _walletProvider.GetWallet(network)
.GetUnspentCoins(schemeSettings.AccountDerivation, false, cancellation);
var pmi = new PaymentMethodId(vm.CryptoCode, PaymentTypes.BTCLike);
var walletTransactionsInfoAsync = await this.WalletRepository.GetWalletTransactionsInfo(walletId,
utxos.SelectMany(GetWalletObjectsQuery.Get).Distinct().ToArray());
vm.InputsAvailable = utxos.Select(coin =>
@@ -605,8 +608,7 @@ namespace BTCPayServer.Controllers
Amount = coin.Value.GetValue(network),
Comment = info?.Comment,
Labels = _labelService.CreateTransactionTagModels(info, Request),
Link = string.Format(CultureInfo.InvariantCulture, network.BlockExplorerLink,
coin.OutPoint.Hash.ToString()),
Link = _transactionLinkProviders.GetTransactionLink(pmi, coin.OutPoint.ToString()),
Confirmations = coin.Confirmations
};
}).ToArray();