Make NBXplorer service classes extensible for plugins (#7308)
What changed, and why it matters
This commit is a routine software-engineering change: it marks several internal service methods and fields as virtual or protected so that third-party plugins can extend them more easily. There is no security bug being fixed and no new vulnerability being introduced in the diff itself.
No security action required. Review as normal code-quality/plugin-extensibility change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch makes ExplorerClientProvider, NBXplorerConnectionFactory, and WalletHistogramService extensible by adding a protected constructor, changing a private readonly Dictionary to protected, and marking several public methods as virtual. These are pure API-visibility changes intended to support plugin overrides without reflection. No logic, validation, authentication, authorization, or data-handling code is modified.
Changed components
BTCPayServer/ExplorerClientProvider.csBTCPayServer/Services/NBXplorerConnectionFactory.csBTCPayServer/Services/Wallets/WalletHistogramService.csInspect captured patch +18 / −9
diff --git a/BTCPayServer/ExplorerClientProvider.cs b/BTCPayServer/ExplorerClientProvider.cs
index e58a3b1..05e7b5a 100644
--- a/BTCPayServer/ExplorerClientProvider.cs
+++ b/BTCPayServer/ExplorerClientProvider.cs
@@ -22,6 +22,15 @@ namespace BTCPayServer
readonly NBXplorerDashboard _Dashboard;
+ protected ExplorerClientProvider(
+ BTCPayNetworkProvider networkProviders,
+ NBXplorerDashboard dashboard)
+ {
+ Logs = new Logs();
+ _Dashboard = dashboard;
+ _NetworkProviders = networkProviders;
+ }
+
public ExplorerClientProvider(
IHttpClientFactory httpClientFactory,
BTCPayNetworkProvider networkProviders,
@@ -70,9 +79,9 @@ namespace BTCPayServer
return explorer;
}
- readonly Dictionary<string, ExplorerClient> _Clients = new Dictionary<string, ExplorerClient>();
+ protected readonly Dictionary<string, ExplorerClient> _Clients = new Dictionary<string, ExplorerClient>();
- public ExplorerClient GetExplorerClient(string cryptoCode)
+ public virtual ExplorerClient GetExplorerClient(string cryptoCode)
{
var network = _NetworkProviders.GetNetwork<BTCPayNetwork>(cryptoCode);
if (network == null)
@@ -81,24 +90,24 @@ namespace BTCPayServer
return client;
}
- public ExplorerClient GetExplorerClient(BTCPayNetworkBase network)
+ public virtual ExplorerClient GetExplorerClient(BTCPayNetworkBase network)
{
ArgumentNullException.ThrowIfNull(network);
return GetExplorerClient(network.CryptoCode);
}
- public bool IsAvailable(BTCPayNetworkBase network)
+ public virtual bool IsAvailable(BTCPayNetworkBase network)
{
return IsAvailable(network.CryptoCode);
}
- public bool IsAvailable(string cryptoCode)
+ public virtual bool IsAvailable(string cryptoCode)
{
cryptoCode = cryptoCode.ToUpperInvariant();
return _Clients.ContainsKey(cryptoCode) && _Dashboard.IsFullySynched(cryptoCode, out var unused);
}
- public BTCPayNetwork GetNetwork(string cryptoCode)
+ public virtual BTCPayNetwork GetNetwork(string cryptoCode)
{
var network = _NetworkProviders.GetNetwork<BTCPayNetwork>(cryptoCode);
if (network == null)
@@ -108,7 +117,7 @@ namespace BTCPayServer
return null;
}
- public IEnumerable<(BTCPayNetwork, ExplorerClient)> GetAll()
+ public virtual IEnumerable<(BTCPayNetwork, ExplorerClient)> GetAll()
{
foreach (var net in _NetworkProviders.GetAll().OfType<BTCPayNetwork>())
{
diff --git a/BTCPayServer/Services/NBXplorerConnectionFactory.cs b/BTCPayServer/Services/NBXplorerConnectionFactory.cs
index 7697979..e0738d0 100644
--- a/BTCPayServer/Services/NBXplorerConnectionFactory.cs
+++ b/BTCPayServer/Services/NBXplorerConnectionFactory.cs
@@ -40,7 +40,7 @@ namespace BTCPayServer.Services
}
}
- public async Task<DbConnection> OpenConnection()
+ public virtual async Task<DbConnection> OpenConnection()
{
int maxRetries = 10;
int retries = maxRetries;
diff --git a/BTCPayServer/Services/Wallets/WalletHistogramService.cs b/BTCPayServer/Services/Wallets/WalletHistogramService.cs
index 17e9221..df77442 100644
--- a/BTCPayServer/Services/Wallets/WalletHistogramService.cs
+++ b/BTCPayServer/Services/Wallets/WalletHistogramService.cs
@@ -21,7 +21,7 @@ public class WalletHistogramService
_connectionFactory = connectionFactory;
}
- public async Task<HistogramData> GetHistogram(StoreData store, WalletId walletId, HistogramType type)
+ public virtual async Task<HistogramData> GetHistogram(StoreData store, WalletId walletId, HistogramType type)
{
// https://github.com/dgarage/NBXplorer/blob/master/docs/Postgres-Schema.md
if (_connectionFactory.Available)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.