3

Using bitcoin-cli decoderawtransaction, i got the txid of the only one vin, and the value of two vout are set at 0.015 BTC. Then, using bitcoin-cli gettransaction, i got negative value of amount and fee. How could the transaction have negative value of amount and fee ? Could this be the reason of that error "bad-txns-in-belowout"?

./bitcoin-cli -regtest decoderawtransaction "hexvalue"
{
  "txid": "35d2e765217d71db34fd0cd1cf52f419fc525069ac87ed9f413b194851c70849",
  "hash": "35d2e765217d71db34fd0cd1cf52f419fc525069ac87ed9f413b194851c70849",
  "version": 1,
  "size": 338,
  "vsize": 338,
  "locktime": 0,
  "vin": [
    {
      "txid": "2146415931a60db99ebf60849e2874dd67d37f870249a1ff06adcc6b8244155b",
      "vout": 0,
''' 
    }
  "vout": [
    {
      "value": 0.01500000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 dd100be7d9aea5721158ebde6d6a1fd8fff93bb1 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914dd100be7d9aea5721158ebde6d6a1fd8fff93bb188ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "n1fprNxRhWrpkJ34A4cNsSZbHsnzhob2KL"
        ]
      }
    },
    {
      "value": 0.01500000,
      "n": 1,
...
    }
}

./bitcoin-cli -regtest gettransaction 2146415931a60db99ebf60849e2874dd67d37f870249a1ff06adcc6b8244155b
{
  "amount": -0.08000000,
  "fee": -0.00100000,
  "confirmations": 0,
  "trusted": true,
  "txid": "2146415931a60db99ebf60849e2874dd67d37f870249a1ff06adcc6b8244155b",
...
}

1 Answer 1

3

How could the transaction have negative value of amount and fee ? Could this be the reason of that error "bad-txns-in-belowout"?

No, it is not. The negatives you see are normal; the values are actually positive, but because you are sending money away from your wallet, they will display as negative relative to your wallet.

That error means that the value of the inputs is less than the value of the outputs. You need to check that output 0 of 2146415931a60db99ebf60849e2874dd67d37f870249a1ff06adcc6b8244155b actually has the value that you want to spend.

4
  • I don't understand. I set the amount and fee to positive 0.08 and 0.001 BTC, How could the transaction turn out to have negative amount and fee ?
    – styling
    Commented Jan 13, 2018 at 2:59
  • Sorry, I slightly misunderstood your question, although my answer is till mostly correct. The negative values are relative to your wallet. Your wallet in that transaction is losing 0.08 + 0.001, so if you were to add those values to your wallet and get the correct balance, they need to be negative. The negatives there are normal for sending from your wallet. The problem is that the output that you are spending does not have enough money. I will update my answer accordingly.
    – Ava Chow
    Commented Jan 13, 2018 at 3:05
  • Thank you. In bitcoin-cli, is there a command to check the output 0 value of txid 2146415931a60db99ebf60849e2874dd67d37f870249a1ff06adcc6b8244155b
    – styling
    Commented Jan 13, 2018 at 11:07
  • Assuming that the transaction still contains an unspent output, you can use getrawtransaction. If that transaction is part of your wallet, you can use gettransaction and listunspent.
    – Ava Chow
    Commented Jan 13, 2018 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.