[ad_1]
I’m trying to send Bitcoin via testnet.
I’ve looked at questions on this site, but they seem out of date.
Is the QBitNinjaClient working? getbalance
always returns an error:
Newtonsoft.Json.JsonReaderException: ‘Unexpected character encountered
while parsing value: <. Path ”, line 0, position 0.’
var fpk = new BitcoinSecret("cVDNzGDRPxQ6vkQ9VJcJpLKhuvFRQMYEaMegEw9hK5z5ZttkSut2", Network.TestNet);
var fspk = fpk.GetAddress(ScriptPubKeyType.Legacy);
var api = new QBitNinjaClient("http://tapi.qbit.ninja/", fpk.Network);
var fbal = await api.GetBalance(fspk, true);
var fcoin = new List<ICoin>();
foreach (var o in fbal.Operations)
{
if (o.Confirmations < 2) continue; // 2 confirmations
fcoin.AddRange(o.ReceivedCoins);
}
var builder = fpk.Network.CreateTransactionBuilder();
var tx = builder
.AddCoins(fcoin)
.AddKeys(new ISecret[] { fpk })
.Send(new BitcoinPubKeyAddress("myUo9SDsAZKVfnYdJgbVvXcmCFVL7Adxi9", fpk.Network), Money.Coins(0.001m))
.SubtractFees()
.SendFees(Money.Coins(0.00001m))
.SetChange(fpk)
.BuildTransaction(true);
Debug.Assert(builder.Verify(tx));
var r = await api.Broadcast(tx);
[ad_2]
Source link