< Summary - Combined Code Coverage

Information
Class: NLightning.Domain.Channels.Models.ChannelKeySetModel
Assembly: NLightning.Domain
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Domain/Channels/Models/ChannelKeySetModel.cs
Tag: 36_15743069263
Line coverage
78%
Covered lines: 25
Uncovered lines: 7
Coverable lines: 32
Total lines: 69
Line coverage: 78.1%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
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/ChannelKeySetModel.cs

#LineLine coverage
 1namespace NLightning.Domain.Channels.Models;
 2
 3using Crypto.Constants;
 4using Crypto.ValueObjects;
 5
 6public class ChannelKeySetModel
 7{
 1448    public uint KeyIndex { get; }
 1169    public CompactPubKey FundingCompactPubKey { get; }
 8810    public CompactPubKey RevocationCompactBasepoint { get; }
 15611    public CompactPubKey PaymentCompactBasepoint { get; }
 8812    public CompactPubKey DelayedPaymentCompactBasepoint { get; }
 13
 8814    public CompactPubKey HtlcCompactBasepoint { get; }
 20015    public CompactPubKey CurrentPerCommitmentCompactPoint { get; private set; }
 24816    public ulong CurrentPerCommitmentIndex { get; private set; }
 17
 18    /// <summary>
 19    /// For remote key sets: stores their last revealed per-commitment secret
 20    /// This is needed to create penalty transactions if they broadcast old commitments
 21    /// For local key sets: this should be null (we don't store our own secrets)
 22    /// </summary>
 18023    public byte[]? LastRevealedPerCommitmentSecret { get; private set; }
 24
 18025    public ChannelKeySetModel(uint keyIndex, CompactPubKey fundingCompactPubKey,
 18026                              CompactPubKey revocationCompactBasepoint, CompactPubKey paymentCompactBasepoint,
 18027                              CompactPubKey delayedPaymentCompactBasepoint, CompactPubKey htlcCompactBasepoint,
 18028                              CompactPubKey currentPerCommitmentCompactPoint,
 18029                              ulong currentPerCommitmentIndex = CryptoConstants.FirstPerCommitmentIndex,
 18030                              byte[]? lastRevealedPerCommitmentSecret = null)
 31    {
 18032        KeyIndex = keyIndex;
 18033        FundingCompactPubKey = fundingCompactPubKey;
 18034        RevocationCompactBasepoint = revocationCompactBasepoint;
 18035        PaymentCompactBasepoint = paymentCompactBasepoint;
 18036        DelayedPaymentCompactBasepoint = delayedPaymentCompactBasepoint;
 18037        HtlcCompactBasepoint = htlcCompactBasepoint;
 18038        CurrentPerCommitmentCompactPoint = currentPerCommitmentCompactPoint;
 18039        CurrentPerCommitmentIndex = currentPerCommitmentIndex;
 18040        LastRevealedPerCommitmentSecret = lastRevealedPerCommitmentSecret;
 18041    }
 42
 43    public void UpdatePerCommitmentPoint(CompactPubKey newPoint)
 44    {
 045        CurrentPerCommitmentCompactPoint = newPoint;
 046        CurrentPerCommitmentIndex--;
 047    }
 48
 49    /// <summary>
 50    /// Store a revealed per-commitment secret from the counterparty
 51    /// This is called when they send a revoke_and_ack message
 52    /// </summary>
 53    public void RevealPerCommitmentSecret(byte[] secret)
 54    {
 055        LastRevealedPerCommitmentSecret = secret;
 056    }
 57
 58    /// <summary>
 59    /// Create a ChannelKeySet for the remote party (we don't generate their keys)
 60    /// </summary>
 61    public static ChannelKeySetModel CreateForRemote(CompactPubKey fundingPubKey, CompactPubKey revocationBasepoint,
 62                                                     CompactPubKey paymentBasepoint,
 63                                                     CompactPubKey delayedPaymentBasepoint, CompactPubKey htlcBasepoint,
 64                                                     CompactPubKey firstPerCommitmentPoint)
 65    {
 066        return new ChannelKeySetModel(0, fundingPubKey, revocationBasepoint, paymentBasepoint, delayedPaymentBasepoint,
 067                                      htlcBasepoint, firstPerCommitmentPoint);
 68    }
 69}