< Summary - Combined Code Coverage

Information
Class: NLightning.Domain.Channels.Models.ChannelModel
Assembly: NLightning.Domain
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Domain/Channels/Models/ChannelModel.cs
Tag: 36_15743069263
Line coverage
82%
Covered lines: 68
Uncovered lines: 14
Coverable lines: 82
Total lines: 130
Line coverage: 82.9%
Branch coverage
79%
Covered branches: 19
Total branches: 24
Branch coverage: 79.1%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Domain/Channels/Models/ChannelModel.cs

#LineLine coverage
 1using NLightning.Domain.Protocol.Models;
 2
 3namespace NLightning.Domain.Channels.Models;
 4
 5using Bitcoin.Transactions.Outputs;
 6using Bitcoin.ValueObjects;
 7using Crypto.ValueObjects;
 8using Enums;
 9using Money;
 10using ValueObjects;
 11
 12public class ChannelModel
 13{
 14    #region Base Properties
 15
 88416    public ChannelConfig ChannelConfig { get; }
 21217    public ChannelId ChannelId { get; private set; }
 018    public ShortChannelId ShortChannelId { get; set; }
 7219    public CommitmentNumber CommitmentNumber { get; }
 020    public uint FundingCreatedAtBlockHeight { get; set; }
 12021    public FundingOutputInfo FundingOutput { get; }
 7222    public bool IsInitiator { get; }
 023    public CompactPubKey RemoteNodeId { get; }
 15224    public ChannelState State { get; private set; }
 025    public ChannelVersion Version { get; }
 26
 27    #endregion
 28
 29    #region Signatures
 30
 431    public CompactSignature? LastSentSignature { get; }
 432    public CompactSignature? LastReceivedSignature { get; }
 33
 34    #endregion
 35
 36    #region Local Information
 37
 038    public ICollection<ShortChannelId>? LocalAliases { get; set; }
 7239    public LightningMoney LocalBalance { get; }
 35640    public ChannelKeySetModel LocalKeySet { get; }
 441    public ulong LocalNextHtlcId { get; }
 6842    public ICollection<Htlc>? LocalOfferedHtlcs { get; }
 043    public ICollection<Htlc>? LocalFulfilledHtlcs { get; }
 044    public ICollection<Htlc>? LocalOldHtlcs { get; }
 445    public ulong LocalRevocationNumber { get; }
 1646    public BitcoinScript? LocalUpfrontShutdownScript { get; }
 47
 48    #endregion
 49
 50    #region Remote Information
 51
 052    public ShortChannelId? RemoteAlias { get; set; }
 7253    public LightningMoney RemoteBalance { get; }
 42054    public ChannelKeySetModel RemoteKeySet { get; }
 455    public ulong RemoteNextHtlcId { get; }
 456    public ulong RemoteRevocationNumber { get; }
 057    public ICollection<Htlc>? RemoteFulfilledHtlcs { get; }
 6858    public ICollection<Htlc>? RemoteOfferedHtlcs { get; }
 059    public ICollection<Htlc>? RemoteOldHtlcs { get; }
 060    public BitcoinScript? RemoteUpfrontShutdownScript { get; }
 61
 62    #endregion
 63
 11664    public ChannelModel(ChannelConfig channelConfig, ChannelId channelId, CommitmentNumber commitmentNumber,
 11665                        FundingOutputInfo fundingOutput, bool isInitiator, CompactSignature? lastSentSignature,
 11666                        CompactSignature? lastReceivedSignature, LightningMoney localBalance,
 11667                        ChannelKeySetModel localKeySet, ulong localNextHtlcId, ulong localRevocationNumber,
 11668                        LightningMoney remoteBalance, ChannelKeySetModel remoteKeySet, ulong remoteNextHtlcId,
 11669                        CompactPubKey remoteNodeId, ulong remoteRevocationNumber, ChannelState state,
 11670                        ChannelVersion version, ICollection<Htlc>? localOfferedHtlcs = null,
 11671                        ICollection<Htlc>? localFulfilledHtlcs = null, ICollection<Htlc>? localOldHtlcs = null,
 11672                        BitcoinScript? localUpfrontShutdownScript = null, ICollection<Htlc>? remoteOfferedHtlcs = null,
 11673                        ICollection<Htlc>? remoteFulfilledHtlcs = null, ICollection<Htlc>? remoteOldHtlcs = null,
 11674                        BitcoinScript? remoteUpfrontShutdownScript = null)
 75    {
 11676        ChannelConfig = channelConfig;
 11677        ChannelId = channelId;
 11678        CommitmentNumber = commitmentNumber;
 11679        FundingOutput = fundingOutput;
 11680        IsInitiator = isInitiator;
 11681        LastSentSignature = lastSentSignature;
 11682        LastReceivedSignature = lastReceivedSignature;
 11683        LocalBalance = localBalance;
 11684        LocalKeySet = localKeySet;
 11685        LocalNextHtlcId = localNextHtlcId;
 11686        LocalRevocationNumber = localRevocationNumber;
 11687        RemoteBalance = remoteBalance;
 11688        RemoteKeySet = remoteKeySet;
 11689        RemoteNextHtlcId = remoteNextHtlcId;
 11690        RemoteRevocationNumber = remoteRevocationNumber;
 11691        State = state;
 11692        Version = version;
 11693        RemoteNodeId = remoteNodeId;
 11694        LocalOfferedHtlcs = localOfferedHtlcs ?? new List<Htlc>();
 11695        LocalFulfilledHtlcs = localFulfilledHtlcs ?? new List<Htlc>();
 11696        LocalOldHtlcs = localOldHtlcs ?? new List<Htlc>();
 11697        RemoteOfferedHtlcs = remoteOfferedHtlcs ?? new List<Htlc>();
 11698        RemoteFulfilledHtlcs = remoteFulfilledHtlcs ?? new List<Htlc>();
 11699        RemoteOldHtlcs = remoteOldHtlcs ?? new List<Htlc>();
 116100        LocalUpfrontShutdownScript = localUpfrontShutdownScript;
 116101        RemoteUpfrontShutdownScript = remoteUpfrontShutdownScript;
 116102    }
 103
 104    public void UpdateState(ChannelState newState)
 105    {
 8106        if (State == ChannelState.V2Opening && newState < ChannelState.V2Opening
 8107         || State >= ChannelState.V1Opening && newState == ChannelState.V2Opening)
 0108            throw new ArgumentOutOfRangeException(nameof(newState), "Invalid channel state for update.");
 109
 8110        if (newState <= State)
 0111            throw new ArgumentOutOfRangeException(nameof(newState), "New state must be greater than current state.");
 112
 8113        State = newState;
 8114    }
 115
 116    public void UpdateChannelId(ChannelId newChannelId)
 117    {
 8118        if (newChannelId == ChannelId.Zero)
 0119            throw new ArgumentException("New channel ID cannot be empty.", nameof(newChannelId));
 120
 8121        ChannelId = newChannelId;
 8122    }
 123
 124    public ChannelSigningInfo GetSigningInfo()
 125    {
 8126        return new ChannelSigningInfo(FundingOutput.TransactionId!.Value, FundingOutput.Index!.Value,
 8127                                      FundingOutput.Amount, LocalKeySet.FundingCompactPubKey,
 8128                                      RemoteKeySet.FundingCompactPubKey, LocalKeySet.KeyIndex);
 129    }
 130}

