added vanity address support
This commit is contained in:
parent
57791c34a5
commit
866f0ce501
@ -22,6 +22,7 @@ from flask import Blueprint, Response, request, g
|
||||
import onionrblocks
|
||||
from onionrcrypto import hashers
|
||||
from onionrutils import bytesconverter
|
||||
from onionrutils import mnemonickeys
|
||||
ib = Blueprint('insertblock', __name__)
|
||||
|
||||
@ib.route('/insertblock', methods=['POST'])
|
||||
@ -48,7 +49,9 @@ def client_api_insert_block():
|
||||
to = ''
|
||||
try:
|
||||
if bData['encrypt']:
|
||||
to = bData['to']
|
||||
to = bData['to'].strip()
|
||||
if " " in to:
|
||||
to = mnemonickeys.get_base32(to)
|
||||
encrypt = True
|
||||
encryptType = 'asym'
|
||||
except KeyError:
|
||||
|
@ -46,6 +46,7 @@ def get_arguments():
|
||||
('importblocks', 'import-blocks', 'import-block'): importnewblocks.import_new_blocks,
|
||||
('addid', 'add-id'): pubkeymanager.add_ID,
|
||||
('changeid', 'change-id'): pubkeymanager.change_ID,
|
||||
('add-vanity', 'addvanity'): pubkeymanager.add_vanity,
|
||||
('resettor', 'reset-tor'): resettor.reset_tor,
|
||||
('resetplugins', 'reset-plugins'): resetplugins.reset,
|
||||
('reset-tor-node-transport',): resettor.reset_tor_key_pair,
|
||||
|
@ -19,14 +19,19 @@
|
||||
'''
|
||||
|
||||
import sys, getpass
|
||||
|
||||
import unpaddedbase32
|
||||
import vanityonionr
|
||||
import mnemonic
|
||||
|
||||
import logger, onionrexceptions
|
||||
from onionrutils import stringvalidators, bytesconverter
|
||||
from onionrusers import onionrusers, contactmanager
|
||||
import config
|
||||
from coredb import keydb
|
||||
import keymanager, onionrcrypto
|
||||
import unpaddedbase32
|
||||
from etc import onionrvalues
|
||||
|
||||
DETERMINISTIC_REQUIREMENT = onionrvalues.PASSWORD_LENGTH
|
||||
def add_ID():
|
||||
key_manager = keymanager.KeyManager()
|
||||
@ -80,3 +85,31 @@ def change_ID():
|
||||
logger.warn('That key does not exist', terminal=True)
|
||||
else:
|
||||
logger.warn('Invalid key %s' % (key,), terminal=True)
|
||||
|
||||
def add_vanity():
|
||||
key_manager = keymanager.KeyManager()
|
||||
tell = lambda tell: logger.info(tell, terminal=True)
|
||||
words = ''
|
||||
m = mnemonic.Mnemonic('english')
|
||||
length = len(sys.argv) - 2
|
||||
if length == 0: return
|
||||
for i in range(2, len(sys.argv)):
|
||||
words += ' '
|
||||
words += sys.argv[i]
|
||||
try:
|
||||
if length == 1:
|
||||
tell('Finding vanity, this should only take a few moments.')
|
||||
else:
|
||||
tell('Finding vanity, this will probably take a really long time.')
|
||||
try:
|
||||
vanity = vanityonionr.find_multiprocess(words)
|
||||
except ValueError:
|
||||
logger.warn('Vanity words must be valid english bip39', terminal=True)
|
||||
else:
|
||||
b32_pub = unpaddedbase32.b32encode(vanity[0])
|
||||
tell('Found vanity address:\n' + m.to_mnemonic(vanity[0]))
|
||||
tell('Base32 Public key: %s' % (b32_pub.decode(),))
|
||||
key_manager.addKey(b32_pub, unpaddedbase32.b32encode(vanity[1]))
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
add_vanity.onionr_help = "<space separated bip32 words> - Generates and stores an Onionr vanity address (see https://github.com/trezor/python-mnemonic/blob/master/mnemonic/wordlist/english.txt)"
|
@ -17,6 +17,7 @@
|
||||
<script defer src='/shared/node_modules/pnotify/dist/iife/PNotifyButtons.js'></script>
|
||||
<script defer src='/shared/navbar.js'></script>
|
||||
<script defer src='/shared/misc.js'></script>
|
||||
<script defer src='/mail/sethumanreadable.js'></script>
|
||||
<script defer src='/mail/mail.js'></script>
|
||||
<script defer src='/mail/sendmail.js'></script>
|
||||
</head>
|
||||
|
@ -177,19 +177,25 @@ function loadInboxEntries(bHash){
|
||||
humanDate.setUTCSeconds(resp['meta']['time'])
|
||||
humanDate = humanDate.toString()
|
||||
validSig.style.display = 'none'
|
||||
if (resp['meta']['signer'] != ''){
|
||||
senderInput.value = httpGet('/friends/getinfo/' + resp['meta']['signer'] + '/name')
|
||||
if (typeof resp['meta']['signer'] != 'undefined' && resp['meta']['signer'] != ''){
|
||||
let name = httpGet('/friends/getinfo/' + resp['meta']['signer'] + '/name')
|
||||
if (name.length == 0){
|
||||
setHumanReadableValue(senderInput, resp['meta']['signer'])
|
||||
entry.setAttribute('data-nameSet', false)
|
||||
}
|
||||
else{
|
||||
entry.setAttribute('data-nameSet', true)
|
||||
}
|
||||
}
|
||||
else{
|
||||
senderInput.value = 'Anonymous'
|
||||
entry.setAttribute('data-nameSet', false)
|
||||
}
|
||||
if (! resp['meta']['validSig']){
|
||||
validSig.style.display = 'inline'
|
||||
validSig.innerText = 'Signature Validity: Bad'
|
||||
validSig.style.color = 'red'
|
||||
}
|
||||
entry.setAttribute('data-nameSet', true)
|
||||
if (senderInput.value == ''){
|
||||
senderInput.value = resp['meta']['signer'] || 'Anonymous'
|
||||
entry.setAttribute('data-nameSet', false)
|
||||
}
|
||||
//bHashDisplay.innerText = bHash.substring(0, 10)
|
||||
entry.setAttribute('data-hash', bHash)
|
||||
entry.setAttribute('data-pubkey', resp['meta']['signer'])
|
||||
|
@ -38,7 +38,9 @@ function sendMail(to, message, subject){
|
||||
.then((resp) => resp.text()) // Transform the data into json
|
||||
.then(function(data) {
|
||||
sendForm.style.display = 'block'
|
||||
alert('Queued for sending!')
|
||||
PNotify.success({
|
||||
text: 'Queued for sending!'
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -50,12 +52,16 @@ friendPicker.onchange = function(){
|
||||
sendForm.onsubmit = function(){
|
||||
if (friendPicker.value.trim().length !== 0 && to.value.trim().length !== 0){
|
||||
if (friendPicker.value !== to.value){
|
||||
alert('You have selected both a friend and entered a public key manually.')
|
||||
PNotify.error({
|
||||
text: 'You have selected both a friend and entered a public key manually.'
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
if (to.value.length !== 56 && to.value.length !== 52){
|
||||
alert('Public key is not valid')
|
||||
if (! to.value.includes(" ") && to.value.length !== 56 && to.value.length !== 52){
|
||||
PNotify.error({
|
||||
text: 'User ID is not valid'
|
||||
})
|
||||
}
|
||||
else{
|
||||
sendMail(to.value, messageContent.value, subject.value)
|
||||
|
@ -11,3 +11,4 @@ streamedrequests==1.0.0
|
||||
jinja2==2.10.1
|
||||
toomanyobjs==1.1.0
|
||||
mnemonic==0.18
|
||||
vanityonionr==0.0.0
|
@ -185,6 +185,8 @@ unpaddedbase32==0.1.0 \
|
||||
urllib3==1.24.2 \
|
||||
--hash=sha256:4c291ca23bbb55c76518905869ef34bdd5f0e46af7afe6861e8375643ffee1a0 \
|
||||
--hash=sha256:9a247273df709c4fedb38c711e44292304f73f39ab01beda9f6b9fc375669ac3
|
||||
vanityonionr==0.0.0 \
|
||||
--hash=sha256:a61976c62363f05cc9f92e57c2c2deaad7753abc9e5d3ee9ad5745330b8d942e
|
||||
werkzeug==0.15.5 \
|
||||
--hash=sha256:87ae4e5b5366da2347eb3116c0e6c681a0e939a33b2805e2c0cbd282664932c4 \
|
||||
--hash=sha256:a13b74dd3c45f758d4ebdb224be8f1ab8ef58b3c0ffc1783a8c7d9f4f50227e6 \
|
||||
|
Loading…
Reference in New Issue
Block a user