diff --git a/BTCPayApp.Core/Attempt2/LightningNodeService.cs b/BTCPayApp.Core/Attempt2/LightningNodeService.cs index 98e3de0..411cf14 100644 --- a/BTCPayApp.Core/Attempt2/LightningNodeService.cs +++ b/BTCPayApp.Core/Attempt2/LightningNodeService.cs @@ -65,14 +65,24 @@ public LightningNodeManager( public async Task StartNode() { - if (_nodeScope is not null || State is LightningNodeState.Loaded or LightningNodeState.NotConfigured || _onChainWalletManager.State is not OnChainWalletState.Loaded) + if (_nodeScope is not null || State is LightningNodeState.Loaded or LightningNodeState.NotConfigured ) + { return; + } + + _logger.LogInformation("Starting lightning node"); await _controlSemaphore.WaitAsync(); _logger.LogInformation("Starting lightning node: lock acquired"); try { + if (_onChainWalletManager.State is not OnChainWalletState.Loaded) + { + State = LightningNodeState.WaitingForConnection; + + return; + } if (_nodeScope is null) { _nodeScope = _serviceScopeFactory.CreateScope(); diff --git a/BTCPayApp.Tests/CoreTests.cs b/BTCPayApp.Tests/CoreTests.cs index 932dad1..375cd9d 100644 --- a/BTCPayApp.Tests/CoreTests.cs +++ b/BTCPayApp.Tests/CoreTests.cs @@ -139,7 +139,7 @@ await node2.LNManager.Node.UpdateConfig(async config => return (config, true); }); await TestUtils.EventuallyAsync(async () => - Assert.True((await node.LNManager.Node.GetConfig()).AcceptInboundConnection)); + Assert.True((await node2.LNManager.Node.GetConfig()).AcceptInboundConnection)); TestUtils.Eventually( async () => Assert.NotNull(node.App.Services.GetRequiredService().Endpoint));