| | 1 | | namespace NLightning.Domain.Protocol.Payloads; |
| | 2 | |
|
| | 3 | | using Constants; |
| | 4 | | using Interfaces; |
| | 5 | | using Messages; |
| | 6 | | using ValueObjects; |
| | 7 | |
|
| | 8 | | /// <summary> |
| | 9 | | /// Represents a tx_add_input payload. |
| | 10 | | /// </summary> |
| | 11 | | /// <remarks> |
| | 12 | | /// The tx_add_input payload is used to add an input to the transaction. |
| | 13 | | /// </remarks> |
| | 14 | | /// <seealso cref="TxAddInputMessage"/> |
| | 15 | | /// <seealso cref="ValueObjects.ChannelId"/> |
| | 16 | | public class TxAddInputPayload : IMessagePayload |
| | 17 | | { |
| | 18 | | /// <summary> |
| | 19 | | /// The channel id. |
| | 20 | | /// </summary> |
| 8 | 21 | | public ChannelId ChannelId { get; } |
| | 22 | |
|
| | 23 | | /// <summary> |
| | 24 | | /// The serial id. |
| | 25 | | /// </summary> |
| 8 | 26 | | public ulong SerialId { get; } |
| | 27 | |
|
| | 28 | | /// <summary> |
| | 29 | | /// The previous transaction id. |
| | 30 | | /// </summary> |
| 12 | 31 | | public byte[] PrevTx { get; } |
| | 32 | |
|
| | 33 | | /// <summary> |
| | 34 | | /// The previous transaction vout. |
| | 35 | | /// </summary> |
| 8 | 36 | | public uint PrevTxVout { get; } |
| | 37 | |
|
| | 38 | | /// <summary> |
| | 39 | | /// The sequence. |
| | 40 | | /// </summary> |
| 8 | 41 | | public uint Sequence { get; } |
| | 42 | |
|
| | 43 | | /// <summary> |
| | 44 | | /// Initializes a new instance of the TxAddInputPayload class. |
| | 45 | | /// </summary> |
| | 46 | | /// <param name="channelId">The channel id.</param> |
| | 47 | | /// <param name="serialId">The serial id.</param> |
| | 48 | | /// <param name="prevTx">The previous transaction id.</param> |
| | 49 | | /// <param name="prevTxVout">The previous transaction vout.</param> |
| | 50 | | /// <param name="sequence">The sequence.</param> |
| | 51 | | /// <exception cref="ArgumentException">Sequence is out of bounds.</exception> |
| 12 | 52 | | public TxAddInputPayload(ChannelId channelId, ulong serialId, byte[] prevTx, uint prevTxVout, uint sequence) |
| | 53 | | { |
| 12 | 54 | | if (sequence > InteractiveTransactionConstants.MAX_SEQUENCE) |
| | 55 | | { |
| 4 | 56 | | throw new ArgumentException($"Sequence must be less than or equal to {InteractiveTransactionConstants.MAX_SE |
| | 57 | | } |
| | 58 | |
|
| 8 | 59 | | ChannelId = channelId; |
| 8 | 60 | | SerialId = serialId; |
| 8 | 61 | | PrevTx = prevTx; |
| 8 | 62 | | PrevTxVout = prevTxVout; |
| 8 | 63 | | Sequence = sequence; |
| 8 | 64 | | } |
| | 65 | | } |