コード例 #1
0
    def on_receive(self, keyhash, message):
        self.print_error("signal arrived for", keyhash)
        for key, _hash, window in self.keys:
            if _hash == keyhash:
                break
        else:
            self.print_error("keyhash not found")
            return

        wallet = window.wallet
        if isinstance(wallet.keystore, keystore.Hardware_KeyStore):
            window.show_warning(
                _('An encrypted transaction was retrieved from cosigning pool.'
                  ) + '\n' +
                _('However, hardware wallets do not support message decryption, '
                  'which makes them not compatible with the current design of cosigner pool.'
                  ))
            return
        elif wallet.has_keystore_encryption():
            password = window.password_dialog(
                _('An encrypted transaction was retrieved from cosigning pool.'
                  ) + '\n' + _('Please enter your password to decrypt it.'))
            if not password:
                return
        else:
            password = None
            if not window.question(
                    _("An encrypted transaction was retrieved from cosigning pool."
                      ) + '\n' + _("Do you want to open it now?")):
                return

        xprv = wallet.keystore.get_master_private_key(password)
        if not xprv:
            return
        try:
            k = bip32.deserialize_xprv(xprv)[-1]
            EC = ecc.ECPrivkey(k)
            message = bh2u(EC.decrypt_message(message))
        except Exception as e:
            traceback.print_exc(file=sys.stdout)
            window.show_error(_('Error decrypting message') + ':\n' + str(e))
            return

        self.listener.clear(keyhash)
        tx = transaction.Transaction(message)
        show_transaction(tx, window, prompt_if_unsaved=True)
コード例 #2
0
ファイル: qt.py プロジェクト: ahmedbodi/electrum
    def on_receive(self, keyhash, message):
        self.print_error("signal arrived for", keyhash)
        for key, _hash, window in self.keys:
            if _hash == keyhash:
                break
        else:
            self.print_error("keyhash not found")
            return

        wallet = window.wallet
        if isinstance(wallet.keystore, keystore.Hardware_KeyStore):
            window.show_warning(_('An encrypted transaction was retrieved from cosigning pool.') + '\n' +
                                _('However, hardware wallets do not support message decryption, '
                                  'which makes them not compatible with the current design of cosigner pool.'))
            return
        elif wallet.has_keystore_encryption():
            password = window.password_dialog(_('An encrypted transaction was retrieved from cosigning pool.') + '\n' +
                                              _('Please enter your password to decrypt it.'))
            if not password:
                return
        else:
            password = None
            if not window.question(_("An encrypted transaction was retrieved from cosigning pool.") + '\n' +
                                   _("Do you want to open it now?")):
                return

        xprv = wallet.keystore.get_master_private_key(password)
        if not xprv:
            return
        try:
            k = bip32.deserialize_xprv(xprv)[-1]
            EC = ecc.ECPrivkey(k)
            message = bh2u(EC.decrypt_message(message))
        except Exception as e:
            traceback.print_exc(file=sys.stdout)
            window.show_error(_('Error decrypting message') + ':\n' + str(e))
            return

        self.listener.clear(keyhash)
        tx = transaction.Transaction(message)
        show_transaction(tx, window, prompt_if_unsaved=True)
コード例 #3
0
ファイル: trustedcoin.py プロジェクト: zhiyuan2007/electrum
 def f(xprv):
     _, _, _, _, c, k = deserialize_xprv(xprv)
     pk = bip32_private_key([0, 0], k, c)
     key = ecc.ECPrivkey(pk)
     sig = key.sign_message(message, True)
     return base64.b64encode(sig).decode()
コード例 #4
0
ファイル: trustedcoin.py プロジェクト: chrisrico/electrum
 def f(xprv):
     _, _, _, _, c, k = deserialize_xprv(xprv)
     pk = bip32_private_key([0, 0], k, c)
     key = ecc.ECPrivkey(pk)
     sig = key.sign_message(message, True)
     return base64.b64encode(sig).decode()
コード例 #5
0
ファイル: xprv.py プロジェクト: AbdussamadA/electrum-xprv
    entropy_in_bytes = entropy.to_bytes( entropy_size , sys.byteorder )
    xprv,xpub = bip32.bip32_root( entropy_in_bytes, key_type )
    master_key = xprv
elif args.master_key == "-":
    master_key = sys.stdin.readline().strip()

if args.convert:
    if args.gen_master:
        sys.exit( "Convert option cannot be used with generate master option" )
    else:
        convert_type = args.convert if args.convert !="p2pkh" else "standard"
        if bip32.is_xpub(master_key):
            xtype, depth, fingerprint, child_number, c, K_or_k = bip32.deserialize_xpub( master_key )
            master_key = bip32.serialize_xpub( convert_type, c,  K_or_k, depth, fingerprint, child_number )
        elif bip32.is_xprv(master_key):
            xtype, depth, fingerprint, child_number, c, K_or_k = bip32.deserialize_xprv( master_key )
            master_key = bip32.serialize_xprv( convert_type, c,  K_or_k, depth, fingerprint, child_number )
        else:
            sys.exit( "Master key is not a valid extended key" )

derivation_path = args.derivation_path if args.derivation_path != "m" else "m/"
if bip32.is_bip32_derivation( derivation_path ):
	if bip32.is_xpub(master_key):
		if args.output_xprv:
				sys.exit( "Cannot derive extended private key from extended public key\n" )
		if derivation_path == "m/":
			print( master_key )
		else:
			try:
				xpub = bip32.bip32_public_derivation( master_key, "m/", derivation_path )
				sys.stderr.write( "Derivation Path: {}\n".format( derivation_path ) )