Code Optimization

Interesting things in software development and code optimization

Blockchain, Bitcoin and C#

Do you need to work with blockchain and bitcoin?

There is a library or even two of them to help you. NBitcoin and QBitNinja will help you.


If you need to track your address for income transactions, for example to check if anyone has paid you for your service or goods.

First thing you need to install those NuGet packages.

Then you need your private key hex bytes and when you get it all then just a few lines of code will provide you with all data you need:


Key key = new Key(new byte[] { /*your private key hex bytes*/ });
var addr = key.PubKey.Hash.GetAddress(Network.Main);
var client = new QBitNinjaClient(Network.Main);
var rbalance = client.GetBalance(addr, true).Result;


After that the rblanace will contain Operations property that will list all operations for your address.

Just go over all items in the rbalance.Operations and find everything you need to confirm or decline your user operation.


Thank you


1vqHSTrq1GEoEF7QsL8dhmJfRMDVxhv2y



Loading