Solved new address creations issues
This commit is contained in:
parent
c813f679ae
commit
95990d8def
|
@ -158,7 +158,7 @@ def encodeAddress(version, stream, ripe):
|
|||
raise Exception(
|
||||
'Programming error in encodeAddress: The length of'
|
||||
' a given ripe hash was not 20.')
|
||||
ripe = ripe.lstrip('\x00')
|
||||
ripe = ripe.lstrip('\x00'.encode('utf-8'))
|
||||
|
||||
storedBinaryData = encodeVarint(version) + encodeVarint(stream) + ripe
|
||||
|
||||
|
@ -264,7 +264,8 @@ def decodeAddress(address):
|
|||
return 'ripetoolong', 0, 0, ''
|
||||
elif len(embeddedRipeData) < 4:
|
||||
return 'ripetooshort', 0, 0, ''
|
||||
x00string = '\x00' * (20 - len(embeddedRipeData))
|
||||
x00string = '\x00'.encode('utf-8') * (20 - len(embeddedRipeData))
|
||||
|
||||
return status, addressVersionNumber, streamNumber, \
|
||||
x00string + embeddedRipeData
|
||||
|
||||
|
|
|
@ -334,7 +334,6 @@ NavigationLayout:
|
|||
BoxLayout:
|
||||
AnchorLayout:
|
||||
MDRaisedButton:
|
||||
size_hint: .6, .35
|
||||
height: dp(40)
|
||||
MDLabel:
|
||||
font_style: 'H4'
|
||||
|
@ -383,7 +382,6 @@ NavigationLayout:
|
|||
txt_input: txt_input
|
||||
rv: rv
|
||||
size : (890, 60)
|
||||
size_hint: 1,1
|
||||
MyTextInput:
|
||||
id: txt_input
|
||||
size_hint_y: None
|
||||
|
@ -414,7 +412,6 @@ NavigationLayout:
|
|||
spacing:50
|
||||
AnchorLayout:
|
||||
MDRaisedButton:
|
||||
size_hint: 1, None
|
||||
height: dp(40)
|
||||
on_press: root.reset_composer()
|
||||
MDLabel:
|
||||
|
@ -512,7 +509,6 @@ NavigationLayout:
|
|||
BoxLayout:
|
||||
AnchorLayout:
|
||||
MDRaisedButton:
|
||||
size_hint: .5, .35
|
||||
height: dp(40)
|
||||
on_press: app.root.ids.scr_mngr.current = 'random'
|
||||
MDLabel:
|
||||
|
@ -556,7 +552,6 @@ NavigationLayout:
|
|||
BoxLayout:
|
||||
AnchorLayout:
|
||||
MDRaisedButton:
|
||||
size_hint: .5, None
|
||||
height: dp(40)
|
||||
on_release: root.generateaddress(app)
|
||||
opposite_colors: True
|
||||
|
@ -586,7 +581,6 @@ NavigationLayout:
|
|||
BoxLayout:
|
||||
AnchorLayout:
|
||||
MDRaisedButton:
|
||||
size_hint: .6, .55
|
||||
height: dp(40)
|
||||
MDLabel:
|
||||
font_style: 'H4'
|
||||
|
@ -599,7 +593,6 @@ NavigationLayout:
|
|||
BoxLayout:
|
||||
AnchorLayout:
|
||||
MDRaisedButton:
|
||||
size_hint: .6, .55
|
||||
height: dp(40)
|
||||
MDLabel:
|
||||
font_style: 'H4'
|
||||
|
@ -612,7 +605,6 @@ NavigationLayout:
|
|||
BoxLayout:
|
||||
AnchorLayout:
|
||||
MDRaisedButton:
|
||||
size_hint: .6, .55
|
||||
height: dp(40)
|
||||
MDLabel:
|
||||
font_style: 'H4'
|
||||
|
@ -633,7 +625,6 @@ NavigationLayout:
|
|||
BoxLayout:
|
||||
MDCheckbox:
|
||||
id: chkbox
|
||||
size_hint: None, None
|
||||
size: dp(48), dp(64)
|
||||
active: True
|
||||
MDLabel:
|
||||
|
@ -718,7 +709,6 @@ NavigationLayout:
|
|||
Rectangle:
|
||||
pos: self.pos
|
||||
size: self.size
|
||||
size_hint: 1, None
|
||||
height: dp(40)
|
||||
on_press: root.get_available_credits(self)
|
||||
MDLabel:
|
||||
|
@ -763,7 +753,6 @@ NavigationLayout:
|
|||
Rectangle:
|
||||
pos: self.pos
|
||||
size: self.size
|
||||
size_hint: 1, None
|
||||
height: dp(40)
|
||||
MDLabel:
|
||||
font_style: 'H4'
|
||||
|
@ -807,7 +796,6 @@ NavigationLayout:
|
|||
Rectangle:
|
||||
pos: self.pos
|
||||
size: self.size
|
||||
size_hint: 1, None
|
||||
height: dp(40)
|
||||
MDLabel:
|
||||
font_style: 'H4'
|
||||
|
@ -819,7 +807,6 @@ NavigationLayout:
|
|||
|
||||
<GrashofPopup>:
|
||||
id: popup
|
||||
size_hint : (None,None)
|
||||
height: 2*(label.height + address.height) + 10
|
||||
width :app.window_size[0] - app.window_size[0]/10
|
||||
title: 'add contact\'s'
|
||||
|
@ -852,7 +839,6 @@ NavigationLayout:
|
|||
orientation: 'horizontal'
|
||||
MDRaisedButton:
|
||||
id: save_addr
|
||||
size_hint: 1.5, None
|
||||
height: dp(40)
|
||||
on_release:
|
||||
root.savecontact()
|
||||
|
@ -863,7 +849,6 @@ NavigationLayout:
|
|||
color: (1,1,1,1)
|
||||
halign: 'center'
|
||||
MDRaisedButton:
|
||||
size_hint: 1.5, None
|
||||
height: dp(40)
|
||||
on_press: root.dismiss()
|
||||
on_press: root.close_pop()
|
||||
|
@ -874,7 +859,6 @@ NavigationLayout:
|
|||
color: (1,1,1,1)
|
||||
halign: 'center'
|
||||
MDRaisedButton:
|
||||
size_hint: 2, None
|
||||
height: dp(40)
|
||||
MDLabel:
|
||||
font_style: 'H4'
|
||||
|
@ -965,7 +949,6 @@ NavigationLayout:
|
|||
|
||||
<MyaddDetailPopup>:
|
||||
id: myadd_popup
|
||||
size_hint : (None,None)
|
||||
height: 4.5*(myaddr_label.height+ my_add_btn.children[0].height)
|
||||
width :app.window_size[0] - app.window_size[0]/10
|
||||
background: './images/popup.jpeg'
|
||||
|
@ -1010,7 +993,6 @@ NavigationLayout:
|
|||
spacing:5
|
||||
orientation: 'horizontal'
|
||||
MDRaisedButton:
|
||||
size_hint: 2, None
|
||||
height: dp(40)
|
||||
on_press: root.send_message_from()
|
||||
MDLabel:
|
||||
|
@ -1020,7 +1002,6 @@ NavigationLayout:
|
|||
color: (1,1,1,1)
|
||||
halign: 'center'
|
||||
MDRaisedButton:
|
||||
size_hint: 1.5, None
|
||||
height: dp(40)
|
||||
on_press: root.dismiss()
|
||||
on_press: app.root.ids.scr_mngr.current = 'showqrcode'
|
||||
|
@ -1032,7 +1013,6 @@ NavigationLayout:
|
|||
color: (1,1,1,1)
|
||||
halign: 'center'
|
||||
MDRaisedButton:
|
||||
size_hint: 1.5, None
|
||||
height: dp(40)
|
||||
on_press: root.dismiss()
|
||||
on_press: root.close_pop()
|
||||
|
@ -1045,7 +1025,6 @@ NavigationLayout:
|
|||
|
||||
<AddbookDetailPopup>:
|
||||
id: addbook_popup
|
||||
size_hint : (None,None)
|
||||
height: 4*(add_label.height)
|
||||
width :app.window_size[0] - app.window_size[0]/10
|
||||
background: './images/popup.jpeg'
|
||||
|
@ -1092,7 +1071,6 @@ NavigationLayout:
|
|||
spacing:5
|
||||
orientation: 'horizontal'
|
||||
MDRaisedButton:
|
||||
size_hint: 2, None
|
||||
height: dp(40)
|
||||
on_press: root.send_message_to()
|
||||
MDLabel:
|
||||
|
@ -1102,7 +1080,6 @@ NavigationLayout:
|
|||
color: (1,1,1,1)
|
||||
halign: 'center'
|
||||
MDRaisedButton:
|
||||
size_hint: 1.5, None
|
||||
height: dp(40)
|
||||
font_size: '10sp'
|
||||
on_press: root.update_addbook_label(root.address)
|
||||
|
@ -1113,7 +1090,6 @@ NavigationLayout:
|
|||
color: (1,1,1,1)
|
||||
halign: 'center'
|
||||
MDRaisedButton:
|
||||
size_hint: 1.5, None
|
||||
height: dp(40)
|
||||
on_press: root.dismiss()
|
||||
on_press: root.close_pop()
|
||||
|
|
|
@ -29,7 +29,6 @@ class addressGenerator(StoppableThread):
|
|||
super(addressGenerator, self).stopThread()
|
||||
|
||||
def run(self):
|
||||
|
||||
while state.shutdown == 0:
|
||||
queueValue = queues.addressGeneratorQueue.get()
|
||||
nonceTrialsPerByte = 0
|
||||
|
@ -134,7 +133,7 @@ class addressGenerator(StoppableThread):
|
|||
ripe = RIPEMD160Hash(sha.digest()).digest()
|
||||
if (
|
||||
ripe[:numberOfNullBytesDemandedOnFrontOfRipeHash] ==
|
||||
'\x00' * numberOfNullBytesDemandedOnFrontOfRipeHash
|
||||
'\x00'.encode('utf-8') * numberOfNullBytesDemandedOnFrontOfRipeHash
|
||||
):
|
||||
break
|
||||
logger.info(
|
||||
|
@ -151,19 +150,20 @@ class addressGenerator(StoppableThread):
|
|||
# The user must have a pretty fast computer.
|
||||
# time.time() - startTime equaled zero.
|
||||
pass
|
||||
|
||||
address = encodeAddress(
|
||||
addressVersionNumber, streamNumber, ripe)
|
||||
|
||||
# An excellent way for us to store our keys
|
||||
# is in Wallet Import Format. Let us convert now.
|
||||
# https://en.bitcoin.it/wiki/Wallet_import_format
|
||||
privSigningKey = '\x80' + potentialPrivSigningKey
|
||||
privSigningKey = '\x80'.encode('utf-8') + potentialPrivSigningKey
|
||||
checksum = hashlib.sha256(hashlib.sha256(
|
||||
privSigningKey).digest()).digest()[0:4]
|
||||
privSigningKeyWIF = arithmetic.changebase(
|
||||
privSigningKey + checksum, 256, 58)
|
||||
|
||||
privEncryptionKey = '\x80' + potentialPrivEncryptionKey
|
||||
privEncryptionKey = '\x80'.encode('utf-8') + potentialPrivEncryptionKey
|
||||
checksum = hashlib.sha256(hashlib.sha256(
|
||||
privEncryptionKey).digest()).digest()[0:4]
|
||||
privEncryptionKeyWIF = arithmetic.changebase(
|
||||
|
|
|
@ -143,8 +143,8 @@ class singleCleaner(StoppableThread):
|
|||
|
||||
# inv/object tracking
|
||||
for connection in \
|
||||
BMConnectionPool().inboundConnections.values() + \
|
||||
BMConnectionPool().outboundConnections.values():
|
||||
list(BMConnectionPool().inboundConnections.values()) + \
|
||||
list(BMConnectionPool().outboundConnections.values()):
|
||||
connection.clean()
|
||||
|
||||
# discovery tracking
|
||||
|
|
|
@ -86,7 +86,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
|||
"""Process incoming header"""
|
||||
self.magic, self.command, self.payloadLength, self.checksum = \
|
||||
protocol.Header.unpack(self.read_buf[:protocol.Header.size])
|
||||
self.command = self.command.rstrip('\x00')
|
||||
self.command = self.command.rstrip('\x00'.encode('utf-8'))
|
||||
if self.magic != 0xE9BEB4D9:
|
||||
# skip 1 byte in order to sync
|
||||
self.set_state("bm_header", length=1)
|
||||
|
|
|
@ -328,8 +328,8 @@ class BMConnectionPool(object):
|
|||
|
||||
reaper = []
|
||||
for i in (
|
||||
self.inboundConnections.values() +
|
||||
self.outboundConnections.values()
|
||||
list(self.inboundConnections.values()) +
|
||||
list(self.outboundConnections.values())
|
||||
):
|
||||
minTx = time.time() - 20
|
||||
if i.fullyEstablished:
|
||||
|
@ -342,10 +342,10 @@ class BMConnectionPool(object):
|
|||
time.time() - i.lastTx)
|
||||
i.set_state("close")
|
||||
for i in (
|
||||
self.inboundConnections.values() +
|
||||
self.outboundConnections.values() +
|
||||
self.listeningSockets.values() +
|
||||
self.udpSockets.values()
|
||||
list(self.inboundConnections.values()) +
|
||||
list(self.outboundConnections.values()) +
|
||||
list(self.listeningSockets.values()) +
|
||||
list(self.udpSockets.values())
|
||||
):
|
||||
if not (i.accepting or i.connecting or i.connected):
|
||||
reaper.append(i)
|
||||
|
|
|
@ -7,7 +7,7 @@ from random import choice, sample, expovariate
|
|||
from threading import RLock
|
||||
from time import time
|
||||
|
||||
import network.connectionpool
|
||||
from network import connectionpool
|
||||
import state
|
||||
from debug import logging
|
||||
from queues import invQueue
|
||||
|
@ -182,8 +182,8 @@ class Dandelion(): # pylint: disable=old-style-class
|
|||
try:
|
||||
# random two connections
|
||||
self.stem = sample(
|
||||
connectionpool.BMConnectionPool(
|
||||
).outboundConnections.values(), MAX_STEMS)
|
||||
list(connectionpool.BMConnectionPool(
|
||||
).outboundConnections.values()), MAX_STEMS)
|
||||
# not enough stems available
|
||||
except ValueError:
|
||||
self.stem = connectionpool.BMConnectionPool(
|
||||
|
|
|
@ -362,7 +362,7 @@ class TCPServer(AdvancedDispatcher):
|
|||
"""TCP connection server for Bitmessage protocol"""
|
||||
|
||||
def __init__(self, host='127.0.0.1', port=8444):
|
||||
if not hasattr(self, '_map'):
|
||||
if not '_map' in dir(self):
|
||||
AdvancedDispatcher.__init__(self)
|
||||
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.set_reuse_addr()
|
||||
|
|
|
@ -94,9 +94,9 @@ def isBitSetWithinBitfield(fourByteString, n):
|
|||
def encodeHost(host):
|
||||
"""Encode a given host to be used in low-level socket operations"""
|
||||
if host.find('.onion') > -1:
|
||||
return '\xfd\x87\xd8\x7e\xeb\x43' + base64.b32decode(host.split(".")[0], True)
|
||||
return '\xfd\x87\xd8\x7e\xeb\x43'.encode('utf-8') + base64.b32decode(host.split(".")[0], True)
|
||||
elif host.find(':') == -1:
|
||||
return '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + \
|
||||
return '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF'.encode('utf-8') + \
|
||||
socket.inet_aton(host)
|
||||
return socket.inet_pton(socket.AF_INET6, host)
|
||||
|
||||
|
|
|
@ -39,11 +39,13 @@ def get_code_string(base):
|
|||
|
||||
def encode(val, base, minlen=0):
|
||||
code_string = get_code_string(base)
|
||||
result = ""
|
||||
result = str.encode(result)
|
||||
result = ''
|
||||
# result = str.encode(result)
|
||||
count = 0
|
||||
while val > 0:
|
||||
count += 1
|
||||
print(f'code_string[int(val) % base:int(val) % base + 1] -{code_string[int(val) % base:int(val) % base + 1]}')
|
||||
print(f'result-{result}')
|
||||
result = code_string[int(val) % base:int(val) % base + 1] + result
|
||||
val = int(val / base)
|
||||
if len(result) < minlen:
|
||||
|
@ -53,13 +55,12 @@ def encode(val, base, minlen=0):
|
|||
|
||||
def decode(string, base):
|
||||
code_string = get_code_string(base)
|
||||
string.decode()
|
||||
result = 0
|
||||
if base == 16:
|
||||
string = string.lower()
|
||||
while string:
|
||||
result *= base
|
||||
result += code_string.find(string.decode()[0])
|
||||
result += code_string.find(string[0])
|
||||
string = string[1:]
|
||||
return result
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ def reloadMyAddressHashes():
|
|||
keyfileSecure = checkSensitiveFilePermissions(state.appdata + 'keys.dat')
|
||||
hasEnabledKeys = False
|
||||
for addressInKeysFile in BMConfigParser().addresses():
|
||||
isEnabled = BMConfigParser().getboolean(addressInKeysFile, 'enabled')
|
||||
isEnabled = BMConfigParser().safeGet(addressInKeysFile, 'enabled')
|
||||
if isEnabled:
|
||||
hasEnabledKeys = True
|
||||
# status
|
||||
|
|
Reference in New Issue
Block a user