2013-12-08 07:36:49 +04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
#
|
|
|
|
|
# mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
|
|
|
|
|
# Copyright (C) 2013 by philemon <mmgen-py@yandex.com>
|
2013-12-10 10:52:17 +04:00
|
|
|
#
|
2013-12-08 07:36:49 +04:00
|
|
|
# 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.
|
2013-12-10 10:52:17 +04:00
|
|
|
#
|
2013-12-08 07:36:49 +04:00
|
|
|
# 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.
|
2013-12-10 10:52:17 +04:00
|
|
|
#
|
2013-12-08 07:36:49 +04:00
|
|
|
# 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-addrimport: Import addresses generated by mmgen-addrgen into an
|
|
|
|
|
online bitcoind watching wallet.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
from mmgen.Opts import *
|
|
|
|
|
from mmgen.license import *
|
2013-12-10 10:52:17 +04:00
|
|
|
from mmgen.utils import check_infile,confirm_or_exit
|
|
|
|
|
from mmgen.tx import connect_to_bitcoind,parse_addrs_file
|
2013-12-08 07:36:49 +04:00
|
|
|
|
|
|
|
|
help_data = {
|
|
|
|
|
'prog_name': sys.argv[0].split("/")[-1],
|
|
|
|
|
'desc': """Import addresses generated by mmgen-addrgen into an
|
|
|
|
|
online bitcoind watching wallet""",
|
|
|
|
|
'usage':"[opts] [infile]",
|
|
|
|
|
'options': """
|
|
|
|
|
-h, --help Print this help message
|
|
|
|
|
-q, --quiet Suppress warnings
|
|
|
|
|
-v, --verbose Produce more verbose output
|
|
|
|
|
"""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
short_opts = "hqv"
|
|
|
|
|
long_opts = "help", "quiet", "verbose"
|
|
|
|
|
|
|
|
|
|
opts,cmd_args = process_opts(sys.argv,help_data,"".join(short_opts),long_opts)
|
|
|
|
|
|
|
|
|
|
if len(cmd_args) != 1: usage(help_data)
|
|
|
|
|
|
|
|
|
|
check_infile(cmd_args[0])
|
|
|
|
|
|
|
|
|
|
seed_id,addr_data = parse_addrs_file(cmd_args[0])
|
|
|
|
|
|
2014-01-29 20:03:59 +04:00
|
|
|
import mmgen.config
|
|
|
|
|
mmgen.config.http_timeout = 3600
|
|
|
|
|
|
|
|
|
|
c = connect_to_bitcoind()
|
2013-12-08 07:36:49 +04:00
|
|
|
|
|
|
|
|
message = """
|
2013-12-10 10:52:17 +04:00
|
|
|
Importing addresses can take a long time - up to 30 min. per address on a
|
2013-12-08 07:36:49 +04:00
|
|
|
low-powered computer such as a netbook.
|
|
|
|
|
"""
|
|
|
|
|
confirm_or_exit(message, "continue", expect="YES")
|
|
|
|
|
|
2014-01-29 20:03:59 +04:00
|
|
|
|
2013-12-08 07:36:49 +04:00
|
|
|
for n,i in enumerate(addr_data):
|
2013-12-10 10:52:17 +04:00
|
|
|
comment = " " + i[2] if len(i) == 3 else ""
|
|
|
|
|
label = "%s:%s%s" % (seed_id,i[0],comment)
|
2013-12-08 07:36:49 +04:00
|
|
|
msg("Importing %-6s %-34s (%s)" % (
|
|
|
|
|
("%s/%s:" % (n+1,len(addr_data))),
|
|
|
|
|
i[1], label)
|
|
|
|
|
)
|
|
|
|
|
c.importaddress(i[1],label)
|