mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
Merge 187504b038 into merged_master (Bitcoin PR bitcoin/bitcoin#23662)
This commit is contained in:
commit
949e4ece60
1 changed files with 9 additions and 5 deletions
|
|
@ -19,12 +19,17 @@
|
|||
namespace wallet {
|
||||
static CAmountMap GetReceived(const CWallet& wallet, const UniValue& params, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
|
||||
{
|
||||
std::set<CTxDestination> address_set;
|
||||
std::set<CScript> output_scripts;
|
||||
|
||||
if (by_label) {
|
||||
// Get the set of addresses assigned to label
|
||||
std::string label = LabelFromValue(params[0]);
|
||||
address_set = wallet.GetLabelAddresses(label);
|
||||
for (const auto& address : wallet.GetLabelAddresses(label)) {
|
||||
auto output_script{GetScriptForDestination(address)};
|
||||
if (wallet.IsMine(output_script)) {
|
||||
output_scripts.insert(output_script);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Get the address
|
||||
CTxDestination dest = DecodeDestination(params[0].get_str());
|
||||
|
|
@ -35,7 +40,7 @@ static CAmountMap GetReceived(const CWallet& wallet, const UniValue& params, boo
|
|||
if (!wallet.IsMine(script_pub_key)) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Address not found in wallet");
|
||||
}
|
||||
address_set.insert(dest);
|
||||
output_scripts.insert(script_pub_key);
|
||||
}
|
||||
|
||||
// Minimum confirmations
|
||||
|
|
@ -68,8 +73,7 @@ static CAmountMap GetReceived(const CWallet& wallet, const UniValue& params, boo
|
|||
|
||||
for (unsigned int i = 0; i < wtx.tx->vout.size(); i++) {
|
||||
const CTxOut& txout = wtx.tx->vout[i];
|
||||
CTxDestination address;
|
||||
if (ExtractDestination(txout.scriptPubKey, address) && wallet.IsMine(address) && address_set.count(address)) {
|
||||
if (output_scripts.count(txout.scriptPubKey) > 0) {
|
||||
if (wallet.GetTxDepthInMainChain(wtx) >= min_depth) {
|
||||
CAmountMap wtxValue;
|
||||
CAmount amt = wtx.GetOutputValueOut(wallet, i);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue