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.
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."}