I am using BitcoinSharp and I can't seem to connect to any peers the just keep disconnecting me after the version message is sent.
My main code looks like this...
// TODO: see http://code.google.com/p/bitcoinj/wiki/GettingStarted
NetworkParameters param = NetworkParameters.ProdNet();
// Creates a brand new keypair.
EcKey key = new EcKey();
// Gets the raw public key bytes. You don't normally need this.
byte[] publicKey = key.PubKey;// GetPubKey();
// Gets the address corresponding to the public key.
Address addr = key.ToAddress(param);
Debug.WriteLine(addr.ToString()); // -> 1HwBZk111V4eEEC4BcN8fZd3RVifig2WjY
// Try to read the wallet from storage, create a new one if not possible.
Wallet wallet;
FileStream walletFile;
try
{
walletFile = new FileStream("wallet.dat", FileMode.Open);
wallet = Wallet.LoadFromFileStream(walletFile);
}
catch
{
walletFile = new FileStream("wallet.dat", FileMode.Create);
wallet = new Wallet(param);
wallet.Keychain.Add(new EcKey());
wallet.SaveToFileStream(walletFile);
}
// Fetch the first key in the wallet (should be the only key).
key = wallet.Keychain[0];
// Load the block chain, if there is one stored locally.
//var localIp = Dns.GetHostEntry(Dns.GetHostName()).AddressList.Where(ip => ip.AddressFamily == AddressFamily.InterNetwork).First();
//NetworkConnection conn = NetworkConnection (IPAddress.Parse("23.20.196.190"), param, 0 /* bestInKeychain */, 0);
IBlockStore blockStore = new DiskBlockStore(param, new FileInfo("production_net.blockchain"));
BlockChain chain = new BlockChain(param, wallet, blockStore);
//
//Peer peer = new Peer(param, new PeerAddress(IPAddress.Parse("192.168.2.110")), chain);
PeerGroup group = new PeerGroup(blockStore, param, chain);
group.AddAddress(new PeerAddress(IPAddress.Parse("23.20.196.190")));
//group.AddAddress(new PeerAddress(IPAddress.Parse("107.20.229.34")));
group.AddAddress(new PeerAddress(IPAddress.Parse("107.20.229.35")));
//group.AddAddress(new PeerAddress(IPAddress.Parse("192.168.2.110")));
//group.AddPeerDiscovery(new BitCoinSharp.Discovery.SeedPeers(param));
group.PeerConnected += new EventHandler
(group_PeerConnected);
group.PeerDisconnected += new EventHandler(group_PeerDisconnected);
//group.
Console.WriteLine("starting");
group.Start();
//Console.WriteLine("running");
//group.Run();
Console.WriteLine("hit enter to stop");
Console.ReadLine();
My console output with the debugging on looks like this...
NOTE: I am behind a NAT router and my firewall is off but I did not port redirect to my dev box on my router, I'm assuming that's not needed since I'm making the connection.
10 bitcoins if you can help me get this going so I can send and receive bitcoins.