<p>I figured it out, I simply was missing a step. I wasn't signing my transaction before sending.</p>
<pre><code>&gt;&gt;&gt; t.sign('my_private_key')
&gt;&gt;&gt; res = srv.sendrawtransaction(t.raw_hex())
&gt;&gt;&gt; res
{
    'txid': 
    '8ca3d23d55dbded21a3ee8809ba55e2fa97394332020fad55582ab29e9619de4', 
    'response_dict': 
    '8ca3d23d55dbded21a3ee8809ba55e2fa97394332020fad55582ab29e9619de4'
}`
</code></pre>

CC BY-SA 4.0
2021-12-03T10:22:54.940Z
2021-12-03T10:22:54.940Z
Sonny Parlin
<p>I'm using bitcoinlib for python to create a transaction and send it but I'm getting the following error:</p>
<pre><code>Funds not sent, exception error: Error connecting to blockchair on url 
https://api.blockchair.com/bitcoin/push/transaction?data=01000000000101a988402108fbbdc3dc790926a41e3378042f90a80e2fbf67f8ad117644c100803700000000ffffffff0231810000000000001600149dde1d0113a7468f605bef751aa03a020cad3d2b000000000000000017a914f1b553ddc46d0414e9b05b9667d65c5081d4f00a870000000000, 
response [400] 
{
    &quot;data&quot;:null,
    &quot;context&quot;:
    {
         &quot;code&quot;:400,
         &quot;source&quot;:&quot;R&quot;,
         &quot;error&quot;:&quot;Invalid transaction. Error: TX decode failed. Make sure the tx has at least one input.&quot;,
         &quot;market_price_usd&quot;:56609,&quot;cache&quot;:
         { 
             &quot;live&quot;:true,
             &quot;duration&quot;:60,
             &quot;since&quot;:&quot;2021-12-03 03:58:11&quot;,
             &quot;until&quot;:&quot;2021-12-03 03:59:11&quot;,&quot;time&quot;:null
         },
         &quot;api&quot;:
         {
             &quot;version&quot;:&quot;2.0.94&quot;,
             &quot;last_major_update&quot;:&quot;2021-07-19 00:00:00&quot;,
             &quot;next_major_update&quot;:null,
             &quot;documentation&quot;:&quot;https:\/\/blockchair.com\/api\/docs&quot;,&quot;notice&quot;:&quot;:)&quot;
         },
         &quot;server&quot;:&quot;BTC3&quot;,
         &quot;time&quot;:0.0013239383697509766,
         &quot;render_time&quot;:0.006116151809692383,
         &quot;full_time&quot;:0.007440090179443359,
         &quot;request_cost&quot;:1
    }
}
</code></pre>
<p>Here is my decoded transaction:</p>
<pre><code>{
    &quot;addresses&quot;: [
        &quot;bc1q23dd73raxnk6cvz62wl2gthkfx3ksdqq0tqrn0&quot;,
        &quot;bc1qnh0p6qgn5arg7czmaa634gp6qgx260ftspufv2&quot;,
        &quot;3Pj3zdw77aqsELdoh5pQErWvK2hAYbJx2w&quot;
    ],
    &quot;block_height&quot;: -1,
    &quot;block_index&quot;: -1,
    &quot;confirmations&quot;: 0,
    &quot;double_spend&quot;: false,
    &quot;fees&quot;: 683,
    &quot;hash&quot;: &quot;7f2f01b7a7d55cc9e13aa6604b115fcf07ada6ee6179a6342c0f8d7d5668de3d&quot;,
    &quot;inputs&quot;: [
        {
            &quot;addresses&quot;: [
                &quot;bc1q23dd73raxnk6cvz62wl2gthkfx3ksdqq0tqrn0&quot;
            ],
            &quot;age&quot;: 712033,
            &quot;output_index&quot;: 55,
            &quot;output_value&quot;: 33756,
            &quot;prev_hash&quot;: 
&quot;8000c1447611adf867bf2f0ea8902f0478331ea4260979dcc3bdfb08214088a9&quot;,
            &quot;script_type&quot;: &quot;pay-to-witness-pubkey-hash&quot;,
            &quot;sequence&quot;: 4294967295
        }
    ],
    &quot;outputs&quot;: [
        {
            &quot;addresses&quot;: [
                &quot;bc1qnh0p6qgn5arg7czmaa634gp6qgx260ftspufv2&quot;
            ],
            &quot;script&quot;: &quot;00149dde1d0113a7468f605bef751aa03a020cad3d2b&quot;,
            &quot;script_type&quot;: &quot;pay-to-witness-pubkey-hash&quot;,
            &quot;value&quot;: 33073
        },
        {
            &quot;addresses&quot;: [
                &quot;3Pj3zdw77aqsELdoh5pQErWvK2hAYbJx2w&quot;
            ],
            &quot;script&quot;: &quot;a914f1b553ddc46d0414e9b05b9667d65c5081d4f00a87&quot;,
            &quot;script_type&quot;: &quot;pay-to-script-hash&quot;,
            &quot;value&quot;: 0
        }
    ],
    &quot;preference&quot;: &quot;low&quot;,
    &quot;received&quot;: &quot;2021-12-03T03:58:47.770766807Z&quot;,
    &quot;relayed_by&quot;: &quot;3.237.60.136&quot;,
    &quot;size&quot;: 117,
    &quot;total&quot;: 33073,
    &quot;ver&quot;: 1,
    &quot;vin_sz&quot;: 1,
    &quot;vout_sz&quot;: 2,
    &quot;vsize&quot;: 115
}
</code></pre>
<p>The python code I used to create the transaction:</p>
<pre><code>w = Wallet(wallet_name, db_uri=db_uri)
t = w.transaction_create([(to_address, float(satstosend))])
</code></pre>
<p>I'm not sure why it's complaining that I don't have an input, but it's odd to me that I see one input and two outputs. I'm not sure if I'm creating the transaction incorrectly or if it has something to do with the fact that I'm trying to send from a native segwit address to a segwit address (bc1 -&gt; 3XX). Any help would be appreciated.</p>

CC BY-SA 4.0
2021-12-03T05:02:25.873Z
It's possible that blockchair believes the transaction to be a non-segwit transaction (because of the marker and flag bytes required for segwit txs) and so is incorrectly parsing it. Have you tried a different broadcast API?
Ava Chow
CC BY-SA 4.0
2021-12-03T08:29:47.777Z
Yes I've tried blocksmurfer and ran into a generic error telling me the transaction failed but with no reason.
Sonny Parlin
CC BY-SA 4.0
2021-12-03T09:05:42.690Z
So after trying a few different providers, blockstream gave me the same error message. `Funds not sent, exception error: Error connecting to blockstream on url https://blockstream.info/api/tx, response [400] sendrawtransaction RPC error: {"code":-22,"message":"TX decode failed. Make sure the tx has at least one input."}`
Sonny Parlin
<transactions><hash><sendtoaddress><python-bitcoinlib>
Invalid transaction. Error: TX decode failed. Make sure the tx has at least one input
Sonny Parlin
# Invalid transaction. Error: TX decode failed. Make sure the tx has at least one input

