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