The verification passed. But nothing happen after that. The balance in both accounts remain the same.
Anything wrong in the way that I build my transaction?
var fpk = new BitcoinSecret("<my private key>", 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("<To address>", fpk.Network), Money.Coins(0.001))
.SubtractFees()
.SendFees(Money.Coins(0.00001))
.SetChange(fpk)
.BuildTransaction(true);
Debug.Assert(builder.Verify(tx));
var r = await api.Broadcast(tx);
The response was success but with error code:
ErrorCode: INVALID
Reason: "Unknown"
{
"hash": "a7d08d4f1993ea1b4143738c9ebf7cb4a04cd26fae7e97e3fa0dd0994718cf70",
"ver": 1,
"vin_sz": 1,
"vout_sz": 2,
"lock_time": 0,
"size": 225,
"in": [
{
"prev_out": {
"hash": "a98e4e3ad94d69f415c3849aedfb3d371afb24f49096b4b6de250c52ea9e7608",
"n": 0
},
"scriptSig": "304402201064fbd041900c2fe594a46cd4e0536427c94c82934bd125b3d5efd2863838d802206256840d67972126470443c71cfe1b72d2198a1d771a5eead54123573bafe87a01 030e9c36c9e37c2047f8c42cc5d56ff5ab1fc1b51b716fbbb2fc20201618401c0c"
}
],
"out": [
{
"value": "0.00998000",
"scriptPubKey": "OP_DUP OP_HASH160 35343be6a983983c1a69871ddf3d604126a8e06f OP_EQUALVERIFY OP_CHECKSIG"
},
{
"value": "0.00009000",
"scriptPubKey": "OP_DUP OP_HASH160 6652f3e81f9f8a832fecf707fc7b5757bf7faff5 OP_EQUALVERIFY OP_CHECKSIG"
}
]
}
Invalid base58 data
– Apr 11 '21 at 23:18BitcoinPubKeyAddress
withBitcoinWitPubKeyAddress
. Code: https://pastebin.com/sQbdzmzL Tx: https://tbtc.bitaps.com/1312cde5f927bb0dcfeed457c53cf2b85678a2dc02468dc951366f872b7d3a4a – Apr 12 '21 at 13:16QBitNinja.GetBalance(<pubKey>, true)
to get all the unspent amount for particular address. – s k Apr 14 '21 at 14:12scantxoutset
can be used for it: https://bitcoin.stackexchange.com/a/99288/ – Apr 14 '21 at 14:24