Bitcoin Forum
November 11, 2024, 06:19:13 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: JSON error while creating raw transaction with Python  (Read 602 times)
arosca (OP)
Newbie
*
Offline Offline

Activity: 38
Merit: 0


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
DannyHamilton
Legendary
*
Offline Offline

Activity: 3486
Merit: 4832



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 (OP)
Newbie
*
Offline Offline

Activity: 38
Merit: 0


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:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!