There is a common confusion amongst bitcoin newcomers regarding how an offline wallet is able to receive bitcoins and then later send those same bitcoins to another address. The core of the misunderstanding is revealed in the commonly asked question:
How can an offline computer receive bitcoins? Doesn't the offline computer need to download a piece of information that represents the bitcoin?
The answer to the latter question is no, the offline computer does not need to download anything to receive bitcoins. However, to be able to spend the bitcoins, the offline computer needs to be transferred a piece of information called an Unspent Transaction Outputs (UTXO) from a computer connected to the bitcoin network.
The reason that the offline wallet does not need to download anything to receive a bitcoin is because to own a bitcoin means to have the potential ability to extend a chain of transactions. To understand this let's walk through an example.
Bitcoins first appear in the blockchain as a single transaction paid out to a miner.1 When the miner mines a block, a piece of data gets added to the blockchain that looks something like:
50 BTC -> 1A7Ae2RczM1T2ZqgLQhLRzx5RdcJWvHDot (TX ID: 4039)2
Now let's say the miner decides to send his bitcoins to someone else's address. In the next block, He will add data to the blockchain that looks like
Use the output from TX ID 4039 to send 50 BTC from 1A7Ae2RczM1T2ZqgLQhLRzx5RdcJWvHDot -> 1C26k7Z7JMmhKf1zZyZUEFEvcQCEPqRPvx + (Signature from 1A7Ae2RczM1T2ZqgLQhLRzx5RdcJWvHDot)3 (TX ID: 5019)
Now let's say you are friends with the owner of address 1C26k7Z7JMmhKf1zZyZUEFEvcQCEPqRPvx and you want him to send you some bitcoins. So with your offline wallet you generate a public / private key pair - your bitcoin address is 1NKrRM2M5TmdVJRHwAeWXAZyAGHJ7U1dEV. Then the owner of address 1C26.. can then send you the bitcoins by appending a transaction to the blockchain that looks like the previous one:
Use the output from TX ID 5019 to send 50 BTC from 1C26k7Z7JMmhKf1zZyZUEFEvcQCEPqRPvx -> 1NKrRM2M5TmdVJRHwAeWXAZyAGHJ7U1dEV + (Signature from 1C26k7Z7JMmhKf1zZyZUEFEvcQCEPqRPvx) (TX ID: 8492)
Once this transaction is in the blockchain, you have effectively "received" the bitcoins. The offline computer itself does not (yet) need to have the transaction data, once the transaction is in the blockchain the bitcoin network has acknowledged that the owner of the 50 BTC is the person with the private key corresponding to (your) bitcoin address 1NKrRM2M5TmdVJRHwAeWXAZyAGHJ7U1dEV.
This being said, at the moment you want to spend the bitcoins that you have in address 1NKrRM2M5TmdVJRHwAeWXAZyAGHJ7U1dEV, your offline computer will need the data in the above transaction with ID 8492. This is because the offline computer creates the transaction signature. To generate that signature, the offline computer needs to have the information of the transaction it is creating. That information includes the source of the bitcoins to be spent, i.e. the UTXO from TX with ID 8492.
To conclude let's go over how someone may use an offline wallet to receive and then send bitcoins. First, the bitcoin user creates his public/private key on the offline computer. He then monitors the blockchain using an online computer to see that he has received funds. Finally, when he wants to spend the funds, he downloads the necessary information from the blockchain (i.e. the relevant UTXO's), puts the UTXO information on his offline computer, uses the UTXO information to create a signed transaction,4 and transfers that signed transaction to an online computer that broadcasts the transaction to the network.
For some more technical details regarding bitcoin transactions check out jfw's series "bitcoin transactions and their signing".
- This transaction is commonly called a coinbase transaction. A company called "Coinbase" took this term and used it as their name. [↩]
- This "transaction id" is actually a hash of the data in the transaction, not just a number. I chose to represent the tx hash as a number for sake of explanation. [↩]
- This signature is a piece of data that is a mathematical proof showing that the person who generated the address 1A7Ae2RczM1T2ZqgLQhLRzx5RdcJWvHDot authorizes the transaction. [↩]
- Alternatively he creates the transaction on the online computer, and the only task of the offline computer is to sign the transaction. In this scenario the offline computer doesn't need to have (direct) access to the UTXO. [↩]
Hey Will this is a great article I just started to read it I'll put together questions, talk with you soon.
Please do put together those questions and ask here!