'signtx':"Sign an unsigned transaction created by a deseeded wallet\nSyntax: signtx <filename>",
'seed':
"Print the generation seed of your wallet.",
- 'import':
+ 'importprivkey':
'Imports a key pair\nSyntax: import <address>:<privatekey>',
'signmessage':
'Signs a message with a key\nSyntax: signmessage <address> <message>\nIf you want to lead or end a message with spaces, or want double spaces inside the message make sure you quote the string. I.e. " Hello This is a weird String "',
'help', 'validateaddress',
'signmessage', 'verifymessage',
'eval', 'set', 'get', 'create', 'addresses',
- 'import', 'seed',
+ 'importprivkey', 'seed',
'deseed','reseed',
'freeze','unfreeze',
'prioritize','unprioritize']
-protected_commands = ['payto', 'password', 'mktx', 'signtx', 'seed', 'import','signmessage' ]
+protected_commands = ['payto', 'password', 'mktx', 'signtx', 'seed', 'importprivkey','signmessage' ]
# get password routine
def prompt_password(prompt, confirm=True):
else:
password = None
- if cmd == 'import':
+ if cmd == 'importprivkey':
# See if they specificed a key on the cmd line, if not prompt
if len(args) > 1:
- keypair = args[1]
+ sec = args[1]
else:
- keypair = prompt_password('Enter Address:PrivateKey (will not echo):', False)
+ sec = prompt_password('Enter PrivateKey (will not echo):', False)
try:
- wallet.import_key(keypair,password)
+ addr = wallet.import_key(sec,password)
wallet.save()
- print_msg("Keypair imported")
+ print_msg("Keypair imported: ", addr)
except BaseException as e:
print_msg("Error: Keypair import failed: " + str(e))
self.interface.poke('synchronizer')
while not self.is_up_to_date(): time.sleep(0.1)
- def import_key(self, keypair, password):
+ def import_key(self, sec, password):
- address, sec = keypair.split(':')
- if not self.is_valid(address):
- raise BaseException('Invalid Bitcoin address')
- if address in self.all_addresses():
- raise BaseException('Address already in wallet')
-
# rebuild public key from private key, compressed or uncompressed
pkey = regenerate_key(sec)
if not pkey:
# rebuild private and public key from regenerated secret
private_key = GetPrivKey(pkey, compressed)
public_key = GetPubKey(pkey, compressed)
- addr = public_key_to_bc_address(public_key)
+ address = public_key_to_bc_address(public_key)
- # sanity check
- if not address == addr :
- raise BaseException('Address does not match private key')
+ if address in self.all_addresses():
+ raise BaseException('Address already in wallet')
# store the originally requested keypair into the imported keys table
self.imported_keys[address] = self.pw_encode(sec, password )
+ return address
def new_seed(self, password):