"can't concat str to bytes" : unable to create transaction (0.7.0)
Th0rgal opened this issue · 5 comments
I'm using bit 0.7.0. I am trying to send a transaction (on the testnet) but I get this error:
2020-08-07 10:33:03,734 [ERROR] <web.server:error_middleware> can't concat str to bytes
Traceback (most recent call last):
File "cashplace/web/server.py", line 41, in error_middleware
response = await handler(request)
File "cashplace/web/server.py", line 62, in middleware
return await handler(request)
File "cashplace/web/queries.py", line 163, in confirm_reception
ticket.finalize(fast)
File "cashplace/tickets.py", line 279, in finalize
fee=fee
File "/home/thomas/.conda/lib/python3.7/site-packages/bit/wallet.py", line 721, in create_transaction
return create_new_transaction(self, unspents, outputs)
File "/home/thomas/.conda/lib/python3.7/site-packages/bit/transaction.py", line 721, in create_new_transaction
outputs = construct_outputs(outputs)
File "/home/thomas/.conda/lib/python3.7/site-packages/bit/transaction.py", line 485, in construct_outputs
script_pubkey = OP_RETURN + len(dest).to_bytes(1, byteorder='little') + dest
TypeError: can't concat str to bytes
here is my code:
self.key.create_transaction(
[
(
self.master_address,
int(self.amount * (1 - self.rate)),
"satoshi",
),
(self.receiver_address, int(self.amount * self.rate), "satoshi",),
],
leftover=self.leftover_address,
fee=fee
)
self.master_address is a string
Did I do something wrong? Is there a bug here: https://github.com/ofek/bit/blob/master/bit/transaction.py#L485 ?
Are you making sure that self.amount
is strictly greater than 0? Because if it is 0 then it won't work (I think Bit should have a check to make sure outputs don't have 0 amounts and I will look into that later).
Are you making sure that
self.amount
is strictly greater than 0? Because if it is 0 then it won't work (I think Bit should have a check to make sure outputs don't have 0 amounts and I will look into that later).
Good question, I'll check it now
You were right, it was 0. I tried with 1 but it didn't work either tho :(
edit: wait a second, I might be dumb
(re)edit: the leftover was null too actually
I didn't get any error this time but the coins didn't move. Do I need to do something specific to broadcast the transaction?
is this solved? If you use key.send()
the transaction is broadcasted, if you use key.create_transaction()
you just get the serialized tx and you need to broadcast it yourself. Search the txid in a testnet bitcoin explorer, if it's there means it was broadcasted.
is this solved? If you use
key.send()
the transaction is broadcasted, if you usekey.create_transaction()
you just get the serialized tx and you need to broadcast it yourself. Search the txid in a testnet bitcoin explorer, if it's there means it was broadcasted.
Alright thanks for your help! I missed it in the doc.