Skip to content
Snippets Groups Projects

add Auth Encrypted WIF feature

Merged Moul requested to merge Tortue95:auth_ewif into master

Created by: Tortue95

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
70 75
71 76
72 77 def auth_by_wif():
73 wif = input("Please enter your WIF address: ")
74 seed = get_seed_from_wif(wif)
75 return seed
78 wif = input("Please enter your WIF or Encrypted WIF address: ")
79
80 regex = re.compile('^[1-9A-HJ-NP-Za-km-z]*$')
81 if not re.search(regex, wif):
82 print("Error: the format of WIF is invalid")
83 exit(1)
84
  • Author Owner

    Created by: jytou

    Ça vaut le coup de faire une méthode verifyWIF() ou quelque chose du genre pour éviter la duplication de code.

  • Author Owner
  • Moul
  • Moul
  • Moul
    Moul @moul started a thread on commit d130dc24
  • 70 75
    71 76
    72 77 def auth_by_wif():
    73 wif = input("Please enter your WIF address: ")
    74 seed = get_seed_from_wif(wif)
    75 return seed
    78 wif = input("Please enter your WIF or Encrypted WIF address: ")
    79
    80 regex = re.compile('^[1-9A-HJ-NP-Za-km-z]*$')
    81 if not re.search(regex, wif):
    82 print("Error: the format of WIF is invalid")
    83 exit(1)
    84
    • Author Owner

      Created by: Tortue95

      le double check de la base58 ici ne me dérange pas car get_seed_from_wif() ou get_seed_from_ewif() devrait être dans l'API et pas auth_by_wif() il faudrait plutôt créer une fonction check_base_58() car c'est la seul chose commune

  • Moul
  • Moul
  • Moul
    Moul @moul started a thread on commit d130dc24
  • 86 88 fi = wif_bytes[0:1]
    87 89
    88 90 if fi == b'\x01':
    89 return get_seed_from_wif(wif)
    91 return get_seed_from_wifv1(wif)
    90 92 elif fi == b'\x02':
    91 password = getpass.getpass("Please enter the password of WIF (masked): ")
    92 return get_seed_from_ewif(wif,password)
    93 password = getpass.getpass("Please enter the " +
    • Author Owner

      Created by: jytou

      Why folding this string? It makes it more difficult to read.

  • Moul
    Moul @moul started a thread on commit d130dc24
  • 173 182 for c in s:
    174 183 n *= 58
    175 184 if c not in b58_digits:
    176 raise InvalidBase58Error('Character %r is not a valid base58 character' % c)
    185 raise InvalidBase58Error('Character %r is not a ' +
  • Moul
    Moul @moul started a thread on commit d130dc24
  • 173 182 for c in s:
    174 183 n *= 58
    175 184 if c not in b58_digits:
    176 raise InvalidBase58Error('Character %r is not a valid base58 character' % c)
    185 raise InvalidBase58Error('Character %r is not a ' +
  • Moul
    Moul @moul started a thread on commit d130dc24
  • 173 182 for c in s:
    174 183 n *= 58
    175 184 if c not in b58_digits:
    176 raise InvalidBase58Error('Character %r is not a valid base58 character' % c)
    185 raise InvalidBase58Error('Character %r is not a ' +
    • Author Owner

      Created by: Tortue95

      but true we probably can do that:

              password = getpass.getpass(
                     "Please enter the password of WIF (masked): ")
  • Moul
    Moul @moul started a thread on commit d130dc24
  • 173 182 for c in s:
    174 183 n *= 58
    175 184 if c not in b58_digits:
    176 raise InvalidBase58Error('Character %r is not a valid base58 character' % c)
    185 raise InvalidBase58Error('Character %r is not a ' +
    • Author Owner

      Created by: jytou

      I must admit I'm not a big fan of the 80 characters per line rule. It made sense in the 90s, but now who has an 80 characters dispay? When a guide/rule/law is obsolete or produces bad result, it is meant to be ignored. :p Anyway, the 2nd folding is ok for me.

  • Moul
    Moul @moul started a thread on commit d130dc24
  • 173 182 for c in s:
    174 183 n *= 58
    175 184 if c not in b58_digits:
    176 raise InvalidBase58Error('Character %r is not a valid base58 character' % c)
    185 raise InvalidBase58Error('Character %r is not a ' +
    • Author Owner

      Personally, I didn't succeed to do the 80 char per line. I let that on the code. But, other pep8 checks are good to take. I think we can apply this rule for Silkaj project.

  • Moul
    Moul @moul started a thread on commit d130dc24
  • 173 182 for c in s:
    174 183 n *= 58
    175 184 if c not in b58_digits:
    176 raise InvalidBase58Error('Character %r is not a valid base58 character' % c)
    185 raise InvalidBase58Error('Character %r is not a ' +
    • Author Owner

      Created by: jytou

      I think you meant "can't". :) And I do agree that other checks are good, but not this one.

  • Moul
    Moul @moul started a thread on commit d130dc24
  • 173 182 for c in s:
    174 183 n *= 58
    175 184 if c not in b58_digits:
    176 raise InvalidBase58Error('Character %r is not a valid base58 character' % c)
    185 raise InvalidBase58Error('Character %r is not a ' +
    • Author Owner

      We can apply all checks done by pep8 excepted the 80 char per line rule.

  • Moul added Feature label

    added Feature label

  • Please register or sign in to reply
    Loading