NBitcoin: TransactionBuilder.Verify fails but transaction is successful on the blockchain

What could cause TransactionBuilder.Verify to return false? This transaction is successfully signed, and I’m able to broadcast it to the blockchain, but for some reason it always returns “false”. e.g.

var builder = new TransactionBuilder();
            var tx = builder
                .AddCoins(coinsToSpend)
                .AddKeys(signingKeys.ToArray())
                .Send(addressToSend, amountToSend)
                .SendFees("0.00001008")
                .SetChange(changeScriptPubKey)                
                .BuildTransaction(true);

Console.WriteLine(builder.Verify(tx)); // always false

The result transaction looks like:

{
  "hash": "b7090c8a07059d1e469e95b73deb42daaa2e1d7e4c9aa4d04ad16de13351a5c5",
  "ver": 1,
  "vin_sz": 1,
  "vout_sz": 2,
  "lock_time": 0,
  "size": 223,
  "in": [
    {
      "prev_out": {
        "hash": "53911e43ec41e5a3b74aed43c3f1368514ac366ac6fc7b4b991853012058adac",
        "n": 1
      },
      "scriptSig": "30440220602d34b8bc0547732753f9251bb8dcbe9dbf039e3af8e88017472d6684e2287b022016c79e734cdad383cf504a079068b1a111bd6715fda164b7bb6e4a1c0bc1da3101 02312d1962a3c7626228c555684971f84e0008fd364e6646303885099be9b69af1"
    }
  ],
  "out": [
    {
      "value": "0.29998992",
      "scriptPubKey": "OP_DUP OP_HASH160 33ab50867662afb080281e0bdb389751bb2c8a08 OP_EQUALVERIFY OP_CHECKSIG"
    },
    {
      "value": "0.20000000",
      "scriptPubKey": "OP_HASH160 f46ba62dc8063b6e798076609d69b1e6803be6e9 OP_EQUAL"
    }
  ]
}

The amounts and fee seems OK, and the fact that the transaction is accepted on the blockchain just drives me crazy. Please assist. I am currently using a single Testnet address for my transactions (including the change address)

Here are all the successful transactions I made:

https://live.blockcypher.com/btc-testnet/address/mkE9yyrgdttSRY7UYQLVUHVY9g7Saqh2Qv/

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

This is only the base type. Look in NBitcoin.Policy for all different type of errors.