(Asked by: username_0 on 2021-12-03)

I'm using bitcoinlib for python to create a transaction and send it but I'm getting the following error:

```
Funds not sent, exception error: Error connecting to blockchair on url 
https://api.blockchair.com/bitcoin/push/transaction?data=01000000000101a988402108fbbdc3dc790926a41e3378042f90a80e2fbf67f8ad117644c100803700000000ffffffff0231810000000000001600149dde1d0113a7468f605bef751aa03a020cad3d2b000000000000000017a914f1b553ddc46d0414e9b05b9667d65c5081d4f00a870000000000, 
response [400] 
{
    "data":null,
    "context":
    {
         "code":400,
         "source":"R",
         "error":"Invalid transaction. Error: TX decode failed. Make sure the tx has at least one input.",
         "market_price_usd":56609,"cache":
         { 
             "live":true,
             "duration":60,
             "since":"2021-12-03 03:58:11",
             "until":"2021-12-03 03:59:11","time":null
         },
         "api":
         {
             "version":"2.0.94",
             "last_major_update":"2021-07-19 00:00:00",
             "next_major_update":null,
             "documentation":"https:\/\/blockchair.com\/api\/docs","notice":":)"
         },
         "server":"BTC3",
         "time":0.0013239383697509766,
         "render_time":0.006116151809692383,
         "full_time":0.007440090179443359,
         "request_cost":1
    }
}

```

