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