Esempio n. 1
0
 def send_pin(self, pin: str) -> bool:
     self.client.open()
     if not pin.isdigit():
         raise BadArgumentError("Non-numeric PIN provided")
     resp = self.client.call_raw(messages.PinMatrixAck(pin=pin))
     if isinstance(resp, messages.Failure):
         self.client.features = self.client.call_raw(messages.GetFeatures())
         if isinstance(self.client.features, messages.Features):
             if not self.client.features.pin_protection:
                 raise DeviceAlreadyUnlockedError("This device does not need a PIN")
             if self.client.features.unlocked:
                 raise DeviceAlreadyUnlockedError(
                     "The PIN has already been sent to this device"
                 )
         return False
     elif isinstance(resp, messages.PassphraseRequest):
         pass_resp = self.client.call_raw(
             messages.PassphraseAck(
                 passphrase=self.client.ui.get_passphrase(available_on_device=False),
                 on_device=False,
             )
         )
         if isinstance(pass_resp, messages.Deprecated_PassphraseStateRequest):
             self.client.call_raw(messages.Deprecated_PassphraseStateAck())
     return True
Esempio n. 2
0
 def prompt_pin(self) -> bool:
     self.coin_name = "Bitcoin" if self.chain == Chain.MAIN else "Testnet"
     self.client.open()
     self._prepare_device()
     if not self.client.features.pin_protection:
         raise DeviceAlreadyUnlockedError("This device does not need a PIN")
     if self.client.features.unlocked:
         raise DeviceAlreadyUnlockedError(
             "The PIN has already been sent to this device"
         )
     print(
         "Use 'sendpin' to provide the number positions for the PIN as displayed on your device's screen",
         file=sys.stderr,
     )
     print(PIN_MATRIX_DESCRIPTION, file=sys.stderr)
     self.client.call_raw(
         messages.GetPublicKey(
             address_n=[0x8000002C, 0x80000001, 0x80000000],
             ecdsa_curve_name=None,
             show_display=False,
             coin_name=self.coin_name,
             script_type=messages.InputScriptType.SPENDADDRESS,
         )
     )
     return True
Esempio n. 3
0
 def prompt_pin(self):
     self.coin_name = 'Testnet' if self.is_testnet else 'Bitcoin'
     self.client.open()
     self.client.init_device()
     if not self.client.features.pin_protection:
         raise DeviceAlreadyUnlockedError('This device does not need a PIN')
     if self.client.features.pin_cached:
         raise DeviceAlreadyUnlockedError('The PIN has already been sent to this device')
     print('Use \'sendpin\' to provide the number positions for the PIN as displayed on your device\'s screen', file=sys.stderr)
     print(PIN_MATRIX_DESCRIPTION, file=sys.stderr)
     self.client.call_raw(proto.GetPublicKey(address_n=[0x8000002c, 0x80000001, 0x80000000], ecdsa_curve_name=None, show_display=False, coin_name=self.coin_name, script_type=proto.InputScriptType.SPENDADDRESS))
     return {'success': True}
Esempio n. 4
0
 def send_pin(self, pin):
     self.client.open()
     if not pin.isdigit():
         raise BadArgumentError("Non-numeric PIN provided")
     resp = self.client.call_raw(proto.PinMatrixAck(pin=pin))
     if isinstance(resp, proto.Failure):
         self.client.features = self.client.call_raw(proto.GetFeatures())
         if isinstance(self.client.features, proto.Features):
             if not self.client.features.pin_protection:
                 raise DeviceAlreadyUnlockedError('This device does not need a PIN')
             if self.client.features.pin_cached:
                 raise DeviceAlreadyUnlockedError('The PIN has already been sent to this device')
         return {'success': False}
     return {'success': True}