Bitcoin Forum
November 18, 2017, 04:21:37 PM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: JSON error while creating raw transaction with Python  (Read 513 times)
arosca
Jr. Member
*
Offline Offline

Activity: 38


View Profile
April 21, 2014, 03:31:34 PM
 #1

I've been trying to create a raw transaction over JSON-RPC using Python and can't figure out why I receive this error:

Code:
>>> client.createrawtransaction([{'txid': 'e1e5775f467a2803a4ebc6e17f223617062d9a98a953d5eaef06ab9ae0b2a400', 'vout': 17.9995}], {'mtBA36egrarxkCuzu64e7EtuwUUphS8GWn': 17.999})

Traceback (most recent call last):
  File "<pyshell#42>", line 1, in <module>
    client.createrawtransaction([{'txid': 'e1e5775f467a2803a4ebc6e17f223617062d9a98a953d5eaef06ab9ae0b2a400', 'vout': 17.9995}], {'mtBA36egrarxkCuzu64e7EtuwUUphS8GWn': 17.999})
  File "C:\Python27\lib\site-packages\jsonrpc\proxy.py", line 45, in __call__
    raise JSONRPCException(resp['error'])
JSONRPCException
1511022097
Hero Member
*
Offline Offline

Posts: 1511022097

View Profile Personal Message (Offline)

Ignore
1511022097
Reply with quote  #2

1511022097
Report to moderator
"This isn't the kind of software where we can leave so many unresolved bugs that we need a tracker for them." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
DannyHamilton
Legendary
*
Offline Offline

Activity: 1974



View Profile
April 21, 2014, 03:44:58 PM
 #2

I've been trying to create a raw transaction over JSON-RPC using Python and can't figure out why I receive this error:

Code:
>>> client.createrawtransaction([{'txid': 'e1e5775f467a2803a4ebc6e17f223617062d9a98a953d5eaef06ab9ae0b2a400', 'vout': 17.9995}], {'mtBA36egrarxkCuzu64e7EtuwUUphS8GWn': 17.999})

Traceback (most recent call last):
  File "<pyshell#42>", line 1, in <module>
    client.createrawtransaction([{'txid': 'e1e5775f467a2803a4ebc6e17f223617062d9a98a953d5eaef06ab9ae0b2a400', 'vout': 17.9995}], {'mtBA36egrarxkCuzu64e7EtuwUUphS8GWn': 17.999})
  File "C:\Python27\lib\site-packages\jsonrpc\proxy.py", line 45, in __call__
    raise JSONRPCException(resp['error'])
JSONRPCException

vout is an integer index into the transaction referenced by txid.  It can't be 17.9995.

if you run:

Code:
listunspent

you should get a list of unspent outputs that your wallet has the ability to spend.

Each unspent output will have a "txid" value and a "vout" value.  These are the two pieces of information that you have to supply to createrawtransaction if you want to spend that output.

arosca
Jr. Member
*
Offline Offline

Activity: 38


View Profile
April 21, 2014, 05:53:34 PM
 #3

Duh... Thank you very much.

For reference, here is code that worked:
Code:
client.createrawtransaction([{'txid': 'e1e5775f467a2803a4ebc6e17f223617062d9a98a953d5eaef06ab9ae0b2a400', 'vout': 0}, {'txid': 'e1e5775f467a2803a4ebc6e17f223617062d9a98a953d5eaef06ab9ae0b2a400', 'vout': 1}], {'mtBA36egrarxkCuzu64e7EtuwUUphS8GWn':17.9998})
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!