diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d9662c39aa..cc187b50b0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4327,6 +4327,13 @@ uint256 CWallet::GetAssetIDFromLabel(const std::string& label) const return uint256(); } +CAssetID CWallet::GetAssetIDFromString(const std::string& asset) const +{ + // TODO: may be worth LOCK(cs_wallet) here and do GetAsset* inline instead + CAssetID id(uint256S(asset)); + return GetAssetLabelFromID(id) == "" ? GetAssetIDFromLabel(asset) : id; +} + CKey CWallet::GetBlindingKey(const CScript* script) const { CKey key; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 23cd65266c..713a5c891d 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1012,6 +1012,12 @@ public: std::string GetAssetLabelFromID(const uint256& id) const; /* Returns asset id corresponding to asset label */ uint256 GetAssetIDFromLabel(const std::string& label) const; + /** + * Returns asset id coresponding to the given asset expression, which is either an asset label or a hex value. + * @param asset A label string or a hex value corresponding to an asset + * @return The asset ID for the given expression + */ + CAssetID GetAssetIDFromString(const std::string& asset) const; //! script == NULL gives the backward compatible blinding key CKey GetBlindingKey(const CScript* script) const;