By Rich Apodaca | Updated November 27th, 2018
Bitcoin can be coldly unforgiving of mistakes, and nowhere is this better demonstrated than with switch addresses. Albeit switch addresses provide a key privacy contraption, they can also lead to confusion, loss, or theft when not understood.
This article explains how to securely use one of BitcoinвЂ™s least understood features. It finishes with a list of common pitfalls and ways to avoid them.
This article wasgoed very first published te March 2014. Since then, wallet software has improved, eliminating some of the threats described below. Specifically cases (1) and (Four) should only be encountered when using older, unsupported software.
Imagine paying for groceries with a debit card. The checker totals the amount due and you swipe your card spil usual. However, you notice the payment terminal is asking for all of the money te your account.
The checker smiles, explaining that this is part of your bankвЂ™s fresh prizes program. You have three options: (1) send the switch back to your current account, (Two) send the switch to a newly-created bankgebouw account, or (Three) say nothing and send the switch to the payment terminal company.
Counterintuitive? Confusing? Alarming? Many Bitcoin users are astonished to find eerie similarities inbetween this diabolical debit card and the way transactions seem to work.
Thinking about Bitcoin ter terms of past practices with online banking and debit cards can lead to problems. Fortunately, an older payment method offers better insights into how Bitcoin works and why.
The similarities inbetween Bitcoin and specie run deep. Ter his whitepaper, Satoshi Nakamoto even described Bitcoin spil an вЂњelectronic metselspecie system.вЂќ Understanding the close connection inbetween Bitcoin and contant is the key to understanding switch addresses.
Imagine needing to track different pools of paper bills, maybe spil part of a collection drive. You might use envelopes to keep the bills physically separate from each other – a вЂњcash envelopeвЂќ.
A Bitcoin address can be thought of spil the digital omschrijving of a specie envelope.
Contant Envelope. A Bitcoin address spil a digital вЂњcash envelopeвЂќ.
Like a contant envelope, an address can hold zero or more units of electronic metselspecie. Instead of paper bills, Bitcoin uses the electronic omschrijving – вЂњunspent outputsвЂќ. The balance of any address can be found by summing the value of each unspent output it contains, just like the amount held te a metselspecie envelope can be found by counting the values of all bills.
The purpose of the Bitcoin network is to enable the regulated transfer of unspent outputs inbetween addresses through transactions. A more detailed explanation may be helpful when reading this article.
Imagine that Alice, who wields an address containing one unspent output worth Ten bitcoin (BTC), wants to pay Bob Ten bitcoin. Alice moves the funds with a transaction sending hier single unspent output to BobвЂ™s empty address. Ter doing so, AliceвЂ™s address balance falls to zero and BobвЂ™s address balance rises to Ten bitcoin.
One Output Transaction Alice pays Bob Ten BTC, using hier only unspent output. AliceвЂ™s address balance falls by Ten BTC. BobвЂ™s increases by Ten BTC. Alice may not re-spend the Ten BTC.
After the transaction, Bob can give the unspent output he received from Alice to someone else. However, Alice will neither be permitted to take back the unspent output she transferred, strafgevangenis will she be able to spend it again.
A few days straks, Alice wants to pay Bob Five BTC from an address containing a single output valued at Ten BTC. Alice has a problem: she needs to pay Bob, but she doesnвЂ™t want to give him the entire Ten BTC. Alice wouldnвЂ™t be permitted to rip a $Ten bill ter half to pay Bob $Five. Likewise, Bitcoin requires Alice to send the network hier entire Ten BTC unspent output – intact.
To resolve this dilemma, Alice uses a transaction that splits hier payment, a feature fully supported by Bitcoin. One part of the transaction sends Five BTC to BobвЂ™s address and the other comebacks Five BTC back to hier own. Ter a similar way, Alice could pauze a $Ten bill at the bankgebouw into two $Five bills, providing one to Bob and keeping one for herself.
Switch Address Transaction. Alice pays Bob Five BTC. Having no an unspent output ter the keurig amount, Alice splits the transaction into a Five BTC payment to Bob and a Five BTC switch payment to herself. Both Alice and Bob may now use their respective Five BTC unspent outputs.
Overheen time, AliceвЂ™s address accumulates unspent outputs from people who have paid hier. Hier address now contains unspent outputs valued at 20 BTC, Ten BTC, and Five BTC.
Once again, itвЂ™s time for Alice to pay Bob – this time 8 BTC. Alice creates a transaction that splits hier Ten BTC unspent output, sending 8 BTC to BobвЂ™s address and returning Two BTC to hier own spil switch. AliceвЂ™s address balance falls to 27 BTC and BobвЂ™s address balance rises to 8 BTC.
Switch Address with Numerous Outputs. Alice pays Bob 8 BTC. Hier address doesnвЂ™t contain an 8 BTC unspent output, so she uses one valued at Ten BTC, receiving the remaining Two BTC spil switch.
Ter the previous examples, Alice directed switch into the same address she spent from. Albeit this decision simplified accounting, it unluckily diminished BobвЂ™s privacy spil well spil hier own.
By vormgeving, every Bitcoin transaction remains permanently viewable ter a global public ledger called the вЂњblock chainвЂќ. Privacy depends on the stringent separation inbetween addresses and individual identities, a prototype referred to spil pseudonymity.
Any observer capable of linking Bitcoin addresses to individual identities can start to draw conclusions about money transfers inbetween people. Users make this job more difficult by sending switch to newly-created addresses.
To see why, imagine a transaction that sends funds from Address A to Address B. If switch is returned to Address A, the block chain clearly exposes that the person controlling Address A paid the person controlling Address B. The same reasoning holds if two or more addresses are involved. Any transaction involving Address A spil a sender exposes the receiving address unambiguously.
Switch Address is Sender. Switch is returned to the sending address. The intended payee is unambiguous.
Should the identity of the person controlling either receiving or payment addresses become known, the identities of the other parties could become known spil well.
Now imagine that Address A initiates a payment to B, but this time directs switch to a newly-generated switch address C. Without knowing which address receives switch, all wij can deduce is that a transaction split Address AвЂ™s balance inbetween Addresses B and C. The identity of the person controlling Addresses B or C may or may not be the same spil the identity of the person controlling Address A. Given another transaction from Address C, the picture becomes even murkier. Which of the transfers represent payments and which represent the receipt of switch?
Switch Address is not Sender. Switch is returned to a newly-created switch address. The intended payee is ambiguous.
An observer attempting to verbinding individual identities to addresses voorwaarde gather more secondary information and expend more resources when all parties send switch to newly-created addresses.
Coordinating numerous addresses is a complicated task. Wallet software slijper the user from the need to do this by hand.
Albeit switch addresses play a key role te improving privacy, wallet developers can implement this feature ter a number of ways. Four strategies are presently te use, each with its own implications for privacy and security.
- Single-Address Wallets use a single address to receive both payments and switch. Extra addresses may added when a receiving address is by hand added, or a private key is imported. Examples include Blockchain.informatie and MultiBit.
- Random Address Pool Wallets use a fixed-size pool of randomly-generated addresses. Switch is sent to the next available empty address, causing the creation of a fresh empty address to take its place. The best-known example is Bitcoin-Qt.
- Deterministic Address Pool Wallets contain a practically infinite pool of deterministically-generated addresses. A subset of this pool contains addresses reserved for receiving switch. Examples include Electrum and Armory.
- Hybrid Wallets use numerous strategies, depending on setting. MultiBit, Mycelium, and Electrum are examples.
LetвЂ™s now consider ways that misunderstanding switch addresses, combined with semi-manual address management, can lead to loss or theft of funds.
Incorrect use of Bitcoin switch addresses account for many cases of loss or theft of funds. Here are some disaster scripts and ways to avoid them.
1. Backup Failure
Alice uses Bitcoin-Qt. Understanding the importance of backups, she created an encrypted wallet backup long ago and stored it te a safe place. After making dozens of transactions with Bitcoin-Qt, AliceвЂ™s hard drive crashed.
Alice bought a fresh hard drive and then re-installed Bitcoin-Qt on it. She then restored hier wallet backup. To hier horror, Alice discovered the restored wallet wasgoed empty.
Explanation: Alice generated enough switch addresses to overflow the original pool of 100. On the 100th spending transaction, Bitcoin-Qt moved AliceвЂ™s switch (which happend to be hier entire balance) into an address not te the backup. Restoring the backup only restored empty addresses.
Recovery: Even if a hard drive canвЂ™t boot an operating system, individual files can still be recovered. Using gegevens recovery implements, Alice may be able to salvage the Bitcoin-Qt wallet from the faulty hard drive, and with it hier lost funds.
- Count the number of manually-created addresses and spending transactions since your last backup. If this number is greater than about 80, back up again. Weekly backups might be enough for most users.
- Set a very high value (e.g., Ten,000) for the -keypool option, either spil a instruction line parameter, or te the bitcoin.conf verkeersopstopping.
- Switch to a deterministic wallet.
Two. Failure to Monitor Switch Address
Bob uses Electrum to send infrequent bitcoin payments. Worried about possible theft, he dreamed a way to keep an eye on his bitcoin balance from one of his many devices.
Bob determined on blockchain.informatie to monitor address activity. BobвЂ™s Electrum wallet contained several addresses, but only one of them held bitcoin (0.Trio BTC). Assuming this wasgoed the only address heвЂ™d be using, Bob pasted it into the blockchain.informatie search window and bookmarked the resulting pagina.
A few weeks straks, Bob made a 0.Two BTC payment to Overstock from his Electrum wallet. After receiving his merchandise, Bob determined to check his balance with blockchain.informatie.
Disturbingly, Bob discovered that part of his Overstock payment wasgoed transferred to an unknown address. Thinking that his rekentuig running Electrum had bot compromised, Bob re-formated the hard drive.
Explanation: Albeit it may look to Bob spil if an eavesdropper switched his transaction before it wasgoed sent to Overstock, heвЂ™s instead witnessing the result of normal wallet operation. Electrum sent the switch from BobвЂ™s transaction to one of its deterministically-generated switch addresses. This cleared the balance from the sending address, the only one Bob wasgoed monitoring.
Recovery: Electrum encourages the storage of its 12-word address generation seed ter a safe location. Should Bob still have access to the seed, he can re-generate his old wallet and recover the switch from the Overstock transaction.
- If using a deterministic wallet, create a watching-only wallet to monitor addresses.
- If using Bitcoin-Qt, by hand update your list of see addresses after every payment, or switch to a deterministic wallet.
Trio. Spending from a Paper Wallet
Carlos is a saver. Awhile back he bought 20 bitcoins at $Ten apiece, and then transferred them to a paper wallet he created at bitaddress.org. He didnвЂ™t do anything with Bitcoin since then.
One day Carlos noticed a overeenkomst on fresh laptops at Overstock and determined to pay using one of his saved bitcoins. But Carlos had a problem: he needed to get his paper wallet into a software wallet to pay Overstock.
Carlos downloaded MultiBit and imported his paper walletвЂ™s private key. After paying Overstock, he exited the program.
Carlos wasgoed worried about leaving any trace of his private key on his rekentuig, so he securely deleted MultiBit and its gegevens directory. He then returned his paper wallet to its safe location.
After a few weeks, Carlos checked his paper walletвЂ™s balance. To his shock, the balance read zero. Nineteen bitcoins were sent to an unacquainted address on the same day spil the Overstock payment.
Explanation: Carlos suspects foul play, but heвЂ™s actually eyeing the result of normal wallet behavior. The Nineteen missing bitcoins were sent to a switch address, leaving his paper wallet empty.
Recovery: Te securely deleting the MultiBit gegevens directory, Carlos lost any chance of recovering the missing funds.
- Before deleting any hot wallet with an imported paper wallet private key, send the remaining balance back to a paper wallet.
- Use a software wallet that will come back switch back to the paper wallet. One example is Mycelium. Another is Blockchain.informatie through the вЂњcustom spendвЂќ option. Both approaches would come back switch to the paper wallet, albeit doing so degrades privacy.
Four. Sharing a Wallet
Dave runs Bitcoin-Qt on two computers, a laptop and a desktop ter his garage. Wanting to use both computers to make payments, Dave copied a clean wallet.dat backup verkeersopstopping from the laptop to the desktop.
After making many payments without a problem from both computers, Dave noticed something odd one day. His laptop wallet displayed a zero balance, but his desktop wallet demonstrated the keurig balance.
Explanation: DaveвЂ™s pc network wasgoed not compromised, strafgevangenis did he uncover a bug te Bitcoin-Qt. Instead, his copy of Bitcoin-Qt running on the desktop used the last available pool address held jointly with the laptop. On his last transaction, DaveвЂ™s switch wasgoed sent to an address unknown to the laptop.
Recovery: Back up the wallets on both the laptop and the desktop. Uitvoer all private keys from both computers, and sweep them into a fresh wallet. If sharing wallets is critical, donвЂ™t proceed using Bitcoin-Qt.
- DonвЂ™t use Bitcoin-Qt to share wallets among numerous computers. Use Electrum or Armory, which were designed specifically with this use case ter mind.
Five. Theft from an Imported Paper Wallet
Rechttoe received a paper wallet containing Two BTC spil a bounty at a company event. Anxious to see how Bitcoin works, he installed MultiBit and imported the paper walletвЂ™s private key. Not observing a need to keep the paper wallet, Klinkklaar threw it into the recycling bin at his office.
Overheen time, Klinkklaar depleted his Bitcoin funds. To re-fund his wallet, Rechttoe bought an extra Two BTC from Coinbase and then transferred them into his MultiBit wallet.
Shortly thereafter, Open bought a set of sheets from Overstock for 0.1 BTC. Albeit this payment confirmed without punt, Klinkklaar noticed something odd. Without his approval, a 2nd withdrawal wasgoed made to an unknown address, emptying his wallet of the remaining 1.9 BTC.
Explanation: Albeit Open wasgoed the victim of theft, the route of attack wasgoed not his pc or network. It wasgoed the paper wallet he threw into the recycling bin.
Unknown to Rechttoe, the paper wallet wasgoed taken from the recycling bin by Eve, a dishonest coworker. Eve added the private key to a custom-made program that automatically detects deposits into a list of observed addresses, and then withdraws them instantaneously.
MultiBit, working spil designed, used the imported paper wallet address to receive 1.9 BTC te switch from FrankвЂ™s Overstock payment. EveвЂ™s program noticed the transfer and instantaneously withdrew the funds.
Eve pulled off hier heist without access to FrankвЂ™s pc, or even skill of FrankвЂ™s identity. The project worked because Eve know one of the private keys being used to receive switch ter FrankвЂ™s MultiBit wallet.
Recovery: Klinkklaar cannot recover the funds, strafgevangenis is he likely to determine the identity of the thief.
- Sweeping a paper wallet creates a normal transaction into an existing wallet address, depleting the paper wallet. The paper wallet private key is never again used by the wallet software. Unless you have a compelling reason to do otherwise, sweep paper wallets instead of importing them. This is especially significant for paper wallets that you did not generate yourself securely.
Albeit the examples te the previous section resulted ter finish loss of funds, the same mechanisms also permit for partial loss. Thesis conditions were assumed, which may or may not hold at the time a switch address problem arises:
- The entire balance of a wallet resides at a single address.
- This single address contains one unspent output.
For example, a single address that receives numerous payments will contain numerous unspent outputs. Likewise, wallet balances can become distributed across numerous switch addresses spil the user spends funds.
Imagine AliceвЂ™s wallet contains two addresses, Address 1 and Address Two, with a total value of 15 BTC. To make a 6 BTC payment, the wallet chooses a 7 BTC unspent output from Address 1, receiving 1 BTC switch into Address Two. Spil expected, hier wallet balance decreases to 9 BTC.
Lost Address Unspent Outputs. Alice loses 1 BTC after restoring a backup te which a switch address wasgoed missing.
Then disaster strikes – AliceвЂ™s hard drive fails. After installing a fresh hard drive and restoring hier wallet backup, Alice notices something odd. Before the hard drive crash, hier wallet balance wasgoed 9 BTC. But the balance only read 8 BTC after recovering the backup. Why does 1 BTC seem to be missing?
Alice wasgoed using a random address pool wallet, ter which Address Two wasgoed not contained ter hier original backup. Restoring the backup talent the appearance that Address Two had вЂњdisappearedвЂќ, and along with it the 1 BTC spent output it contained.
Ter a sense, Alice wasgoed fortunate because she could have lost hier entire wallet balance. On the other arm, without understanding switch addresses, Alice would likely be very confused about what happened to the missing 1 BTC. The same mistake could toebijten again.
When used correctly, switch addresses help prevent the identities and spending histories of Bitcoin users from being made public. But with this capability comes the potential for loss and theft. To avoid potentially costly mistakes, familiarize yourself with switch addresses and how your wallet software implements them.
IвЂ™m grateful to members of the Bitcoin Subreddit who helped clarify two key technical points te the original version of this article.