Tuesday, July 2, 2024

Error ship Bitcoin in testnet utilizing Nbitcoin and QBitNinjaClient C#

I attempt an excessive amount of to ship bitcoin in testnet. I attempted to search out somes questions right here and to previous.

my query is:

QBitNinjaClient its prepared work yeat ? as a result of i noticed the parametrs to getbalance finish at all times give a error:

Newtonsoft.Json.JsonReaderException: ‘Sudden character encountered
whereas parsing worth: <. Path ”, line 0, place 0.’

  var fpk = new BitcoinSecret("cVDNzGDRPxQ6vkQ9VJcJpLKhuvFRQMYEaMegEw9hK5z5ZttkSut2", Community.TestNet);
            var fspk = fpk.GetAddress(ScriptPubKeyType.Legacy);
            var api = new QBitNinjaClient("http://tapi.qbit.ninja/", fpk.Community);
            var fbal = await api.GetBalance(fspk, true);
            var fcoin = new Checklist<ICoin>();
            foreach (var o in fbal.Operations)
            {
                if (o.Confirmations < 2) proceed; // 2 confirmations
                fcoin.AddRange(o.ReceivedCoins);
            }

            var builder = fpk.Community.CreateTransactionBuilder();
            var tx = builder
                .AddCoins(fcoin)
                .AddKeys(new ISecret[] { fpk })
                .Ship(new BitcoinPubKeyAddress("myUo9SDsAZKVfnYdJgbVvXcmCFVL7Adxi9", fpk.Community), Cash.Cash(0.001m))
                .SubtractFees()
                .SendFees(Cash.Cash(0.00001m))
                .SetChange(fpk)
                .BuildTransaction(true);

            Debug.Assert(builder.Confirm(tx));
            var r = await api.Broadcast(tx);

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles