sendrawtransaction failed to check transaction balance #3859

issue codefinderin opened this issue on March 12, 2014
  1. codefinderin commented at 11:24 PM on March 12, 2014: none

    exp: https://www.biteasy.com/testnet/transactions/98ce7b1e52532768f723608555154f2d72ff9794a3a2b05d896a56b4a3773018

    0.1 btc sent to 2NAjrXTdtt2f8YhX8LGa73uxHEEj3pCVkzC, now send 0.0999 from it

    bitcoind only be able to find the first outpout 0.0991 amount, the second input of 0.1 is missing, so when you send 0.0999 you will get an error, bicoind think you only have 0.0991

    in main.cpp if (nValueIn < GetValueOut(tx)) return state.DoS(100, error("CheckInputs() : %s value in %lld < value %lld out", tx.GetHash().ToString().c_str(),nValueIn,GetValueOut(tx)));

    ERROR: CheckInputs() : 53c3e82d8b6598f6b148d3f3ac68187fae33fc0306d8662bb2f68886e63ab0cc value in 9910000 < value 9990000 out ERROR: AcceptToMemoryPool: : ConnectInputs failed 53c3e82d8b6598f6b148d3f3ac68187fae33fc0306d8662bb2f68886e63ab0cc

    the solution will be foreach all outputs for (unsigned int i = 0; i < tx.vin.size(); i++) { for (unsigned int i = 0; i < tx.vout.size(); i++){ nValueIn += coins.vout[i].nValue; //nValueIn += coins.vout[prevout.n].nValue; } }

  2. gavinandresen commented at 11:57 PM on March 12, 2014: contributor

    I'm confused. What commands did you use to create the raw transaction? The raw transaction API never checks balances, you tell it which unspent transaction outputs to use.

  3. codefinderin commented at 12:06 AM on March 13, 2014: none

    @gavinandresen ./bitcoind createrawtransaction '[{"txid":"98ce7b1e52532768f723608555154f2d72ff9794a3a2b05d896a56b4a3773018","vout":0,"scriptPubKey":"a914bfe44905713c4c7c50e01f4a4a2013cb13dab6c387","redeemScript":"522103bdbcfa53f42f3f8013e7b3b29907ddcaf7a5e5c5938c38470ddeadcab18a479b210357a44da8b8058914c7c5e2f3647296ed35322a5329275f58d714a8af5764274021025edcf4ce9331f82a6a39857a3b06e685f0b2047a1d4ab83a75a61afd204a28b653ae"}]' '{"n3DHibtRCQnEGgsdWtewTAb5gVETbRTqf5":0.09,"mxYszJzH34CxFN9odR5eAjq8sAxQ7wXbhf":0.0099}'

    after both signed (spend from a 2 of 3) ./bitcoind sendrawtransaction 0100000001183077a3b4566a895db0a2a39497ff722d4f1555856023f7682753521e7bce9800000000fdff00004830450221009e07e22bf4697fab63302032cfe4ab6b8d21611b41f8b22462b857ec1fa7e76e0220483aac02e8e67995e6b236691efc17f4aba9331d83a09d2c3410815ea50d92b7014930460221009a2e4cfa4ca8464223297f643dba62469967c86e66d6be2cd0c29657f900d0d0022100e2203872e32f582100c9f8644bf46ecefbecbb3d0fb57f89fd6da181c6181830014c69522103bdbcfa53f42f3f8013e7b3b29907ddcaf7a5e5c5938c38470ddeadcab18a479b210357a44da8b8058914c7c5e2f3647296ed35322a5329275f58d714a8af5764274021025edcf4ce9331f82a6a39857a3b06e685f0b2047a1d4ab83a75a61afd204a28b653aeffffffff0240548900000000001976a914edfb7e5f37f0e09eb917327fc42d81e62bbf443588ac301b0f00000000001976a914bad76037c3c4c31c57806de92bc35417a3f4c04b88ac00000000

    error: {"code":-22,"message":"TX rejected"}

    found in debug.log ERROR: CheckInputs() : 6cc1a87f44d327bbec00d2e7128735556e9e1f8f8df583b7fa4e7c377b0b0d97 value in 9910000 < value 9990000 out ERROR: AcceptToMemoryPool: : ConnectInputs failed 6cc1a87f44d327bbec00d2e7128735556e9e1f8f8df583b7fa4e7c377b0b0d97

  4. gavinandresen commented at 12:32 AM on March 13, 2014: contributor

    See pull request #3730 which improves the error message when sendrawtransaction failed (help test/improve, please!).

    createrawtransaction doesn't look up previous transaction output amounts (by design-- if it did, you couldn't create a chain of dependent transactions), so doesn't know the total value in. signrawtransaction is designed to work when you don't know all the transaction inputs, so it can't figure out whether or not you included enough value in to cover the value out.

    So having sendrawtransaction fail with a better error message is the best that can be done (but @sipa has a proposal for a different createrawtransaction that would do more for you).

  5. codefinderin commented at 12:56 AM on March 13, 2014: none

    @gavinandresen just did, got this: ./bitcoind9 sendrawtransaction 0100000001183077a3b4566a895db0a2a39497ff722d4f1555856023f7682753521e7bce9800000000fdfe00004830450221009e07e22bf4697fab63302032cfe4ab6b8d21611b41f8b22462b857ec1fa7e76e0220483aac02e8e67995e6b236691efc17f4aba9331d83a09d2c3410815ea50d92b701483045022049592518e84d85c1fa579d03e57ef732180d4523d47552b4769edd18ceff5ebb022100e5924fcc46a138289a253e6e4e7219515cc5df4c48423e1ac02bc18ef6fd0dbd014c69522103bdbcfa53f42f3f8013e7b3b29907ddcaf7a5e5c5938c38470ddeadcab18a479b210357a44da8b8058914c7c5e2f3647296ed35322a5329275f58d714a8af5764274021025edcf4ce9331f82a6a39857a3b06e685f0b2047a1d4ab83a75a61afd204a28b653aeffffffff0240548900000000001976a914edfb7e5f37f0e09eb917327fc42d81e62bbf443588ac301b0f00000000001976a914bad76037c3c4c31c57806de92bc35417a3f4c04b88ac00000000 error: {"code":-25,"message":"18: bad-txns-inputs-spent"}

    found in debug.log ERROR: AcceptToMemoryPool : inputs already spent

    however, there is no spend in block explorer, check at here: https://www.biteasy.com/testnet/addresses/2NAjrXTdtt2f8YhX8LGa73uxHEEj3pCVkzC

  6. codefinderin commented at 12:58 AM on March 13, 2014: none

    ./bitcoind9 decoderawtransaction: { "txid" : "89a84859f15f8adec5fa7db5e31fbc7cbf5b3d7e2ddf9e6f347d45f469e8f50f", "version" : 1, "locktime" : 0, "vin" : [ { "txid" : "98ce7b1e52532768f723608555154f2d72ff9794a3a2b05d896a56b4a3773018", "vout" : 0, "scriptSig" : { "asm" : "0 30450221009e07e22bf4697fab63302032cfe4ab6b8d21611b41f8b22462b857ec1fa7e76e0220483aac02e8e67995e6b236691efc17f4aba9331d83a09d2c3410815ea50d92b701 3045022049592518e84d85c1fa579d03e57ef732180d4523d47552b4769edd18ceff5ebb022100e5924fcc46a138289a253e6e4e7219515cc5df4c48423e1ac02bc18ef6fd0dbd01 522103bdbcfa53f42f3f8013e7b3b29907ddcaf7a5e5c5938c38470ddeadcab18a479b210357a44da8b8058914c7c5e2f3647296ed35322a5329275f58d714a8af5764274021025edcf4ce9331f82a6a39857a3b06e685f0b2047a1d4ab83a75a61afd204a28b653ae", "hex" : "004830450221009e07e22bf4697fab63302032cfe4ab6b8d21611b41f8b22462b857ec1fa7e76e0220483aac02e8e67995e6b236691efc17f4aba9331d83a09d2c3410815ea50d92b701483045022049592518e84d85c1fa579d03e57ef732180d4523d47552b4769edd18ceff5ebb022100e5924fcc46a138289a253e6e4e7219515cc5df4c48423e1ac02bc18ef6fd0dbd014c69522103bdbcfa53f42f3f8013e7b3b29907ddcaf7a5e5c5938c38470ddeadcab18a479b210357a44da8b8058914c7c5e2f3647296ed35322a5329275f58d714a8af5764274021025edcf4ce9331f82a6a39857a3b06e685f0b2047a1d4ab83a75a61afd204a28b653ae" }, "sequence" : 4294967295 } ], "vout" : [ { "value" : 0.09000000, "n" : 0, "scriptPubKey" : { "asm" : "OP_DUP OP_HASH160 edfb7e5f37f0e09eb917327fc42d81e62bbf4435 OP_EQUALVERIFY OP_CHECKSIG", "hex" : "76a914edfb7e5f37f0e09eb917327fc42d81e62bbf443588ac", "reqSigs" : 1, "type" : "pubkeyhash", "addresses" : [ "n3DHibtRCQnEGgsdWtewTAb5gVETbRTqf5" ] } }, { "value" : 0.00990000, "n" : 1, "scriptPubKey" : { "asm" : "OP_DUP OP_HASH160 bad76037c3c4c31c57806de92bc35417a3f4c04b OP_EQUALVERIFY OP_CHECKSIG", "hex" : "76a914bad76037c3c4c31c57806de92bc35417a3f4c04b88ac", "reqSigs" : 1, "type" : "pubkeyhash", "addresses" : [ "mxYszJzH34CxFN9odR5eAjq8sAxQ7wXbhf" ] } } ] }

    the "txid" : "98ce7b1e52532768f723608555154f2d72ff9794a3a2b05d896a56b4a3773018" is correct

  7. codefinderin commented at 1:13 AM on March 13, 2014: none

    i tried to create another new raw and send it with bitcoind version 0.9 + #3730 it works well through the new version, https://www.biteasy.com/testnet/transactions/6c3885ec45836f1b8db96865ef581fd233d27893ed68eff2bd66a3c264f46103

    no more value in < value out issue

    there must be something wrong in the difference between 0.8.6 & 0.9 + #3730 , what is it? because this time my address randomly in the first place of tx.vout so the bitcoind found the correct 0.1 amount? this can't be good, and where is the previous missing "already spent" tx?

  8. codefinderin commented at 9:06 PM on March 13, 2014: none

    i see, the vout in createrawtransaction should match the output order in the income TX

  9. codefinderin closed this on Mar 13, 2014

  10. bellaj commented at 9:14 AM on August 12, 2017: none

    in my case i have restarted the bitcoin client and it's ok seems like a sync issue.

  11. sidhujag referenced this in commit f98f314b58 on Dec 13, 2020
  12. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-19 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me