| | | 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.MaxInputsAllowed) |
| | | 21 | | { |
| | 0 | 22 | | throw new InvalidOperationException($"There are more than {InteractiveTransactionConstants.MaxInputsAllowed} |
| | | 23 | | } |
| | | 24 | | |
| | 0 | 25 | | if (currentOutputCount > InteractiveTransactionConstants.MaxOutputsAllowed) |
| | | 26 | | { |
| | 0 | 27 | | throw new InvalidOperationException($"There are more than {InteractiveTransactionConstants.MaxOutputsAllowed |
| | | 28 | | } |
| | | 29 | | |
| | 0 | 30 | | if (estimatedTxWeight > InteractiveTransactionConstants.MaxStandardTxWeight) |
| | | 31 | | { |
| | 0 | 32 | | throw new InvalidOperationException($"The estimated weight of the transaction is greater than {InteractiveTr |
| | | 33 | | } |
| | 0 | 34 | | } |
| | | 35 | | } |