本文整理匯總了Python中electrum.wallet.BIP32_HD_Wallet.sign_message方法的典型用法代碼示例。如果您正苦於以下問題:Python BIP32_HD_Wallet.sign_message方法的具體用法?Python BIP32_HD_Wallet.sign_message怎麽用?Python BIP32_HD_Wallet.sign_message使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類electrum.wallet.BIP32_HD_Wallet
的用法示例。
在下文中一共展示了BIP32_HD_Wallet.sign_message方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: sign_message
# 需要導入模塊: from electrum.wallet import BIP32_HD_Wallet [as 別名]
# 或者: from electrum.wallet.BIP32_HD_Wallet import sign_message [as 別名]
def sign_message(self, address, message, password):
if self.has_seed():
return BIP32_HD_Wallet.sign_message(self, address, message, password)
use2FA = False
self.signing = True
self.get_client() # prompt for the PIN before displaying the dialog if necessary
if not self.check_proper_device():
self.give_error('Wrong device or password')
address_path = self.address_id(address)
self.plugin.handler.show_message("Signing message ...")
try:
info = self.get_client().signMessagePrepare(address_path, message)
pin = ""
if info['confirmationNeeded']:
# TODO : handle different confirmation types. For the time being only supports keyboard 2FA
use2FA = True
confirmed, p, pin = self.password_dialog()
if not confirmed:
raise Exception('Aborted by user')
pin = pin.encode()
self.client.bad = True
self.device_checked = False
self.get_client(True)
signature = self.get_client().signMessageSign(pin)
except BTChipException, e:
if e.sw == 0x6a80:
self.give_error("Unfortunately, this message cannot be signed by the Ledger wallet. Only alphanumerical messages shorter than 140 characters are supported. Please remove any extra characters (tab, carriage return) and retry.")
else:
self.give_error(e, True)
示例2: sign_message
# 需要導入模塊: from electrum.wallet import BIP32_HD_Wallet [as 別名]
# 或者: from electrum.wallet.BIP32_HD_Wallet import sign_message [as 別名]
def sign_message(self, address, message, password):
if self.has_seed():
return BIP32_HD_Wallet.sign_message(self, address, message, password)
if not self.check_proper_device():
give_error("Wrong device or password")
try:
address_path = self.address_id(address)
address_n = self.plugin.get_client().expand_path(address_path)
except Exception, e:
give_error(e)