< Summary - Combined Code Coverage

Information
Class: NLightning.Domain.Protocol.Payloads.TxAddOutputPayload
Assembly: NLightning.Domain
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Domain/Protocol/Payloads/TxAddOutputPayload.cs
Tag: 30_15166811759
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 63
Line coverage: 100%
Branch coverage
50%
Covered branches: 3
Total branches: 6
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_ChannelId()100%11100%
get_SerialId()100%11100%
get_Amount()100%11100%
get_Script()100%11100%
.ctor(...)50%66100%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Domain/Protocol/Payloads/TxAddOutputPayload.cs

#LineLine coverage
 1using NBitcoin;
 2
 3namespace NLightning.Domain.Protocol.Payloads;
 4
 5using Interfaces;
 6using Messages;
 7using Money;
 8using ValueObjects;
 9
 10/// <summary>
 11/// Represents a tx_add_output payload.
 12/// </summary>
 13/// <remarks>
 14/// The tx_add_output payload is used to add an output to the transaction.
 15/// </remarks>
 16/// <seealso cref="TxAddOutputMessage"/>
 17/// <seealso cref="ValueObjects.ChannelId"/>
 18public class TxAddOutputPayload : IMessagePayload
 19{
 20    /// <summary>
 21    /// The channel id.
 22    /// </summary>
 823    public ChannelId ChannelId { get; }
 24
 25    /// <summary>
 26    /// The serial id.
 27    /// </summary>
 828    public ulong SerialId { get; }
 29
 30    /// <summary>
 31    /// The sats amount.
 32    /// </summary>
 833    public LightningMoney Amount { get; }
 34
 35    /// <summary>
 36    /// The spending script.
 37    /// </summary>
 1238    public Script Script { get; }
 39
 40    /// <summary>
 41    /// Initializes a new instance of the <see cref="TxAddOutputPayload"/> class.
 42    /// </summary>
 43    /// <param name="channelId">The channel id.</param>
 44    /// <param name="serialId">The serial id.</param>
 45    /// <param name="amount">The sats amount.</param>
 46    /// <param name="script">The spending script.</param>
 47    /// <exception cref="ArgumentException">ScriptPubKey length is out of bounds.</exception>
 1248    public TxAddOutputPayload(LightningMoney amount, ChannelId channelId, Script script, ulong serialId)
 49    {
 50        // Check if script is only types P2WSH, P2WPKH, or P2TR using NBitcoin
 1251        if (!PayToWitScriptHashTemplate.Instance.CheckScriptPubKey(script)
 1252            && !PayToWitPubKeyHashTemplate.Instance.CheckScriptPubKey(script)
 1253            && !PayToTaprootTemplate.Instance.CheckScriptPubKey(script))
 54        {
 455            throw new ArgumentException("Script is non-standard");
 56        }
 57
 858        ChannelId = channelId;
 859        SerialId = serialId;
 860        Amount = amount;
 861        Script = script;
 862    }
 63}