I got an error: TX rejected – code: -22. What is that?

This is a rather ambiguous error that bitcoind can issue for a variety of reasons. The full error line looks something like:
lib.exceptions.BitcoindError: {'message': 'TX rejected', 'code': -22}.

If you receive this error, please check the following:

  • Ensure that you have enough BTC in the account you are attempting to issue the transaction from (i.e. the source account). To be safe, you should have at least 0.0004 BTC in the account.
  • Ensure that this BTC in the account has at least a few confirmations on the blockchain.
  • Ensure that bitcoind is running and configured properly. Make sure you aren’t getting any other errors in your bitcoind debug.log file (which is located in the same directory as your bitcoin.conf file).
  • Try waiting 10-20 minutes and issuing the transaction again.

If you do all of this and are still getting this error, please call the command once more, except this time, add the --unsigned tag.

So, for example, a send command to send 1 XCP may look like:

counterparty-client --unsigned send --source=19MjB56IrEausRoM48vEfbRnqX7QqU7KkM --destination=1NnNyxgprjVysZKdT4nGVbeyqN6n1nJJvA --quantity=1 --asset=XCP

What this does is have counterpartyd produce a raw encoded version of the transaction, and output it to the screen (it does not pass the transaction to bitcoind, or sign it in any way). Please note that the –unsigned flag goes before the command itself, as in the example above.

Then, submit a bug report that contains:

  • The original command you used, as well as all counterparty-client output (including the hex returned)
  • The last 100 lines or so of your bitcoind debug.log, after issuing the transaction (this is optional, but highly recommended, as it will make troubleshooting easier)

Since this raw transaction is not signed, it cannot be broadcast and is thus safe to send in a bug report.