def sign_transaction(c,tx_hex,tx_num_str,sig_data,keys=None): if keys: qmsg("Passing %s key%s to bitcoind" % (len(keys),suf(keys,"k"))) dmsg("Keys:\n %s" % "\n ".join(keys)) msg_r("Signing transaction{}...".format(tx_num_str)) from mmgen.rpc import exceptions try: sig_tx = c.signrawtransaction(tx_hex,sig_data,keys) except exceptions.InvalidAddressOrKey: msg("failed\nInvalid address or key") sys.exit(3) return sig_tx
if change > 0 and not change_addr: msg(wmsg['throwaway_change'] % change) sys.exit(2) if change_addr in tx_out and not change: msg("Warning: Change address will be unused as transaction produces no change") del tx_out[change_addr] for k,v in tx_out.items(): tx_out[k] = float(v) if change > 0: tx_out[change_addr] = float(change) tx_in = [{"txid":i.txid, "vout":i.vout} for i in sel_unspent] dmsg("tx_in: %s\ntx_out: %s" % (repr(tx_in),repr(tx_out))) if opt.comment_file: if keypress_confirm("Edit comment?",False): comment = get_tx_comment_from_user(comment) else: if keypress_confirm("Add a comment to transaction?",False): comment = get_tx_comment_from_user() else: comment = False tx_hex = c.createrawtransaction(tx_in,tx_out) qmsg("Transaction successfully created") amt = send_amt or change tx_id = make_chksum_6(unhexlify(tx_hex)).upper() metadata = tx_id, amt, make_timestamp()