MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetAddressGroupings

Function GetAddressGroupings

src/wallet/receive.cpp:427–518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

425}
426
427std::set< std::set<CTxDestination> > GetAddressGroupings(const CWallet& wallet)
428{
429 AssertLockHeld(wallet.cs_wallet);
430 std::set< std::set<CTxDestination> > groupings;
431 std::set<CTxDestination> grouping;
432
433 for (const auto& walletEntry : wallet.mapWallet)
434 {
435 const CWalletTx& wtx = walletEntry.second;
436
437 if (wtx.tx->vin.size() > 0)
438 {
439 bool any_mine = false;
440 // group all input addresses with each other
441 for (const CTxIn& txin : wtx.tx->vin)
442 {
443 CTxDestination address;
444 if(!InputIsMine(wallet, txin)) /* If this input isn't mine, ignore it */
445 continue;
446 if(!ExtractDestination(wallet.mapWallet.at(txin.prevout.hash).tx->vout[txin.prevout.n].scriptPubKey, address))
447 continue;
448 grouping.insert(address);
449 any_mine = true;
450 }
451
452 // group change with input addresses
453 if (any_mine)
454 {
455 for (const CTxOut& txout : wtx.tx->vout)
456 if (OutputIsChange(wallet, txout))
457 {
458 CTxDestination txoutAddr;
459 if(!ExtractDestination(txout.scriptPubKey, txoutAddr))
460 continue;
461 grouping.insert(txoutAddr);
462 }
463 }
464 if (grouping.size() > 0)
465 {
466 groupings.insert(grouping);
467 grouping.clear();
468 }
469 }
470
471 // group lone addrs by themselves
472 for (const auto& txout : wtx.tx->vout)
473 if (wallet.IsMine(txout))
474 {
475 CTxDestination address;
476 if(!ExtractDestination(txout.scriptPubKey, address))
477 continue;
478 grouping.insert(address);
479 groupings.insert(grouping);
480 grouping.clear();
481 }
482 }
483
484 std::set< std::set<CTxDestination>* > uniqueGroupings; // a set of pointers to groups of addresses

Callers 1

listaddressgroupingsFunction · 0.85

Calls 11

InputIsMineFunction · 0.85
ExtractDestinationFunction · 0.85
OutputIsChangeFunction · 0.85
findMethod · 0.80
sizeMethod · 0.45
insertMethod · 0.45
clearMethod · 0.45
IsMineMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected