New port numbers
[electrum-nvc.git] / docs / console.html
1 <html>
2 <head>
3 This is the documentation for the Electrum Console.<br/>
4 </head>
5 <body>
6 <div style="width:45em">
7 <br/>
8 Most Electrum command-line commands are also available in the console. <br/>
9 The results are Python objects, even though they are
10 sometimes rendered as JSON for clarity.<br/>
11 <br/>
12 Let us call <tt>listunspent()</tt>, to see the list of unspent outputs in the wallet:
13 <pre>
14 >> listunspent()
15 [
16     {
17         "address": "12cmY5RHRgx8KkUKASDcDYRotget9FNso3", 
18         "index": 0, 
19         "raw_output_script": "76a91411bbdc6e3a27c44644d83f783ca7df3bdc2778e688ac", 
20         "tx_hash": "e7029df9ac8735b04e8e957d0ce73987b5c9c5e920ec4a445130cdeca654f096", 
21         "value": 0.01
22     }, 
23     {
24         "address": "1GavSCND6TB7HuCnJSTEbHEmCctNGeJwXF", 
25         "index": 0, 
26         "raw_output_script": "76a914aaf437e25805f288141bfcdc27887ee5492bd13188ac", 
27         "tx_hash": "b30edf57ca2a31560b5b6e8dfe567734eb9f7d3259bb334653276efe520735df", 
28         "value": 9.04735316
29     }
30 ]
31 </pre>
32 Note that the result is rendered as JSON. <br/>
33 However, if we save it to a Python variable, it is rendered as a Python object:
34 <pre>
35 >> u = listunspent()
36 >> u
37 [{'tx_hash': u'e7029df9ac8735b04e8e957d0ce73987b5c9c5e920ec4a445130cdeca654f096', 'index': 0, 'raw_output_script': '76a91411bbdc6e3a27c44644d83f783ca7df3bdc2778e688ac', 'value': 0.01, 'address': '12cmY5RHRgx8KkUKASDcDYRotget9FNso3'}, {'tx_hash': u'b30edf57ca2a31560b5b6e8dfe567734eb9f7d3259bb334653276efe520735df', 'index': 0, 'raw_output_script': '76a914aaf437e25805f288141bfcdc27887ee5492bd13188ac', 'value': 9.04735316, 'address': '1GavSCND6TB7HuCnJSTEbHEmCctNGeJwXF'}]
38 </pre>
39 <br/>
40 This makes it possible to combine Electrum commands with Python.<br/>
41 For example, let us pick only the addresses in the previous result:
42 <pre>
43 >> map(lambda x:x.get('address'), listunspent())
44 [
45     "12cmY5RHRgx8KkUKASDcDYRotget9FNso3", 
46     "1GavSCND6TB7HuCnJSTEbHEmCctNGeJwXF"
47 ]
48 </pre>
49 Here we combine two commands, <tt>listunspent</tt>
50 and <tt>dumpprivkeys</tt>, in order to dump the private keys of all adresses that have unspent outputs:
51 <pre>
52 >> dumpprivkeys( map(lambda x:x.get('address'), listunspent()) )
53 {
54     "12cmY5RHRgx8KkUKASDcDYRotget9FNso3": "***************************************************", 
55     "1GavSCND6TB7HuCnJSTEbHEmCctNGeJwXF": "***************************************************"
56 }
57 </pre>
58 Note that <tt>dumpprivkey</tt> will ask for your password if your
59 wallet is encrypted.
60 <br/>
61 The GUI methods can be accessed through the <tt>gui</tt> variable.
62 For example, you can display a QR code from a string using
63 gui.show_qrcode.
64 Example: 
65 <pre>
66 gui.show_qrcode(dumpprivkey(listunspent()[0]['address']))
67 </pre>
68
69 </div> 
70 </body>
71 </html>