Esempio n. 1
0
        private Transaction BuildSignedCloseTransaction(LocalChannel channel, TransactionSignature remoteClosingSignature, ulong feeSatoshi)
        {
            var builder = new CloseChannelTransactionBuilder(channel, _networkParameters);

            builder.FeeSatoshi = feeSatoshi;
            return(builder.BuildWithSignatures(remoteClosingSignature));
        }
Esempio n. 2
0
        private void RespondWithClosingSigned(IPeer peer, LocalChannel channel, ulong fee = 0)
        {
            var   oldState   = channel.State;
            ulong ourFeeRate = _blockchainClientService.GetFeeRatePerKw(3);

            channel.State = LocalChannelState.ClosingSigned;

            var builder = new CloseChannelTransactionBuilder(channel, _networkParameters);

            builder.FeeSatoshi = 0;
            var zeroFeeTx = builder.Build();

            builder.FeeSatoshi = fee != 0 ? fee : TransactionFee.CalculateFee(ourFeeRate, (ulong)zeroFeeTx.GetSerializedSize(2, SerializationType.Network));

            ClosingSignedMessage closingSignedMessage = new ClosingSignedMessage();

            closingSignedMessage.FeeSatoshi = builder.FeeSatoshi;
            closingSignedMessage.ChannelId  = channel.ChannelId.HexToByteArray();
            closingSignedMessage.Signature  = builder.Sign().ToRawSignature();

            peer.Messaging.Send(closingSignedMessage);
            _channelLoggingService.LogStateUpdate(channel, oldState, "Respond with closing signed");
        }