< Summary - Combined Code Coverage

Information
Class: NLightning.Infrastructure.Bitcoin.Factories.CommitmentTransactionFactory
Assembly: NLightning.Infrastructure.Bitcoin
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Infrastructure.Bitcoin/Factories/CommitmentTransactionFactory.cs
Tag: 30_15166811759
Line coverage
100%
Covered lines: 26
Uncovered lines: 0
Coverable lines: 26
Total lines: 78
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
CreateCommitmentTransaction(...)100%11100%
CreateCommitmentTransaction(...)100%44100%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Infrastructure.Bitcoin/Factories/CommitmentTransactionFactory.cs

#LineLine coverage
 1using Microsoft.Extensions.Options;
 2using NBitcoin;
 3
 4namespace NLightning.Infrastructure.Bitcoin.Factories;
 5
 6using Domain.Bitcoin.Services;
 7using Domain.Money;
 8using Domain.Node.Options;
 9using Domain.Protocol.Factories;
 10using Outputs;
 11using Protocol.Models;
 12using Transactions;
 13
 14public class CommitmentTransactionFactory : ICommitmentTransactionFactory
 15{
 16    private readonly IFeeService _feeService;
 17    private readonly NodeOptions _nodeOptions;
 18
 10019    public CommitmentTransactionFactory(IFeeService feeService, IOptions<NodeOptions> nodeOptions)
 20    {
 10021        _feeService = feeService;
 10022        _nodeOptions = nodeOptions.Value;
 10023    }
 24
 25    public CommitmentTransaction CreateCommitmentTransaction(FundingOutput fundingOutput, PubKey localPaymentBasepoint,
 26                                                             PubKey remotePaymentBasepoint, PubKey localDelayedPubKey,
 27                                                             PubKey revocationPubKey, LightningMoney toLocalAmount,
 28                                                             LightningMoney toRemoteAmount, uint toSelfDelay,
 29                                                             CommitmentNumber commitmentNumber, bool isChannelFunder,
 30                                                             params BitcoinSecret[] secrets)
 31    {
 3632        var commitmentTransaction = new CommitmentTransaction(_nodeOptions.AnchorAmount, _nodeOptions.DustLimitAmount,
 3633                                                              _nodeOptions.MustTrimHtlcOutputs, _nodeOptions.Network,
 3634                                                              fundingOutput, localPaymentBasepoint,
 3635                                                              remotePaymentBasepoint, localDelayedPubKey,
 3636                                                              revocationPubKey, toLocalAmount, toRemoteAmount,
 3637                                                              toSelfDelay, commitmentNumber, isChannelFunder);
 38
 3639        commitmentTransaction.ConstructTransaction(_feeService.GetCachedFeeRatePerKw());
 40
 3641        commitmentTransaction.SignTransaction(secrets);
 42
 3643        return commitmentTransaction;
 44    }
 45
 46    public CommitmentTransaction CreateCommitmentTransaction(FundingOutput fundingOutput, PubKey localPaymentBasepoint,
 47                                                             PubKey remotePaymentBasepoint, PubKey localDelayedPubKey,
 48                                                             PubKey revocationPubKey, LightningMoney toLocalAmount,
 49                                                             LightningMoney toRemoteAmount, uint toSelfDelay,
 50                                                             CommitmentNumber commitmentNumber, bool isChannelFunder,
 51                                                             IEnumerable<OfferedHtlcOutput> offeredHtlcs,
 52                                                             IEnumerable<ReceivedHtlcOutput> receivedHtlcs,
 53                                                             params BitcoinSecret[] secrets)
 54    {
 6455        var commitmentTransaction = new CommitmentTransaction(_nodeOptions.AnchorAmount, _nodeOptions.DustLimitAmount,
 6456                                                              _nodeOptions.MustTrimHtlcOutputs, _nodeOptions.Network,
 6457                                                              fundingOutput, localPaymentBasepoint,
 6458                                                              remotePaymentBasepoint, localDelayedPubKey,
 6459                                                              revocationPubKey, toLocalAmount, toRemoteAmount,
 6460                                                              toSelfDelay, commitmentNumber, isChannelFunder);
 61
 31262        foreach (var offeredHtlc in offeredHtlcs)
 63        {
 9264            commitmentTransaction.AddOfferedHtlcOutput(offeredHtlc);
 65        }
 66
 32867        foreach (var receivedHtlc in receivedHtlcs)
 68        {
 10069            commitmentTransaction.AddReceivedHtlcOutput(receivedHtlc);
 70        }
 71
 6472        commitmentTransaction.ConstructTransaction(_feeService.GetCachedFeeRatePerKw());
 73
 6474        commitmentTransaction.SignTransaction(secrets);
 75
 6476        return commitmentTransaction;
 77    }
 78}