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<PeerConnectedEventArgs>(group_PeerConnected);
group.PeerDisconnected += new EventHandler<PeerDisconnectedEventArgs>(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...
production_net.blockchain
468 [9] INFO BitCoinSharp.Store.DiskBlockStore (null) - Read chain head from dis
k: 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
468 [9] INFO BitCoinSharp.Store.DiskBlockStore (null) - Block chain read complet
e in 0ms
468 [9] INFO BitCoinSharp.BlockChain (null) - chain head is:
v1 block:
previous block: 0000000000000000000000000000000000000000000000000000000000000
000
merkle root: 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
time: [1231006505] 01/01/0001 12:04:24 AM
difficulty target (nBits): 486604799
nonce: 2083236893
starting
hit enter to stop
515 [PeerGroup-1-thread-1] INFO BitCoinSharp.PeerGroup (null) - Connecting to Pe
er(23.20.196.190:0)
24375 [PeerGroup-1-thread-1] DEBUG BitCoinSharp.BitcoinSerializer (null) - Sendi
ng version message: f9beb4d976657273696f6e00000000007000000060ea0000000000000000
00002f24cc4f00000000000000000000000000000000000000000000ffff7f000001208d00000000
0000000000000000000000000000ffff7f000001208d00000000000000001b2f426974436f696e53
686172703a302e362d534e415053484f542f00000000
75765 [PeerGroup-1-thread-1] INFO BitCoinSharp.PeerGroup (null) - Error talking
to Peer(107.20.229.35:0): Socket is disconnected
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.