Bitcoin Forum
October 22, 2018, 03:00:14 AM *
News: Make sure you are not using versions of Bitcoin Core other than 0.17.0 [Torrent], 0.16.3, 0.15.2, or 0.14.3. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: JSON error while creating raw transaction with Python  (Read 532 times)
arosca
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
1540177214
Hero Member
*
Offline Offline

Posts: 1540177214

View Profile Personal Message (Offline)

Ignore
1540177214
Reply with quote  #2

1540177214
Report to moderator
1540177214
Hero Member
*
Offline Offline

Posts: 1540177214

View Profile Personal Message (Offline)

Ignore
1540177214
Reply with quote  #2

1540177214
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1540177214
Hero Member
*
Offline Offline

Posts: 1540177214

View Profile Personal Message (Offline)

Ignore
1540177214
Reply with quote  #2

1540177214
Report to moderator
1540177214
Hero Member
*
Offline Offline

Posts: 1540177214

View Profile Personal Message (Offline)

Ignore
1540177214
Reply with quote  #2

1540177214
Report to moderator
DannyHamilton
Legendary
*
Offline Offline

Activity: 2198
Merit: 1382



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
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:  

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!