void SendVersionPacket() { IPEndPoint remote = (IPEndPoint)mSocket.RemoteEndPoint; IPEndPoint local = (IPEndPoint)mSocket.LocalEndPoint; // Send version packet MemoryStream stream = new MemoryStream(); BinaryWriter w = new BinaryWriter(stream); // -- PAYLOAD -- // version w.Write(mProtocolVersion); // Services Int64 services = 0x0000000000000001; w.Write(services); // Timestamp UInt64 timestamp = Utils.UnixTime(); w.Write(timestamp); // addr_recv w.Write(services); w.Write((UInt64)0); w.Write((ushort)0); w.Write((ushort)0xFFFF); byte[] remoteBytes = remote.Address.GetAddressBytes(); w.Write(remoteBytes); w.Write(Utils.Byteswap(mPort)); // addr_from w.Write(services); w.Write((UInt64)0); w.Write((ushort)0); w.Write((ushort)0xFFFF); byte[] localBytes = local.Address.GetAddressBytes(); w.Write(localBytes); w.Write(Utils.Byteswap(mPort)); // nonce w.Write((UInt64)0xC4ACFF3D04805523); // user_agent w.Write((byte)0xF); w.Write("/Satoshi:0.8.6/".ToArray()); // start_height w.Write(mOwner.CurrentHeight); byte[] packetData = stream.ToArray(); SendPacket("version", packetData); w.Close(); }