| | 1 | | namespace NLightning.Domain.Protocol.Payloads; |
| | 2 | |
|
| | 3 | | using Channels.ValueObjects; |
| | 4 | | using Constants; |
| | 5 | | using Interfaces; |
| | 6 | | using Messages; |
| | 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="Channels.ValueObjects.ChannelId"/> |
| | 16 | | public class TxAddInputPayload : IChannelMessagePayload |
| | 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.MaxSequence) |
| | 55 | | { |
| 4 | 56 | | throw new ArgumentException( |
| 4 | 57 | | $"Sequence must be less than or equal to {InteractiveTransactionConstants.MaxSequence}", |
| 4 | 58 | | nameof(sequence)); |
| | 59 | | } |
| | 60 | |
|
| 8 | 61 | | ChannelId = channelId; |
| 8 | 62 | | SerialId = serialId; |
| 8 | 63 | | PrevTx = prevTx; |
| 8 | 64 | | PrevTxVout = prevTxVout; |
| 8 | 65 | | Sequence = sequence; |
| 8 | 66 | | } |
| | 67 | | } |