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

var builder = fpk.Network.CreateTransactionBuilder();
var tx = builder
    .AddKeys(new ISecret[] { fpk })
    .Send(new BitcoinPubKeyAddress("<To address>", fpk.Network), Money.Coins(0.001))

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"
  • I have just noticed that my ErrorCode = Invalid, and Reason: Unknown, but my transaction did went through. I am confused now.
    – s k
    Apr 10 at 8:54
  • I am getting a different error when I run this code: Invalid base58 data
    – Prayank
    Apr 11 at 23:18
  • @Prayank You need to put in your own private and public keys into the code.
    – s k
    Apr 12 at 0:46
  • Yes I did that. Will share the code when I switch on my desktop again. On mobile right now.
    – Prayank
    Apr 12 at 1:08
  • Its working for me. No errors. Had to replace BitcoinPubKeyAddress with BitcoinWitPubKeyAddress. Code: pastebin.com/sQbdzmzL Tx: tbtc.bitaps.com/…
    – Prayank
    Apr 12 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.