-
Notifications
You must be signed in to change notification settings - Fork 49
/
console.html
133 lines (111 loc) · 4.6 KB
/
console.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!DOCTYPE html>
<html lang=en>
<head>
<title>Electrum Bitcoin Client</title>
<meta charset=utf-8 />
<meta name=description content="Lightweight Bitcoin Client" />
<meta name=keywords content="electrum,bitcoin,blockchain,lightweight,instant" />
<!--<meta name=viewport content="width=device-width, initial-scale=1.0" />-->
<!--[if lt IE 9]>
<script type="text/javascript" src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Styles -->
<link rel="stylesheet" type="text/css" href="css/screen.css" />
<!-- /Styles -->
<!-- Links -->
<link rel="shortcut icon" href="favicon.ico" />
<link rel=apple-touch-icon-precomposed href=.png />
<link rel=author type=text/plain href=humans.txt>
<!-- /Links -->
<!-- Analytics -->
<!-- /Analytics -->
<!-- js -->
<script src=https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js></script>
<script>
$(document).ready(function(){
$('#translations').load('langs_nav.html #langs_main');
$('#nav').load('langs_nav.html #nav_en');
});
</script>
<!-- /js -->
</head>
<body>
<header>
<div class="container">
<nav id=translations>
<!-- langs -->
</nav>
<nav id=nav>
<!-- nav -->
<!-- DON'T MODIFY for translations, use 'langs_nav.html' as explained in the README file -->
<ul id=nav_en class=nav>
<li><a href="index.html">Home</a></li>
<li><a href="download.html">Download</a></li>
<li><a href="documentation.html">Documentation</a></li>
<li><a href="community.html">Community</a></li>
</ul>
<!-- /DON'T MODIFY end -->
</nav>
<div class=header>
<i id=electrum_logo><img src="media/electrum_logo.png" alt="Electrum" border="none" width="70" align="top" /></i>
<div id=logo><span><h1>Electrum</h1></span></div>
<h2>Lightweight Bitcoin Client</h2>
</div>
</div>
</header>
<section class="container">
<p>Most Electrum command-line commands are also available in the console.
<br/>
The results are Python objects, even though they are sometimes rendered as JSON for clarity.</p>
<p>Let us call <tt>listunspent()</tt>, to see the list of unspent outputs in the wallet:</p>
<pre>
>> listunspent()
[
{
"address": "12cmY5RHRgx8KkUKASDcDYRotget9FNso3",
"index": 0,
"raw_output_script": "76a91411bbdc6e3a27c44644d83f783ca7df3bdc2778e688ac",
"tx_hash": "e7029df9ac8735b04e8e957d0ce73987b5c9c5e920ec4a445130cdeca654f096",
"value": 0.01
},
{
"address": "1GavSCND6TB7HuCnJSTEbHEmCctNGeJwXF",
"index": 0,
"raw_output_script": "76a914aaf437e25805f288141bfcdc27887ee5492bd13188ac",
"tx_hash": "b30edf57ca2a31560b5b6e8dfe567734eb9f7d3259bb334653276efe520735df",
"value": 9.04735316
}
]</pre>
<p>Note that the result is rendered as JSON. <br/>
However, if we save it to a Python variable, it is rendered as a Python object:</p>
<pre>
>> u = listunspent()
>> u
[{'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'}]
</pre>
<p><br/>
This makes it possible to combine Electrum commands with Python.<br/>
For example, let us pick only the addresses in the previous result:</p>
<pre>
>> map(lambda x:x.get('address'), listunspent())
[
"12cmY5RHRgx8KkUKASDcDYRotget9FNso3",
"1GavSCND6TB7HuCnJSTEbHEmCctNGeJwXF"
]</pre>
<p>Here we combine two commands, <tt>listunspent</tt> and <tt>dumpprivkeys</tt>, in order to dump the private keys of all addresses that have unspent outputs:</p>
<pre>
>> dumpprivkeys( map(lambda x:x.get('address'), listunspent()) )
{
"12cmY5RHRgx8KkUKASDcDYRotget9FNso3": "***************************************************",
"1GavSCND6TB7HuCnJSTEbHEmCctNGeJwXF": "***************************************************"
}</pre>
<p>Note that <tt>dumpprivkey</tt> will ask for your password if your wallet is encrypted.</p>
<p>The GUI methods can be accessed through the <tt>gui</tt> variable. For example, you can display a QR code from a string using
<tt>gui.show_qrcode</tt>.
<br/><br/>
Example:</p>
<pre>
gui.show_qrcode(dumpprivkey(listunspent()[0]['address']))</pre>
</section><!-- /container -->
</body>
</html>