diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5f871e0a3e..9567d4ca86 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4,11 +4,13 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "amount.h" +#include "assetsdir.h" #include "base58.h" #include "chain.h" #include "core_io.h" #include "consensus/validation.h" #include "crypto/hmac_sha256.h" +#include "global/common.h" #include "init.h" #include "main.h" #include "net.h" @@ -45,7 +47,7 @@ static CCriticalSection cs_nWalletUnlockTime; */ static CAsset GetAssetFromString(const std::string& strasset) { - CAsset asset = pwalletMain->GetAssetFromLabel(strasset); + CAsset asset = gAssetsDir.GetAsset(strasset); if (asset.IsNull() && strasset.size() == 64 && IsHex(strasset)) { asset = CAsset(uint256S(strasset)); } @@ -92,11 +94,12 @@ UniValue PushAssetBalance(CAmountMap& balance, CWallet* wallet, std::string stra if (it->first.IsNull()) continue; UniValue pair(UniValue::VOBJ); - if (wallet->GetLabelFromAsset(it->first) != "") { - obj.push_back((Pair(wallet->GetLabelFromAsset(it->first), ValueFromAmount(it->second)))); - } - else + const std::string label = gAssetsDir.GetLabel(it->first); + if (label != "") { + obj.push_back(Pair(label, ValueFromAmount(it->second))); + } else { obj.push_back(Pair(it->first.GetHex(), ValueFromAmount(it->second))); + } } } else { CAsset asset = GetAssetFromString(strasset); @@ -3226,8 +3229,8 @@ UniValue dumpassetlabels(const UniValue& params, bool fHelp) "\nLists all known asset id/label pairs in this wallet. This list can be modified with `-assetdir` configuration argument.\n" ); UniValue obj(UniValue::VOBJ); - for (CAsset as : pwalletMain->GetKnownAssets()) { - obj.push_back(Pair(pwalletMain->GetLabelFromAsset(as), as.GetHex())); + for (CAsset as : gAssetsDir.GetKnownAssets()) { + obj.push_back(Pair(gAssetsDir.GetLabel(as), as.GetHex())); } return obj; } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 3a0c1d6824..846f22b1e3 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -5,7 +5,6 @@ #include "wallet/wallet.h" -#include "assetsdir.h" #include "base58.h" #include "checkpoints.h" #include "chain.h" @@ -13,7 +12,6 @@ #include "consensus/consensus.h" #include "consensus/validation.h" #include "crypto/hmac_sha256.h" -#include "global/common.h" #include "key.h" #include "keystore.h" #include "main.h" @@ -91,11 +89,6 @@ const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const return &(it->second); } -std::vector CWallet::GetKnownAssets() const -{ - return gAssetsDir.GetKnownAssets(); -} - CPubKey CWallet::GenerateNewKey() { AssertLockHeld(cs_wallet); // mapKeyMetadata @@ -3934,18 +3927,6 @@ bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree, CAmount nAbsurdFee) return ::AcceptToMemoryPool(mempool, state, *this, fLimitFree, NULL, false, nAbsurdFee); } -std::string CWallet::GetLabelFromAsset(const CAsset& id) const -{ - LOCK(cs_wallet); - return gAssetsDir.GetLabel(id); -} - -CAsset CWallet::GetAssetFromLabel(const std::string& label) const -{ - LOCK(cs_wallet); - return gAssetsDir.GetAsset(label); -} - CKey CWallet::GetBlindingKey(const CScript* script) const { CKey key; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index bcc615e7a2..0f974a8e52 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -695,7 +695,6 @@ public: const CWalletTx* GetWalletTx(const uint256& hash) const; - std::vector GetKnownAssets() const; //! check whether we are allowed to upgrade (or already support) to the named feature bool CanSupportFeature(enum WalletFeature wf) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; } @@ -930,11 +929,6 @@ public: /* Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent. */ bool AbandonTransaction(const uint256& hashTx); - /* Returns the label of associated asset id */ - std::string GetLabelFromAsset(const CAsset& id) const; - /* Returns asset id corresponding to asset label */ - CAsset GetAssetFromLabel(const std::string& label) const; - //! script == NULL gives the backward compatible blinding key CKey GetBlindingKey(const CScript* script) const; CPubKey GetBlindingPubKey(const CScript& script) const;