tcmdline.py - electrum - Electrum Bitcoin wallet
HTML git clone https://git.parazyd.org/electrum
DIR Log
DIR Files
DIR Refs
DIR Submodules
---
tcmdline.py (1895B)
---
1 #!/usr/bin/env python
2 #
3 # Electrum - Lightweight Bitcoin Client
4 # Copyright (C) 2015 Thomas Voegtlin
5 #
6 # Permission is hereby granted, free of charge, to any person
7 # obtaining a copy of this software and associated documentation files
8 # (the "Software"), to deal in the Software without restriction,
9 # including without limitation the rights to use, copy, modify, merge,
10 # publish, distribute, sublicense, and/or sell copies of the Software,
11 # and to permit persons to whom the Software is furnished to do so,
12 # subject to the following conditions:
13 #
14 # The above copyright notice and this permission notice shall be
15 # included in all copies or substantial portions of the Software.
16 #
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 # SOFTWARE.
25
26 from electrum.i18n import _
27 from electrum.plugin import hook
28 from .trustedcoin import TrustedCoinPlugin
29
30
31 class Plugin(TrustedCoinPlugin):
32
33 def prompt_user_for_otp(self, wallet, tx): # FIXME this is broken
34 if not isinstance(wallet, self.wallet_class):
35 return
36 if not wallet.can_sign_without_server():
37 self.logger.info("twofactor:sign_tx")
38 auth_code = None
39 if wallet.keystores['x3/'].can_sign(tx, ignore_watching_only=True):
40 msg = _('Please enter your Google Authenticator code:')
41 auth_code = int(input(msg))
42 else:
43 self.logger.info("twofactor: xpub3 not needed")
44 wallet.auth_code = auth_code
45