Seriously. I thought this bit of code from the MtGox leak was interesting. Sure looks like a potential double-spend race condition:
$out = \DB::DAO('Money_Bitcoin_Block_Tx_Out')->searchOne(array('Hash' => $bean->Hash, 'N' => $bean->N));
if ($out) {
if ($out->Claimed == 'Y') {
$bean->Available = 'N';
$bean->commit();
continue;
}
}
What if someone else claims $out between the read and commit? Is no one at BTC exchanges really asking these kinds of questions?
Re:BTC Stolen from Poloniex
by stcredzero on Tuesday March 04, 2014 @11:45AM
(#7341325)
This is exactly what Erlang would excel at implementing. Not that one couldn't do it wrong in that language as well. Same goes for Go and Clojure and a number of other languages with advanced concurrency features.
I know it's not easy but it is important to get it right.