Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: OmegaStarScream on December 20, 2015, 02:27:26 PM



Title: Accepting Bitcoin using ASP.NET ?
Post by: OmegaStarScream on December 20, 2015, 02:27:26 PM
I'm running a website on ASP.NET C# and it's connected to a MSSQL Database . What I want to do is when people send BTC to an address (I don't really care if the care is the same or keep generating new one each time) , so once they send BTC .. I want to execute a MSSQL Query into my database to give them some sort of points etc ... ? Who think he can help on this task pls


Title: Re: Accepting Bitcoin using ASP.NET ?
Post by: tyz on December 20, 2015, 09:48:25 PM
Do you want to use the Bitcoin core or an api like the one from Coinbase.com?
When the last is the case then it is not a big deal to implement what you require. The api is documented very well.


Title: Re: Accepting Bitcoin using ASP.NET ?
Post by: doof on December 20, 2015, 11:01:35 PM
I'm running a website on ASP.NET C# and it's connected to a MSSQL Database . What I want to do is when people send BTC to an address (I don't really care if the care is the same or keep generating new one each time) , so once they send BTC .. I want to execute a MSSQL Query into my database to give them some sort of points etc ... ? Who think he can help on this task pls

3 ways, in order of ease:

You will have to write a service, worker processor etc to poll the address looking for new transactions.

1.  Use Blockchain.info.  They have a nugget package and good enough for small transactions, but you're trusting them to report correct:
Code:
        public ActionResult Wallet()
        {
            ViewBag.Address = System.Configuration.ConfigurationManager.AppSettings["WalletAddress"];

            Info.Blockchain.API.BlockExplorer.BlockExplorer ex = new Info.Blockchain.API.BlockExplorer.BlockExplorer();
            var address = ex.GetAddress(System.Configuration.ConfigurationManager.AppSettings["WalletAddress"]);

            Decimal amount = Convert.ToDecimal(address.FinalBalance / 100000000.0M);
            String balance = String.Format("{0:0.######}", amount);
            ViewBag.Balance = balance;

            return View();
        }

2.  Same approach, but poll your own bitcoind instance.  There are a few .net wrappers for bitcoind. 
  • Have a server running bitcoind in server mode
  • Set the credentials and configs and firewalls up
  • Use JSON RPC calls (web client will do) to query an address that bitcoind hosts

3.  Roll your own blockchain passer and keep updating it.  There are a few .net ones out there, but too much over kill for a few tx a day.

Hope this helps.


Title: Re: Accepting Bitcoin using ASP.NET ?
Post by: OmegaStarScream on December 21, 2015, 05:18:11 AM
Do you want to use the Bitcoin core or an api like the one from Coinbase.com?
When the last is the case then it is not a big deal to implement what you require. The api is documented very well.

I'm not even sure what's the difference between running Bitcoin Core itself and running Coinbase.com API or BlockTrail/Blockchain etc ... ?


I'm running a website on ASP.NET C# and it's connected to a MSSQL Database . What I want to do is when people send BTC to an address (I don't really care if the care is the same or keep generating new one each time) , so once they send BTC .. I want to execute a MSSQL Query into my database to give them some sort of points etc ... ? Who think he can help on this task pls

3 ways, in order of ease:

You will have to write a service, worker processor etc to poll the address looking for new transactions.

1.  Use Blockchain.info.  They have a nugget package and good enough for small transactions, but you're trusting them to report correct:
Code:

        public ActionResult Wallet()
        {
            ViewBag.Address = System.Configuration.ConfigurationManager.AppSettings["WalletAddress"];

            Info.Blockchain.API.BlockExplorer.BlockExplorer ex = new Info.Blockchain.API.BlockExplorer.BlockExplorer();
            var address = ex.GetAddress(System.Configuration.ConfigurationManager.AppSettings["WalletAddress"]);

            Decimal amount = Convert.ToDecimal(address.FinalBalance / 100000000.0M);
            String balance = String.Format("{0:0.######}", amount);
            ViewBag.Balance = balance;

            return View();
        }

2.  Same approach, but poll your own bitcoind instance.  There are a few .net wrappers for bitcoind. 
  • Have a server running bitcoind in server mode
  • Set the credentials and configs and firewalls up
  • Use JSON RPC calls (web client will do) to query an address that bitcoind hosts

3.  Roll your own blockchain passer and keep updating it.  There are a few .net ones out there, but too much over kill for a few tx a day.

Hope this helps.

Very curious what do you mean by "trust them to report correct" ? can they report that I received X on the transaction while I received Y ?


Title: Re: Accepting Bitcoin using ASP.NET ?
Post by: doof on December 21, 2015, 06:58:44 AM
Quote
I'm not even sure what's the difference between running Bitcoin Core itself and running Coinbase.com API or BlockTrail/Blockchain etc ... ?

The difference is they do it vs you do it.  They could have a website / API that returns anything.  Its not in their best interest to do so, but they could get hacked, a software bug etc.

If you stand up you're own infrastructure and report on your own daemon, then you only have to trust yourself, and the build of bitcoin core.

Quote
Very curious what do you mean by "trust them to report correct" ? can they report that I received X on the transaction while I received Y ?

They could do what ever they like.  How are you to know that query on address a will give a correct result?  If you believe they're reputable and their systems are working correctly, then fine.

Maybe think about it like this.  You need to report on the weather in your favourite city.  You could call an API like weather.com for the information.  Or you could setup your own monitoring system and report on that.


Title: Re: Accepting Bitcoin using ASP.NET ?
Post by: OmegaStarScream on December 21, 2015, 12:34:24 PM
Quote
I'm not even sure what's the difference between running Bitcoin Core itself and running Coinbase.com API or BlockTrail/Blockchain etc ... ?

The difference is they do it vs you do it.  They could have a website / API that returns anything.  Its not in their best interest to do so, but they could get hacked, a software bug etc.

If you stand up you're own infrastructure and report on your own daemon, then you only have to trust yourself, and the build of bitcoin core.

Quote
Very curious what do you mean by "trust them to report correct" ? can they report that I received X on the transaction while I received Y ?

They could do what ever they like.  How are you to know that query on address a will give a correct result?  If you believe they're reputable and their systems are working correctly, then fine.

Maybe think about it like this.  You need to report on the weather in your favourite city.  You could call an API like weather.com for the information.  Or you could setup your own monitoring system and report on that.

Make sense , and on the same time It's scary little bit and will make me think more then once before using an API of any website . Well .. thanks for your explanation mate , I hope I will successfully setup everything up .


Title: Re: Accepting Bitcoin using ASP.NET ?
Post by: ftdgoodluck on December 21, 2015, 02:21:55 PM
You can scan the blockchain manually, using NBitcoin library (https://github.com/MetacoSA/NBitcoin). You'll need a bitcoind running on your server.
Or you can simply trust some of the "big players", that are providing statistics information (as mentioned above).

Ease or reliability - that is the question, that you should ask as a developer.