Browse Source

convert tabs to whitespace in bitrpc.py

This is a minor change to bitrpc.py to conform with the formatting of
the other python source code in the repo.
0.10
Bryan Bishop 11 years ago
parent
commit
b881100aab
  1. 480
      contrib/bitrpc/bitrpc.py

480
contrib/bitrpc/bitrpc.py

@ -10,315 +10,315 @@ rpcpass = ""
if rpcpass == "": if rpcpass == "":
access = ServiceProxy("http://127.0.0.1:8332") access = ServiceProxy("http://127.0.0.1:8332")
else: else:
access = ServiceProxy("http://"+rpcuser+":"+rpcpass+"@127.0.0.1:8332") access = ServiceProxy("http://"+rpcuser+":"+rpcpass+"@127.0.0.1:8332")
cmd = sys.argv[1].lower() cmd = sys.argv[1].lower()
if cmd == "backupwallet": if cmd == "backupwallet":
try: try:
path = raw_input("Enter destination path/filename: ") path = raw_input("Enter destination path/filename: ")
print access.backupwallet(path) print access.backupwallet(path)
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "getaccount": elif cmd == "getaccount":
try: try:
addr = raw_input("Enter a Bitcoin address: ") addr = raw_input("Enter a Bitcoin address: ")
print access.getaccount(addr) print access.getaccount(addr)
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "getaccountaddress": elif cmd == "getaccountaddress":
try: try:
acct = raw_input("Enter an account name: ") acct = raw_input("Enter an account name: ")
print access.getaccountaddress(acct) print access.getaccountaddress(acct)
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "getaddressesbyaccount": elif cmd == "getaddressesbyaccount":
try: try:
acct = raw_input("Enter an account name: ") acct = raw_input("Enter an account name: ")
print access.getaddressesbyaccount(acct) print access.getaddressesbyaccount(acct)
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "getbalance": elif cmd == "getbalance":
try: try:
acct = raw_input("Enter an account (optional): ") acct = raw_input("Enter an account (optional): ")
mc = raw_input("Minimum confirmations (optional): ") mc = raw_input("Minimum confirmations (optional): ")
try: try:
print access.getbalance(acct, mc) print access.getbalance(acct, mc)
except: except:
print access.getbalance() print access.getbalance()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "getblockbycount": elif cmd == "getblockbycount":
try: try:
height = raw_input("Height: ") height = raw_input("Height: ")
print access.getblockbycount(height) print access.getblockbycount(height)
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "getblockcount": elif cmd == "getblockcount":
try: try:
print access.getblockcount() print access.getblockcount()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "getblocknumber": elif cmd == "getblocknumber":
try: try:
print access.getblocknumber() print access.getblocknumber()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "getconnectioncount": elif cmd == "getconnectioncount":
try: try:
print access.getconnectioncount() print access.getconnectioncount()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "getdifficulty": elif cmd == "getdifficulty":
try: try:
print access.getdifficulty() print access.getdifficulty()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "getgenerate": elif cmd == "getgenerate":
try: try:
print access.getgenerate() print access.getgenerate()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "gethashespersec": elif cmd == "gethashespersec":
try: try:
print access.gethashespersec() print access.gethashespersec()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "getinfo": elif cmd == "getinfo":
try: try:
print access.getinfo() print access.getinfo()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "getnewaddress": elif cmd == "getnewaddress":
try: try:
acct = raw_input("Enter an account name: ") acct = raw_input("Enter an account name: ")
try: try:
print access.getnewaddress(acct) print access.getnewaddress(acct)
except: except:
print access.getnewaddress() print access.getnewaddress()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "getreceivedbyaccount": elif cmd == "getreceivedbyaccount":
try: try:
acct = raw_input("Enter an account (optional): ") acct = raw_input("Enter an account (optional): ")
mc = raw_input("Minimum confirmations (optional): ") mc = raw_input("Minimum confirmations (optional): ")
try: try:
print access.getreceivedbyaccount(acct, mc) print access.getreceivedbyaccount(acct, mc)
except: except:
print access.getreceivedbyaccount() print access.getreceivedbyaccount()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "getreceivedbyaddress": elif cmd == "getreceivedbyaddress":
try: try:
addr = raw_input("Enter a Bitcoin address (optional): ") addr = raw_input("Enter a Bitcoin address (optional): ")
mc = raw_input("Minimum confirmations (optional): ") mc = raw_input("Minimum confirmations (optional): ")
try: try:
print access.getreceivedbyaddress(addr, mc) print access.getreceivedbyaddress(addr, mc)
except: except:
print access.getreceivedbyaddress() print access.getreceivedbyaddress()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "gettransaction": elif cmd == "gettransaction":
try: try:
txid = raw_input("Enter a transaction ID: ") txid = raw_input("Enter a transaction ID: ")
print access.gettransaction(txid) print access.gettransaction(txid)
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "getwork": elif cmd == "getwork":
try: try:
data = raw_input("Data (optional): ") data = raw_input("Data (optional): ")
try: try:
print access.gettransaction(data) print access.gettransaction(data)
except: except:
print access.gettransaction() print access.gettransaction()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "help": elif cmd == "help":
try: try:
cmd = raw_input("Command (optional): ") cmd = raw_input("Command (optional): ")
try: try:
print access.help(cmd) print access.help(cmd)
except: except:
print access.help() print access.help()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "listaccounts": elif cmd == "listaccounts":
try: try:
mc = raw_input("Minimum confirmations (optional): ") mc = raw_input("Minimum confirmations (optional): ")
try: try:
print access.listaccounts(mc) print access.listaccounts(mc)
except: except:
print access.listaccounts() print access.listaccounts()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "listreceivedbyaccount": elif cmd == "listreceivedbyaccount":
try: try:
mc = raw_input("Minimum confirmations (optional): ") mc = raw_input("Minimum confirmations (optional): ")
incemp = raw_input("Include empty? (true/false, optional): ") incemp = raw_input("Include empty? (true/false, optional): ")
try: try:
print access.listreceivedbyaccount(mc, incemp) print access.listreceivedbyaccount(mc, incemp)
except: except:
print access.listreceivedbyaccount() print access.listreceivedbyaccount()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "listreceivedbyaddress": elif cmd == "listreceivedbyaddress":
try: try:
mc = raw_input("Minimum confirmations (optional): ") mc = raw_input("Minimum confirmations (optional): ")
incemp = raw_input("Include empty? (true/false, optional): ") incemp = raw_input("Include empty? (true/false, optional): ")
try: try:
print access.listreceivedbyaddress(mc, incemp) print access.listreceivedbyaddress(mc, incemp)
except: except:
print access.listreceivedbyaddress() print access.listreceivedbyaddress()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "listtransactions": elif cmd == "listtransactions":
try: try:
acct = raw_input("Account (optional): ") acct = raw_input("Account (optional): ")
count = raw_input("Number of transactions (optional): ") count = raw_input("Number of transactions (optional): ")
frm = raw_input("Skip (optional):") frm = raw_input("Skip (optional):")
try: try:
print access.listtransactions(acct, count, frm) print access.listtransactions(acct, count, frm)
except: except:
print access.listtransactions() print access.listtransactions()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "move": elif cmd == "move":
try: try:
frm = raw_input("From: ") frm = raw_input("From: ")
to = raw_input("To: ") to = raw_input("To: ")
amt = raw_input("Amount:") amt = raw_input("Amount:")
mc = raw_input("Minimum confirmations (optional): ") mc = raw_input("Minimum confirmations (optional): ")
comment = raw_input("Comment (optional): ") comment = raw_input("Comment (optional): ")
try: try:
print access.move(frm, to, amt, mc, comment) print access.move(frm, to, amt, mc, comment)
except: except:
print access.move(frm, to, amt) print access.move(frm, to, amt)
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "sendfrom": elif cmd == "sendfrom":
try: try:
frm = raw_input("From: ") frm = raw_input("From: ")
to = raw_input("To: ") to = raw_input("To: ")
amt = raw_input("Amount:") amt = raw_input("Amount:")
mc = raw_input("Minimum confirmations (optional): ") mc = raw_input("Minimum confirmations (optional): ")
comment = raw_input("Comment (optional): ") comment = raw_input("Comment (optional): ")
commentto = raw_input("Comment-to (optional): ") commentto = raw_input("Comment-to (optional): ")
try: try:
print access.sendfrom(frm, to, amt, mc, comment, commentto) print access.sendfrom(frm, to, amt, mc, comment, commentto)
except: except:
print access.sendfrom(frm, to, amt) print access.sendfrom(frm, to, amt)
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "sendmany": elif cmd == "sendmany":
try: try:
frm = raw_input("From: ") frm = raw_input("From: ")
to = raw_input("To (in format address1:amount1,address2:amount2,...): ") to = raw_input("To (in format address1:amount1,address2:amount2,...): ")
mc = raw_input("Minimum confirmations (optional): ") mc = raw_input("Minimum confirmations (optional): ")
comment = raw_input("Comment (optional): ") comment = raw_input("Comment (optional): ")
try: try:
print access.sendmany(frm,to,mc,comment) print access.sendmany(frm,to,mc,comment)
except: except:
print access.sendmany(frm,to) print access.sendmany(frm,to)
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "sendtoaddress": elif cmd == "sendtoaddress":
try: try:
to = raw_input("To (in format address1:amount1,address2:amount2,...): ") to = raw_input("To (in format address1:amount1,address2:amount2,...): ")
amt = raw_input("Amount:") amt = raw_input("Amount:")
comment = raw_input("Comment (optional): ") comment = raw_input("Comment (optional): ")
commentto = raw_input("Comment-to (optional): ") commentto = raw_input("Comment-to (optional): ")
try: try:
print access.sendtoaddress(to,amt,comment,commentto) print access.sendtoaddress(to,amt,comment,commentto)
except: except:
print access.sendtoaddress(to,amt) print access.sendtoaddress(to,amt)
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "setaccount": elif cmd == "setaccount":
try: try:
addr = raw_input("Address: ") addr = raw_input("Address: ")
acct = raw_input("Account:") acct = raw_input("Account:")
print access.setaccount(addr,acct) print access.setaccount(addr,acct)
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "setgenerate": elif cmd == "setgenerate":
try: try:
gen= raw_input("Generate? (true/false): ") gen= raw_input("Generate? (true/false): ")
cpus = raw_input("Max processors/cores (-1 for unlimited, optional):") cpus = raw_input("Max processors/cores (-1 for unlimited, optional):")
try: try:
print access.setgenerate(gen, cpus) print access.setgenerate(gen, cpus)
except: except:
print access.setgenerate(gen) print access.setgenerate(gen)
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "settxfee": elif cmd == "settxfee":
try: try:
amt = raw_input("Amount:") amt = raw_input("Amount:")
print access.settxfee(amt) print access.settxfee(amt)
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "stop": elif cmd == "stop":
try: try:
print access.stop() print access.stop()
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "validateaddress": elif cmd == "validateaddress":
try: try:
addr = raw_input("Address: ") addr = raw_input("Address: ")
print access.validateaddress(addr) print access.validateaddress(addr)
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "walletpassphrase": elif cmd == "walletpassphrase":
try: try:
pwd = raw_input("Enter wallet passphrase: ") pwd = raw_input("Enter wallet passphrase: ")
access.walletpassphrase(pwd, 60) access.walletpassphrase(pwd, 60)
print "\n---Wallet unlocked---\n" print "\n---Wallet unlocked---\n"
except: except:
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
elif cmd == "walletpassphrasechange": elif cmd == "walletpassphrasechange":
try: try:
pwd = raw_input("Enter old wallet passphrase: ") pwd = raw_input("Enter old wallet passphrase: ")
pwd2 = raw_input("Enter new wallet passphrase: ") pwd2 = raw_input("Enter new wallet passphrase: ")
access.walletpassphrasechange(pwd, pwd2) access.walletpassphrasechange(pwd, pwd2)
print print
print "\n---Passphrase changed---\n" print "\n---Passphrase changed---\n"
except: except:
print print
print "\n---An error occurred---\n" print "\n---An error occurred---\n"
print print
else: else:
print "Command not found or not supported" print "Command not found or not supported"

Loading…
Cancel
Save