Windows bugfixes, base32 routines in 'mmgen-tool'
This commit is contained in:
parent
c821f796e9
commit
1ce8a6c2fd
6 changed files with 44 additions and 24 deletions
|
|
@ -33,7 +33,10 @@ def launch_walletchk(): import mmgen.main_walletchk
|
|||
def launch_walletgen(): import mmgen.main_walletgen
|
||||
|
||||
def main(progname):
|
||||
import sys, termios
|
||||
try: import termios
|
||||
except: eval("launch_"+progname+"()") # Windows
|
||||
else:
|
||||
import sys
|
||||
fd = sys.stdin.fileno()
|
||||
old = termios.tcgetattr(fd)
|
||||
try: eval("launch_"+progname+"()")
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ if len(cmd_args) == 1:
|
|||
pf(infile,addr_data)
|
||||
seed_id = addr_data.keys()[0]
|
||||
e = addr_data[seed_id]
|
||||
addr_list = [(k,e[k][0],e[k][1]) for k in e.keys()]
|
||||
def s_addrdata(a): return ("{:>0%s}"%g.mmgen_idx_max_digits).format(a)
|
||||
addr_list = [(k,e[k][0],e[k][1]) for k in sorted(e.keys(),key=s_addrdata)]
|
||||
else:
|
||||
msg_r("You must specify an mmgen address list (or a list of ")
|
||||
msg("non-%s addresses with\nthe '--addrlist' option)" % g.proj_name)
|
||||
|
|
|
|||
|
|
@ -66,9 +66,14 @@ class BitcoinConnection(object):
|
|||
return self.proxy.importaddress(address,label,rescan)
|
||||
except JSONRPCException as e:
|
||||
if e.error['message'] == "Method not found":
|
||||
from mmgen.util import msg_r
|
||||
msg_r("""
|
||||
ERROR: 'importaddress' method not found. Is your bitcoind enabled for watch-only addresses?""")
|
||||
from mmgen.util import msg
|
||||
msg("""
|
||||
*******************************************************************************
|
||||
*******************************************************************************
|
||||
ERROR: 'importaddress' not found. Does your bitcoind support watch-only addrs?
|
||||
*******************************************************************************
|
||||
*******************************************************************************
|
||||
""")
|
||||
raise _wrap_exception(e.error)
|
||||
|
||||
# sendrawtransaction <hex string> [allowhighfees=false]
|
||||
|
|
@ -471,6 +476,14 @@ ERROR: 'importaddress' method not found. Is your bitcoind enabled for watch-onl
|
|||
else:
|
||||
return self.proxy.listaccounts(minconf,includeWatchonly).keys()
|
||||
except JSONRPCException as e:
|
||||
from mmgen.util import msg
|
||||
msg("""
|
||||
*******************************************************************************
|
||||
*******************************************************************************
|
||||
ERROR: 'listaccounts' failed. Does your bitcoind support watch-only addresses?
|
||||
*******************************************************************************
|
||||
*******************************************************************************
|
||||
""")
|
||||
raise _wrap_exception(e.error)
|
||||
|
||||
def listreceivedbyaccount(self, minconf=1, includeempty=False):
|
||||
|
|
|
|||
|
|
@ -423,7 +423,7 @@ def viewtx(infile,pager=False):
|
|||
tx_data = get_lines_from_file(infile,"transaction data")
|
||||
|
||||
metadata,tx_hex,inputs_data,b2m_map,comment = parse_tx_file(tx_data,infile)
|
||||
view_tx_data(c,inputs_data,tx_hex,b2m_map,comment,metadata,pager)
|
||||
view_tx_data(c,inputs_data,tx_hex,b2m_map,comment,metadata,pager,pause=False)
|
||||
|
||||
def addrfile_chksum(infile): parse_addrfile(infile,{})
|
||||
def keyaddrfile_chksum(infile): parse_keyaddr_file(infile,{})
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ Only ASCII printable characters are permitted.
|
|||
sys.exit(3)
|
||||
|
||||
|
||||
def view_tx_data(c,inputs_data,tx_hex,b2m_map,comment,metadata,pager=False):
|
||||
def view_tx_data(c,inputs_data,tx_hex,b2m_map,comment,metadata,pager=False,pause=True):
|
||||
|
||||
td = c.decoderawtransaction(tx_hex)
|
||||
|
||||
|
|
@ -187,6 +187,7 @@ def view_tx_data(c,inputs_data,tx_hex,b2m_map,comment,metadata,pager=False):
|
|||
if pager: do_pager(o)
|
||||
else:
|
||||
print "\n"+o
|
||||
if pause:
|
||||
get_char("Press any key to continue: ")
|
||||
msg("")
|
||||
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ def open_file_or_exit(filename,mode):
|
|||
try:
|
||||
f = open(filename, mode)
|
||||
except:
|
||||
what = "reading" if mode == 'r' else "writing"
|
||||
what = "reading" if 'r' in mode else "writing"
|
||||
msg("Unable to open file '%s' for %s" % (filename,what))
|
||||
sys.exit(2)
|
||||
return f
|
||||
|
|
@ -329,7 +329,7 @@ def write_to_file(outfile,data,opts,what="data",confirm_overwrite=False,verbose=
|
|||
else:
|
||||
msg("Overwriting file '%s'" % outfile)
|
||||
|
||||
f = open_file_or_exit(outfile,'w')
|
||||
f = open_file_or_exit(outfile,'wb')
|
||||
try:
|
||||
f.write(data)
|
||||
except:
|
||||
|
|
@ -546,7 +546,7 @@ def get_lines_from_file(infile,what="",trim_comments=False):
|
|||
def get_data_from_file(infile,what="data",dash=False):
|
||||
if dash and infile == "-": return sys.stdin.read()
|
||||
qmsg("Getting %s from file '%s'" % (what,infile))
|
||||
f = open_file_or_exit(infile,'r')
|
||||
f = open_file_or_exit(infile,'rb')
|
||||
data = f.read()
|
||||
f.close()
|
||||
return data
|
||||
|
|
@ -641,8 +641,10 @@ def get_hash_preset_from_user(hp='3',what="data"):
|
|||
|
||||
def my_raw_input(prompt,echo=True,insert_txt="",use_readline=True):
|
||||
|
||||
try: import readline
|
||||
except: use_readline = False # Windows
|
||||
|
||||
if use_readline and sys.stdout.isatty():
|
||||
import readline
|
||||
def st_hook(): readline.insert_text(insert_txt)
|
||||
readline.set_startup_hook(st_hook)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue