pybitcash / bitcash

BitCash: Python Bitcoin Cash Library (fork of ofek's Bit)
https://bitcash.dev
MIT License
97 stars 39 forks source link

message option (OP_RETURN) not working #104

Closed LivioZ closed 3 years ago

LivioZ commented 3 years ago

So I tried to send a transaction with optional message field, but without an address and/or with 0 value, there is an error, if I put an address and a value > 0 it goes on but the final transaction has not a OP_RETURN (obviously(?)). Thanks for helping.

merc1er commented 3 years ago

I tried to send a transaction with optional message field, but without an address and/or with 0 value

You cannot send a transaction without output or with 0 value.

if I put an address and a value > 0 it goes on but the final transaction has not a OP_RETURN

Could you provide a minimal reproducible example?

Here is a code snippet that works as expected:

from bitcash import Key

key = Key()
print(key.to_wif())
print(key.address)

# you need to fund the wallet before executing the code below

key.get_balance()
key.send(
    [],
    leftover="bitcoincash:qrjluzvef02tz5czm5u90jkdalte8qldyqc7afjlsd",
    message="This was sent with BitCash"
)
LivioZ commented 3 years ago

Oh ok, thank you for that snippet, that's all I needed, I didn't know how to exactly put the parameters for an OP_RETURN transaction, maybe put this example in the docs?

merc1er commented 3 years ago

It should already be there as an example: https://pybitcash.github.io/bitcash/guide/advanced.html#blockchain-storage-op-return

LivioZ commented 3 years ago

Yea, but those ... in key.send(..., message='Simplicity level is over 9000!!!') were not explicit enough for me.