Skip to content

Commit 95990d8

Browse files
committed
Solved new address creations issues
1 parent c813f67 commit 95990d8

11 files changed

Lines changed: 28 additions & 50 deletions

File tree

src/addresses.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def encodeAddress(version, stream, ripe):
158158
raise Exception(
159159
'Programming error in encodeAddress: The length of'
160160
' a given ripe hash was not 20.')
161-
ripe = ripe.lstrip('\x00')
161+
ripe = ripe.lstrip('\x00'.encode('utf-8'))
162162

163163
storedBinaryData = encodeVarint(version) + encodeVarint(stream) + ripe
164164

@@ -264,7 +264,8 @@ def decodeAddress(address):
264264
return 'ripetoolong', 0, 0, ''
265265
elif len(embeddedRipeData) < 4:
266266
return 'ripetooshort', 0, 0, ''
267-
x00string = '\x00' * (20 - len(embeddedRipeData))
267+
x00string = '\x00'.encode('utf-8') * (20 - len(embeddedRipeData))
268+
268269
return status, addressVersionNumber, streamNumber, \
269270
x00string + embeddedRipeData
270271

src/bitmessagekivy/main.kv

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ NavigationLayout:
334334
BoxLayout:
335335
AnchorLayout:
336336
MDRaisedButton:
337-
size_hint: .6, .35
338337
height: dp(40)
339338
MDLabel:
340339
font_style: 'H4'
@@ -383,7 +382,6 @@ NavigationLayout:
383382
txt_input: txt_input
384383
rv: rv
385384
size : (890, 60)
386-
size_hint: 1,1
387385
MyTextInput:
388386
id: txt_input
389387
size_hint_y: None
@@ -414,7 +412,6 @@ NavigationLayout:
414412
spacing:50
415413
AnchorLayout:
416414
MDRaisedButton:
417-
size_hint: 1, None
418415
height: dp(40)
419416
on_press: root.reset_composer()
420417
MDLabel:
@@ -512,7 +509,6 @@ NavigationLayout:
512509
BoxLayout:
513510
AnchorLayout:
514511
MDRaisedButton:
515-
size_hint: .5, .35
516512
height: dp(40)
517513
on_press: app.root.ids.scr_mngr.current = 'random'
518514
MDLabel:
@@ -556,7 +552,6 @@ NavigationLayout:
556552
BoxLayout:
557553
AnchorLayout:
558554
MDRaisedButton:
559-
size_hint: .5, None
560555
height: dp(40)
561556
on_release: root.generateaddress(app)
562557
opposite_colors: True
@@ -586,7 +581,6 @@ NavigationLayout:
586581
BoxLayout:
587582
AnchorLayout:
588583
MDRaisedButton:
589-
size_hint: .6, .55
590584
height: dp(40)
591585
MDLabel:
592586
font_style: 'H4'
@@ -599,7 +593,6 @@ NavigationLayout:
599593
BoxLayout:
600594
AnchorLayout:
601595
MDRaisedButton:
602-
size_hint: .6, .55
603596
height: dp(40)
604597
MDLabel:
605598
font_style: 'H4'
@@ -612,7 +605,6 @@ NavigationLayout:
612605
BoxLayout:
613606
AnchorLayout:
614607
MDRaisedButton:
615-
size_hint: .6, .55
616608
height: dp(40)
617609
MDLabel:
618610
font_style: 'H4'
@@ -633,7 +625,6 @@ NavigationLayout:
633625
BoxLayout:
634626
MDCheckbox:
635627
id: chkbox
636-
size_hint: None, None
637628
size: dp(48), dp(64)
638629
active: True
639630
MDLabel:
@@ -718,7 +709,6 @@ NavigationLayout:
718709
Rectangle:
719710
pos: self.pos
720711
size: self.size
721-
size_hint: 1, None
722712
height: dp(40)
723713
on_press: root.get_available_credits(self)
724714
MDLabel:
@@ -763,7 +753,6 @@ NavigationLayout:
763753
Rectangle:
764754
pos: self.pos
765755
size: self.size
766-
size_hint: 1, None
767756
height: dp(40)
768757
MDLabel:
769758
font_style: 'H4'
@@ -807,7 +796,6 @@ NavigationLayout:
807796
Rectangle:
808797
pos: self.pos
809798
size: self.size
810-
size_hint: 1, None
811799
height: dp(40)
812800
MDLabel:
813801
font_style: 'H4'
@@ -819,7 +807,6 @@ NavigationLayout:
819807

