Use custom output scripts on createrawtransaction

Use custom output scripts on createrawtransaction

Manage alerts

Loading saved threads...

David Corral · External communityPost link
External question — Bitcoin Stack Exchange Author: David Corral Original post: https://bitcoin.stackexchange.com/questions/126138 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. For research and testing purposes, I am trying to create a transaction that uses custom or weird scripts on its outputs, obviously on a testing environment. To not make things too complicated, I just simply want to use OP_TRUE as the script. For this reason, I construct the output as such: def create_outputs(params): vouts = [] val_per_out = 0.005 ... out = { "51": val_per_out, #I use "51" as address because I saw it's the hex representation for OP_TRUE } vouts.append(out) ... return vouts Then, I create the transaction: vouts = create_outputs(params) raw_tx = rpc_connection.createrawtransaction(vins, vouts, nLockTime) However, when execution gets to the last line of code, it throws <JSONRPCException '-5: Invalid Bitcoin address: 51'>. I assume that the issue, obviously, is that just putting 51 as the address is not valid, but I do not know how can I use the custom script then, so any help would be greatly appreciated.
Quote
Report
RedGrittyBrick · External communityPost link
External answer — Bitcoin Stack Exchange Author: RedGrittyBrick Original post: https://bitcoin.stackexchange.com/a/126140 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. The documentation says "address": amount, (numeric or string, required) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in BTC Since addresses don't appear in transactions, the RPC function has to create an output script based on its understanding of the address. As you want a custom script and not a standard script I don't see how you can use this RPC. The documentation continues Returns hex-encoded raw transaction. I would consider creating a hex-encoded raw transaction directly without calling an RPC. I would attempt this based on the documentation for the network encoding of the transaction data. Alternatively, it might be possible to specify a standard address as a placeholder, parse the returned raw transaction and replace the standard output script with a custom script.
Quote
Report

Post Reply

Checking account access…