switch pubkeymanager and contactmanager over to niceware
This commit is contained in:
parent
991c79b350
commit
37db4b514e
@ -21,9 +21,9 @@
|
|||||||
import sys, getpass
|
import sys, getpass
|
||||||
|
|
||||||
import unpaddedbase32
|
import unpaddedbase32
|
||||||
import vanityonionr
|
import niceware
|
||||||
import mnemonic
|
|
||||||
|
|
||||||
|
import vanityonionr
|
||||||
import logger, onionrexceptions
|
import logger, onionrexceptions
|
||||||
from onionrutils import stringvalidators, bytesconverter
|
from onionrutils import stringvalidators, bytesconverter
|
||||||
from onionrusers import onionrusers, contactmanager
|
from onionrusers import onionrusers, contactmanager
|
||||||
@ -95,7 +95,6 @@ def add_vanity():
|
|||||||
key_manager = keymanager.KeyManager()
|
key_manager = keymanager.KeyManager()
|
||||||
tell = lambda tell: logger.info(tell, terminal=True)
|
tell = lambda tell: logger.info(tell, terminal=True)
|
||||||
words = ''
|
words = ''
|
||||||
m = mnemonic.Mnemonic('english')
|
|
||||||
length = len(sys.argv) - 2
|
length = len(sys.argv) - 2
|
||||||
if length == 0: return
|
if length == 0: return
|
||||||
for i in range(2, len(sys.argv)):
|
for i in range(2, len(sys.argv)):
|
||||||
@ -112,7 +111,7 @@ def add_vanity():
|
|||||||
logger.warn('Vanity words must be valid english bip39', terminal=True)
|
logger.warn('Vanity words must be valid english bip39', terminal=True)
|
||||||
else:
|
else:
|
||||||
b32_pub = unpaddedbase32.b32encode(vanity[0])
|
b32_pub = unpaddedbase32.b32encode(vanity[0])
|
||||||
tell('Found vanity address:\n' + m.to_mnemonic(vanity[0]))
|
tell('Found vanity address:\n' + niceware.bytes_to_passphrase(vanity[0]))
|
||||||
tell('Base32 Public key: %s' % (b32_pub.decode(),))
|
tell('Base32 Public key: %s' % (b32_pub.decode(),))
|
||||||
key_manager.addKey(b32_pub, unpaddedbase32.b32encode(vanity[1]))
|
key_manager.addKey(b32_pub, unpaddedbase32.b32encode(vanity[1]))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
@ -17,18 +17,20 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
'''
|
'''
|
||||||
import os, json, onionrexceptions
|
import os, json
|
||||||
import unpaddedbase32
|
import unpaddedbase32
|
||||||
|
import niceware
|
||||||
|
|
||||||
|
import onionrexceptions
|
||||||
from onionrusers import onionrusers
|
from onionrusers import onionrusers
|
||||||
from onionrutils import bytesconverter, epoch
|
from onionrutils import bytesconverter, epoch
|
||||||
from utils import identifyhome
|
from utils import identifyhome
|
||||||
from onionrutils import mnemonickeys
|
from onionrutils import mnemonickeys
|
||||||
import mnemonic
|
|
||||||
class ContactManager(onionrusers.OnionrUser):
|
class ContactManager(onionrusers.OnionrUser):
|
||||||
def __init__(self, publicKey, saveUser=False, recordExpireSeconds=5):
|
def __init__(self, publicKey, saveUser=False, recordExpireSeconds=5):
|
||||||
try:
|
try:
|
||||||
if mnemonickeys.DELIMITER in publicKey:
|
if mnemonickeys.DELIMITER in publicKey:
|
||||||
publicKey = mnemonic.Mnemonic('english').to_entropy(publicKey.split(mnemonickeys.DELIMITER))
|
publicKey = mnemonickeys.get_base32(publicKey.split(mnemonickeys.DELIMITER))
|
||||||
publicKey = unpaddedbase32.b32encode(bytesconverter.str_to_bytes(publicKey))
|
publicKey = unpaddedbase32.b32encode(bytesconverter.str_to_bytes(publicKey))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user