diff --git a/src/masternodes/mn_checks.cpp b/src/masternodes/mn_checks.cpp index e7167c133b..6e30418cd2 100644 --- a/src/masternodes/mn_checks.cpp +++ b/src/masternodes/mn_checks.cpp @@ -87,6 +87,19 @@ std::string ToString(CustomTxType type) { return "None"; } +CustomTxType FromString(const std::string& str) { + static const auto customTxTypeMap = []() { + std::map generatedMap; + for (auto i = 0u; i < 256; i++) { + auto txType = static_cast(i); + generatedMap.emplace(ToString(txType), txType); + } + return generatedMap; + }(); + auto type = customTxTypeMap.find(str); + return type == customTxTypeMap.end() ? CustomTxType::None : type->second; +} + static ResVal BurntTokens(CTransaction const & tx) { CBalances balances; for (const auto& out : tx.vout) { diff --git a/src/masternodes/mn_checks.h b/src/masternodes/mn_checks.h index 07a14eb129..c198134d5a 100644 --- a/src/masternodes/mn_checks.h +++ b/src/masternodes/mn_checks.h @@ -169,6 +169,7 @@ inline CustomTxType CustomTxCodeToType(uint8_t ch) { } std::string ToString(CustomTxType type); +CustomTxType FromString(const std::string& str); // it's disabled after Dakota height inline bool NotAllowedToFail(CustomTxType txType, int height) { diff --git a/src/masternodes/rpc_accounts.cpp b/src/masternodes/rpc_accounts.cpp index f202a70f16..0900cf57b0 100644 --- a/src/masternodes/rpc_accounts.cpp +++ b/src/masternodes/rpc_accounts.cpp @@ -1027,6 +1027,8 @@ UniValue listaccounthistory(const JSONRPCRequest& request) { const auto str = optionsObj["txtype"].get_str(); if (str.size() == 1) { txType = CustomTxCodeToType(str[0]); + } else { + txType = FromString(str); } } if (!optionsObj["limit"].isNull()) { diff --git a/test/functional/rpc_listaccounthistory.py b/test/functional/rpc_listaccounthistory.py index 6b792a6b55..579695fc0a 100755 --- a/test/functional/rpc_listaccounthistory.py +++ b/test/functional/rpc_listaccounthistory.py @@ -114,6 +114,8 @@ def run_test(self): result = self.nodes[1].listaccounthistory() assert_equal(result, []) + assert_equal(self.nodes[0].listaccounthistory('all', {"txtype": "MintToken"}), self.nodes[0].listaccounthistory('all', {"txtype": "M"})) + # REVERTING: #======================== self.start_node(2)