Selecting the Stones: Choosing Inputs for the Masterpiece
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
-
COutPoint: In the language of the Core, an "OutPoint" is the most basic unit of location. It is like a "GPS Coordinate" for a specific digital bill in a global, invisible vault. Thetxidtells the node which "Folder" to look in, and then(vout) tells it which "Page" of that folder contains the coins you are claiming. It is the "Address of the Wealth." Without this precise coordinate, the Librarian would be forced to search the entire vault for your money, which would be physically impossible. It is the "Specific Identity" of the coin. -
rawTx.vin.push_back: This is the act of "Loading the Stone" onto the drafting table. Each input you specify is added to the list of sources for your new transaction. At this stage, the input is "Blank"—it has no signature yet. It is just an "Intention to Spend," a claim that you own the coins at that specific coordinate. You are essentially saying, "I am going to use the gold at this location to pay for my new house." It is the "Draft of the Claim," the first step in the move.
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.
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: