Exemple #1
0
def do_license_msg(immed=False):

	import mmgen.license as gpl
	if opt.quiet or g.no_license: return

	p = "Press 'w' for conditions and warranty info, or 'c' to continue:"
	msg(gpl.warning)
	prompt = "%s " % p.strip()

	while True:
		reply = get_char(prompt, immed_chars="wc" if immed else "")
		if reply == 'w':
			from mmgen.term import do_pager
			do_pager(gpl.conditions)
		elif reply == 'c':
			msg(""); break
		else:
			msg_r("\r")
	msg("")
Exemple #2
0
def view_tx_data(c,inputs_data,tx_hex,b2m_map,comment,metadata,pager=False,pause=True,terse=False):

	td = c.decoderawtransaction(tx_hex)

	fs = "Transaction {} - {} BTC - {} GMT\n" if terse else \
	"TRANSACTION DATA\n\nHeader: [Tx ID: {}] [Amount: {} BTC] [Time: {}]\n\n"
	out = fs.format(*metadata)

	enl = "" if terse else "\n"
	if comment: out += "Comment: %s\n%s" % (comment,enl)
	out += "Inputs:\n" + enl

	nonmm_str = "non-{pnm} address".format(pnm=g.proj_name)

	total_in = 0
	for n,i in enumerate(td['vin']):
		for j in inputs_data:
			if j['txid'] == i['txid'] and j['vout'] == i['vout']:
				days = int(j['confirmations'] * g.mins_per_block / (60*24))
				total_in += j['amount']
				if not j['mmid']: j['mmid'] = nonmm_str
				mmid_fmt = " ({:>{l}})".format(j['mmid'],l=34-len(j['address']))
				if terse:
					out += "  %s: %-54s %s BTC" % (n+1,j['address'] + mmid_fmt,
							trim_exponent(j['amount']))
				else:
					for d in (
	(n+1, "tx,vout:",       "%s,%s" % (i['txid'], i['vout'])),
	("",  "address:",       j['address'] + mmid_fmt),
	("",  "comment:",       j['comment']),
	("",  "amount:",        "%s BTC" % trim_exponent(j['amount'])),
	("",  "confirmations:", "%s (around %s days)" % (j['confirmations'], days))
					):
						if d[2]: out += ("%3s %-8s %s\n" % d)
				out += "\n"

				break
	total_out = 0
	out += "Outputs:\n" + enl
	for n,i in enumerate(td['vout']):
		btcaddr = i['scriptPubKey']['addresses'][0]
		mmid,comment=b2m_map[btcaddr] if btcaddr in b2m_map else (nonmm_str,"")
		mmid_fmt = " ({:>{l}})".format(mmid,l=34-len(j['address']))
		total_out += i['value']
		if terse:
			out += "  %s: %-54s %s BTC" % (n+1,btcaddr + mmid_fmt,
					trim_exponent(i['value']))
		else:
			for d in (
					(n+1, "address:",  btcaddr + mmid_fmt),
					("",  "comment:",  comment),
					("",  "amount:",   trim_exponent(i['value']))
				):
				if d[2]: out += ("%3s %-8s %s\n" % d)
		out += "\n"

	fs = "In %s BTC - Out %s BTC - Fee %s BTC\n" if terse else \
		"Total input:  %s BTC\nTotal output: %s BTC\nTX fee:       %s BTC\n"
	out += fs % (
		trim_exponent(total_in),
		trim_exponent(total_out),
		trim_exponent(total_in-total_out)
	)

	o = out.encode("utf8")
	if pager: do_pager(o)
	else:
		sys.stdout.write(o)
		if pause:
			get_char("Press any key to continue: ")
			msg("")