The Storage of Identity: How Labels and Purpose are Saved
18. The Storage of Identity: How Labels and Purpose are Saved
A bank is more than just "Gold"; it is a "Ledger of Relationships." You need to know that the 0.5 BTC you received came from "Employer X" and that the 0.1 BTC you sent went to "Friend Y." In Bitcoin Core, this "Human Layer" is stored as Metadata. Specifically, it is stored in the Address Book (Purpose/Label) records of the SQLite database. For the Sovereign Architect, this metadata is the "Identity of the Vault."
While your private keys represent your "Power," your labels represent your "Knowledge." If you lose your labels, you might still own your money, but you will have "Lost the Context" of your life. You won't know which coins are "Private" and which are "Public." Understanding how this metadata is stored is vital for maintaining your financial "Hygiene."
Analyzing the Metadata Row: WritePurpose
In the source code (src/wallet/walletdb.cpp), we see how the wallet saves a label for a specific address.
/**
* This function saves the "Human Name" of a Bitcoin address to the vault.
*/
bool WalletBatch::WritePurpose(const CTxDestination& dest, const std::string& strPurpose)
{
// 1. We encode the destination (address) as a string.
// 2. We use the key 'purpose' + address string.
// 3. We save the 'strPurpose' (e.g., "send" or "receive").
return Write(std::make_pair(std::string("purpose"), EncodeDestination(dest)), strPurpose);
}
Explaining the Identity: The Sticky Note
-
"The Purpose": Every address in your book has a "Reason for Being." If you generated it to get paid, its purpose is "receive." If you added it to pay someone else, its purpose is "send." This allows the GUI to "Filter" your view, showing you only the relevant addresses. It is the "Organization of the Clerk."
-
"The Label": This is the "Human Name." You can change it at any time without touching the blockchain. In the database, the label is just a "String" attached to an "Address." It is like putting a "Sticky Note" on a piece of gold in your vault. The gold doesn't change, but your understanding of the gold does. It is the "Context of the Sovereign."
-
"Local Only": It is crucial to remember that Labels are NEVER Saved on the Blockchain. They only exist in your
wallet.dat. If you send money to "Alice" and label the transaction "For the Pizza," Alice will never see that label, and the miners won't either. This is your "Private Accounting," and its security is as important as the security of your keys. It is the "Privacy of the Record."
The "Hygiene" of the Sovereign
By diligently labeling your addresses, you are building a "Map of your Sovereignty." This map allows you to use "Coin Control" (Volume 1, Chapter 17) with absolute precision. You can see which "Gold Pieces" belong to which "Identities" and ensure they never touch. You are the "Master of the Identity," the one who ensures the "Human Truth" of your bank is as organized as the "Mathematical Truth."
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: