public bool Subscribe(string address, int num_confirmations_required, string pingback_url)
{
if (address == "") {
//print "Could not subscribe, address not set.";
return false;
}
if (!InitializeAgent(num_confirmations_required, pingback_url)) {
//print "Could not initialize agent";
return false;
}
string url = SubscriptionURL(num_confirmations_required);
if (url == "") {
//print "Could not make URL";
return false;
}
string data = "address="+address;
m_log.Info("[FreeMoney] Planning to hit remote service to set up a notification for the address "+address);
//Console.WriteLine(url);
//Console.WriteLine(data);
//string useragent = "Bitcoin payment module for OpenSim - https://github.com/edmundedgar/Mod-Bitcoin";
HttpWebRequest httpWebRequest=(HttpWebRequest)WebRequest.Create(url);
httpWebRequest.Headers.Add("Authorization: "+ m_config["bitcoin_ping_service_1_accesskey"]);
httpWebRequest.Method = "POST";
ASCIIEncoding encoding = new ASCIIEncoding ();
byte[] byte1 = encoding.GetBytes (data);
//httpWebRequest.ContentType = "application/x-www-form-urlencoded";
httpWebRequest.ContentLength = byte1.Length;
Stream newStream = httpWebRequest.GetRequestStream ();
newStream.Write (byte1, 0, byte1.Length);
newStream.Close();
HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse ();
/*
string response;
using (StreamReader streamReader = new StreamReader (httpWebResponse.GetResponseStream ())) {
response = streamReader.ReadToEnd ();
streamReader.Close ();
}
*/
return (httpWebResponse.StatusCode == HttpStatusCode.OK);
}