Closed MarioPalomaresGallego closed 3 years ago
Hi,
Two things:
inputs = [{'address': 'Byq3GzVtEQRsMMauYUSL4Tjc3NyvrffX4f'}]
outputs = [{'value': 0,'script':'null-data','data_string':'hello world'}]
unsigned_tx = bcy.create_unsigned_tx(inputs=inputs, outputs=outputs, coin_symbol='bcy',api_key=BCY_API_TOKEN)
privkey_list = ['1dd9c95d6ee47975b6cf84fb5c23a862919c9a033cee9ded7b7312b8b803a1ad']
pubkey_list = ['0353d016dfb40e236d505c3aa500246821a1ef239962b26331f4067eed3857281e']
tx_signatures = bcy.make_tx_signatures(txs_to_sign=unsigned_tx['tosign'], privkey_list=privkey_list, pubkey_list=pubkey_list)
result = bcy.broadcast_signed_transaction(unsigned_tx=unsigned_tx, signatures=tx_signatures, pubkeys=pubkey_list,api_key=BCY_API_TOKEN, coin_symbol='bcy')
This is the easy way to do op_return https://www.blockcypher.com/dev/bitcoin/?python#txoutput.
outputs = [{'value': 0,'script_type':'null-data','data_string':'hello world'}]
or
outputs = [{'value': 0,'script_type':'null-data','data_hex':'01'}]
Cheers :)
Hi, i am trying to do an OP_RETURN transaction but when broadcasting the tx i get the following error:
Output at 0 can't have zero for value.
The code i am using to generate the transaction is the following:
inputs = [{'address': addr}] outputs = [{'address': C2_ADDR, 'value': 0,'script_type':"null-data",'script':"OP_RETURN ".encode().hex() + msg.hex()}] unsigned_tx = bcy.create_unsigned_tx(inputs=inputs, outputs=outputs, coin_symbol='bcy',api_key=BCY_API_TOKEN) privkey_list = [private_key] pubkey_list = [public_key] tx_signatures = bcy.make_tx_signatures(txs_to_sign=unsigned_tx['tosign'], privkey_list=privkey_list, pubkey_list=pubkey_list) result = bcy.broadcast_signed_transaction(unsigned_tx=unsigned_tx, signatures=tx_signatures, pubkeys=pubkey_list,api_key=BCY_API_TOKEN, coin_symbol='bcy')
Am I missing some parameter?. Error seems strange to me since these transactions are unspendable, and actually there is an assertion in the code avoiding the value of the transaction to be non-zero.
By the way i have seen in the documentation that there is the option to make "pay-to-pubkey" transactions but looking at the create_unsigned_tx function it doesn´t seem to be possible, how can i make these type of transactions?