BTC - Transaction Broadcast Error

A Bitcoin broadcast fails when the node rejects the signed transaction. Test the raw hex with testmempoolaccept to see why, then fix inputs and outputs.

A Bitcoin transaction fails to broadcast when the node refuses the signed transaction, most often because its data is malformed, an input is already spent, or the amounts don't add up. Tatum returns btc.blockchain.broadcast.error. Run the raw transaction through testmempoolaccept to get the node's exact reason, then review how you built the transaction from its inputs, outputs and amounts.

Symptom

When broadcasting a BTC transaction, you may encounter errors looking as follows:

{
    "statusCode": 403,
    "errorCode": "btc.blockchain.broadcast.error",
    "message": "Unable to broadcast transaction.",
    "cause": "Request failed with status code 500"
}

If cause names a specific reason, go straight to its page:

causePage
max-fee-exceededBTC maxfeerate limit error
dust (code 64)Dust amount detected in one output
txn-mempool-conflict, txn-already-in-mempoolTransaction already exists in mempool
too-long-mempool-chainToo long mempool chain

Cause

Tatum checks the transaction with the Bitcoin node before broadcasting it. A cause of Request failed with status code 500 means the node returned an error instead of a reject reason Tatum recognizes: the transaction payload was built improperly and the blockchain refuses to accept it. Common reasons, with the messages Bitcoin Core uses:

  • Malformed transaction data (TX decode failed): the hex is truncated, incomplete or isn't a signed transaction.
  • Inputs missing or already spent (missing-inputs from testmempoolaccept, bad-txns-inputs-missingorspent from sendrawtransaction): an input points to a UTXO that doesn't exist or that another transaction already spent.
  • Outputs larger than inputs (bad-txns-in-belowout): the outputs add up to more than the inputs, so nothing is left for the fee.
  • Invalid signature (mandatory-script-verify-flag-failed): an input's signature doesn't verify, for example because it was signed with the wrong private key.
  • Fee too low (min relay fee not met, mempool min fee not met): the fee rate is below what the node accepts. See UTXO minimum relay fee.

Solution

  1. Take the raw txData from your broadcast request. For example, this request to /v3/bitcoin/broadcast failed (signatureId is only present when you sign with Tatum KMS):

    {
      "txData": "020000000001af4800000000000016001419619f650a88532d25fed24dc06aada4a0cb238d00000000",
      "signatureId": "654cf9d2ca22c5a2a9c###"
    }
  2. Test it with the Bitcoin RPC method testmempoolaccept. It checks whether the node would accept the transaction, without broadcasting it:

    curl --location 'https://bitcoin-mainnet.gateway.tatum.io' \
    --header 'Content-Type: application/json' \
    --header 'x-api-key: {YOUR_API_KEY}' \
    --data '{
        "id": "1",
        "jsonrpc": "2.0",
        "method": "testmempoolaccept",
        "params": [
            [
                "020000000001af4800000000000016001419619f650a88532d25fed24dc06aada4a0cb238d00000000"
            ]
        ]
    }'

    This txData can't even be decoded, so the node returns an error:

    {
      "id": "1",
      "jsonrpc": "2.0",
      "error": {
        "code": -22,
        "message": "TX decode failed: 020000000001af4800000000000016001419619f650a88532d25fed24dc06aada4a0cb238d00000000 Make sure the tx has at least one input."
      }
    }

    A transaction that decodes but is invalid returns "allowed": false and a reject-reason instead, here an input that is missing or already spent:

    {
      "result": [
        {
          "txid": "243293bbf0974f5d8d4d2a6f9ee7dd2c188c20db1f8d79b6378445e15e0cb3be",
          "wtxid": "f52bf0b288f50f01eade6b251e9ee98ea467711f3ebff001b07bb25d9aaafa95",
          "allowed": false,
          "reject-reason": "missing-inputs"
        }
      ],
      "id": "1",
      "jsonrpc": "2.0"
    }
  3. Decode the transaction and check its inputs, outputs and amounts. Use the RPC method decoderawtransaction or a reliable blockchain explorer, such as BlockCypher. Analyze the decoded transaction to ensure its structure and content are correct: each input (vin) must reference an unspent output, which you can check with Get UTXO info by tx hash and index, and the outputs (vout) plus the fee must equal the inputs.

  4. Rebuild, sign and broadcast the transaction again. Fix the reason from step 2 and use fresh UTXOs. See Building a UTXO transaction.

FAQ

How do I broadcast a Bitcoin transaction with Tatum?

Send the signed raw transaction hex as txData to POST /v3/bitcoin/broadcast, or call sendrawtransaction on the Bitcoin RPC gateway. Both return the transaction ID. To build, sign and broadcast in one call, use POST /v3/bitcoin/transaction.

What does bad-txns-inputs-missingorspent mean?

An input of your transaction references an output that doesn't exist or is already spent, often by an earlier transaction you sent from the same address. Get current UTXOs from the UTXO Indexer and rebuild the transaction.

How do I check that a broadcast BTC transaction is confirmed?

Look up its transaction ID. A pending Bitcoin transaction returns "blockNumber": null until a block includes it. See How to check a transaction by hash.

Still stuck?

Report the issue to support with the endpoint you called, the full error response (with its dashboardLog ID if present) and the raw txData.


Did this page help you?