I try to create a raw transaction using the Bitcoin Core RPC through curl.
Python script:
import requests
data = '{"jsonrpc":"2.0","id":"curltext","method":"createrawtransaction", "params": [\'[{"txid":"bffa31485fe5bfbb7e86463ff6c7ee4f084936d54d0471fba7763538e7fd0aa6","vout":0, "sequence":1}]\' \'{"2Mt1FE9NVXP7fRYuPEZBHrFgoCEc4TGb2ZY":0.01}\']}'
print(data)
rawtx = requests.post("http://user:[email protected]:18443", data=data).text
print(rawtx)
Output error:
{"jsonrpc":"2.0","id":"curltext","method":"createrawtransaction", "params": ['[{"txid":"bffa31485fe5bfbb7e86463ff6c7ee4f084936d54d0471fba7763538e7fd0aa6","vout":0, "sequence":1}]' '{"2Mt1FE9NVXP7fRYuPEZBHrFgoCEc4TGb2ZY":0.01}']}
{'result': None, 'error': {'code': -32700, 'message': 'Parse error'}, 'id': None}
I've tried escaping in multiple ways, but can't get it working.
Bitcoin CLI command:
bitcoin-cli -testnet createrawtransaction '[{"txid":"bffa31485fe5bfbb7e86463ff6c7ee4f084936d54d0471fba7763538e7fd0aa6","vout":0, "sequence":1}]' '{"2Mt1FE9NVXP7fRYuPEZBHrFgoCEc4TGb2ZY":0.01}'
Expected output (tx hex):
0200000001a60afde7383576a7fb71044dd53649084feec7f63f46867ebbbfe55f4831fabf0000000000010000000140420f000000000017a9140853562996d502a0abe2538657e5bf7bb261b6868700000000