testnet support

Hello,

I've added support for testnet coins. I'm assuming you won't like it as is, as it's pretty awkward, but I figured I should make a proposition first before asking for advice on how to best do it.


I guess it should check a particular magic value? Also, please do not include commented lines.