Beispiel #1
0
        public void Handle(IPeer peer, FundingSignedMessage message, PendingChannel pendingChannel)
        {
            var channel   = pendingChannel.Channel;
            var oldState  = channel.State;
            var signature = SignatureConverter.RawToTransactionSignature(message.Signature);

            if (!_commitmentService.IsValidRemoteCommitmentSignature(channel, signature))
            {
                _channelLoggingService.LogError(channel, LocalChannelError.InvalidCommitmentSignature, $"Remote {peer.NodeAddress} sent us an invalid commitment signature");
                string error = "Invalid commitment transaction signature.";
                channel.State = LocalChannelState.FundingFailed;
                peer.Messaging.Send(new ErrorMessage(message.ChannelId, error));
                throw new ChannelException(error, channel);
            }

            channel.LocalCommitmentTxParameters.RemoteSignature = signature;
            channel.State = LocalChannelState.FundingSigned;
            _channelService.AddChannel(peer, channel);
            _fundingService.BroadcastFundingTransaction(channel);
            _blockchainMonitorService.WatchForTransactionId(channel.FundingTransactionId, (ushort)channel.MinimumDepth);
            _channelService.RemovePendingChannel(pendingChannel);
            _channelLoggingService.LogStateUpdate(channel, oldState);
        }