Пример #1
0
 def import_key(self, sec, password):
     try:
         pubkey = public_key_from_private_key(sec)
     except Exception:
         raise BaseException('Invalid private key')
     # allow overwrite
     self.keypairs[pubkey] = pw_encode(sec, password)
     return pubkey
Пример #2
0
 def signtransaction(self, tx, privkey=None):
     """Sign a transaction. The wallet keys will be used unless a private key is provided."""
     tx = Transaction(tx)
     if privkey:
         pubkey = stratis.public_key_from_private_key(privkey)
         h160 = stratis.hash_160(pubkey.decode('hex'))
         x_pubkey = 'fd' + (chr(0) + h160).encode('hex')
         tx.sign({x_pubkey: privkey})
     else:
         self.wallet.sign_transaction(tx, self._password)
     return tx.as_dict()
Пример #3
0
 def get_private_key(self, pubkey, password):
     pk = pw_decode(self.keypairs[pubkey], password)
     # this checks the password
     if pubkey != public_key_from_private_key(pk):
         raise InvalidPassword()
     return pk