-
Notifications
You must be signed in to change notification settings - Fork 11
/
qtdialogs.py
15199 lines (12327 loc) · 605 KB
/
qtdialogs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: UTF-8 -*-
################################################################################
# #
# Copyright (C) 2011-2015, Armory Technologies, Inc. #
# Distributed under the GNU Affero General Public License (AGPL v3) #
# See LICENSE or http://www.gnu.org/licenses/agpl.html #
# #
################################################################################
import functools
import shutil
import socket
import sys
import time
from zipfile import ZipFile, ZIP_DEFLATED
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from armoryengine.ALL import *
from armorycolors import Colors, htmlColor
from armorymodels import *
import qrc_img_resources
from qtdefines import *
from armoryengine.PyBtcAddress import calcWalletIDFromRoot
from announcefetch import DEFAULT_MIN_PRIORITY
from ui.UpgradeDownloader import UpgradeDownloaderDialog
from armoryengine.MultiSigUtils import calcLockboxID, createLockboxEntryStr,\
LBPREFIX, isBareLockbox, isP2SHLockbox
from ui.MultiSigModels import LockboxDisplayModel, LockboxDisplayProxy,\
LOCKBOXCOLS
from armoryengine.PyBtcWalletRecovery import RECOVERMODE
NO_CHANGE = 'NoChange'
MIN_PASSWD_WIDTH = lambda obj: tightSizeStr(obj, '*' * 16)[0]
STRETCH = 'Stretch'
CLICKED = 'clicked()'
BACKUP_TYPE_135A = '1.35a'
BACKUP_TYPE_135C = '1.35c'
BACKUP_TYPE_0_TEXT = tr('Version 0 (from script, 9 lines)')
BACKUP_TYPE_135a_TEXT = tr('Version 1.35a (5 lines Unencrypted)')
BACKUP_TYPE_135a_SP_TEXT = tr('Version 1.35a (5 lines + SecurePrint™)')
BACKUP_TYPE_135c_TEXT = tr('Version 1.35c (3 lines Unencrypted)')
BACKUP_TYPE_135c_SP_TEXT = tr('Version 1.35c (3 lines + SecurePrint™)')
MAX_QR_SIZE = 198
MAX_SATOSHIS = 2100000000000000
################################################################################
class DlgUnlockWallet(ArmoryDialog):
def __init__(self, wlt, parent=None, main=None, unlockMsg='Unlock Wallet', \
returnResult=False, returnPassphrase=False):
super(DlgUnlockWallet, self).__init__(parent, main)
self.wlt = wlt
self.returnResult = returnResult
self.returnPassphrase = returnPassphrase
##### Upper layout
lblDescr = QLabel("Enter your passphrase to unlock this wallet")
lblPasswd = QLabel("Passphrase:")
self.edtPasswd = QLineEdit()
self.edtPasswd.setEchoMode(QLineEdit.Password)
self.edtPasswd.setMinimumWidth(MIN_PASSWD_WIDTH(self))
self.edtPasswd.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
self.btnAccept = QPushButton("Unlock")
self.btnCancel = QPushButton("Cancel")
self.connect(self.btnAccept, SIGNAL(CLICKED), self.acceptPassphrase)
self.connect(self.btnCancel, SIGNAL(CLICKED), self.reject)
buttonBox = QDialogButtonBox()
buttonBox.addButton(self.btnAccept, QDialogButtonBox.AcceptRole)
buttonBox.addButton(self.btnCancel, QDialogButtonBox.RejectRole)
layoutUpper = QGridLayout()
layoutUpper.addWidget(lblDescr, 1, 0, 1, 2)
layoutUpper.addWidget(lblPasswd, 2, 0, 1, 1)
layoutUpper.addWidget(self.edtPasswd, 2, 1, 1, 1)
self.frmUpper = QFrame()
self.frmUpper.setLayout(layoutUpper)
##### Lower layout
# Add scrambled keyboard (EN-US only)
ttipScramble = self.main.createToolTipWidget(\
tr('Using a visual keyboard to enter your passphrase '
'protects you against simple keyloggers. Scrambling '
'makes it difficult to use, but prevents even loggers '
'that record mouse clicks.'))
self.createKeyButtons()
self.rdoScrambleNone = QRadioButton(tr('Regular Keyboard'))
self.rdoScrambleLite = QRadioButton(tr('Scrambled (Simple)'))
self.rdoScrambleFull = QRadioButton(tr('Scrambled (Dynamic)'))
btngrp = QButtonGroup(self)
btngrp.addButton(self.rdoScrambleNone)
btngrp.addButton(self.rdoScrambleLite)
btngrp.addButton(self.rdoScrambleFull)
btngrp.setExclusive(True)
defaultScramble = self.main.getSettingOrSetDefault('ScrambleDefault', 0)
if defaultScramble == 0:
self.rdoScrambleNone.setChecked(True)
elif defaultScramble == 1:
self.rdoScrambleLite.setChecked(True)
elif defaultScramble == 2:
self.rdoScrambleFull.setChecked(True)
self.connect(self.rdoScrambleNone, SIGNAL(CLICKED), self.changeScramble)
self.connect(self.rdoScrambleLite, SIGNAL(CLICKED), self.changeScramble)
self.connect(self.rdoScrambleFull, SIGNAL(CLICKED), self.changeScramble)
btnRowFrm = makeHorizFrame([self.rdoScrambleNone, \
self.rdoScrambleLite, \
self.rdoScrambleFull, \
STRETCH])
self.layoutKeyboard = QGridLayout()
self.frmKeyboard = QFrame()
self.frmKeyboard.setLayout(self.layoutKeyboard)
showOSD = self.main.getSettingOrSetDefault('KeybdOSD', False)
self.layoutLower = QGridLayout()
self.layoutLower.addWidget(btnRowFrm , 0, 0)
self.layoutLower.addWidget(self.frmKeyboard , 1, 0)
self.frmLower = QFrame()
self.frmLower.setLayout(self.layoutLower)
self.frmLower.setVisible(showOSD)
##### Expand button
self.btnShowOSD = QPushButton(tr('Show Keyboard >>>'))
self.btnShowOSD.setCheckable(True)
self.btnShowOSD.setChecked(showOSD)
if showOSD:
self.toggleOSD()
self.connect(self.btnShowOSD, SIGNAL('toggled(bool)'), self.toggleOSD)
frmAccept = makeHorizFrame([self.btnShowOSD, ttipScramble, STRETCH, buttonBox])
##### Complete Layout
layout = QVBoxLayout()
layout.addWidget(self.frmUpper)
layout.addWidget(frmAccept)
layout.addWidget(self.frmLower)
self.setLayout(layout)
self.setWindowTitle(unlockMsg + ' - ' + wlt.uniqueIDB58)
# Add scrambled keyboard
self.layout().setSizeConstraint(QLayout.SetFixedSize)
self.changeScramble()
self.redrawKeys()
#############################################################################
def toggleOSD(self, *args):
isChk = self.btnShowOSD.isChecked()
self.main.settings.set('KeybdOSD', isChk)
self.frmLower.setVisible(isChk)
if isChk:
self.btnShowOSD.setText(tr('Hide Keyboard <<<'))
else:
self.btnShowOSD.setText(tr('Show Keyboard >>>'))
#############################################################################
def createKeyboardKeyButton(self, keyLow, keyUp, defRow, special=None):
theBtn = LetterButton(keyLow, keyUp, defRow, special, self.edtPasswd, self)
self.connect(theBtn, SIGNAL(CLICKED), theBtn.insertLetter)
theBtn.setMaximumWidth(40)
return theBtn
#############################################################################
def redrawKeys(self):
for btn in self.btnList:
btn.setText(btn.upper if self.btnShift.isChecked() else btn.lower)
self.btnShift.setText(tr('SHIFT'))
self.btnSpace.setText(tr('SPACE'))
self.btnDelete.setText(tr('DEL'))
#############################################################################
def deleteKeyboard(self):
for btn in self.btnList:
btn.setParent(None)
del btn
self.btnList = []
self.btnShift.setParent(None)
self.btnSpace.setParent(None)
self.btnDelete.setParent(None)
del self.btnShift
del self.btnSpace
del self.btnDelete
del self.frmKeyboard
del self.layoutKeyboard
#############################################################################
def createKeyButtons(self):
# TODO: Add some locale-agnostic method here, that could replace
# the letter arrays with something more appropriate for non en-us
self.letLower = r"`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./"
self.letUpper = r'~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?'
self.letRows = r'11111111111112222222222222333333333334444444444'
self.letPairs = zip(self.letLower, self.letUpper, self.letRows)
self.btnList = []
for l, u, r in zip(self.letLower, self.letUpper, self.letRows):
if l == '7':
# Because QPushButtons interpret ampersands as special characters
u = 2 * u
if l.isdigit():
self.btnList.append(self.createKeyboardKeyButton('#' + l, u, int(r)))
else:
self.btnList.append(self.createKeyboardKeyButton(l, u, int(r)))
# Add shift and space keys
self.btnShift = self.createKeyboardKeyButton('', '', 5, 'shift')
self.btnSpace = self.createKeyboardKeyButton(' ', ' ', 5, 'space')
self.btnDelete = self.createKeyboardKeyButton(' ', ' ', 5, 'delete')
self.btnShift.setCheckable(True)
self.btnShift.setChecked(False)
#############################################################################
def reshuffleKeys(self):
if self.rdoScrambleFull.isChecked():
self.changeScramble()
#############################################################################
def changeScramble(self):
self.deleteKeyboard()
self.frmKeyboard = QFrame()
self.layoutKeyboard = QGridLayout()
self.createKeyButtons()
if self.rdoScrambleNone.isChecked():
opt = 0
prevRow = 1
col = 0
for btn in self.btnList:
row = btn.defRow
if not row == prevRow:
col = 0
if row > 3 and col == 0:
col += 1
prevRow = row
self.layoutKeyboard.addWidget(btn, row, col)
col += 1
self.layoutKeyboard.addWidget(self.btnShift, self.btnShift.defRow, 0, 1, 3)
self.layoutKeyboard.addWidget(self.btnSpace, self.btnSpace.defRow, 4, 1, 5)
self.layoutKeyboard.addWidget(self.btnDelete, self.btnDelete.defRow, 11, 1, 2)
self.btnShift.setMaximumWidth(1000)
self.btnSpace.setMaximumWidth(1000)
self.btnDelete.setMaximumWidth(1000)
elif self.rdoScrambleLite.isChecked():
opt = 1
nchar = len(self.btnList)
rnd = SecureBinaryData().GenerateRandom(2 * nchar).toBinStr()
newBtnList = [[self.btnList[i], rnd[2 * i:2 * (i + 1)]] for i in range(nchar)]
newBtnList.sort(key=lambda x: x[1])
prevRow = 0
col = 0
for i, btn in enumerate(newBtnList):
row = i / 12
if not row == prevRow:
col = 0
prevRow = row
self.layoutKeyboard.addWidget(btn[0], row, col)
col += 1
self.layoutKeyboard.addWidget(self.btnShift, self.btnShift.defRow, 0, 1, 3)
self.layoutKeyboard.addWidget(self.btnSpace, self.btnSpace.defRow, 4, 1, 5)
self.layoutKeyboard.addWidget(self.btnDelete, self.btnDelete.defRow, 10, 1, 2)
self.btnShift.setMaximumWidth(1000)
self.btnSpace.setMaximumWidth(1000)
self.btnDelete.setMaximumWidth(1000)
elif self.rdoScrambleFull.isChecked():
opt = 2
extBtnList = self.btnList[:]
extBtnList.extend([self.btnShift, self.btnSpace])
nchar = len(extBtnList)
rnd = SecureBinaryData().GenerateRandom(2 * nchar).toBinStr()
newBtnList = [[extBtnList[i], rnd[2 * i:2 * (i + 1)]] for i in range(nchar)]
newBtnList.sort(key=lambda x: x[1])
prevRow = 0
col = 0
for i, btn in enumerate(newBtnList):
row = i / 12
if not row == prevRow:
col = 0
prevRow = row
self.layoutKeyboard.addWidget(btn[0], row, col)
col += 1
self.layoutKeyboard.addWidget(self.btnDelete, self.btnDelete.defRow - 1, 11, 1, 2)
self.btnShift.setMaximumWidth(40)
self.btnSpace.setMaximumWidth(40)
self.btnDelete.setMaximumWidth(40)
self.frmKeyboard.setLayout(self.layoutKeyboard)
self.layoutLower.addWidget(self.frmKeyboard, 1, 0)
self.main.settings.set('ScrambleDefault', opt)
self.redrawKeys()
#############################################################################
def acceptPassphrase(self):
self.securePassphrase = SecureBinaryData(str(self.edtPasswd.text()))
self.edtPasswd.setText('')
if self.returnResult:
self.accept()
return
try:
if self.returnPassphrase == False:
unlockProgress = DlgProgress(self, self.main, HBar=1,
Title=tr("Unlocking Wallet"))
unlockProgress.exec_(self.wlt.unlock, securePassphrase=self.securePassphrase)
self.securePassphrase.destroy()
else:
if self.wlt.verifyPassphrase(self.securePassphrase) == False:
raise PassphraseError
self.accept()
except PassphraseError:
QMessageBox.critical(self, tr('Invalid Passphrase'), \
tr('That passphrase is not correct!'), QMessageBox.Ok)
self.securePassphrase.destroy()
self.edtPasswd.setText('')
return
#############################################################################
class LetterButton(QPushButton):
def __init__(self, Low, Up, Row, Spec, edtTarget, parent):
super(LetterButton, self).__init__('')
self.lower = Low
self.upper = Up
self.defRow = Row
self.special = Spec
self.target = edtTarget
self.parent = parent
if self.special:
super(LetterButton, self).setFont(GETFONT('Var', 8))
else:
super(LetterButton, self).setFont(GETFONT('Fixed', 10))
if self.special == 'space':
self.setText(tr('SPACE'))
self.lower = ' '
self.upper = ' '
self.special = 5
elif self.special == 'shift':
self.setText(tr('SHIFT'))
self.special = 5
self.insertLetter = self.pressShift
elif self.special == 'delete':
self.setText(tr('DEL'))
self.special = 5
self.insertLetter = self.pressBackspace
def insertLetter(self):
currPwd = str(self.parent.edtPasswd.text())
insChar = self.upper if self.parent.btnShift.isChecked() else self.lower
if len(insChar) == 2 and insChar.startswith('#'):
insChar = insChar[1]
self.parent.edtPasswd.setText(currPwd + insChar)
self.parent.reshuffleKeys()
def pressShift(self):
self.parent.redrawKeys()
def pressBackspace(self):
currPwd = str(self.parent.edtPasswd.text())
if len(currPwd) > 0:
self.parent.edtPasswd.setText(currPwd[:-1])
self.parent.redrawKeys()
################################################################################
class DlgGenericGetPassword(ArmoryDialog):
def __init__(self, descriptionStr, parent=None, main=None):
super(DlgGenericGetPassword, self).__init__(parent, main)
lblDescr = QRichLabel(descriptionStr)
lblPasswd = QRichLabel(tr("Password:"))
self.edtPasswd = QLineEdit()
self.edtPasswd.setEchoMode(QLineEdit.Password)
self.edtPasswd.setMinimumWidth(MIN_PASSWD_WIDTH(self))
self.edtPasswd.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
self.btnAccept = QPushButton(tr("OK"))
self.btnCancel = QPushButton(tr("Cancel"))
self.connect(self.btnAccept, SIGNAL(CLICKED), self.accept)
self.connect(self.btnCancel, SIGNAL(CLICKED), self.reject)
buttonBox = QDialogButtonBox()
buttonBox.addButton(self.btnAccept, QDialogButtonBox.AcceptRole)
buttonBox.addButton(self.btnCancel, QDialogButtonBox.RejectRole)
layout = QGridLayout()
layout.addWidget(lblDescr, 1, 0, 1, 2)
layout.addWidget(lblPasswd, 2, 0, 1, 1)
layout.addWidget(self.edtPasswd, 2, 1, 1, 1)
layout.addWidget(buttonBox, 3, 1, 1, 2)
self.setLayout(layout)
self.setWindowTitle(tr('Enter Password'))
self.setWindowIcon(QIcon(self.main.iconfile))
################################################################################
class DlgBugReport(ArmoryDialog):
def __init__(self, parent=None, main=None):
super(DlgBugReport, self).__init__(parent, main)
tsPage = 'https://bitcoinarmory.com/troubleshooting'
faqPage = 'https://bitcoinarmory.com/faq'
lblDescr = QRichLabel(tr("""
<b><u>Send a bug report to the Armory team</u></b>
<br><br>
If you are having difficulties with Armory, you should first visit
our <a href="%(tsurl)s">troubleshooting page</a> and our
<a href="%(faqurl)s">FAQ page</a> which describe solutions to
many common problems.
<br><br>
If you do not find the answer to your problem on those pages,
please describe it in detail below, and any steps taken to
reproduce the problem. The more information you provide, the
more likely we will be able to help you.
<br><br>
<b><font color="%(color)s">Note:</font></b> Please keep in mind we
are a small open-source company, and do not have a formal customer
support department. We will do our best to help you, but cannot
respond to everyone!""") \
% {'tsurl' : tsPage, 'faqurl' : faqPage, 'color' :htmlColor('TextBlue')})
self.chkNoLog = QCheckBox(tr('Do not send log file with report'))
self.chkNoLog.setChecked(False)
self.btnMoreInfo = QLabelButton(tr('Privacy Info'))
self.connect(self.btnMoreInfo, SIGNAL(CLICKED), \
self.main.logFilePrivacyWarning)
self.noLogWarn = QRichLabel(tr("""
<font color="%(color)s">You are unlikely to get a response unless you
provide a log file and a reasonable description with your support
request.""") % { 'color' : htmlColor('TextWarn') })
self.noLogWarn.setVisible(False)
self.connect(self.chkNoLog, SIGNAL('toggled(bool)'), \
self.noLogWarn.setVisible)
self.lblEmail = QRichLabel(tr('Email Address:'))
self.edtEmail = QLineEdit()
self.edtEmail.setMaxLength(100)
self.lblSubject = QRichLabel(tr('Subject:'))
self.edtSubject = QLineEdit()
self.edtSubject.setMaxLength(64)
self.edtSubject.setText(tr("Bug Report"))
self.txtDescr = QTextEdit()
self.txtDescr.setFont(GETFONT('Fixed', 9))
w,h = tightSizeNChar(self, 80)
self.txtDescr.setMinimumWidth(w)
self.txtDescr.setMinimumHeight(4*h)
self.lblOS = QRichLabel(tr("""
Note: if you are using this computer to report an Armory problem
on another computer, please include the operating system of the
other computer and the version of Armory it is running."""))
self.btnSubmit = QPushButton(tr('Submit Report'))
self.btnCancel = QPushButton(tr('Cancel'))
self.btnbox = QDialogButtonBox()
self.btnbox.addButton(self.btnSubmit, QDialogButtonBox.AcceptRole)
self.btnbox.addButton(self.btnCancel, QDialogButtonBox.RejectRole)
self.connect(self.btnSubmit, SIGNAL(CLICKED), self.submitReport)
self.connect(self.btnCancel, SIGNAL(CLICKED), self, SLOT('reject()'))
armoryver = getVersionString(BTCARMORY_VERSION)
lblDetect = QRichLabel( tr("""
<b>Detected:</b> %(osname)s (%(osvariant)s) / %(mem)0.2f GB RAM / Armory version %(ver)s<br>
<font size=2>(this data will be submitted automatically with the
report)</font>""") % \
{ 'osname' : OS_NAME, 'osvariant' : OS_VARIANT[0], 'mem' : SystemSpecs.Memory, 'ver' : armoryver})
layout = QGridLayout()
i = -1
i += 1
layout.addWidget(lblDescr, i,0, 1,2)
i += 1
layout.addWidget(HLINE(), i,0, 1,2)
i += 1
layout.addWidget(lblDetect, i,0, 1,2)
i += 1
layout.addWidget(HLINE(), i,0, 1,2)
i += 1
layout.addWidget(self.lblEmail, i,0, 1,1)
layout.addWidget(self.edtEmail, i,1, 1,1)
i += 1
layout.addWidget(self.lblSubject, i,0, 1,1)
layout.addWidget(self.edtSubject, i,1, 1,1)
i += 1
layout.addWidget(QLabel(tr("Description of problem:")), i,0, 1,2)
i += 1
layout.addWidget(self.txtDescr, i,0, 1,2)
i += 1
frmchkbtn = makeHorizFrame([self.chkNoLog, self.btnMoreInfo, 'Stretch'])
layout.addWidget(frmchkbtn, i,0, 1,2)
i += 1
layout.addWidget(self.noLogWarn, i,0, 1,2)
i += 1
layout.addWidget(self.btnbox, i,0, 1,2)
self.setLayout(layout)
self.setWindowTitle(tr('Submit a Bug Report'))
self.setWindowIcon(QIcon(self.main.iconfile))
#############################################################################
def submitReport(self):
if self.main.getUserAgreeToPrivacy(True):
self.userAgreedToPrivacyPolicy = True
else:
return
emailAddr = unicode(self.edtEmail.text()).strip()
emailLen = lenBytes(emailAddr)
subjectText = unicode(self.edtSubject.text()).strip()
subjectLen = lenBytes(subjectText)
description = unicode(self.txtDescr.toPlainText()).strip()
descrLen = lenBytes(description)
if emailLen == 0 or not '@' in emailAddr:
reply = MsgBoxCustom(MSGBOX.Warning, tr('Missing Email'), tr("""
You must supply a valid email address so we can follow up on your
request."""), \
noStr=tr('Go Back'), yesStr=tr('Submit without Email'))
if not reply:
return
else:
emailAddr = '<NO EMAIL SUPPPLIED>'
if descrLen < 10:
QMessageBox.warning(self, tr('Empty Description'), tr("""
You must describe what problem you are having, and any steps
to reproduce the problem. The Armory team cannot look for
problems in the log file if it doesn't know what those problems
are!."""), QMessageBox.Ok)
return
maxDescr = 16384
if descrLen > maxDescr:
reply = MsgBoxCustom(MSGBOX.Warning, tr('Long Description'), tr("""
You have exceeded the maximum size of the description that can
be submitted to our ticket system, which is %(bytes)d bytes.
If you click "Continue", the last %(last)s bytes of your description
will be removed before sending.""") % { 'bytes' : maxDescr, 'last' : descrLen-maxDescr}, \
noStr=tr('Go Back'), yesStr=tr('Continue'))
if not reply:
return
else:
description = unicode_truncate(description, maxDescr)
# This is a unique-but-not-traceable ID, to simply match users to log files
uniqID = binary_to_base58(hash256(USER_HOME_DIR)[:4])
dateStr = unixTimeToFormatStr(RightNow(), '%Y%m%d_%H%M')
osvariant = OS_VARIANT[0] if OS_MACOSX else '-'.join(OS_VARIANT)
reportMap = {}
reportMap['uniqID'] = uniqID
reportMap['OSmajor'] = OS_NAME
reportMap['OSvariant'] = osvariant
reportMap['ArmoryVer'] = getVersionString(BTCARMORY_VERSION)
reportMap['TotalRAM'] = '%0.2f' % SystemSpecs.Memory
reportMap['isAmd64'] = str(SystemSpecs.IsX64).lower()
reportMap['userEmail'] = emailAddr
reportMap['userSubject'] = subjectText
reportMap['userDescr'] = description
reportMap['userTime'] = unixTimeToFormatStr(RightNow())
reportMap['userTimeUTC'] = unixTimeToFormatStr(RightNowUTC())
reportMap['agreedPrivacy'] = str(self.userAgreedToPrivacyPolicy)
combinedLogName = 'armory_log_%s_%s.txt' % (uniqID, dateStr)
combinedLogPath = os.path.join(ARMORY_HOME_DIR, combinedLogName)
self.main.saveCombinedLogFile(combinedLogPath)
if self.chkNoLog.isChecked():
reportMap['fileLog'] = '<NO LOG FILE SUBMITTED>'
else:
with open(combinedLogPath, 'r') as f:
reportMap['fileLog'] = f.read()
LOGDEBUG('Sending the following dictionary of values to server')
for key,val in reportMap.iteritems():
if key=='fileLog':
LOGDEBUG(key.ljust(12) + ': ' + binary_to_hex(sha256(val)))
else:
LOGDEBUG(key.ljust(12) + ': ' + val)
expectedResponseMap = {}
expectedResponseMap['logHash'] = binary_to_hex(sha256(reportMap['fileLog']))
try:
import urllib3
http = urllib3.PoolManager()
headers = urllib3.make_headers('ArmoryBugReportWindowNotABrowser')
response = http.request('POST', BUG_REPORT_URL, reportMap, headers)
responseMap = ast.literal_eval(response._body)
LOGINFO('-'*50)
LOGINFO('Response JSON:')
for key,val in responseMap.iteritems():
LOGINFO(key.ljust(12) + ': ' + str(val))
LOGINFO('-'*50)
LOGINFO('Expected JSON:')
for key,val in expectedResponseMap.iteritems():
LOGINFO(key.ljust(12) + ': ' + str(val))
LOGDEBUG('Connection info:')
LOGDEBUG(' status: ' + str(response.status))
LOGDEBUG(' version: ' + str(response.version))
LOGDEBUG(' reason: ' + str(response.reason))
LOGDEBUG(' strict: ' + str(response.strict))
if responseMap==expectedResponseMap:
LOGINFO('Server verified receipt of log file')
cemail = 'contact@bitcoinarmory.com'
QMessageBox.information(self, tr('Submitted!'), tr("""
<b>Your report was submitted successfully!</b>
<br><br>
You should receive and email shortly from our support system.
If you do not receive it, you should follow up your request
with an email to <a href="%(url)s">%(url)s</a>. If you do, please
attach the following file to your email:
<br><br>
%(path)s
<br><br>
Please be aware that the team receives lots of reports,
so it may take a few days for the team to get back to
you.""") % {'url' : cemail, 'path' : combinedLogPath}, QMessageBox.Ok)
self.accept()
else:
raise ConnectionError('Failed to send bug report')
except:
LOGEXCEPT('Failed:')
bugpage = 'https://bitcoinarmory.com/support/'
QMessageBox.information(self, tr('Submitted!'), tr("""
There was a problem submitting your bug report. It is recommended
that you submit this information through our webpage instead:
<br><br>
<a href="%(url)s">%(url)s</a>""") % { 'url' : bugpage }, QMessageBox.Ok)
self.reject()
################################################################################
# Hack! We need to replicate the DlgBugReport... but to be as safe as
# possible for 0.91.1, we simply duplicate the dialog and modify directly.
# TODO: There's definitely a way to make DlgBugReport more generic so that
# both these contexts can be handled by it.
class DlgInconsistentWltReport(ArmoryDialog):
def __init__(self, parent, main, logPathList):
super(DlgInconsistentWltReport, self).__init__(parent, main)
QMessageBox.critical(self, tr('Inconsistent Wallet!'), tr("""
<font color="%s" size=4><b><u>Important:</u> Wallet Consistency
Issues Detected!</b></font>
<br><br>
Armory now detects certain kinds of hardware errors, and one
or more of your wallets
was flagged. The consistency logs need to be analyzed by the
Armory team to determine if any further action is required.
<br><br>
<b>This warning will pop up every time you start Armory until
the wallet is fixed</b>""") % (htmlColor('TextWarn')),
QMessageBox.Ok)
# logPathList is [wltID, corruptFolder] pairs
self.logPathList = logPathList[:]
walletList = [self.main.walletMap[wid] for wid,folder in logPathList]
getWltStr = lambda w: '<b>Wallet "%s" (%s)</b>' % \
(w.labelName, w.uniqueIDB58)
if len(logPathList) == 1:
wltDispStr = getWltStr(walletList[0]) + ' is'
else:
strList = [getWltStr(w) for w in walletList]
wltDispStr = ', '.join(strList[:-1]) + ' and ' + strList[-1] + ' are '
lblTopDescr = QRichLabel(tr("""
<b><u><font color="%s" size=4>Submit Wallet Analysis Logs for
Review</font></u></b><br>""") % htmlColor('TextWarn'),
hAlign=Qt.AlignHCenter)
#too complex to tr() right now
lblDescr = QRichLabel(("""
Armory has detected that %s inconsistent,
possibly due to hardware errors out of our control. It <u>strongly
recommended</u> you submit the wallet logs to the Armory team
for review. Until you hear back from an Armory representative,
we recommend:
<ul>
<li><b>Do not delete any data in your Armory home directory</b></li>
<li><b>Do not send or receive any funds with the affected
wallet(s)</b></li>
<li><b>Create a backup of the wallet analysis logs</b></li>
</ul>
""") % (wltDispStr))
self.chkIncludeReg = QCheckBox(tr("""Include all log files"""))
self.chkIncludeWOW = QCheckBox(tr("""Include watch-only
wallet""", "Include watch-only wallets", len(walletList)))
self.chkIncludeWOW.setChecked(False)
self.chkIncludeReg.setChecked(True)
self.btnMoreInfo = QLabelButton('Privacy Warning')
self.connect(self.btnMoreInfo, SIGNAL(CLICKED), \
self.main.logFileTriplePrivacyWarning)
btnBackupLogs = QPushButton(tr("Save backup of log files"))
self.connect(btnBackupLogs, SIGNAL('clicked()'), self.doBackupLogs)
frmBackup = makeHorizFrame(['Stretch', btnBackupLogs, 'Stretch'])
self.lblEmail = QRichLabel(tr('Email Address:'))
self.edtEmail = QLineEdit()
self.edtEmail.setMaxLength(100)
self.lblSubject = QRichLabel(tr('Subject:'))
self.edtSubject = QLineEdit()
self.edtSubject.setMaxLength(64)
self.edtSubject.setText("Wallet Consistency Logs")
self.txtDescr = QTextEdit()
self.txtDescr.setFont(GETFONT('Fixed', 9))
w,h = tightSizeNChar(self, 80)
self.txtDescr.setMinimumWidth(w)
self.txtDescr.setMinimumHeight(int(2.5*h))
self.btnSubmit = QPushButton(tr('Submit Data to ATI'))
self.btnCancel = QPushButton(tr('Cancel'))
self.btnbox = QDialogButtonBox()
self.btnbox.addButton(self.btnSubmit, QDialogButtonBox.AcceptRole)
self.btnbox.addButton(self.btnCancel, QDialogButtonBox.RejectRole)
self.connect(self.btnSubmit, SIGNAL(CLICKED), self.submitReport)
self.connect(self.btnCancel, SIGNAL(CLICKED), self, SLOT('reject()'))
armoryver = getVersionString(BTCARMORY_VERSION)
lblDetect = QRichLabel( tr("""
<b>Detected:</b> %(osname)s (%(osvariant)s) / %(mem)0.2f GB RAM / Armory version %(ver)s<br>
<font size=2>(this data will be included with the data
submission""") % \
{ 'osname' : OS_NAME, 'osvariant' : OS_VARIANT[0], 'mem' : SystemSpecs.Memory, 'ver' : armoryver})
layout = QGridLayout()
i = -1
i += 1
layout.addWidget(lblTopDescr, i,0, 1,2)
i += 1
layout.addWidget(lblDescr, i,0, 1,2)
i += 1
layout.addWidget(frmBackup, i,0, 1,2)
i += 1
layout.addWidget(HLINE(), i,0, 1,2)
i += 1
layout.addWidget(self.lblEmail, i,0, 1,1)
layout.addWidget(self.edtEmail, i,1, 1,1)
i += 1
layout.addWidget(self.lblSubject, i,0, 1,1)
layout.addWidget(self.edtSubject, i,1, 1,1)
i += 1
layout.addWidget(QLabel(tr("Additional Info:")), i,0, 1,2)
i += 1
layout.addWidget(self.txtDescr, i,0, 1,2)
i += 1
frmChkBtnRL = makeHorizFrame([self.chkIncludeReg,
self.chkIncludeWOW,
self.btnMoreInfo,])
layout.addWidget(frmChkBtnRL, i,0, 1,2)
i += 1
layout.addWidget(self.btnbox, i,0, 1,2)
self.setLayout(layout)
self.setWindowTitle(tr('Send Wallet Logs to ATI'))
self.setWindowIcon(QIcon(self.main.iconfile))
#############################################################################
def submitReport(self):
self.userAgreedToPrivacyPolicy = False
if self.main.getUserAgreeToPrivacy(True):
self.userAgreedToPrivacyPolicy = True
else:
return
emailAddr = unicode(self.edtEmail.text()).strip()
emailLen = lenBytes(emailAddr)
subjectText = unicode(self.edtSubject.text()).strip()
subjectLen = lenBytes(subjectText)
description = unicode(self.txtDescr.toPlainText()).strip()
descrLen = lenBytes(description)
if emailLen == 0 or not '@' in emailAddr:
QMessageBox.warning(self, tr('Missing Email'), tr("""
You must supply a valid email address so we can follow up on your
submission."""), QMessageBox.Ok)
return
maxDescr = 16384
if descrLen > maxDescr:
reply = MsgBoxCustom(MSGBOX.Warning, tr('Long Description'), tr("""
You have exceeded the maximum size of the description that can
be submitted to our ticket system, which is %(bytes)d bytes.
If you click "Continue", the last %(last)s bytes of your description
will be removed before sending.""") % { 'bytes' : maxDescr, 'last' : (descrLen-maxDescr)}, \
noStr=tr('Go Back'), yesStr=tr('Continue'))
if not reply:
return
else:
description = unicode_truncate(description, maxDescr)
# This is a unique-but-not-traceable ID, to simply match users to log files
uniqID = binary_to_base58(hash256(USER_HOME_DIR)[:4])
dateStr = unixTimeToFormatStr(RightNow(), '%Y%m%d_%H%M')
osvariant = OS_VARIANT[0] if OS_MACOSX else '-'.join(OS_VARIANT)
reportMap = {}
reportMap['uniqID'] = uniqID
reportMap['OSmajor'] = OS_NAME
reportMap['OSvariant'] = osvariant
reportMap['ArmoryVer'] = getVersionString(BTCARMORY_VERSION)
reportMap['TotalRAM'] = '%0.2f' % SystemSpecs.Memory
reportMap['isAmd64'] = str(SystemSpecs.IsX64).lower()
reportMap['userEmail'] = emailAddr
reportMap['userSubject'] = subjectText
reportMap['userDescr'] = description
reportMap['userTime'] = unixTimeToFormatStr(RightNow())
reportMap['userTimeUTC'] = unixTimeToFormatStr(RightNowUTC())
reportMap['agreedPrivacy'] = str(self.userAgreedToPrivacyPolicy)
fileUploadKey = 'fileWalletLogs'
# Create a zip file of all logs (for all dirs), and put raw into map
zpath = self.createZipfile()
with open(zpath, 'rb') as f:
reportMap[fileUploadKey] = f.read()
LOGDEBUG('Sending the following dictionary of values to server')
for key,val in reportMap.iteritems():
if key==fileUploadKey:
LOGDEBUG(key.ljust(12) + ': ' + binary_to_hex(sha256(val)))
else:
LOGDEBUG(key.ljust(12) + ': ' + val)
expectedResponseMap = {}
with open(zpath, 'rb') as f:
expectedResponseMap['fileWalletLogsHash'] = \
binary_to_hex(sha256(f.read()))
try:
import urllib3
http = urllib3.PoolManager()
headers = urllib3.make_headers('ArmoryBugReportWindowNotABrowser')
response = http.request('POST', BUG_REPORT_URL, reportMap, headers)
responseMap = ast.literal_eval(response._body)
LOGINFO('-'*50)
LOGINFO('Response JSON:')
for key,val in responseMap.iteritems():
LOGINFO(key.ljust(12) + ': ' + str(val))
LOGINFO('-'*50)
LOGINFO('Expected JSON:')
for key,val in expectedResponseMap.iteritems():
LOGINFO(key.ljust(12) + ': ' + str(val))
LOGDEBUG('Connection info:')
LOGDEBUG(' status: ' + str(response.status))
LOGDEBUG(' version: ' + str(response.version))
LOGDEBUG(' reason: ' + str(response.reason))
LOGDEBUG(' strict: ' + str(response.strict))
if responseMap==expectedResponseMap:
LOGINFO('Server verified receipt of log file')
cemail = 'contact@bitcoinarmory.com'
QMessageBox.information(self, tr('Submitted!'), tr("""
<b>Your report was submitted successfully!</b>
<br><br>
You should receive and email shortly from our support system.
If you do not receive it, you should follow up your request
with an email to <a href="%(url)s">%(url)s</a>.
You should hear back from an Armory representative within
24 hours.""") % { 'url' : cemail }, QMessageBox.Ok)
self.accept()
else:
raise ConnectionError('Failed to send bug report')
except:
LOGEXCEPT('Failed:')
bugpage = 'https://bitcoinarmory.com/support/'
QMessageBox.information(self, tr('Submission Error!'), tr("""
There was a problem submitting your data through Armory.
Please create a new support ticket using our webpage, and attach
the following file to it:
<br><br>
%(zpath)s
<br><br>
Click below to go to the support page to open a new ticket.
<br><br>
<a href=%(url)s">%(url)s</a>""") % {'zpath' : zpath, 'url' :bugpage}, QMessageBox.Ok)
try:
strOut = 'Raw response from server:\n'
strOut += response.text
LOGINFO(strOut)
except:
# Get here if response._body doesn't exist... never got that far
pass
self.reject()
#############################################################################
def createZipfile(self, zfilePath=None, forceIncludeAllData=False):
"""
If not forceIncludeAllData, then we will exclude wallet file and/or
regular logs, depending on the user's checkbox selection. For making
a user backup, we always want to include everything, regardless of
that selection.
"""
# Should we include wallet files from logs directory?
includeWlt = self.chkIncludeWOW.isChecked()
includeReg = self.chkIncludeReg.isChecked()
# Set to default save path if needed
if zfilePath is None:
zfilePath = os.path.join(ARMORY_HOME_DIR, 'wallet_analyze_logs.zip')
# Remove a previous copy
if os.path.exists(zfilePath):
os.remove(zfilePath)
LOGINFO('Creating archive: %s', zfilePath)
zfile = ZipFile(zfilePath, 'w', ZIP_DEFLATED)
# Iterate over all log directories (usually one)