Browse Source

Merge #892: Remove unused key-type param for importprivkey

df83764 Remove unused key-type param for importprivkey (Daniel McNally)
master
Adam Gibson 5 years ago
parent
commit
29fe25282c
No known key found for this signature in database
GPG Key ID: 141001A1AF77F20B
  1. 3
      jmclient/jmclient/wallet.py
  2. 27
      jmclient/jmclient/wallet_utils.py

3
jmclient/jmclient/wallet.py

@ -1619,13 +1619,10 @@ class ImportWalletMixin(object):
args: args:
mixdepth: int, mixdepth to import key into mixdepth: int, mixdepth to import key into
wif: str, private key in WIF format wif: str, private key in WIF format
key_type: int, must match a TYPE_* constant of this module,
used to verify against the key type extracted from WIF
raises: raises:
WalletError: if key's network does not match wallet network WalletError: if key's network does not match wallet network
WalletError: if key is not compressed and type is not P2PKH WalletError: if key is not compressed and type is not P2PKH
WalletError: if key_type does not match data from WIF
returns: returns:
path of imported key path of imported key

27
jmclient/jmclient/wallet_utils.py

@ -95,31 +95,9 @@ The method is one of the following:
type='str', type='str',
dest='hd_path', dest='hd_path',
help='hd wallet path (e.g. m/0/0/0/000)') help='hd wallet path (e.g. m/0/0/0/000)')
parser.add_option('--key-type', # note: keep in sync with map_key_type
type='choice',
choices=('standard', 'segwit-p2sh'),
action='store',
dest='key_type',
default=None,
help=("Key type when importing private keys.\n"
"If your address starts with '1' use 'standard', "
"if your address starts with '3' use 'segwit-p2sh'.\n"
"Native segwit addresses (starting with 'bc') are "
"not yet supported."))
return parser return parser
def map_key_type(parser_key_choice):
if not parser_key_choice:
return parser_key_choice
if parser_key_choice == 'standard':
return TYPE_P2PKH
if parser_key_choice == 'segwit-p2sh':
return TYPE_P2SH_P2WPKH
raise Exception("Unknown key type choice '{}'.".format(parser_key_choice))
"""The classes in this module manage representations """The classes in this module manage representations
of wallet states; but they know nothing about Bitcoin, of wallet states; but they know nothing about Bitcoin,
so do not attempt to validate addresses, keys, BIP32 or relationships. so do not attempt to validate addresses, keys, BIP32 or relationships.
@ -1028,7 +1006,7 @@ def wallet_showseed(wallet):
return text return text
def wallet_importprivkey(wallet, mixdepth, key_type): def wallet_importprivkey(wallet, mixdepth):
jmprint("WARNING: This imported key will not be recoverable with your 12 " jmprint("WARNING: This imported key will not be recoverable with your 12 "
"word mnemonic phrase. Make sure you have backups.", "warning") "word mnemonic phrase. Make sure you have backups.", "warning")
jmprint("WARNING: Make sure that the type of the public address previously " jmprint("WARNING: Make sure that the type of the public address previously "
@ -1566,8 +1544,7 @@ def wallet_tool_main(wallet_root_path):
#note: must be interactive (security) #note: must be interactive (security)
if options.mixdepth is None: if options.mixdepth is None:
parser.error("You need to specify a mixdepth with -m") parser.error("You need to specify a mixdepth with -m")
wallet_importprivkey(wallet_service, options.mixdepth, wallet_importprivkey(wallet_service, options.mixdepth)
map_key_type(options.key_type))
return "Key import completed." return "Key import completed."
elif method == "signmessage": elif method == "signmessage":
if len(args) < 3: if len(args) < 3:

Loading…
Cancel
Save