mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Prevent multiple calls to ExtractDestination
This commit is contained in:
parent
77b637f20e
commit
0bf6f30262
@ -2341,13 +2341,14 @@ UniValue listunspent(const UniValue& params, bool fHelp)
|
|||||||
"\nResult\n"
|
"\nResult\n"
|
||||||
"[ (array of json object)\n"
|
"[ (array of json object)\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
" \"txid\" : \"txid\", (string) the transaction id \n"
|
" \"txid\" : \"txid\", (string) the transaction id \n"
|
||||||
" \"vout\" : n, (numeric) the vout value\n"
|
" \"vout\" : n, (numeric) the vout value\n"
|
||||||
" \"address\" : \"address\", (string) the bitcoin address\n"
|
" \"address\" : \"address\", (string) the bitcoin address\n"
|
||||||
" \"account\" : \"account\", (string) DEPRECATED. The associated account, or \"\" for the default account\n"
|
" \"account\" : \"account\", (string) DEPRECATED. The associated account, or \"\" for the default account\n"
|
||||||
" \"scriptPubKey\" : \"key\", (string) the script key\n"
|
" \"scriptPubKey\" : \"key\", (string) the script key\n"
|
||||||
" \"amount\" : x.xxx, (numeric) the transaction amount in " + CURRENCY_UNIT + "\n"
|
" \"amount\" : x.xxx, (numeric) the transaction amount in " + CURRENCY_UNIT + "\n"
|
||||||
" \"confirmations\" : n, (numeric) The number of confirmations\n"
|
" \"confirmations\" : n, (numeric) The number of confirmations\n"
|
||||||
|
" \"redeemScript\" : n (string) The redeemScript if scriptPubKey is P2SH\n"
|
||||||
" \"spendable\" : xxx, (bool) Whether we have the private keys to spend this output\n"
|
" \"spendable\" : xxx, (bool) Whether we have the private keys to spend this output\n"
|
||||||
" \"solvable\" : xxx (bool) Whether we know how to spend this output, ignoring the lack of keys\n"
|
" \"solvable\" : xxx (bool) Whether we know how to spend this output, ignoring the lack of keys\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
@ -2393,38 +2394,34 @@ UniValue listunspent(const UniValue& params, bool fHelp)
|
|||||||
if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth)
|
if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (setAddress.size()) {
|
CTxDestination address;
|
||||||
CTxDestination address;
|
const CScript& scriptPubKey = out.tx->vout[out.i].scriptPubKey;
|
||||||
if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address))
|
bool fValidAddress = ExtractDestination(scriptPubKey, address);
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!setAddress.count(address))
|
if (setAddress.size() && (!fValidAddress || !setAddress.count(address)))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
CAmount nValue = out.tx->vout[out.i].nValue;
|
|
||||||
const CScript& pk = out.tx->vout[out.i].scriptPubKey;
|
|
||||||
UniValue entry(UniValue::VOBJ);
|
UniValue entry(UniValue::VOBJ);
|
||||||
entry.push_back(Pair("txid", out.tx->GetHash().GetHex()));
|
entry.push_back(Pair("txid", out.tx->GetHash().GetHex()));
|
||||||
entry.push_back(Pair("vout", out.i));
|
entry.push_back(Pair("vout", out.i));
|
||||||
CTxDestination address;
|
|
||||||
if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) {
|
if (fValidAddress) {
|
||||||
entry.push_back(Pair("address", CBitcoinAddress(address).ToString()));
|
entry.push_back(Pair("address", CBitcoinAddress(address).ToString()));
|
||||||
|
|
||||||
if (pwalletMain->mapAddressBook.count(address))
|
if (pwalletMain->mapAddressBook.count(address))
|
||||||
entry.push_back(Pair("account", pwalletMain->mapAddressBook[address].name));
|
entry.push_back(Pair("account", pwalletMain->mapAddressBook[address].name));
|
||||||
}
|
|
||||||
entry.push_back(Pair("scriptPubKey", HexStr(pk.begin(), pk.end())));
|
if (scriptPubKey.IsPayToScriptHash()) {
|
||||||
if (pk.IsPayToScriptHash()) {
|
|
||||||
CTxDestination address;
|
|
||||||
if (ExtractDestination(pk, address)) {
|
|
||||||
const CScriptID& hash = boost::get<CScriptID>(address);
|
const CScriptID& hash = boost::get<CScriptID>(address);
|
||||||
CScript redeemScript;
|
CScript redeemScript;
|
||||||
if (pwalletMain->GetCScript(hash, redeemScript))
|
if (pwalletMain->GetCScript(hash, redeemScript))
|
||||||
entry.push_back(Pair("redeemScript", HexStr(redeemScript.begin(), redeemScript.end())));
|
entry.push_back(Pair("redeemScript", HexStr(redeemScript.begin(), redeemScript.end())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entry.push_back(Pair("amount",ValueFromAmount(nValue)));
|
|
||||||
entry.push_back(Pair("confirmations",out.nDepth));
|
entry.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end())));
|
||||||
|
entry.push_back(Pair("amount", ValueFromAmount(out.tx->vout[out.i].nValue)));
|
||||||
|
entry.push_back(Pair("confirmations", out.nDepth));
|
||||||
entry.push_back(Pair("spendable", out.fSpendable));
|
entry.push_back(Pair("spendable", out.fSpendable));
|
||||||
entry.push_back(Pair("solvable", out.fSolvable));
|
entry.push_back(Pair("solvable", out.fSolvable));
|
||||||
results.push_back(entry);
|
results.push_back(entry);
|
||||||
|
Loading…
Reference in New Issue
Block a user