add custom exception for transaction fee overpayment
MODIFY
WalletWasabi.Tests/UnitTests/Transactions/TransactionFactoryTests.cs
WalletWasabi.Tests/UnitTests/Transactions/TransactionFactoryTests.cs
@@ -53,8 +53,7 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
Assert.Equal(result.Fee, output.Amount); // edge case! paid amount equal to paid fee
// The transaction cost is higher than the intended payment.
- var ex = Assert.Throws<InvalidOperationException>(() => transactionFactory.BuildTransaction(payment, new FeeRate(50m)));
- Assert.StartsWith("The transaction fee is more than twice the sent amount", ex.Message);
+ Assert.Throws<TransactionFeeOverpaymentException>(() => transactionFactory.BuildTransaction(payment, new FeeRate(50m)));
}
[Fact]

MODIFY
WalletWasabi/Blockchain/Transactions/TransactionFactory.cs
WalletWasabi/Blockchain/Transactions/TransactionFactory.cs
@@ -207,7 +207,7 @@ namespace WalletWasabi.Blockchain.Transactions
}
if (feePc > 100)
{
- throw new InvalidOperationException($"The transaction fee is more than twice the sent amount: {feePc:0.#}%.");
+ throw new TransactionFeeOverpaymentException(feePc);
}
if (spentCoins.Any(u => !u.Confirmed))

ADD
WalletWasabi/Exceptions/TransactionFeeOverpaymentException.cs
+using System;
+
+namespace WalletWasabi.Exceptions
+{
+ public class TransactionFeeOverpaymentException : Exception
+ {
+ public TransactionFeeOverpaymentException(decimal percentageOfOverpayment)
+ : base($"The transaction fee is more than twice the sent amount: {percentageOfOverpayment:0.#}%.")
+ {
+ PercentageOfOverpayment = percentageOfOverpayment;
+ }
+
+ public decimal PercentageOfOverpayment { get; }
+ }
+}

add custom exception for transaction fee overpayment