TeachMeBitcoin

The Privacy Shield: Avoiding Common Input Ownership Heuristics

From TeachMeBitcoin, the free encyclopedia Reading time: 3 min

18. The Privacy Shield: Avoiding Common Input Ownership Heuristics

In the world of blockchain analysis, spies use a technique called the Common Input Ownership Heuristic. The logic is simple: if a transaction has three inputs, the spy assumes that all three coins belong to the same person. By spending them together, you have linked those three addresses to a single identity. To combat this, the Bitcoin Core wallet includes a "Privacy Shield" in its selection logic. It tries to avoid mixing coins from different "Sources" unless absolutely necessary. It is the "Segregation of the Sovereign."

The Privacy Shield is a design philosophy that manifests as "Pre-Selection Filters." By keeping your "Streams of Wealth" separate, the wallet prevents you from inadvertently "Doxing" your entire history in a single payment.

Analyzing the Shield Logic: OutputGroupTypeMap

In the source code, we see how the wallet segregates coins by their OutputType (Legacy, SegWit, Taproot). By default, the wallet tries to "Pay with like coins."

/**
 * This structure segregates coins by their script type to protect privacy.
 */
struct OutputGroupTypeMap {
    // We maintain separate stacks for Taproot, SegWit, and Legacy coins.
    std::map<OutputType, Groups> groups_by_type;

    /**
     * This function attempts to find a solution in ONE category first.
     */
    util::Result<SelectionResult> AttemptSelection(...) {
        for (auto& [type, group] : groups_by_type) {
            // We try to pay using ONLY SegWit coins, for example.
            if (auto result = ChooseSelectionResult(...)) return result;
        }

        // Only if we fail do we allow "Mixed" types.
        if (allow_mixed) return ChooseSelectionResult(all_groups);
    }
};

Explaining the Shield: The Colored Envelopes

The "Sovereign's Responsibility": Labels

The automated shield is powerful, but it is not perfect. The computer does not know that two addresses belong to you if they are the same OutputType. This is why you must use Labels (Chapter 6). By labeling your coins, you can use "Manual Coin Control" to ensure that you NEVER mix coins from different sources (e.g., "From My Employer" and "From My Side-Hustle"). This "Manual Shield" is the ultimate act of financial sovereignty. You are the "Master of the Separation," ensuring your financial identities are as isolated as islands in a digital ocean.


☕ Help support TeachMeBitcoin

TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!