mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
CA: Switch to standard CAsset::IsNull() API instead of comparing against CAset()
This commit is contained in:
parent
4344ec6a53
commit
0cf9d89441
5 changed files with 13 additions and 12 deletions
|
|
@ -42,6 +42,7 @@ struct CAsset {
|
|||
READWRITE(id);
|
||||
}
|
||||
|
||||
bool IsNull() const { return id.IsNull(); }
|
||||
void SetNull() { id.SetNull(); }
|
||||
|
||||
unsigned char* begin() { return id.begin(); }
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ static void MutateTxAddOutAddr(CMutableTransaction& tx, const std::string& strIn
|
|||
// extract and validate ASSET
|
||||
std::string strAsset = vStrOutAddrParts[2];
|
||||
CAsset asset(uint256S(strAsset));
|
||||
if (asset == CAsset())
|
||||
if (asset.IsNull())
|
||||
throw std::runtime_error("invalid TX output asset type");
|
||||
|
||||
// build standard output script via GetScriptForDestination()
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ BOOST_AUTO_TEST_CASE(naive_blinding_test)
|
|||
|
||||
BOOST_CHECK(factor == uint256());
|
||||
BOOST_CHECK(asset_factor == uint256());
|
||||
BOOST_CHECK(asset == CAsset());
|
||||
BOOST_CHECK(asset.IsNull());
|
||||
BOOST_CHECK(pubkey == CPubKey());
|
||||
BOOST_CHECK(amount == -1);
|
||||
|
||||
|
|
|
|||
|
|
@ -73,17 +73,17 @@ UniValue PushAssetBalance(CAmountMap& balance, CWallet* wallet, std::string& str
|
|||
UniValue obj(UniValue::VOBJ);
|
||||
CAsset id = wallet->GetAssetFromLabel(strasset);
|
||||
std::string label = wallet->GetLabelFromAsset(CAsset(uint256S(strasset)));
|
||||
if (strasset != "*" && (id == CAsset() && label == "")) {
|
||||
if (strasset != "*" && (id.IsNull() && label == "")) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Input does not match a known asset tag/label pair.");
|
||||
}
|
||||
else if (id != CAsset()) {
|
||||
else if (!id.IsNull()) {
|
||||
strasset = id.GetHex();
|
||||
}
|
||||
|
||||
if (strasset == "*") {
|
||||
for(std::map<CAsset, CAmount>::const_iterator it = balance.begin(); it != balance.end(); ++it) {
|
||||
// Unknown assets
|
||||
if (it->first == CAsset())
|
||||
if (it->first.IsNull())
|
||||
continue;
|
||||
UniValue pair(UniValue::VOBJ);
|
||||
if (wallet->GetLabelFromAsset(it->first) != "") {
|
||||
|
|
@ -500,7 +500,7 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
|
|||
CAsset id(uint256S(asset));
|
||||
if (pwalletMain->GetLabelFromAsset(CAsset(uint256S(asset))) == "")
|
||||
id = pwalletMain->GetAssetFromLabel(asset);
|
||||
if (id == CAsset())
|
||||
if (id.IsNull())
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Unknown or invalid asset id/label");
|
||||
|
||||
EnsureWalletIsUnlocked();
|
||||
|
|
@ -1016,7 +1016,7 @@ UniValue sendmany(const JSONRPCRequest& request)
|
|||
CAsset asset(uint256S(strasset));
|
||||
if (pwalletMain->GetLabelFromAsset(CAsset(uint256S(strasset))) == "")
|
||||
asset = pwalletMain->GetAssetFromLabel(strasset);
|
||||
if (asset == CAsset())
|
||||
if (asset.IsNull())
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Unknown or invalid asset id/label");
|
||||
|
||||
if (!address.IsValid())
|
||||
|
|
@ -1279,7 +1279,7 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts)
|
|||
CAsset id(uint256S(asset));
|
||||
if (asset != "*" && pwalletMain->GetLabelFromAsset(CAsset(uint256S(asset))) == "")
|
||||
id = pwalletMain->GetAssetFromLabel(asset);
|
||||
if (asset != "*" && id == CAsset())
|
||||
if (asset != "*" && id.IsNull())
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Unknown or invalid asset id/label");
|
||||
|
||||
// Tally
|
||||
|
|
@ -2651,7 +2651,7 @@ UniValue listunspent(const JSONRPCRequest& request)
|
|||
CAsset asset;
|
||||
if (assetstr != "*") {
|
||||
asset = pwalletMain->GetAssetFromString(assetstr);
|
||||
if (asset == CAsset())
|
||||
if (asset.IsNull())
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Unknown or invalid asset id/label");
|
||||
}
|
||||
|
||||
|
|
@ -2673,7 +2673,7 @@ UniValue listunspent(const JSONRPCRequest& request)
|
|||
|
||||
CAmount nValue = out.tx->GetValueOut(out.i);
|
||||
CAsset assetid = out.tx->GetAsset(out.i);
|
||||
if (nValue == -1 || assetid == CAsset())
|
||||
if (nValue == -1 || assetid.IsNull())
|
||||
continue;
|
||||
|
||||
if (assetstr != "*" && asset != assetid) {
|
||||
|
|
|
|||
|
|
@ -2627,7 +2627,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
|||
unsigned int nSubtractFeeFromAmount = 0;
|
||||
for (const auto& recipient : vecSend)
|
||||
{
|
||||
if (mapValue[recipient.asset] < 0 || recipient.nAmount < 0 || recipient.asset == CAsset())
|
||||
if (mapValue[recipient.asset] < 0 || recipient.nAmount < 0 || recipient.asset.IsNull())
|
||||
{
|
||||
strFailReason = _("Transaction amounts must not be negative");
|
||||
return false;
|
||||
|
|
@ -2953,7 +2953,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
|||
for (unsigned int i = 0; i< vAmounts.size(); i++) {
|
||||
assert((output_pubkeys[i] == CPubKey())==(output_blinds[i] == uint256()));
|
||||
assert((output_pubkeys[i] == CPubKey())==(output_asset_blinds[i] == uint256()));
|
||||
assert(output_assets[i] != CAsset());
|
||||
assert(!output_assets[i].IsNull());
|
||||
wtxNew.SetBlindingData(i, vAmounts[i], output_pubkeys[i], output_blinds[i], output_assets[i], output_asset_blinds[i]);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue