Add decrypt function
Not yet supported in Trezor device, so it currently returns an Unknown Message error
This commit is contained in:
parent
017693fa57
commit
0c81010290
|
@ -4,12 +4,12 @@ from binascii import unhexlify
|
||||||
from struct import pack
|
from struct import pack
|
||||||
from sys import stderr
|
from sys import stderr
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from base64 import b64encode
|
from base64 import b64encode, b64decode
|
||||||
|
|
||||||
from electrum_gui.qt.password_dialog import make_password_dialog, run_password_dialog
|
from electrum_gui.qt.password_dialog import make_password_dialog, run_password_dialog
|
||||||
from electrum_gui.qt.util import ok_cancel_buttons
|
from electrum_gui.qt.util import ok_cancel_buttons
|
||||||
from electrum.account import BIP32_Account
|
from electrum.account import BIP32_Account
|
||||||
from electrum.bitcoin import EncodeBase58Check
|
from electrum.bitcoin import EncodeBase58Check, public_key_to_bc_address
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
from electrum.plugins import BasePlugin
|
from electrum.plugins import BasePlugin
|
||||||
from electrum.transaction import deserialize
|
from electrum.transaction import deserialize
|
||||||
|
@ -166,6 +166,21 @@ class TrezorWallet(NewWallet):
|
||||||
#do nothing - no priv keys available
|
#do nothing - no priv keys available
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def decrypt_message(self, pubkey, message, password):
|
||||||
|
try:
|
||||||
|
address = public_key_to_bc_address(pubkey.decode('hex'))
|
||||||
|
address_path = self.address_id(address)
|
||||||
|
address_n = self.get_client().expand_path(address_path)
|
||||||
|
except Exception, e:
|
||||||
|
raise e
|
||||||
|
try:
|
||||||
|
decrypted_msg = self.get_client().decrypt_message(address_n, b64decode(message))
|
||||||
|
except Exception, e:
|
||||||
|
raise e
|
||||||
|
finally:
|
||||||
|
twd.emit(SIGNAL('trezor_done'))
|
||||||
|
return str(decrypted_msg)
|
||||||
|
|
||||||
def sign_message(self, address, message, password):
|
def sign_message(self, address, message, password):
|
||||||
try:
|
try:
|
||||||
address_path = self.address_id(address)
|
address_path = self.address_id(address)
|
||||||
|
|
Loading…
Reference in New Issue