1 from jsonrpc import ServiceProxy
5 # ===== BEGIN USER SETTINGS =====
6 # if you do not set these you will be prompted for a password for every command
9 # ====== END USER SETTINGS ======
13 access = ServiceProxy("http://127.0.0.1:8332")
15 access = ServiceProxy("http://"+rpcuser+":"+rpcpass+"@127.0.0.1:8332")
16 cmd = sys.argv[1].lower()
18 if cmd == "backupwallet":
20 path = raw_input("Enter destination path/filename: ")
21 print access.backupwallet(path)
23 print "\n---An error occurred---\n"
25 elif cmd == "getaccount":
27 addr = raw_input("Enter a Bitcoin address: ")
28 print access.getaccount(addr)
30 print "\n---An error occurred---\n"
32 elif cmd == "getaccountaddress":
34 acct = raw_input("Enter an account name: ")
35 print access.getaccountaddress(acct)
37 print "\n---An error occurred---\n"
39 elif cmd == "getaddressesbyaccount":
41 acct = raw_input("Enter an account name: ")
42 print access.getaddressesbyaccount(acct)
44 print "\n---An error occurred---\n"
46 elif cmd == "getbalance":
48 acct = raw_input("Enter an account (optional): ")
49 mc = raw_input("Minimum confirmations (optional): ")
51 print access.getbalance(acct, mc)
53 print access.getbalance()
55 print "\n---An error occurred---\n"
57 elif cmd == "getblockbycount":
59 height = raw_input("Height: ")
60 print access.getblockbycount(height)
62 print "\n---An error occurred---\n"
64 elif cmd == "getblockcount":
66 print access.getblockcount()
68 print "\n---An error occurred---\n"
70 elif cmd == "getblocknumber":
72 print access.getblocknumber()
74 print "\n---An error occurred---\n"
76 elif cmd == "getconnectioncount":
78 print access.getconnectioncount()
80 print "\n---An error occurred---\n"
82 elif cmd == "getdifficulty":
84 print access.getdifficulty()
86 print "\n---An error occurred---\n"
88 elif cmd == "getgenerate":
90 print access.getgenerate()
92 print "\n---An error occurred---\n"
94 elif cmd == "gethashespersec":
96 print access.gethashespersec()
98 print "\n---An error occurred---\n"
100 elif cmd == "getinfo":
102 print access.getinfo()
104 print "\n---An error occurred---\n"
106 elif cmd == "getnewaddress":
108 acct = raw_input("Enter an account name: ")
110 print access.getnewaddress(acct)
112 print access.getnewaddress()
114 print "\n---An error occurred---\n"
116 elif cmd == "getreceivedbyaccount":
118 acct = raw_input("Enter an account (optional): ")
119 mc = raw_input("Minimum confirmations (optional): ")
121 print access.getreceivedbyaccount(acct, mc)
123 print access.getreceivedbyaccount()
125 print "\n---An error occurred---\n"
127 elif cmd == "getreceivedbyaddress":
129 addr = raw_input("Enter a Bitcoin address (optional): ")
130 mc = raw_input("Minimum confirmations (optional): ")
132 print access.getreceivedbyaddress(addr, mc)
134 print access.getreceivedbyaddress()
136 print "\n---An error occurred---\n"
138 elif cmd == "gettransaction":
140 txid = raw_input("Enter a transaction ID: ")
141 print access.gettransaction(txid)
143 print "\n---An error occurred---\n"
145 elif cmd == "getwork":
147 data = raw_input("Data (optional): ")
149 print access.gettransaction(data)
151 print access.gettransaction()
153 print "\n---An error occurred---\n"
157 cmd = raw_input("Command (optional): ")
159 print access.help(cmd)
163 print "\n---An error occurred---\n"
165 elif cmd == "listaccounts":
167 mc = raw_input("Minimum confirmations (optional): ")
169 print access.listaccounts(mc)
171 print access.listaccounts()
173 print "\n---An error occurred---\n"
175 elif cmd == "listreceivedbyaccount":
177 mc = raw_input("Minimum confirmations (optional): ")
178 incemp = raw_input("Include empty? (true/false, optional): ")
180 print access.listreceivedbyaccount(mc, incemp)
182 print access.listreceivedbyaccount()
184 print "\n---An error occurred---\n"
186 elif cmd == "listreceivedbyaddress":
188 mc = raw_input("Minimum confirmations (optional): ")
189 incemp = raw_input("Include empty? (true/false, optional): ")
191 print access.listreceivedbyaddress(mc, incemp)
193 print access.listreceivedbyaddress()
195 print "\n---An error occurred---\n"
197 elif cmd == "listtransactions":
199 acct = raw_input("Account (optional): ")
200 count = raw_input("Number of transactions (optional): ")
201 frm = raw_input("Skip (optional):")
203 print access.listtransactions(acct, count, frm)
205 print access.listtransactions()
207 print "\n---An error occurred---\n"
211 frm = raw_input("From: ")
212 to = raw_input("To: ")
213 amt = raw_input("Amount:")
214 mc = raw_input("Minimum confirmations (optional): ")
215 comment = raw_input("Comment (optional): ")
217 print access.move(frm, to, amt, mc, comment)
219 print access.move(frm, to, amt)
221 print "\n---An error occurred---\n"
223 elif cmd == "sendfrom":
225 frm = raw_input("From: ")
226 to = raw_input("To: ")
227 amt = raw_input("Amount:")
228 mc = raw_input("Minimum confirmations (optional): ")
229 comment = raw_input("Comment (optional): ")
230 commentto = raw_input("Comment-to (optional): ")
232 print access.sendfrom(frm, to, amt, mc, comment, commentto)
234 print access.sendfrom(frm, to, amt)
236 print "\n---An error occurred---\n"
238 elif cmd == "sendmany":
240 frm = raw_input("From: ")
241 to = raw_input("To (in format address1:amount1,address2:amount2,...): ")
242 mc = raw_input("Minimum confirmations (optional): ")
243 comment = raw_input("Comment (optional): ")
245 print access.sendmany(frm,to,mc,comment)
247 print access.sendmany(frm,to)
249 print "\n---An error occurred---\n"
251 elif cmd == "sendtoaddress":
253 to = raw_input("To (in format address1:amount1,address2:amount2,...): ")
254 amt = raw_input("Amount:")
255 comment = raw_input("Comment (optional): ")
256 commentto = raw_input("Comment-to (optional): ")
258 print access.sendtoaddress(to,amt,comment,commentto)
260 print access.sendtoaddress(to,amt)
262 print "\n---An error occurred---\n"
264 elif cmd == "setaccount":
266 addr = raw_input("Address: ")
267 acct = raw_input("Account:")
268 print access.setaccount(addr,acct)
270 print "\n---An error occurred---\n"
272 elif cmd == "setgenerate":
274 gen= raw_input("Generate? (true/false): ")
275 cpus = raw_input("Max processors/cores (-1 for unlimited, optional):")
277 print access.setgenerate(gen, cpus)
279 print access.setgenerate(gen)
281 print "\n---An error occurred---\n"
283 elif cmd == "settxfee":
285 amt = raw_input("Amount:")
286 print access.settxfee(amt)
288 print "\n---An error occurred---\n"
294 print "\n---An error occurred---\n"
296 elif cmd == "validateaddress":
298 addr = raw_input("Address: ")
299 print access.validateaddress(addr)
301 print "\n---An error occurred---\n"
303 elif cmd == "walletpassphrase":
305 pwd = raw_input("Enter wallet passphrase: ")
306 access.walletpassphrase(pwd, 60)
307 print "\n---Wallet unlocked---\n"
309 print "\n---An error occurred---\n"
311 elif cmd == "walletpassphrasechange":
313 pwd = raw_input("Enter old wallet passphrase: ")
314 pwd2 = raw_input("Enter new wallet passphrase: ")
315 access.walletpassphrasechange(pwd, pwd2)
317 print "\n---Passphrase changed---\n"
320 print "\n---An error occurred---\n"
324 print "Command not found or not supported"