Ive done some research and I think I get it.
Any address attached to your wallet that has received coins can be selected (automatically by the bitcoin client) as a "From" address for the same wallet.
So any funds sent from a real wallet can be refunded (or bets paid) by sending N btc back to the "From" address.
Correct with the caveat that you actually send outputs so the address you can use is limited by which outputs you have and their value.
Say you have a wallet which has 3 addresses A, B, C
A contains 1 unspent output worth 1 BTC.
B contains 2 unspent outputs worth 2BTC and 1 BTC.
C contains 1 unspent output worth 10 BTC.
So your wallet shows total value of 1+2+1+10 = 14 BTC. Right?
The satoshi wallet doesn't let you (by default) pick the output to spend but if it did and you wanted to spend 11 BTC you have no choice but to use the output on Address C plus one other output.
If you wanted to spend 5 to 10 BTC your only valid output is the one for Address C.
If you wanted to spend 3 BTC you could for example use both outputs from Address B or use 1 output from Address B and one from A (or A + C).
"Value" is just an abstractions. Your wallet doesn't just contain addresses. It contains unspent outputs.
I send you 5 BTC from my address Z to your address A.
You don't just have "5 BTC" as some abstract value in a ledger you have a distinct unspent tx.
Z--> 5 BTC -> A. Since you control A you have "5 BTC" of value BECAUSE you have the ability to include that unspent output as an input in some future tx.
Wow... probably deeper into the guts than you wanted to go.
For the purposes of Satoshi DICE if you send funds from the Satoshi wallet the output (and thus address) used will be "random". It doesn't really matter because any output is fine as you control the private key. If you can send it then you can access the funds returned to the same "random" address.
Most online wallets MTGOX, walletbit etc do not assign a wallet per account, your funds are held in a DB.
The deposit addresses provided are for their own wallet, their software monitors the incoming transactions to each address and if its matched to a pending deposit the funds are assigned to the account.
When Sending funds from an online wallet again the funds are deducted from your account then sent from their wallet, any transfers sent back to the From address used are checked for a pending deposit, none are found so the site takes it as a "donation".
Exactly. Any shared wallet has that issue. If a user has the same 14 BTC on MtGox they aren't held in an address (or addresses) which the user controls. The user's funds are mixed in with every other user and MtGox simply "knows" the user has 14 BTC because it has deposited 14 BTC more than it has withdrawn. Some online wallets like Strongcoin and blockchain.info DO hold user's coins is separate addresses. They operate similar to an offline wallet.