Here is my decoded transaction:

```
{
    "addresses": [
        "bc1q23dd73raxnk6cvz62wl2gthkfx3ksdqq0tqrn0",
        "bc1qnh0p6qgn5arg7czmaa634gp6qgx260ftspufv2",
        "3Pj3zdw77aqsELdoh5pQErWvK2hAYbJx2w"
    ],
    "block_height": -1,
    "block_index": -1,
    "confirmations": 0,
    "double_spend": false,
    "fees": 683,
    "hash": "7f2f01b7a7d55cc9e13aa6604b115fcf07ada6ee6179a6342c0f8d7d5668de3d",
    "inputs": [
        {
            "addresses": [
                "bc1q23dd73raxnk6cvz62wl2gthkfx3ksdqq0tqrn0"
            ],
            "age": 712033,
            "output_index": 55,
            "output_value": 33756,
            "prev_hash": 
"8000c1447611adf867bf2f0ea8902f0478331ea4260979dcc3bdfb08214088a9",
            "script_type": "pay-to-witness-pubkey-hash",
            "sequence": 4294967295
        }
    ],
    "outputs": [
        {
            "addresses": [
                "bc1qnh0p6qgn5arg7czmaa634gp6qgx260ftspufv2"
            ],
            "script": "00149dde1d0113a7468f605bef751aa03a020cad3d2b",
            "script_type": "pay-to-witness-pubkey-hash",
            "value": 33073
        },
        {
            "addresses": [
                "3Pj3zdw77aqsELdoh5pQErWvK2hAYbJx2w"
            ],
            "script": "a914f1b553ddc46d0414e9b05b9667d65c5081d4f00a87",
            "script_type": "pay-to-script-hash",
            "value": 0
        }
    ],
    "preference": "low",
    "received": "2021-12-03T03:58:47.770766807Z",
    "relayed_by": "3.237.60.136",
    "size": 117,
    "total": 33073,
    "ver": 1,
    "vin_sz": 1,
    "vout_sz": 2,
    "vsize": 115
}

```

The python code I used to create the transaction:

```
w = Wallet(wallet_name, db_uri=db_uri)
t = w.transaction_create([(to_address, float(satstosend))])

```

I'm not sure why it's complaining that I don't have an input, but it's odd to me that I see one input and two outputs. I'm not sure if I'm creating the transaction incorrectly or if it has something to do with the fact that I'm trying to send from a native segwit address to a segwit address (bc1 -> 3XX). Any help would be appreciated.

**Tags:** transactions, hash, sendtoaddress, python-bitcoinlib

> **Comments:**
> **username_1**: It's possible that blockchair believes the transaction to be a non-segwit transaction (because of the marker and flag bytes required for segwit txs) and so is incorrectly parsing it. Have you tried a different broadcast API?  
> **username_0**: Yes I've tried blocksmurfer and ran into a generic error telling me the transaction failed but with no reason.  
> **username_0**: So after trying a few different providers, blockstream gave me the same error message. `Funds not sent, exception error: Error connecting to blockstream on url https://blockstream.info/api/tx, response [400] sendrawtransaction RPC error: {"code":-22,"message":"TX decode failed. Make sure the tx has at least one input."}`  

---

## 1 answers

### Answer by username_0 on 2021-12-03. Score: 1 | Accepted answer

I figured it out, I simply was missing a step. I wasn't signing my transaction before sending.

```
>>> t.sign('my_private_key')
>>> res = srv.sendrawtransaction(t.raw_hex())
>>> res
{
    'txid': 
    '8ca3d23d55dbded21a3ee8809ba55e2fa97394332020fad55582ab29e9619de4', 
    'response_dict': 
    '8ca3d23d55dbded21a3ee8809ba55e2fa97394332020fad55582ab29e9619de4'
}`

```


---