820808
<GrashofPopup>:
821809
id: popup
822-
size_hint : (None,None)
823810
height: 2*(label.height + address.height) + 10
824811
width :app.window_size[0] - app.window_size[0]/10
825812
title: 'add contact\'s'
@@ -852,7 +839,6 @@ NavigationLayout:
852839
orientation: 'horizontal'
853840
MDRaisedButton:
854841
id: save_addr
855-
size_hint: 1.5, None
856842
height: dp(40)
857843
on_release:
858844
root.savecontact()
@@ -863,7 +849,6 @@ NavigationLayout:
863849
color: (1,1,1,1)
864850
halign: 'center'
865851
MDRaisedButton:
866-
size_hint: 1.5, None
867852
height: dp(40)
868853
on_press: root.dismiss()
869854
on_press: root.close_pop()
@@ -874,7 +859,6 @@ NavigationLayout:
874859
color: (1,1,1,1)
875860
halign: 'center'
876861
MDRaisedButton:
877-
size_hint: 2, None
878862
height: dp(40)
879863
MDLabel:
880864
font_style: 'H4'
@@ -965,7 +949,6 @@ NavigationLayout:
965949

966950
<MyaddDetailPopup>:
967951
id: myadd_popup
968-
size_hint : (None,None)
969952
height: 4.5*(myaddr_label.height+ my_add_btn.children[0].height)
970953
width :app.window_size[0] - app.window_size[0]/10
971954
background: './images/popup.jpeg'
@@ -1010,7 +993,6 @@ NavigationLayout:
1010993
spacing:5
1011994
orientation: 'horizontal'
1012995
MDRaisedButton:
1013-
size_hint: 2, None
1014996
height: dp(40)
1015997
on_press: root.send_message_from()
1016998
MDLabel:
@@ -1020,7 +1002,6 @@ NavigationLayout:
10201002
color: (1,1,1,1)
10211003
halign: 'center'
10221004
MDRaisedButton:
1023-
size_hint: 1.5, None
10241005
height: dp(40)
10251006
on_press: root.dismiss()
10261007
on_press: app.root.ids.scr_mngr.current = 'showqrcode'
@@ -1032,7 +1013,6 @@ NavigationLayout:
10321013
color: (1,1,1,1)
10331014
halign: 'center'
10341015
MDRaisedButton:
1035-
size_hint: 1.5, None
10361016
height: dp(40)
10371017
on_press: root.dismiss()
10381018
on_press: root.close_pop()
@@ -1045,7 +1025,6 @@ NavigationLayout:
10451025

10461026
<AddbookDetailPopup>:
10471027
id: addbook_popup
1048-
size_hint : (None,None)
10491028
height: 4*(add_label.height)
10501029
width :app.window_size[0] - app.window_size[0]/10
10511030
background: './images/popup.jpeg'
@@ -1092,7 +1071,6 @@ NavigationLayout:
10921071
spacing:5
10931072
orientation: 'horizontal'
10941073
MDRaisedButton:
1095-
size_hint: 2, None
10961074
height: dp(40)
10971075
on_press: root.send_message_to()
10981076
MDLabel:
@@ -1102,7 +1080,6 @@ NavigationLayout:
11021080
color: (1,1,1,1)
11031081
halign: 'center'
11041082
MDRaisedButton:
1105-
size_hint: 1.5, None
11061083
height: dp(40)
11071084
font_size: '10sp'
11081085
on_press: root.update_addbook_label(root.address)
@@ -1113,7 +1090,6 @@ NavigationLayout:
11131090
color: (1,1,1,1)
11141091
halign: 'center'
11151092
MDRaisedButton:
1116-
size_hint: 1.5, None
11171093
height: dp(40)
11181094
on_press: root.dismiss()
11191095
on_press: root.close_pop()

src/class_addressGenerator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def stopThread(self):
2929
super(addressGenerator, self).stopThread()
3030

