diff --git a/src/masternodes/mn_checks.cpp b/src/masternodes/mn_checks.cpp index c03c7c1dec6..ca7fbc3a4fc 100644 --- a/src/masternodes/mn_checks.cpp +++ b/src/masternodes/mn_checks.cpp @@ -87,6 +87,65 @@ std::string ToString(CustomTxType type) { return "None"; } +CustomTxType FromString(const std::string& str) { + static const std::map customTxTypeMap { + { "CreateMasternode", CustomTxType::CreateMasternode }, + { "ResignMasternode", CustomTxType::ResignMasternode }, + { "SetForcedRewardAddress", CustomTxType::SetForcedRewardAddress }, + { "RemForcedRewardAddress", CustomTxType::RemForcedRewardAddress }, + { "UpdateMasternode", CustomTxType::UpdateMasternode }, + { "CreateToken", CustomTxType::CreateToken }, + { "UpdateToken", CustomTxType::UpdateToken }, + { "UpdateTokenAny", CustomTxType::UpdateTokenAny }, + { "MintToken", CustomTxType::MintToken }, + { "CreatePoolPair", CustomTxType::CreatePoolPair }, + { "UpdatePoolPair", CustomTxType::UpdatePoolPair }, + { "PoolSwap", CustomTxType::PoolSwap }, + { "AddPoolLiquidity", CustomTxType::AddPoolLiquidity }, + { "RemovePoolLiquidity", CustomTxType::RemovePoolLiquidity }, + { "UtxosToAccount", CustomTxType::UtxosToAccount }, + { "AccountToUtxos", CustomTxType::AccountToUtxos }, + { "AccountToAccount", CustomTxType::AccountToAccount }, + { "AnyAccountsToAccounts", CustomTxType::AnyAccountsToAccounts }, + { "SmartContract", CustomTxType::SmartContract }, + { "DFIP2203", CustomTxType::DFIP2203 }, + { "SetGovVariable", CustomTxType::SetGovVariable }, + { "SetGovVariableHeight", CustomTxType::SetGovVariableHeight }, + { "AppointOracle", CustomTxType::AppointOracle }, + { "RemoveOracleAppoint", CustomTxType::RemoveOracleAppoint }, + { "UpdateOracleAppoint", CustomTxType::UpdateOracleAppoint }, + { "SetOracleData", CustomTxType::SetOracleData }, + { "AutoAuth", CustomTxType::AutoAuthPrep }, + { "ICXCreateOrder", CustomTxType::ICXCreateOrder }, + { "ICXMakeOffer", CustomTxType::ICXMakeOffer }, + { "ICXSubmitDFCHTLC", CustomTxType::ICXSubmitDFCHTLC }, + { "ICXSubmitEXTHTLC", CustomTxType::ICXSubmitEXTHTLC }, + { "ICXClaimDFCHTLC", CustomTxType::ICXClaimDFCHTLC }, + { "ICXCloseOrder", CustomTxType::ICXCloseOrder }, + { "ICXCloseOffer", CustomTxType::ICXCloseOffer }, + { "SetLoanCollateralToken", CustomTxType::SetLoanCollateralToken }, + { "SetLoanToken", CustomTxType::SetLoanToken }, + { "UpdateLoanToken", CustomTxType::UpdateLoanToken }, + { "LoanScheme", CustomTxType::LoanScheme }, + { "DefaultLoanScheme", CustomTxType::DefaultLoanScheme }, + { "DestroyLoanScheme", CustomTxType::DestroyLoanScheme }, + { "Vault", CustomTxType::Vault }, + { "CloseVault", CustomTxType::CloseVault }, + { "UpdateVault", CustomTxType::UpdateVault }, + { "DepositToVault", CustomTxType::DepositToVault }, + { "WithdrawFromVault", CustomTxType::WithdrawFromVault }, + { "TakeLoan", CustomTxType::TakeLoan }, + { "PaybackLoan", CustomTxType::PaybackLoan }, + { "AuctionBid", CustomTxType::AuctionBid }, + { "FutureSwapExecution", CustomTxType::FutureSwapExecution }, + { "FutureSwapRefund", CustomTxType::FutureSwapRefund }, + { "Reject", CustomTxType::Reject }, + { "None", CustomTxType::None }, + }; + 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 07a14eb1298..c198134d5a5 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 598d73e1c32..2375c8df1b5 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 6b792a6b55b..579695fc0a7 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)