How do off-chain transactions get back on-chain? I've searched in vain, but not been able to find a detailed explanation of how off-chain transactions work.


If I have some BTC on the public blockchain and I want to transfer some of it to someone's wallet off-chain (e.g. we're both using Coinbase) what actually happens? Do I first need to transfer some BTC to a public bitcoin address owned by the wallet provider? This would be akin to Ripple's gateway model I think. If I didn't do this I could double spend (1 tx off-chain and another on-chain), right?
How do I get back on-chain? Is it simply that (assuming I'm correct above) the wallet provider knows my balance off-chain and will make a transfer to my address on-chain?
Coins don't really move "off-chain", in the described case you would send money to an address at Coinbase that is associated with your friend's account. As Coinbase manages their customers' accounts for them, he would see on his account page that his balance increased, but he wouldn't be in control of the private key associated with the address.

Now to "move coins off-chain", means that only the accounted values were updated, while no coins actually moved on the blockchain. Just as if a bank is wiring money from one of their own customers to another own customer, they wouldn't take the money from the vault then put it back, no they would just update the two accounts involved.

In the case of Coinbase it would work like this:

1) Coinbase internal accounting:
rageofreason: 1BTC
friend: 0.5BTC  

2) rageofreason sends friend 0.4BTC

3) Coinbase internal accounting:
rageofreason: 0.6BTC
friend: 0.9BTC

They just update the accounts, no actual bitcoins were moved. Now, when friend closes his Coinbase account he will want them to send the 0.9BTC to an address directly under his control. That moment, bitcoins will move on the chain, as they actually need to be moved to that address instead of just updating balances in the internal accounting of Coinbase.