Author

Topic: Allowing a User to Deposit and Withdraw Bitcoins in ASP.NET(C#) Application (Read 3727 times)

member
Activity: 66
Merit: 10
@arixpcx BitcoinLib is the best c# library for the reference client's (bitcoin core) RPC API:

https://github.com/GeorgeKimionis/BitcoinLib

All you have to do is follow the instructions: https://github.com/GeorgeKimionis/BitcoinLib#instructions-for-bitcoin and you're ready to go. I would recommend you spend some time studying about bitcoin transactions as well as its RPC API commands which shouldn't take a long, then it will be trivial to perform the deposits and withdrawals in your website using this up-to-date and battle-tested library.
newbie
Activity: 14
Merit: 0
Thanks for the reply but I still don't quite understand what I should do with this code.

What should I have on http://local host:8332?
My bitcoin client?

If so, could you address me to a guide of how to install such client?

Also, could you please include an example of how to send a simple transaction with this code?

I'm sorry for the newbie questions, I'm really new to the crypto world and hadn't had a chance to explore it deeply yet.

I would really appreciate if you would give me an example code of how I create an address to the user and send it to an external address, it would really help me with understanding the basics of this client.

Thank you Smiley
hero member
Activity: 518
Merit: 500
r00t-dev
Hi Smiley
I'm creating an ASP.NET website in c#.
I want to allow a registered user to create his own bitcoin wallet in the website in which he will be able to deposit and withdraw bitcoins to an external wallet.

I have experience with ASP.NET and C# but i am pretty new the crypto world.

I've heard about libraries like BitcoinLib and BitcoinSharp but i wasn't able to find a good documentation that would explain to a newbie like me how to create a wallet in my website.

I also tried to use the blockchain.info api but it takes too much to complete a transaction and i have heard some bad comments about that api.
Also, i don't feel comfortable with relying on a third party api.

I would really appreciate if someone would give me or address me to a proper explanation of how i can implement such system in my website.
Thank you very much Smiley

hi,

first you should check some basic stuff: https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list

thanks god we have json-rpc which can be used for wallet-communication.
so C# offers two basic options for this realization:

1. use standard http json reqests. EXAMPLE: (C#)
if you use https JSON-RPC calls (SSL --> see "rpcssl") PLEASE MAKE SURE TO HAVE ACTUAL OPENSSL VERSION INSTALLED!

Code:
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://localhost.:8332");
 webRequest.Credentials = new NetworkCredential("user", "pwd");
 /// important, otherwise the service can't desirialse your request properly
 webRequest.ContentType = "application/json-rpc";
 webRequest.Method = "POST";
 
 JObject joe = new JObject();
 joe.Add(new JProperty("jsonrpc", "1.0"));
 joe.Add(new JProperty("id", "1"));
 joe.Add(new JProperty("method", Method));
 // params is a collection values which the method requires..
 if (Params.Keys.Count == 0)
 {
  joe.Add(new JProperty("params", new JArray()));
 }
 else
 {
     JArray props = new JArray();
     // add the props in the reverse order!
     for (int i = Params.Keys.Count - 1; i >= 0; i--)
     {
        .... // add the params
     }
     joe.Add(new JProperty("params", props));
     }
 
     // serialize json for the request
     string s = JsonConvert.SerializeObject(joe);
     byte[] byteArray = Encoding.UTF8.GetBytes(s);
     webRequest.ContentLength = byteArray.Length;
     Stream dataStream = webRequest.GetRequestStream();
     dataStream.Write(byteArray, 0, byteArray.Length);
     dataStream.Close();
 
 
     WebResponse webResponse = webRequest.GetResponse();
 
     ... // deserialze the response


the 2. option is json.Net ( http://james.newtonking.com/json ) which is a high performance JSON package for .Net


cheers,
bitsta
newbie
Activity: 14
Merit: 0
Hi Smiley
I'm creating an ASP.NET website in c#.
I want to allow a registered user to create his own bitcoin wallet in the website in which he will be able to deposit and withdraw bitcoins to an external wallet.

I have experience with ASP.NET and C# but i am pretty new the crypto world.

I've heard about libraries like BitcoinLib and BitcoinSharp but i wasn't able to find a good documentation that would explain to a newbie like me how to create a wallet in my website.

I also tried to use the blockchain.info api but it takes too much to complete a transaction and i have heard some bad comments about that api.
Also, i don't feel comfortable with relying on a third party api.

I would really appreciate if someone would give me or address me to a proper explanation of how i can implement such system in my website.
Thank you very much Smiley
Jump to: