| | 1 | | // ReSharper disable PropertyCanBeMadeInitOnly.Global |
| | 2 | |
|
| | 3 | | namespace NLightning.Infrastructure.Persistence.Entities.Channel; |
| | 4 | |
|
| | 5 | | using Bitcoin; |
| | 6 | | using Domain.Bitcoin.ValueObjects; |
| | 7 | | using Domain.Channels.ValueObjects; |
| | 8 | | using Domain.Crypto.ValueObjects; |
| | 9 | |
|
| | 10 | | /// <summary> |
| | 11 | | /// Represents a Lightning Network payment channel entity in the persistence layer. |
| | 12 | | /// </summary> |
| | 13 | | public class ChannelEntity |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// The unique channel identifier used to reference this channel on the Lightning Network. |
| | 17 | | /// </summary> |
| 0 | 18 | | public required ChannelId ChannelId { get; set; } |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// The block height at which the funding transaction for the channel was created. |
| | 22 | | /// Used to track the blockchain state relevant to the channel's funding process. |
| | 23 | | /// </summary> |
| 0 | 24 | | public uint FundingCreatedAtBlockHeight { get; set; } |
| | 25 | |
|
| | 26 | | /// <summary> |
| | 27 | | /// The transaction ID of the funding transaction that established this channel. |
| | 28 | | /// </summary> |
| 0 | 29 | | public required TxId FundingTxId { get; set; } |
| | 30 | |
|
| | 31 | | /// <summary> |
| | 32 | | /// The output index in the funding transaction that contains the channel funding. |
| | 33 | | /// </summary> |
| 0 | 34 | | public required ushort FundingOutputIndex { get; set; } |
| | 35 | |
|
| | 36 | | /// <summary> |
| | 37 | | /// The amount of satoshis locked in the funding output for this channel. |
| | 38 | | /// </summary> |
| 0 | 39 | | public required long FundingAmountSatoshis { get; set; } |
| | 40 | |
|
| | 41 | | /// <summary> |
| | 42 | | /// Indicates whether the local node initiated the channel opening. |
| | 43 | | /// </summary> |
| 0 | 44 | | public required bool IsInitiator { get; set; } |
| | 45 | |
|
| | 46 | | /// <summary> |
| | 47 | | /// The public key of the channel counterparty. |
| | 48 | | /// </summary> |
| 0 | 49 | | public required CompactPubKey RemoteNodeId { get; set; } |
| | 50 | |
|
| | 51 | | /// <summary> |
| | 52 | | /// The next HTLC ID to be used by the local node. |
| | 53 | | /// </summary> |
| 0 | 54 | | public required ulong LocalNextHtlcId { get; set; } |
| | 55 | |
|
| | 56 | | /// <summary> |
| | 57 | | /// The next HTLC ID to be used by the remote node. |
| | 58 | | /// </summary> |
| 0 | 59 | | public required ulong RemoteNextHtlcId { get; set; } |
| | 60 | |
|
| | 61 | | /// <summary> |
| | 62 | | /// The current local revocation number. |
| | 63 | | /// </summary> |
| 0 | 64 | | public required ulong LocalRevocationNumber { get; set; } |
| | 65 | |
|
| | 66 | | /// <summary> |
| | 67 | | /// The current remote revocation number. |
| | 68 | | /// </summary> |
| 0 | 69 | | public required ulong RemoteRevocationNumber { get; set; } |
| | 70 | |
|
| | 71 | | /// <summary> |
| | 72 | | /// The last signature sent to the remote node, stored as a byte array. |
| | 73 | | /// </summary> |
| 0 | 74 | | public byte[]? LastSentSignature { get; set; } |
| | 75 | |
|
| | 76 | | /// <summary> |
| | 77 | | /// The last signature received from the remote node, stored as a byte array. |
| | 78 | | /// </summary> |
| 0 | 79 | | public byte[]? LastReceivedSignature { get; set; } |
| | 80 | |
|
| | 81 | | /// <summary> |
| | 82 | | /// The current state of the channel. |
| | 83 | | /// </summary> |
| 0 | 84 | | public required byte State { get; set; } |
| | 85 | |
|
| | 86 | | /// <summary> |
| | 87 | | /// Indicates the channel format version associated with this channel entity, |
| | 88 | | /// used to handle version-specific behaviors within the persistence layer. |
| | 89 | | /// </summary> |
| 0 | 90 | | public required byte Version { get; set; } |
| | 91 | |
|
| | 92 | | /// <summary> |
| | 93 | | /// The current balance of the local node in satoshis. |
| | 94 | | /// </summary> |
| 0 | 95 | | public required decimal LocalBalanceSatoshis { get; set; } |
| | 96 | |
|
| | 97 | | /// <summary> |
| | 98 | | /// The current balance of the remote node in satoshis. |
| | 99 | | /// </summary> |
| 0 | 100 | | public required decimal RemoteBalanceSatoshis { get; set; } |
| | 101 | |
|
| | 102 | | /// <summary> |
| | 103 | | /// Represents the configuration settings associated with the Lightning Network payment channel, |
| | 104 | | /// defining operational parameters such as limits, timeouts, and other key configurations. |
| | 105 | | /// </summary> |
| 0 | 106 | | public virtual ChannelConfigEntity? Config { get; set; } |
| | 107 | |
|
| | 108 | | /// <summary> |
| | 109 | | /// Collection of cryptographic key sets related to the Lightning Network channel. |
| | 110 | | /// Defines entities that store and track keys associated with different roles (local/remote) in the channel. |
| | 111 | | /// </summary> |
| 0 | 112 | | public virtual ICollection<ChannelKeySetEntity>? KeySets { get; set; } |
| | 113 | |
|
| | 114 | | /// <summary> |
| | 115 | | /// The collection of HTLC (Hashed TimeLock Contracts) entities associated with this payment channel. |
| | 116 | | /// Each HTLC represents a conditional payment in the channel. |
| | 117 | | /// </summary> |
| 0 | 118 | | public virtual ICollection<HtlcEntity>? Htlcs { get; set; } |
| | 119 | |
|
| | 120 | | /// <summary> |
| | 121 | | /// A collection of transactions that are monitored for a specific channel, |
| | 122 | | /// typically to track and validate on-chain activity related to the channel's lifecycle. |
| | 123 | | /// </summary> |
| 0 | 124 | | public virtual ICollection<WatchedTransactionEntity>? WatchedTransactions { get; set; } |
| | 125 | |
|
| | 126 | | /// <summary> |
| | 127 | | /// Default constructor for EF Core. |
| | 128 | | /// </summary> |
| 0 | 129 | | internal ChannelEntity() |
| | 130 | | { |
| 0 | 131 | | } |
| | 132 | | } |