| | 1 | | namespace NLightning.Infrastructure.Protocol.Validators; |
| | 2 | |
|
| | 3 | | using Domain.Protocol.Constants; |
| | 4 | |
|
| | 5 | | public static class TxCompleteValidator |
| | 6 | | { |
| | 7 | | public static void Validate(ulong peerInputSatoshis, ulong peerOutputSatoshis, ulong peerFundingOutput, ulong agreed |
| | 8 | | ulong peerPaidFeerate, int currentInputCount, int currentOutputCount, ulong estimatedTxW |
| | 9 | | { |
| 0 | 10 | | if (peerInputSatoshis < peerOutputSatoshis + peerFundingOutput) |
| | 11 | | { |
| 0 | 12 | | throw new InvalidOperationException("The peer's total input satoshis is less than their outputs."); |
| | 13 | | } |
| | 14 | |
|
| 0 | 15 | | if (peerPaidFeerate < agreedFeerate) |
| | 16 | | { |
| 0 | 17 | | throw new InvalidOperationException("The peer's paid feerate does not meet or exceed the agreed feerate."); |
| | 18 | | } |
| | 19 | |
|
| 0 | 20 | | if (currentInputCount > InteractiveTransactionConstants.MAX_INPUTS_ALLOWED) |
| | 21 | | { |
| 0 | 22 | | throw new InvalidOperationException($"There are more than {InteractiveTransactionConstants.MAX_INPUTS_ALLOWE |
| | 23 | | } |
| | 24 | |
|
| 0 | 25 | | if (currentOutputCount > InteractiveTransactionConstants.MAX_OUTPUTS_ALLOWED) |
| | 26 | | { |
| 0 | 27 | | throw new InvalidOperationException($"There are more than {InteractiveTransactionConstants.MAX_OUTPUTS_ALLOW |
| | 28 | | } |
| | 29 | |
|
| 0 | 30 | | if (estimatedTxWeight > InteractiveTransactionConstants.MAX_STANDARD_TX_WEIGHT) |
| | 31 | | { |
| 0 | 32 | | throw new InvalidOperationException($"The estimated weight of the transaction is greater than {InteractiveTr |
| | 33 | | } |
| 0 | 34 | | } |
| | 35 | | } |