Additions/improvements:
mmgen-txsign - sign multiple transactions in one operation
mmgen-addrimport - skip rescanning block chain for new addresses
mmgen-tool - new functions:
Bitcoind operations:
listaccounts - like 'bitcoind listaccounts' but shows MMGen wallet balances
too
getbalance - like 'bitcoind getbalance' but shows confirmed/unconfirmed,
spendable/unspendable
MMGen-specific operations:
id8 - generate 8-character MMGen ID checksum for file (or stdin)
id6 - generate 6-character MMGen ID checksum for file (or stdin)
98 lines
2.6 KiB
Python
Executable file
98 lines
2.6 KiB
Python
Executable file
#!/usr/bin/env python
|
|
#
|
|
# mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
|
|
# Copyright (C) 2013-2014 by philemon <mmgen-py@yandex.com>
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
"""
|
|
mmgen-txsend: Broadcast a Bitcoin transaction to the network
|
|
"""
|
|
|
|
import sys
|
|
|
|
from mmgen.Opts import *
|
|
from mmgen.license import *
|
|
import mmgen.config as g
|
|
from mmgen.tx import *
|
|
from mmgen.util import msg,check_infile,get_lines_from_file,confirm_or_exit
|
|
|
|
prog_name = sys.argv[0].split("/")[-1]
|
|
|
|
help_data = {
|
|
'prog_name': prog_name,
|
|
'desc': "Send a Bitcoin transaction signed by mmgen-txsign",
|
|
'usage': "[opts] <signed transaction file>",
|
|
'options': """
|
|
-h, --help Print this help message
|
|
-d, --outdir d Specify an alternate directory 'd' for output
|
|
-q, --quiet Suppress warnings; overwrite files without prompting
|
|
"""
|
|
}
|
|
|
|
short_opts = "hd:q"
|
|
long_opts = "help","outdir=","quiet"
|
|
|
|
opts,cmd_args = process_opts(sys.argv,help_data,short_opts,long_opts)
|
|
if 'quiet' in opts: g.quiet = True
|
|
check_opts(opts,long_opts)
|
|
|
|
if len(cmd_args) == 1:
|
|
infile = cmd_args[0]
|
|
check_infile(infile)
|
|
else: usage(help_data)
|
|
|
|
# Begin execution
|
|
|
|
try:
|
|
metadata,tx_sig = get_lines_from_file(infile,"signed transaction")
|
|
except:
|
|
msg("Invalid signed transaction file")
|
|
sys.exit(3)
|
|
|
|
metadata = metadata.split()
|
|
if len(metadata) != 3:
|
|
msg("Invalid file header")
|
|
sys.exit(3)
|
|
|
|
from binascii import unhexlify
|
|
try: unhexlify(tx_sig)
|
|
except:
|
|
msg("Invalid signed transaction data")
|
|
sys.exit(3)
|
|
|
|
do_license_msg()
|
|
|
|
qmsg("Signed transaction file '%s' is valid" % infile)
|
|
|
|
warn = "Once this transaction is sent, there's no taking it back!"
|
|
what = "broadcast this transaction to the network"
|
|
expect = "YES, I REALLY WANT TO DO THIS"
|
|
|
|
if g.quiet: warn,expect = "","YES"
|
|
|
|
confirm_or_exit(warn, what, expect)
|
|
|
|
msg("Sending transaction")
|
|
|
|
c = connect_to_bitcoind()
|
|
|
|
try:
|
|
tx = c.sendrawtransaction(tx_sig)
|
|
except:
|
|
msg("Unable to send transaction")
|
|
sys.exit(3)
|
|
|
|
msg("Transaction sent: %s" % tx)
|
|
|
|
print_sent_tx_to_file(tx,metadata,opts)
|