public ActionResult CloseChannel(string cryptoCode, [FromBody] CloseChannelRequest req) { var n = _networkProvider.GetByCryptoCode(cryptoCode.ToLowerInvariant()); var peerMan = _peerManagerProvider.GetPeerManager(n); var channels = peerMan.ChannelManager.ListChannels(_pool); var s = channels.FirstOrDefault(x => x.RemoteNetworkId == req.TheirNetworkKey); if (s is null) { return(NotFound($"There is no opened channel against {req.TheirNetworkKey}")); } peerMan.ChannelManager.CloseChannel(s.ChannelId); peerMan.ProcessEvents(); return(Ok()); }
public async Task <CloseStatusUpdate> CloseChannel(ChannelPoint channelPoint, bool force = false, int targetConf = 1) { var request = new CloseChannelRequest() { ChannelPoint = channelPoint, Force = force, TargetConf = targetConf }; ; using (var stream = lndClient.CloseChannel(request)) { while (await stream.ResponseStream.MoveNext()) { return(stream.ResponseStream.Current); } } return(null); }
public ActionResult CloseChannel(string cryptoCode, [FromBody] CloseChannelRequest req) { var n = _networkProvider.GetByCryptoCode(cryptoCode.ToLowerInvariant()); var peerMan = _peerManagerProvider.GetPeerManager(n); var channels = peerMan.ChannelManager.ListChannels(_pool); var s = channels.FirstOrDefault(x => x.RemoteNetworkId == req.TheirNetworkKey); if (s is null) { return(NotFound($"There is no opened channel against {req.TheirNetworkKey}")); } peerMan.ChannelManager.CloseChannel(s.ChannelId); peerMan.ProcessEvents(); // Technically, we can await the Broadcaster broadcasts the tx. But do not do it because ... // The only way to determine the broadcasted tx is indeed a closing tx of the channel is to check that one // of its input's "prevHash xor prevN" matches the ChannelId, but channel id has different value when it has // not fully opened. return(Ok()); }