TeachMeBitcoin

Selecting the Stones: Choosing Inputs for the Masterpiece

From TeachMeBitcoin, the free encyclopedia Reading time: 4 min

9. Selecting the Stones: Choosing Inputs for the Masterpiece

When a master mason builds a cathedral wall that is intended to stand for a thousand years, they do not just grab random rocks from a pile. They carefully select every stone for its size, its shape, its density, and its strength. In a Bitcoin transaction, the "Stones" are the Inputs. Every input is a reference to a specific "Unspent Output" (a coin) that exists somewhere in the global library of the blockchain. If you do not select the right inputs, your transaction will be "Invalid"—the node will see it as an attempt to "Create Money out of Thin Air" or "Spend Coins that don't belong to you." It is the "Selection of the Source."

In the createrawtransaction command, you must manually provide the "Coordinates" for each coin you want to spend. These coordinates are the Transaction ID (TXID) and the Output Index (vout). This is the "Selection of the Source," the act of identifying exactly which pieces of the past you are using to power the present. It is the "Inventory of Truth."

Analyzing the "Input Parser" Logic in the Core: The Verifier

In the source code workshop, the node iterates through your list of inputs and translates them into the internal vin list. It is a process of "Verification and Alignment," ensuring that every coordinate provided by the architect is in the correct format for the machine.

/**
 * This snippet shows how the node "Parses the Sources."
 * It takes the human labels and turns them into machine coordinates.
 */
for (unsigned int idx = 0; idx < inputs.size(); idx++) {
    const UniValue& input = inputs[idx];

    // 1. Get the Fingerprint of the source transaction.
    // This is the 64-character TXID, the "Folder" of the coin.
    uint256 txid = ParseHashV(input["txid"], "txid");

    // 2. Get the specific "Slot" (the vout) of the coin.
    // A single transaction can have dozens of outputs; we need the right one.
    uint32_t n = input["vout"].get_int();

    // 3. Create the 'OutPoint' (The Coordinate of Wealth).
    // This is the unique identifier for a specific coin in history.
    COutPoint out(txid, n);

    // 4. Load the stone into the "Blueprint."
    // We add the coordinate to the list of inputs for our new building.
    rawTx.vin.push_back(CTxIn(out));
}

Explaining the Logic to a Non-Coder: The GPS of Value

The Responsibility of the Architect: The Art of Selection

In a standard, user-friendly wallet, the software hides this complexity from you. It "Picks the Coins" automatically in the background, often using a hidden algorithm designed to protect your privacy or minimize your fees. But in the "Raw Interface," the responsibility is entirely yours. You must ensure that the coins you've selected are actually "Unspent." If you try to spend a coin that has already been used (a "Double Spend"), the node will reject your blueprint immediately as a violation of the laws of physics.

By selecting your own stones, you are learning the "Physicality of the Ledger." You are seeing the "Atomic Units" of wealth that make up the global economy. You are deciding which parts of your history you want to reveal to the world and which you want to keep hidden. This is the "Art of Coin Selection," a fundamental skill for anyone who wants to achieve true financial privacy and sovereignty. You are no longer just "Sending Money"; you are "Managing an Inventory of Truth." You are the "Master of the Stones," the one who decides which parts of the past will build the future.


☕ 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!