mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
CA: Decouple CWallet from CAssetsDir
Remove: - std::vector<CAsset> GetKnownAssets() const; - std::string GetLabelFromAsset(const CAsset& id) const; - CAsset GetAssetFromLabel(const std::string& label) const;
This commit is contained in:
parent
3cd9298b08
commit
175168ad1e
3 changed files with 10 additions and 32 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<CAsset> 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;
|
||||
|
|
|
|||
|
|
@ -695,7 +695,6 @@ public:
|
|||
|
||||
const CWalletTx* GetWalletTx(const uint256& hash) const;
|
||||
|
||||
std::vector<CAsset> 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue