From 5226b77ffc34f9a91e7161ea13f591fd547fa343 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Sat, 13 Jan 2018 02:28:23 +0900 Subject: [PATCH] Fix bug happening when removing data of nbxplorer --- BTCPayServer/BTCPayServer.csproj | 2 +- BTCPayServer/Services/Wallets/BTCPayWallet.cs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 59c784a30..18000a729 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -2,7 +2,7 @@ Exe netcoreapp2.0 - 1.0.0.74 + 1.0.0.75 diff --git a/BTCPayServer/Services/Wallets/BTCPayWallet.cs b/BTCPayServer/Services/Wallets/BTCPayWallet.cs index dc5f3e5ea..f87dc77db 100644 --- a/BTCPayServer/Services/Wallets/BTCPayWallet.cs +++ b/BTCPayServer/Services/Wallets/BTCPayWallet.cs @@ -57,7 +57,15 @@ namespace BTCPayServer.Services.Wallets public async Task ReserveAddressAsync(DerivationStrategyBase derivationStrategy) { + if (derivationStrategy == null) + throw new ArgumentNullException(nameof(derivationStrategy)); var pathInfo = await _Client.GetUnusedAsync(derivationStrategy, DerivationFeature.Deposit, 0, true).ConfigureAwait(false); + // Might happen on some broken install + if (pathInfo == null) + { + await _Client.TrackAsync(derivationStrategy).ConfigureAwait(false); + pathInfo = await _Client.GetUnusedAsync(derivationStrategy, DerivationFeature.Deposit, 0, true).ConfigureAwait(false); + } return pathInfo.ScriptPubKey.GetDestinationAddress(Network.NBitcoinNetwork); }