| | 1 | | namespace NLightning.Domain.Protocol.Payloads; |
| | 2 | |
|
| | 3 | | using Channels.ValueObjects; |
| | 4 | | using Crypto.ValueObjects; |
| | 5 | | using Interfaces; |
| | 6 | | using Money; |
| | 7 | | using ValueObjects; |
| | 8 | |
|
| | 9 | | /// <summary> |
| | 10 | | /// Represents the payload for the open_channel2 message. |
| | 11 | | /// </summary> |
| | 12 | | /// <remarks> |
| | 13 | | /// Initializes a new instance of the OpenChannel2Payload class. |
| | 14 | | /// </remarks> |
| 20 | 15 | | public class OpenChannel2Payload( |
| 20 | 16 | | ChainHash chainHash, |
| 20 | 17 | | ChannelFlags channelFlags, |
| 20 | 18 | | uint commitmentFeeRatePerKw, |
| 20 | 19 | | CompactPubKey delayedPaymentBasepoint, |
| 20 | 20 | | LightningMoney dustLimitAmount, |
| 20 | 21 | | CompactPubKey firstPerCommitmentPoint, |
| 20 | 22 | | ulong fundingAmount, |
| 20 | 23 | | uint fundingFeeRatePerKw, |
| 20 | 24 | | CompactPubKey fundingPubKey, |
| 20 | 25 | | CompactPubKey htlcBasepoint, |
| 20 | 26 | | LightningMoney htlcMinimumAmount, |
| 20 | 27 | | uint locktime, |
| 20 | 28 | | ushort maxAcceptedHtlcs, |
| 20 | 29 | | LightningMoney maxHtlcValueInFlight, |
| 20 | 30 | | CompactPubKey paymentBasepoint, |
| 20 | 31 | | CompactPubKey revocationBasepoint, |
| 20 | 32 | | CompactPubKey secondPerCommitmentPoint, |
| 20 | 33 | | ushort toSelfDelay, |
| 20 | 34 | | ChannelId channelId) : IChannelMessagePayload |
| | 35 | | { |
| | 36 | | /// <summary> |
| | 37 | | /// The chain_hash value denotes the exact blockchain that the opened channel will reside within. |
| | 38 | | /// </summary> |
| 36 | 39 | | public ChainHash ChainHash { get; } = chainHash; |
| | 40 | |
|
| | 41 | | /// <summary> |
| | 42 | | /// The temporary_channel_id is used to identify this channel on a per-peer basis until the funding transaction |
| | 43 | | /// is established, at which point it is replaced by the channel_id, which is derived from the funding transaction. |
| | 44 | | /// </summary> |
| 36 | 45 | | public ChannelId ChannelId { get; } = channelId; |
| | 46 | |
|
| | 47 | | /// <summary> |
| | 48 | | /// funding_feerate_perkw indicates the fee rate that the opening node will pay for the funding transaction in |
| | 49 | | /// satoshi per 1000-weight, as described in BOLT-3, Appendix F |
| | 50 | | /// </summary> |
| 36 | 51 | | public uint FundingFeeRatePerKw { get; } = fundingFeeRatePerKw; |
| | 52 | |
|
| | 53 | | /// <summary> |
| | 54 | | /// commitment_feerate_perkw indicates the fee rate that will be paid for the commitment transaction in |
| | 55 | | /// satoshi per 1000-weight, as described in BOLT-3, Appendix F |
| | 56 | | /// </summary> |
| 36 | 57 | | public uint CommitmentFeeRatePerKw { get; } = commitmentFeeRatePerKw; |
| | 58 | |
|
| | 59 | | /// <summary> |
| | 60 | | /// funding_satoshis is the amount the sender is putting into the channel. |
| | 61 | | /// </summary> |
| 36 | 62 | | public LightningMoney FundingAmount { get; } = fundingAmount; |
| | 63 | |
|
| | 64 | | /// <summary> |
| | 65 | | /// dust_limit_satoshis is the threshold below which outputs should not be generated for this node's commitment or |
| | 66 | | /// HTLC transactions |
| | 67 | | /// </summary> |
| 36 | 68 | | public LightningMoney DustLimitAmount { get; } = dustLimitAmount; |
| | 69 | |
|
| | 70 | | /// <summary> |
| | 71 | | /// max_htlc_value_in_flight_msat is a cap on total value of outstanding HTLCs offered by the remote node, which |
| | 72 | | /// allows the local node to limit its exposure to HTLCs |
| | 73 | | /// </summary> |
| 36 | 74 | | public LightningMoney MaxHtlcValueInFlightAmount { get; } = maxHtlcValueInFlight; |
| | 75 | |
|
| | 76 | | /// <summary> |
| | 77 | | /// htlc_minimum_msat indicates the smallest value HTLC this node will accept. |
| | 78 | | /// </summary> |
| 36 | 79 | | public LightningMoney HtlcMinimumAmount { get; } = htlcMinimumAmount; |
| | 80 | |
|
| | 81 | | /// <summary> |
| | 82 | | /// to_self_delay is how long (in blocks) the other node will have to wait in case of breakdown before redeeming |
| | 83 | | /// its own funds. |
| | 84 | | /// </summary> |
| 36 | 85 | | public ushort ToSelfDelay { get; } = toSelfDelay; |
| | 86 | |
|
| | 87 | | /// <summary> |
| | 88 | | /// max_accepted_htlcs limits the number of outstanding HTLCs the remote node can offer. |
| | 89 | | /// </summary> |
| 36 | 90 | | public ushort MaxAcceptedHtlcs { get; } = maxAcceptedHtlcs; |
| | 91 | |
|
| | 92 | | /// <summary> |
| | 93 | | /// locktime is the locktime for the funding transaction. |
| | 94 | | /// </summary> |
| 36 | 95 | | public uint Locktime { get; } = locktime; |
| | 96 | |
|
| | 97 | | /// <summary> |
| | 98 | | /// funding_pubkey is the public key in the 2-of-2 multisig script of the funding transaction output. |
| | 99 | | /// </summary> |
| 36 | 100 | | public CompactPubKey FundingPubKey { get; } = fundingPubKey; |
| | 101 | |
|
| | 102 | | /// <summary> |
| | 103 | | /// revocation_basepoint is used to regenerate the scripts required for the penalty transaction |
| | 104 | | /// </summary> |
| 36 | 105 | | public CompactPubKey RevocationBasepoint { get; } = revocationBasepoint; |
| | 106 | |
|
| | 107 | | /// <summary> |
| | 108 | | /// payment_basepoint is used to produce payment signatures for the protocol |
| | 109 | | /// </summary> |
| 36 | 110 | | public CompactPubKey PaymentBasepoint { get; } = paymentBasepoint; |
| | 111 | |
|
| | 112 | | /// <summary> |
| | 113 | | /// delayed_payment_basepoint is used to regenerate the scripts required for the penalty transaction |
| | 114 | | /// </summary> |
| 36 | 115 | | public CompactPubKey DelayedPaymentBasepoint { get; } = delayedPaymentBasepoint; |
| | 116 | |
|
| | 117 | | /// <summary> |
| | 118 | | /// htlc_basepoint is used to produce HTLC signatures for the protocol |
| | 119 | | /// </summary> |
| 36 | 120 | | public CompactPubKey HtlcBasepoint { get; } = htlcBasepoint; |
| | 121 | |
|
| | 122 | | /// <summary> |
| | 123 | | /// first_per_commitment_point is the per-commitment point used for the first commitment transaction |
| | 124 | | /// </summary> |
| 36 | 125 | | public CompactPubKey FirstPerCommitmentPoint { get; } = firstPerCommitmentPoint; |
| | 126 | |
|
| | 127 | | /// <summary> |
| | 128 | | /// second_per_commitment_point is the per-commitment point used for the first commitment transaction |
| | 129 | | /// </summary> |
| 36 | 130 | | public CompactPubKey SecondPerCommitmentPoint { get; } = secondPerCommitmentPoint; |
| | 131 | |
|
| | 132 | | /// <summary> |
| | 133 | | /// Only the least-significant bit of channel_flags is currently defined: announce_channel. This indicates whether |
| | 134 | | /// the initiator of the funding flow wishes to advertise this channel publicly to the network |
| | 135 | | /// </summary> |
| 36 | 136 | | public ChannelFlags ChannelFlags { get; } = channelFlags; |
| | 137 | | } |