Move Translations to RpcParser
MODIFY
WalletWasabi/BitcoinCore/RpcParser.cs
WalletWasabi/BitcoinCore/RpcParser.cs
@@ -8,8 +8,23 @@ using WalletWasabi.BitcoinCore.RpcModels;
namespace WalletWasabi.BitcoinCore
{
- public class RpcParser
+ public static class RpcParser
{
+ public static Dictionary<string, string> ErrorTranslations { get; } = new Dictionary<string, string>
+ {
+ ["too-long-mempool-chain"] = "At least one coin you are trying to spend is part of long or heavy chain of unconfirmed transactions. You must wait for some previous transactions to confirm.",
+ ["bad-txns-inputs-missingorspent"] = "At least one coin you are trying to spend is already spent.",
+ ["missing-inputs"] = "At least one coin you are trying to spend is already spent.",
+ ["txn-mempool-conflict"] = "At least one coin you are trying to spend is already spent.",
+ ["bad-txns-inputs-duplicate"] = "The transaction contains duplicated inputs.",
+ ["bad-txns-nonfinal"] = "The transaction is not final and cannot be broadcasted.",
+ ["bad-txns-oversize"] = "The transaction is too big.",
+
+ ["invalid password"] = "Wrong password.",
+ ["Invalid wallet name"] = "Invalid wallet name.",
+ ["Wallet name is already taken"] = "Wallet name is already taken."
+ };
+
public static RpcPubkeyType ConvertPubkeyType(string pubKeyType)
{
return pubKeyType switch

MODIFY
WalletWasabi/Extensions/ExceptionExtensions.cs
WalletWasabi/Extensions/ExceptionExtensions.cs
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
+using WalletWasabi.BitcoinCore;
using WalletWasabi.Helpers;
using WalletWasabi.Hwi.Exceptions;
using WalletWasabi.Models;
@@ -9,21 +10,6 @@ namespace System
{
public static class ExceptionExtensions
{
- public static Dictionary<string, string> Translations { get; } = new Dictionary<string, string>
- {
- ["too-long-mempool-chain"] = "At least one coin you are trying to spend is part of long or heavy chain of unconfirmed transactions. You must wait for some previous transactions to confirm.",
- ["bad-txns-inputs-missingorspent"] = "At least one coin you are trying to spend is already spent.",
- ["missing-inputs"] = "At least one coin you are trying to spend is already spent.",
- ["txn-mempool-conflict"] = "At least one coin you are trying to spend is already spent.",
- ["bad-txns-inputs-duplicate"] = "The transaction contains duplicated inputs.",
- ["bad-txns-nonfinal"] = "The transaction is not final and cannot be broadcasted.",
- ["bad-txns-oversize"] = "The transaction is too big.",
-
- ["invalid password"] = "Wrong password.",
- ["Invalid wallet name"] = "Invalid wallet name.",
- ["Wallet name is already taken"] = "Wallet name is already taken."
- };
-
public static string ToTypeMessageString(this Exception ex)
{
var trimmed = Guard.Correct(ex.Message);
@@ -63,7 +49,7 @@ namespace System
}
}
- foreach (KeyValuePair<string, string> pair in Translations)
+ foreach (KeyValuePair<string, string> pair in RpcParser.ErrorTranslations)
{
if (trimmed.Contains(pair.Key, StringComparison.InvariantCultureIgnoreCase))
{

Move Translations to RpcParser