Methods/Properties

get_ChannelConfig()
get_ChannelId()
get_ShortChannelId()
get_CommitmentNumber()
get_FundingCreatedAtBlockHeight()
get_FundingOutput()
get_IsInitiator()
get_RemoteNodeId()
get_State()
get_Version()
get_LastSentSignature()
get_LastReceivedSignature()
get_LocalAliases()
get_LocalBalance()
get_LocalKeySet()
get_LocalNextHtlcId()
get_LocalOfferedHtlcs()
get_LocalFulfilledHtlcs()
get_LocalOldHtlcs()
get_LocalRevocationNumber()
get_LocalUpfrontShutdownScript()
get_RemoteAlias()
get_RemoteBalance()
get_RemoteKeySet()
get_RemoteNextHtlcId()
get_RemoteRevocationNumber()
get_RemoteFulfilledHtlcs()
get_RemoteOfferedHtlcs()
get_RemoteOldHtlcs()
get_RemoteUpfrontShutdownScript()
.ctor(NLightning.Domain.Channels.ValueObjects.ChannelConfig,NLightning.Domain.Channels.ValueObjects.ChannelId,NLightning.Domain.Protocol.Models.CommitmentNumber,NLightning.Domain.Bitcoin.Transactions.Outputs.FundingOutputInfo,System.Boolean,NLightning.Domain.Crypto.ValueObjects.CompactSignature,NLightning.Domain.Crypto.ValueObjects.CompactSignature,NLightning.Domain.Money.LightningMoney,NLightning.Domain.Channels.Models.ChannelKeySetModel,System.UInt64,System.UInt64,NLightning.Domain.Money.LightningMoney,NLightning.Domain.Channels.Models.ChannelKeySetModel,System.UInt64,NLightning.Domain.Crypto.ValueObjects.CompactPubKey,System.UInt64,NLightning.Domain.Channels.Enums.ChannelState,NLightning.Domain.Channels.Enums.ChannelVersion,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Nullable`1<NLightning.Domain.Bitcoin.ValueObjects.BitcoinScript>,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Nullable`1<NLightning.Domain.Bitcoin.ValueObjects.BitcoinScript>)
UpdateState(NLightning.Domain.Channels.Enums.ChannelState)
UpdateChannelId(NLightning.Domain.Channels.ValueObjects.ChannelId)
GetSigningInfo()