3131
def run(self):
32-
3332
while state.shutdown == 0:
3433
queueValue = queues.addressGeneratorQueue.get()
3534
nonceTrialsPerByte = 0
@@ -134,7 +133,7 @@ def run(self):
134133
ripe = RIPEMD160Hash(sha.digest()).digest()
135134
if (
136135
ripe[:numberOfNullBytesDemandedOnFrontOfRipeHash] ==
137-
'\x00' * numberOfNullBytesDemandedOnFrontOfRipeHash
136+
'\x00'.encode('utf-8') * numberOfNullBytesDemandedOnFrontOfRipeHash
138137
):
139138
break
140139
logger.info(
@@ -151,19 +150,20 @@ def run(self):
151150
# The user must have a pretty fast computer.
152151
# time.time() - startTime equaled zero.
153152
pass
153+
154154
address = encodeAddress(
155155
addressVersionNumber, streamNumber, ripe)
156156

157157
# An excellent way for us to store our keys
158158
# is in Wallet Import Format. Let us convert now.
159159
# https://en.bitcoin.it/wiki/Wallet_import_format
160-
privSigningKey = '\x80' + potentialPrivSigningKey
160+
privSigningKey = '\x80'.encode('utf-8') + potentialPrivSigningKey
161161
checksum = hashlib.sha256(hashlib.sha256(
162162
privSigningKey).digest()).digest()[0:4]
163163
privSigningKeyWIF = arithmetic.changebase(
164164
privSigningKey + checksum, 256, 58)
165165

166-
privEncryptionKey = '\x80' + potentialPrivEncryptionKey
166+
privEncryptionKey = '\x80'.encode('utf-8') + potentialPrivEncryptionKey
167167
checksum = hashlib.sha256(hashlib.sha256(
168168
privEncryptionKey).digest()).digest()[0:4]
169169
privEncryptionKeyWIF = arithmetic.changebase(

src/class_singleCleaner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ def run(self): # pylint: disable=too-many-branches
143143

144144
# inv/object tracking
145145
for connection in \
146-
BMConnectionPool().inboundConnections.values() + \
147-
BMConnectionPool().outboundConnections.values():
146+
list(BMConnectionPool().inboundConnections.values()) + \
147+
list(BMConnectionPool().outboundConnections.values()):
148148
connection.clean()
149149

150150
# discovery tracking

src/network/bmproto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def state_bm_header(self):
8686
"""Process incoming header"""
8787
self.magic, self.command, self.payloadLength, self.checksum = \
8888
protocol.Header.unpack(self.read_buf[:protocol.Header.size])
89-
self.command = self.command.rstrip('\x00')
89+
self.command = self.command.rstrip('\x00'.encode('utf-8'))
9090
if self.magic != 0xE9BEB4D9:
9191
# skip 1 byte in order to sync
9292
self.set_state("bm_header", length=1)

src/network/connectionpool.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ def loop(self): # pylint: disable=too-many-branches,too-many-statements
328328

329329
reaper = []
330330
for i in (
331-
self.inboundConnections.values() +
332-
self.outboundConnections.values()
331+
list(self.inboundConnections.values()) +
332+
list(self.outboundConnections.values())
333333
):
334334
minTx = time.time() - 20
335335
if i.fullyEstablished:
@@ -342,10 +342,10 @@ def loop(self): # pylint: disable=too-many-branches,too-many-statements
342342
time.time() - i.lastTx)
343343
i.set_state("close")
344344
for i in (
345-
self.inboundConnections.values() +
346-
self.outboundConnections.values() +
347-
self.listeningSockets.values() +
348-
self.udpSockets.values()
345+
list(self.inboundConnections.values()) +
346+
list(self.outboundConnections.values()) +
347+
list(self.listeningSockets.values()) +
348+
list(self.udpSockets.values())
349349
):
350350
if not (i.accepting or i.connecting or i.connected):
351351
reaper.append(i)

src/network/dandelion.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from threading import RLock
88
from time import time
99

10-
import network.connectionpool
10+
from network import connectionpool
1111
import state
1212
from debug import logging
1313
from queues import invQueue
@@ -182,8 +182,8 @@ def reRandomiseStems(self):
182182
try:
183183
# random two connections
184184
self.stem = sample(
185-
connectionpool.BMConnectionPool(
186-
).outboundConnections.values(), MAX_STEMS)
185+
list(connectionpool.BMConnectionPool(
186+
).outboundConnections.values()), MAX_STEMS)
187187
# not enough stems available
188188
except ValueError:
189189
self.stem = connectionpool.BMConnectionPool(

src/network/tcp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ class TCPServer(AdvancedDispatcher):
362362
"""TCP connection server for Bitmessage protocol"""
363363

364364
def __init__(self, host='127.0.0.1', port=8444):
365-
if not hasattr(self, '_map'):
365+
if not '_map' in dir(self):
366366
AdvancedDispatcher.__init__(self)
367367
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
368368
self.set_reuse_addr()

src/protocol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ def isBitSetWithinBitfield(fourByteString, n):
9494
def encodeHost(host):
9595
"""Encode a given host to be used in low-level socket operations"""
9696
if host.find('.onion') > -1:
97-
return '\xfd\x87\xd8\x7e\xeb\x43' + base64.b32decode(host.split(".")[0], True)
97+
return '\xfd\x87\xd8\x7e\xeb\x43'.encode('utf-8') + base64.b32decode(host.split(".")[0], True)
9898
elif host.find(':') == -1:
99-
return '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + \
99+
return '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF'.encode('utf-8') + \
100100
socket.inet_aton(host)
101101
return socket.inet_pton(socket.AF_INET6, host)
102102

src/pyelliptic/arithmetic.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ def get_code_string(base):
3939

4040
def encode(val, base, minlen=0):
4141
code_string = get_code_string(base)
42-
result = ""
43-
result = str.encode(result)
42+
result = ''
43+
# result = str.encode(result)
4444
count = 0
4545
while val > 0:
4646
count += 1
47+
print(f'code_string[int(val) % base:int(val) % base + 1] -{code_string[int(val) % base:int(val) % base + 1]}')
48+
print(f'result-{result}')
4749
result = code_string[int(val) % base:int(val) % base + 1] + result
4850
val = int(val / base)
4951
if len(result) < minlen:
@@ -53,13 +55,12 @@ def encode(val, base, minlen=0):
5355

5456
def decode(string, base):
5557
code_string = get_code_string(base)
56-
string.decode()
5758
result = 0
5859
if base == 16:
5960
string = string.lower()
6061
while string:
6162
result *= base
62-
result += code_string.find(string.decode()[0])
63+
result += code_string.find(string[0])
6364
string = string[1:]
6465
return result
6566

0 commit comments

Comments
 (0)