Browse Source
- add UI-feedback via QValidatedLineEdit - copy button for generated signature was moved to the signature output field - add an addressbook button to verify message tab - input fields are now evenly ordered for sign and verify tabs - update FIRST_CLASS_MESSAGING support to ensure a good UX - add a button and context menu entry in addressbook for verify message (to be consistent with sign message) - focus is now only set/changed, when clearing input fields or adding an address via addressbook - re-work / update some strings - ensure model gets initialized in the SignVerifyMessageDialog constructor - add checks for a valid model to both addressbook buttons - remove unneeded includes for Qt GUI elements that are listed in ui_signverifymessagedialog.h anyway0.8
Philip Kaufmann
13 years ago
15 changed files with 822 additions and 706 deletions
@ -1,181 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<ui version="4.0"> |
|
||||||
<class>MessagePage</class> |
|
||||||
<widget class="QWidget" name="MessagePage"> |
|
||||||
<property name="geometry"> |
|
||||||
<rect> |
|
||||||
<x>0</x> |
|
||||||
<y>0</y> |
|
||||||
<width>627</width> |
|
||||||
<height>380</height> |
|
||||||
</rect> |
|
||||||
</property> |
|
||||||
<property name="windowTitle"> |
|
||||||
<string>Sign Message</string> |
|
||||||
</property> |
|
||||||
<layout class="QVBoxLayout" name="verticalLayout"> |
|
||||||
<item> |
|
||||||
<widget class="QLabel" name="labelExplanation"> |
|
||||||
<property name="text"> |
|
||||||
<string>You can sign messages with your addresses to prove you own them. Be careful not to sign anything vague, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to.</string> |
|
||||||
</property> |
|
||||||
<property name="textFormat"> |
|
||||||
<enum>Qt::AutoText</enum> |
|
||||||
</property> |
|
||||||
<property name="wordWrap"> |
|
||||||
<bool>true</bool> |
|
||||||
</property> |
|
||||||
</widget> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3"> |
|
||||||
<property name="spacing"> |
|
||||||
<number>0</number> |
|
||||||
</property> |
|
||||||
<item> |
|
||||||
<widget class="QValidatedLineEdit" name="signFrom"> |
|
||||||
<property name="toolTip"> |
|
||||||
<string>The address to sign the message with (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)</string> |
|
||||||
</property> |
|
||||||
<property name="maxLength"> |
|
||||||
<number>34</number> |
|
||||||
</property> |
|
||||||
</widget> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<widget class="QPushButton" name="addressBookButton"> |
|
||||||
<property name="toolTip"> |
|
||||||
<string>Choose adress from address book</string> |
|
||||||
</property> |
|
||||||
<property name="text"> |
|
||||||
<string/> |
|
||||||
</property> |
|
||||||
<property name="icon"> |
|
||||||
<iconset resource="../bitcoin.qrc"> |
|
||||||
<normaloff>:/icons/address-book</normaloff>:/icons/address-book</iconset> |
|
||||||
</property> |
|
||||||
<property name="shortcut"> |
|
||||||
<string>Alt+A</string> |
|
||||||
</property> |
|
||||||
<property name="autoDefault"> |
|
||||||
<bool>false</bool> |
|
||||||
</property> |
|
||||||
<property name="flat"> |
|
||||||
<bool>false</bool> |
|
||||||
</property> |
|
||||||
</widget> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<widget class="QPushButton" name="pasteButton"> |
|
||||||
<property name="toolTip"> |
|
||||||
<string>Paste address from clipboard</string> |
|
||||||
</property> |
|
||||||
<property name="text"> |
|
||||||
<string/> |
|
||||||
</property> |
|
||||||
<property name="icon"> |
|
||||||
<iconset resource="../bitcoin.qrc"> |
|
||||||
<normaloff>:/icons/editpaste</normaloff>:/icons/editpaste</iconset> |
|
||||||
</property> |
|
||||||
<property name="shortcut"> |
|
||||||
<string>Alt+P</string> |
|
||||||
</property> |
|
||||||
<property name="autoDefault"> |
|
||||||
<bool>false</bool> |
|
||||||
</property> |
|
||||||
</widget> |
|
||||||
</item> |
|
||||||
</layout> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<widget class="QPlainTextEdit" name="message"> |
|
||||||
<property name="toolTip"> |
|
||||||
<string>Enter the message you want to sign here</string> |
|
||||||
</property> |
|
||||||
</widget> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<widget class="QLineEdit" name="signature"> |
|
||||||
<property name="font"> |
|
||||||
<font> |
|
||||||
<italic>true</italic> |
|
||||||
</font> |
|
||||||
</property> |
|
||||||
<property name="readOnly"> |
|
||||||
<bool>true</bool> |
|
||||||
</property> |
|
||||||
</widget> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout"> |
|
||||||
<item> |
|
||||||
<widget class="QPushButton" name="signMessage"> |
|
||||||
<property name="toolTip"> |
|
||||||
<string>Sign a message to prove you own this address</string> |
|
||||||
</property> |
|
||||||
<property name="text"> |
|
||||||
<string>&Sign Message</string> |
|
||||||
</property> |
|
||||||
<property name="icon"> |
|
||||||
<iconset resource="../bitcoin.qrc"> |
|
||||||
<normaloff>:/icons/edit</normaloff>:/icons/edit</iconset> |
|
||||||
</property> |
|
||||||
</widget> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<widget class="QPushButton" name="copyToClipboard"> |
|
||||||
<property name="toolTip"> |
|
||||||
<string>Copy the current signature to the system clipboard</string> |
|
||||||
</property> |
|
||||||
<property name="text"> |
|
||||||
<string>&Copy Signature</string> |
|
||||||
</property> |
|
||||||
<property name="icon"> |
|
||||||
<iconset resource="../bitcoin.qrc"> |
|
||||||
<normaloff>:/icons/editcopy</normaloff>:/icons/editcopy</iconset> |
|
||||||
</property> |
|
||||||
</widget> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<widget class="QPushButton" name="clearButton"> |
|
||||||
<property name="toolTip"> |
|
||||||
<string>Reset all sign message fields</string> |
|
||||||
</property> |
|
||||||
<property name="text"> |
|
||||||
<string>Clear &All</string> |
|
||||||
</property> |
|
||||||
<property name="icon"> |
|
||||||
<iconset resource="../bitcoin.qrc"> |
|
||||||
<normaloff>:/icons/remove</normaloff>:/icons/remove</iconset> |
|
||||||
</property> |
|
||||||
</widget> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<spacer name="horizontalSpacer"> |
|
||||||
<property name="orientation"> |
|
||||||
<enum>Qt::Horizontal</enum> |
|
||||||
</property> |
|
||||||
<property name="sizeHint" stdset="0"> |
|
||||||
<size> |
|
||||||
<width>40</width> |
|
||||||
<height>20</height> |
|
||||||
</size> |
|
||||||
</property> |
|
||||||
</spacer> |
|
||||||
</item> |
|
||||||
</layout> |
|
||||||
</item> |
|
||||||
</layout> |
|
||||||
</widget> |
|
||||||
<customwidgets> |
|
||||||
<customwidget> |
|
||||||
<class>QValidatedLineEdit</class> |
|
||||||
<extends>QLineEdit</extends> |
|
||||||
<header>qvalidatedlineedit.h</header> |
|
||||||
</customwidget> |
|
||||||
</customwidgets> |
|
||||||
<resources> |
|
||||||
<include location="../bitcoin.qrc"/> |
|
||||||
</resources> |
|
||||||
<connections/> |
|
||||||
</ui> |
|
@ -0,0 +1,386 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<ui version="4.0"> |
||||||
|
<class>SignVerifyMessageDialog</class> |
||||||
|
<widget class="QDialog" name="SignVerifyMessageDialog"> |
||||||
|
<property name="geometry"> |
||||||
|
<rect> |
||||||
|
<x>0</x> |
||||||
|
<y>0</y> |
||||||
|
<width>700</width> |
||||||
|
<height>380</height> |
||||||
|
</rect> |
||||||
|
</property> |
||||||
|
<property name="windowTitle"> |
||||||
|
<string>Messaging - Sign / Verify a Message</string> |
||||||
|
</property> |
||||||
|
<property name="modal"> |
||||||
|
<bool>true</bool> |
||||||
|
</property> |
||||||
|
<layout class="QVBoxLayout" name="verticalLayout"> |
||||||
|
<item> |
||||||
|
<widget class="QTabWidget" name="tabWidget"> |
||||||
|
<property name="currentIndex"> |
||||||
|
<number>0</number> |
||||||
|
</property> |
||||||
|
<widget class="QWidget" name="tabSignMessage"> |
||||||
|
<attribute name="title"> |
||||||
|
<string>&Sign Message</string> |
||||||
|
</attribute> |
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_SM"> |
||||||
|
<item> |
||||||
|
<widget class="QLabel" name="infoLabel_SM"> |
||||||
|
<property name="text"> |
||||||
|
<string>You can sign messages with your addresses to prove you own them. Be careful not to sign anything vague, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to.</string> |
||||||
|
</property> |
||||||
|
<property name="textFormat"> |
||||||
|
<enum>Qt::PlainText</enum> |
||||||
|
</property> |
||||||
|
<property name="wordWrap"> |
||||||
|
<bool>true</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_1_SM"> |
||||||
|
<property name="spacing"> |
||||||
|
<number>0</number> |
||||||
|
</property> |
||||||
|
<item> |
||||||
|
<widget class="QValidatedLineEdit" name="addressIn_SM"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>The address to sign the message with (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)</string> |
||||||
|
</property> |
||||||
|
<property name="maxLength"> |
||||||
|
<number>34</number> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QPushButton" name="addressBookButton_SM"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Choose an address from the address book</string> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string/> |
||||||
|
</property> |
||||||
|
<property name="icon"> |
||||||
|
<iconset resource="../bitcoin.qrc"> |
||||||
|
<normaloff>:/icons/address-book</normaloff>:/icons/address-book</iconset> |
||||||
|
</property> |
||||||
|
<property name="shortcut"> |
||||||
|
<string>Alt+A</string> |
||||||
|
</property> |
||||||
|
<property name="autoDefault"> |
||||||
|
<bool>false</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QPushButton" name="pasteButton_SM"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Paste address from clipboard</string> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string/> |
||||||
|
</property> |
||||||
|
<property name="icon"> |
||||||
|
<iconset resource="../bitcoin.qrc"> |
||||||
|
<normaloff>:/icons/editpaste</normaloff>:/icons/editpaste</iconset> |
||||||
|
</property> |
||||||
|
<property name="shortcut"> |
||||||
|
<string>Alt+P</string> |
||||||
|
</property> |
||||||
|
<property name="autoDefault"> |
||||||
|
<bool>false</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QPlainTextEdit" name="messageIn_SM"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Enter the message you want to sign here</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2_SM"> |
||||||
|
<property name="spacing"> |
||||||
|
<number>0</number> |
||||||
|
</property> |
||||||
|
<item> |
||||||
|
<widget class="QLineEdit" name="signatureOut_SM"> |
||||||
|
<property name="font"> |
||||||
|
<font> |
||||||
|
<italic>true</italic> |
||||||
|
</font> |
||||||
|
</property> |
||||||
|
<property name="readOnly"> |
||||||
|
<bool>true</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QPushButton" name="copySignatureButton_SM"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Copy the current signature to the system clipboard</string> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string/> |
||||||
|
</property> |
||||||
|
<property name="icon"> |
||||||
|
<iconset resource="../bitcoin.qrc"> |
||||||
|
<normaloff>:/icons/editcopy</normaloff>:/icons/editcopy</iconset> |
||||||
|
</property> |
||||||
|
<property name="autoDefault"> |
||||||
|
<bool>false</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3_SM"> |
||||||
|
<item> |
||||||
|
<widget class="QPushButton" name="signMessageButton_SM"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Sign the message to prove you own this Bitcoin address</string> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string>&Sign Message</string> |
||||||
|
</property> |
||||||
|
<property name="icon"> |
||||||
|
<iconset resource="../bitcoin.qrc"> |
||||||
|
<normaloff>:/icons/edit</normaloff>:/icons/edit</iconset> |
||||||
|
</property> |
||||||
|
<property name="autoDefault"> |
||||||
|
<bool>false</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QPushButton" name="clearButton_SM"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Reset all sign message fields</string> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string>Clear &All</string> |
||||||
|
</property> |
||||||
|
<property name="icon"> |
||||||
|
<iconset resource="../bitcoin.qrc"> |
||||||
|
<normaloff>:/icons/remove</normaloff>:/icons/remove</iconset> |
||||||
|
</property> |
||||||
|
<property name="autoDefault"> |
||||||
|
<bool>false</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<spacer name="horizontalSpacer_1_SM"> |
||||||
|
<property name="orientation"> |
||||||
|
<enum>Qt::Horizontal</enum> |
||||||
|
</property> |
||||||
|
<property name="sizeHint" stdset="0"> |
||||||
|
<size> |
||||||
|
<width>40</width> |
||||||
|
<height>48</height> |
||||||
|
</size> |
||||||
|
</property> |
||||||
|
</spacer> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QLabel" name="statusLabel_SM"> |
||||||
|
<property name="font"> |
||||||
|
<font> |
||||||
|
<weight>75</weight> |
||||||
|
<bold>true</bold> |
||||||
|
</font> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string/> |
||||||
|
</property> |
||||||
|
<property name="wordWrap"> |
||||||
|
<bool>true</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<spacer name="horizontalSpacer_2_SM"> |
||||||
|
<property name="orientation"> |
||||||
|
<enum>Qt::Horizontal</enum> |
||||||
|
</property> |
||||||
|
<property name="sizeHint" stdset="0"> |
||||||
|
<size> |
||||||
|
<width>40</width> |
||||||
|
<height>48</height> |
||||||
|
</size> |
||||||
|
</property> |
||||||
|
</spacer> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</widget> |
||||||
|
<widget class="QWidget" name="tabVerifyMessage"> |
||||||
|
<attribute name="title"> |
||||||
|
<string>&Verify Message</string> |
||||||
|
</attribute> |
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_VM"> |
||||||
|
<item> |
||||||
|
<widget class="QLabel" name="infoLabel_VM"> |
||||||
|
<property name="text"> |
||||||
|
<string>Enter the signing address, message (ensure you copy line breaks, spaces, tabs, etc. exactly) and signature below to verify the message. Be careful not to read more into the signature than what is in the signed message itself, to avoid being tricked by a man-in-the-middle attack.</string> |
||||||
|
</property> |
||||||
|
<property name="textFormat"> |
||||||
|
<enum>Qt::PlainText</enum> |
||||||
|
</property> |
||||||
|
<property name="alignment"> |
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> |
||||||
|
</property> |
||||||
|
<property name="wordWrap"> |
||||||
|
<bool>true</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_1_VM"> |
||||||
|
<property name="spacing"> |
||||||
|
<number>0</number> |
||||||
|
</property> |
||||||
|
<item> |
||||||
|
<widget class="QValidatedLineEdit" name="addressIn_VM"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>The address the message was signed with (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)</string> |
||||||
|
</property> |
||||||
|
<property name="maxLength"> |
||||||
|
<number>34</number> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QPushButton" name="addressBookButton_VM"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Choose an address from the address book</string> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string/> |
||||||
|
</property> |
||||||
|
<property name="icon"> |
||||||
|
<iconset resource="../bitcoin.qrc"> |
||||||
|
<normaloff>:/icons/address-book</normaloff>:/icons/address-book</iconset> |
||||||
|
</property> |
||||||
|
<property name="shortcut"> |
||||||
|
<string>Alt+A</string> |
||||||
|
</property> |
||||||
|
<property name="autoDefault"> |
||||||
|
<bool>false</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QPlainTextEdit" name="messageIn_VM"/> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QValidatedLineEdit" name="signatureIn_VM"/> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2_VM"> |
||||||
|
<item> |
||||||
|
<widget class="QPushButton" name="verifyMessageButton_VM"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Verify the message to ensure it was signed with the specified Bitcoin address</string> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string>&Verify Message</string> |
||||||
|
</property> |
||||||
|
<property name="icon"> |
||||||
|
<iconset resource="../bitcoin.qrc"> |
||||||
|
<normaloff>:/icons/transaction_0</normaloff>:/icons/transaction_0</iconset> |
||||||
|
</property> |
||||||
|
<property name="autoDefault"> |
||||||
|
<bool>false</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QPushButton" name="clearButton_VM"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Reset all verify message fields</string> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string>Clear &All</string> |
||||||
|
</property> |
||||||
|
<property name="icon"> |
||||||
|
<iconset resource="../bitcoin.qrc"> |
||||||
|
<normaloff>:/icons/remove</normaloff>:/icons/remove</iconset> |
||||||
|
</property> |
||||||
|
<property name="autoDefault"> |
||||||
|
<bool>false</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<spacer name="horizontalSpacer_1_VM"> |
||||||
|
<property name="orientation"> |
||||||
|
<enum>Qt::Horizontal</enum> |
||||||
|
</property> |
||||||
|
<property name="sizeHint" stdset="0"> |
||||||
|
<size> |
||||||
|
<width>40</width> |
||||||
|
<height>48</height> |
||||||
|
</size> |
||||||
|
</property> |
||||||
|
</spacer> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QLabel" name="statusLabel_VM"> |
||||||
|
<property name="font"> |
||||||
|
<font> |
||||||
|
<weight>75</weight> |
||||||
|
<bold>true</bold> |
||||||
|
</font> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string/> |
||||||
|
</property> |
||||||
|
<property name="wordWrap"> |
||||||
|
<bool>true</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<spacer name="horizontalSpacer_2_VM"> |
||||||
|
<property name="orientation"> |
||||||
|
<enum>Qt::Horizontal</enum> |
||||||
|
</property> |
||||||
|
<property name="sizeHint" stdset="0"> |
||||||
|
<size> |
||||||
|
<width>40</width> |
||||||
|
<height>48</height> |
||||||
|
</size> |
||||||
|
</property> |
||||||
|
</spacer> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</widget> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</widget> |
||||||
|
<customwidgets> |
||||||
|
<customwidget> |
||||||
|
<class>QValidatedLineEdit</class> |
||||||
|
<extends>QLineEdit</extends> |
||||||
|
<header>qvalidatedlineedit.h</header> |
||||||
|
</customwidget> |
||||||
|
</customwidgets> |
||||||
|
<resources> |
||||||
|
<include location="../bitcoin.qrc"/> |
||||||
|
</resources> |
||||||
|
<connections/> |
||||||
|
</ui> |
@ -1,140 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<ui version="4.0"> |
|
||||||
<class>VerifyMessageDialog</class> |
|
||||||
<widget class="QDialog" name="VerifyMessageDialog"> |
|
||||||
<property name="geometry"> |
|
||||||
<rect> |
|
||||||
<x>0</x> |
|
||||||
<y>0</y> |
|
||||||
<width>650</width> |
|
||||||
<height>380</height> |
|
||||||
</rect> |
|
||||||
</property> |
|
||||||
<property name="windowTitle"> |
|
||||||
<string>Verify Signed Message</string> |
|
||||||
</property> |
|
||||||
<layout class="QVBoxLayout" name="verticalLayout"> |
|
||||||
<item> |
|
||||||
<widget class="QLabel" name="label"> |
|
||||||
<property name="text"> |
|
||||||
<string>Enter the signing address, signature and message below (be careful to correctly copy newlines, spaces, tabs and other invisible characters) to verify the message.</string> |
|
||||||
</property> |
|
||||||
<property name="alignment"> |
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> |
|
||||||
</property> |
|
||||||
<property name="wordWrap"> |
|
||||||
<bool>true</bool> |
|
||||||
</property> |
|
||||||
</widget> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<widget class="QValidatedLineEdit" name="lnAddress"> |
|
||||||
<property name="text"> |
|
||||||
<string/> |
|
||||||
</property> |
|
||||||
</widget> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<widget class="QValidatedLineEdit" name="lnSig"> |
|
||||||
<property name="text"> |
|
||||||
<string/> |
|
||||||
</property> |
|
||||||
</widget> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<widget class="QPlainTextEdit" name="edMessage"/> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout"> |
|
||||||
<item> |
|
||||||
<widget class="QPushButton" name="verifyMessage"> |
|
||||||
<property name="toolTip"> |
|
||||||
<string>Verify a message to ensure it was signed with the specified Bitcoin address</string> |
|
||||||
</property> |
|
||||||
<property name="text"> |
|
||||||
<string>&Verify Message</string> |
|
||||||
</property> |
|
||||||
<property name="icon"> |
|
||||||
<iconset resource="../bitcoin.qrc"> |
|
||||||
<normaloff>:/icons/transaction_0</normaloff>:/icons/transaction_0</iconset> |
|
||||||
</property> |
|
||||||
</widget> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<widget class="QPushButton" name="clearButton"> |
|
||||||
<property name="toolTip"> |
|
||||||
<string>Reset all verify message fields</string> |
|
||||||
</property> |
|
||||||
<property name="text"> |
|
||||||
<string>Clear &All</string> |
|
||||||
</property> |
|
||||||
<property name="icon"> |
|
||||||
<iconset resource="../bitcoin.qrc"> |
|
||||||
<normaloff>:/icons/remove</normaloff>:/icons/remove</iconset> |
|
||||||
</property> |
|
||||||
</widget> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<spacer name="horizontalSpacer_2"> |
|
||||||
<property name="orientation"> |
|
||||||
<enum>Qt::Horizontal</enum> |
|
||||||
</property> |
|
||||||
<property name="sizeHint" stdset="0"> |
|
||||||
<size> |
|
||||||
<width>40</width> |
|
||||||
<height>20</height> |
|
||||||
</size> |
|
||||||
</property> |
|
||||||
</spacer> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<widget class="QLabel" name="lblStatus"> |
|
||||||
<property name="minimumSize"> |
|
||||||
<size> |
|
||||||
<width>0</width> |
|
||||||
<height>48</height> |
|
||||||
</size> |
|
||||||
</property> |
|
||||||
<property name="font"> |
|
||||||
<font> |
|
||||||
<weight>75</weight> |
|
||||||
<bold>true</bold> |
|
||||||
</font> |
|
||||||
</property> |
|
||||||
<property name="text"> |
|
||||||
<string/> |
|
||||||
</property> |
|
||||||
<property name="wordWrap"> |
|
||||||
<bool>true</bool> |
|
||||||
</property> |
|
||||||
</widget> |
|
||||||
</item> |
|
||||||
<item> |
|
||||||
<spacer name="horizontalSpacer"> |
|
||||||
<property name="orientation"> |
|
||||||
<enum>Qt::Horizontal</enum> |
|
||||||
</property> |
|
||||||
<property name="sizeHint" stdset="0"> |
|
||||||
<size> |
|
||||||
<width>40</width> |
|
||||||
<height>20</height> |
|
||||||
</size> |
|
||||||
</property> |
|
||||||
</spacer> |
|
||||||
</item> |
|
||||||
</layout> |
|
||||||
</item> |
|
||||||
</layout> |
|
||||||
</widget> |
|
||||||
<customwidgets> |
|
||||||
<customwidget> |
|
||||||
<class>QValidatedLineEdit</class> |
|
||||||
<extends>QLineEdit</extends> |
|
||||||
<header>qvalidatedlineedit.h</header> |
|
||||||
</customwidget> |
|
||||||
</customwidgets> |
|
||||||
<resources> |
|
||||||
<include location="../bitcoin.qrc"/> |
|
||||||
</resources> |
|
||||||
<connections/> |
|
||||||
</ui> |
|
@ -1,143 +0,0 @@ |
|||||||
#include <string> |
|
||||||
#include <vector> |
|
||||||
|
|
||||||
#include <QClipboard> |
|
||||||
#include <QInputDialog> |
|
||||||
#include <QList> |
|
||||||
#include <QListWidgetItem> |
|
||||||
#include <QMessageBox> |
|
||||||
|
|
||||||
#include "main.h" |
|
||||||
#include "wallet.h" |
|
||||||
#include "init.h" |
|
||||||
#include "base58.h" |
|
||||||
|
|
||||||
#include "messagepage.h" |
|
||||||
#include "ui_messagepage.h" |
|
||||||
|
|
||||||
#include "addressbookpage.h" |
|
||||||
#include "guiutil.h" |
|
||||||
#include "walletmodel.h" |
|
||||||
|
|
||||||
MessagePage::MessagePage(QWidget *parent) : |
|
||||||
QDialog(parent), |
|
||||||
ui(new Ui::MessagePage) |
|
||||||
{ |
|
||||||
ui->setupUi(this); |
|
||||||
|
|
||||||
#if (QT_VERSION >= 0x040700) |
|
||||||
/* Do not move this to the XML file, Qt before 4.7 will choke on it */ |
|
||||||
ui->signFrom->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)")); |
|
||||||
ui->signature->setPlaceholderText(tr("Click \"Sign Message\" to get signature")); |
|
||||||
#endif |
|
||||||
|
|
||||||
GUIUtil::setupAddressWidget(ui->signFrom, this); |
|
||||||
ui->signature->installEventFilter(this); |
|
||||||
|
|
||||||
ui->signFrom->setFocus(); |
|
||||||
} |
|
||||||
|
|
||||||
MessagePage::~MessagePage() |
|
||||||
{ |
|
||||||
delete ui; |
|
||||||
} |
|
||||||
|
|
||||||
void MessagePage::setModel(WalletModel *model) |
|
||||||
{ |
|
||||||
this->model = model; |
|
||||||
} |
|
||||||
|
|
||||||
void MessagePage::setAddress(QString addr) |
|
||||||
{ |
|
||||||
ui->signFrom->setText(addr); |
|
||||||
ui->message->setFocus(); |
|
||||||
} |
|
||||||
|
|
||||||
void MessagePage::on_pasteButton_clicked() |
|
||||||
{ |
|
||||||
setAddress(QApplication::clipboard()->text()); |
|
||||||
} |
|
||||||
|
|
||||||
void MessagePage::on_addressBookButton_clicked() |
|
||||||
{ |
|
||||||
AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::ReceivingTab, this); |
|
||||||
dlg.setModel(model->getAddressTableModel()); |
|
||||||
if(dlg.exec()) |
|
||||||
{ |
|
||||||
setAddress(dlg.getReturnValue()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void MessagePage::on_copyToClipboard_clicked() |
|
||||||
{ |
|
||||||
QApplication::clipboard()->setText(ui->signature->text()); |
|
||||||
} |
|
||||||
|
|
||||||
void MessagePage::on_signMessage_clicked() |
|
||||||
{ |
|
||||||
QString address = ui->signFrom->text(); |
|
||||||
|
|
||||||
CBitcoinAddress addr(address.toStdString()); |
|
||||||
if (!addr.IsValid()) |
|
||||||
{ |
|
||||||
QMessageBox::critical(this, tr("Error signing"), tr("%1 is not a valid address.").arg(address), |
|
||||||
QMessageBox::Abort, QMessageBox::Abort); |
|
||||||
return; |
|
||||||
} |
|
||||||
CKeyID keyID; |
|
||||||
if (!addr.GetKeyID(keyID)) |
|
||||||
{ |
|
||||||
QMessageBox::critical(this, tr("Error signing"), tr("%1 does not refer to a key.").arg(address), |
|
||||||
QMessageBox::Abort, QMessageBox::Abort); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
WalletModel::UnlockContext ctx(model->requestUnlock()); |
|
||||||
if(!ctx.isValid()) |
|
||||||
{ |
|
||||||
// Unlock wallet was cancelled
|
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
CKey key; |
|
||||||
if (!pwalletMain->GetKey(keyID, key)) |
|
||||||
{ |
|
||||||
QMessageBox::critical(this, tr("Error signing"), tr("Private key for %1 is not available.").arg(address), |
|
||||||
QMessageBox::Abort, QMessageBox::Abort); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
CDataStream ss(SER_GETHASH, 0); |
|
||||||
ss << strMessageMagic; |
|
||||||
ss << ui->message->document()->toPlainText().toStdString(); |
|
||||||
|
|
||||||
std::vector<unsigned char> vchSig; |
|
||||||
if (!key.SignCompact(Hash(ss.begin(), ss.end()), vchSig)) |
|
||||||
{ |
|
||||||
QMessageBox::critical(this, tr("Error signing"), tr("Sign failed"), |
|
||||||
QMessageBox::Abort, QMessageBox::Abort); |
|
||||||
} |
|
||||||
|
|
||||||
ui->signature->setText(QString::fromStdString(EncodeBase64(&vchSig[0], vchSig.size()))); |
|
||||||
ui->signature->setFont(GUIUtil::bitcoinAddressFont()); |
|
||||||
} |
|
||||||
|
|
||||||
void MessagePage::on_clearButton_clicked() |
|
||||||
{ |
|
||||||
ui->signFrom->clear(); |
|
||||||
ui->message->clear(); |
|
||||||
ui->signature->clear(); |
|
||||||
|
|
||||||
ui->signFrom->setFocus(); |
|
||||||
} |
|
||||||
|
|
||||||
bool MessagePage::eventFilter(QObject *object, QEvent *event) |
|
||||||
{ |
|
||||||
if(object == ui->signature && (event->type() == QEvent::MouseButtonPress || |
|
||||||
event->type() == QEvent::FocusIn)) |
|
||||||
{ |
|
||||||
ui->signature->selectAll(); |
|
||||||
return true; |
|
||||||
} |
|
||||||
return QDialog::eventFilter(object, event); |
|
||||||
} |
|
@ -1,42 +0,0 @@ |
|||||||
#ifndef MESSAGEPAGE_H |
|
||||||
#define MESSAGEPAGE_H |
|
||||||
|
|
||||||
#include <QDialog> |
|
||||||
|
|
||||||
namespace Ui { |
|
||||||
class MessagePage; |
|
||||||
} |
|
||||||
class WalletModel; |
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE |
|
||||||
QT_END_NAMESPACE |
|
||||||
|
|
||||||
class MessagePage : public QDialog |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
|
|
||||||
public: |
|
||||||
explicit MessagePage(QWidget *parent = 0); |
|
||||||
~MessagePage(); |
|
||||||
|
|
||||||
void setModel(WalletModel *model); |
|
||||||
|
|
||||||
void setAddress(QString); |
|
||||||
|
|
||||||
protected: |
|
||||||
bool eventFilter(QObject *object, QEvent *event); |
|
||||||
|
|
||||||
private: |
|
||||||
Ui::MessagePage *ui; |
|
||||||
WalletModel *model; |
|
||||||
|
|
||||||
private slots: |
|
||||||
void on_pasteButton_clicked(); |
|
||||||
void on_addressBookButton_clicked(); |
|
||||||
|
|
||||||
void on_signMessage_clicked(); |
|
||||||
void on_copyToClipboard_clicked(); |
|
||||||
void on_clearButton_clicked(); |
|
||||||
}; |
|
||||||
|
|
||||||
#endif // MESSAGEPAGE_H
|
|
@ -0,0 +1,274 @@ |
|||||||
|
#include "signverifymessagedialog.h" |
||||||
|
#include "ui_signverifymessagedialog.h" |
||||||
|
|
||||||
|
#include "addressbookpage.h" |
||||||
|
#include "base58.h" |
||||||
|
#include "guiutil.h" |
||||||
|
#include "init.h" |
||||||
|
#include "main.h" |
||||||
|
#include "optionsmodel.h" |
||||||
|
#include "walletmodel.h" |
||||||
|
#include "wallet.h" |
||||||
|
|
||||||
|
#include <string> |
||||||
|
#include <vector> |
||||||
|
|
||||||
|
#include <QClipboard> |
||||||
|
|
||||||
|
SignVerifyMessageDialog::SignVerifyMessageDialog(QWidget *parent) : |
||||||
|
QDialog(parent), |
||||||
|
ui(new Ui::SignVerifyMessageDialog), |
||||||
|
model(0) |
||||||
|
{ |
||||||
|
ui->setupUi(this); |
||||||
|
|
||||||
|
#if (QT_VERSION >= 0x040700) |
||||||
|
/* Do not move this to the XML file, Qt before 4.7 will choke on it */ |
||||||
|
ui->addressIn_SM->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)")); |
||||||
|
ui->signatureOut_SM->setPlaceholderText(tr("Click \"Sign Message\" to generate signature")); |
||||||
|
|
||||||
|
ui->addressIn_VM->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)")); |
||||||
|
ui->signatureIn_VM->setPlaceholderText(tr("Enter Bitcoin signature")); |
||||||
|
#endif |
||||||
|
|
||||||
|
GUIUtil::setupAddressWidget(ui->addressIn_SM, this); |
||||||
|
GUIUtil::setupAddressWidget(ui->addressIn_VM, this); |
||||||
|
|
||||||
|
ui->addressIn_SM->installEventFilter(this); |
||||||
|
ui->messageIn_SM->installEventFilter(this); |
||||||
|
ui->signatureOut_SM->installEventFilter(this); |
||||||
|
ui->addressIn_VM->installEventFilter(this); |
||||||
|
ui->messageIn_VM->installEventFilter(this); |
||||||
|
ui->signatureIn_VM->installEventFilter(this); |
||||||
|
|
||||||
|
ui->signatureOut_SM->setFont(GUIUtil::bitcoinAddressFont()); |
||||||
|
ui->signatureIn_VM->setFont(GUIUtil::bitcoinAddressFont()); |
||||||
|
} |
||||||
|
|
||||||
|
SignVerifyMessageDialog::~SignVerifyMessageDialog() |
||||||
|
{ |
||||||
|
delete ui; |
||||||
|
} |
||||||
|
|
||||||
|
void SignVerifyMessageDialog::setModel(WalletModel *model) |
||||||
|
{ |
||||||
|
this->model = model; |
||||||
|
} |
||||||
|
|
||||||
|
void SignVerifyMessageDialog::setAddress_SM(QString address) |
||||||
|
{ |
||||||
|
ui->addressIn_SM->setText(address); |
||||||
|
ui->messageIn_SM->setFocus(); |
||||||
|
} |
||||||
|
|
||||||
|
void SignVerifyMessageDialog::setAddress_VM(QString address) |
||||||
|
{ |
||||||
|
ui->addressIn_VM->setText(address); |
||||||
|
ui->messageIn_VM->setFocus(); |
||||||
|
} |
||||||
|
|
||||||
|
void SignVerifyMessageDialog::showTab_SM(bool fShow) |
||||||
|
{ |
||||||
|
ui->tabWidget->setCurrentIndex(0); |
||||||
|
|
||||||
|
if (fShow) |
||||||
|
this->show(); |
||||||
|
} |
||||||
|
|
||||||
|
void SignVerifyMessageDialog::showTab_VM(bool fShow) |
||||||
|
{ |
||||||
|
ui->tabWidget->setCurrentIndex(1); |
||||||
|
if (fShow) |
||||||
|
this->show(); |
||||||
|
} |
||||||
|
|
||||||
|
void SignVerifyMessageDialog::on_addressBookButton_SM_clicked() |
||||||
|
{ |
||||||
|
if (model && model->getAddressTableModel()) |
||||||
|
{ |
||||||
|
AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::ReceivingTab, this); |
||||||
|
dlg.setModel(model->getAddressTableModel()); |
||||||
|
if (dlg.exec()) |
||||||
|
{ |
||||||
|
setAddress_SM(dlg.getReturnValue()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void SignVerifyMessageDialog::on_pasteButton_SM_clicked() |
||||||
|
{ |
||||||
|
setAddress_SM(QApplication::clipboard()->text()); |
||||||
|
} |
||||||
|
|
||||||
|
void SignVerifyMessageDialog::on_signMessageButton_SM_clicked() |
||||||
|
{ |
||||||
|
/* Clear old signature to ensure users don't get confused on error with an old signature displayed */ |
||||||
|
ui->signatureOut_SM->clear(); |
||||||
|
|
||||||
|
CBitcoinAddress addr(ui->addressIn_SM->text().toStdString()); |
||||||
|
if (!addr.IsValid()) |
||||||
|
{ |
||||||
|
ui->addressIn_SM->setValid(false); |
||||||
|
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); |
||||||
|
ui->statusLabel_SM->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again.")); |
||||||
|
return; |
||||||
|
} |
||||||
|
CKeyID keyID; |
||||||
|
if (!addr.GetKeyID(keyID)) |
||||||
|
{ |
||||||
|
ui->addressIn_SM->setValid(false); |
||||||
|
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); |
||||||
|
ui->statusLabel_SM->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again.")); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
WalletModel::UnlockContext ctx(model->requestUnlock()); |
||||||
|
if (!ctx.isValid()) |
||||||
|
{ |
||||||
|
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); |
||||||
|
ui->statusLabel_SM->setText(tr("Wallet unlock was canceled.")); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
CKey key; |
||||||
|
if (!pwalletMain->GetKey(keyID, key)) |
||||||
|
{ |
||||||
|
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); |
||||||
|
ui->statusLabel_SM->setText(tr("Private key for the entered address is not available.")); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
CDataStream ss(SER_GETHASH, 0); |
||||||
|
ss << strMessageMagic; |
||||||
|
ss << ui->messageIn_SM->document()->toPlainText().toStdString(); |
||||||
|
|
||||||
|
std::vector<unsigned char> vchSig; |
||||||
|
if (!key.SignCompact(Hash(ss.begin(), ss.end()), vchSig)) |
||||||
|
{ |
||||||
|
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); |
||||||
|
ui->statusLabel_SM->setText(QString("<nobr>") + tr("Message signing failed.") + QString("</nobr>")); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
ui->statusLabel_SM->setStyleSheet("QLabel { color: green; }"); |
||||||
|
ui->statusLabel_SM->setText(QString("<nobr>") + tr("Message signed.") + QString("</nobr>")); |
||||||
|
|
||||||
|
ui->signatureOut_SM->setText(QString::fromStdString(EncodeBase64(&vchSig[0], vchSig.size()))); |
||||||
|
} |
||||||
|
|
||||||
|
void SignVerifyMessageDialog::on_copySignatureButton_SM_clicked() |
||||||
|
{ |
||||||
|
QApplication::clipboard()->setText(ui->signatureOut_SM->text()); |
||||||
|
} |
||||||
|
|
||||||
|
void SignVerifyMessageDialog::on_clearButton_SM_clicked() |
||||||
|
{ |
||||||
|
ui->addressIn_SM->clear(); |
||||||
|
ui->messageIn_SM->clear(); |
||||||
|
ui->signatureOut_SM->clear(); |
||||||
|
ui->statusLabel_SM->clear(); |
||||||
|
|
||||||
|
ui->addressIn_SM->setFocus(); |
||||||
|
} |
||||||
|
|
||||||
|
void SignVerifyMessageDialog::on_addressBookButton_VM_clicked() |
||||||
|
{ |
||||||
|
if (model && model->getAddressTableModel()) |
||||||
|
{ |
||||||
|
AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::SendingTab, this); |
||||||
|
dlg.setModel(model->getAddressTableModel()); |
||||||
|
if (dlg.exec()) |
||||||
|
{ |
||||||
|
setAddress_VM(dlg.getReturnValue()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked() |
||||||
|
{ |
||||||
|
CBitcoinAddress addr(ui->addressIn_VM->text().toStdString()); |
||||||
|
if (!addr.IsValid()) |
||||||
|
{ |
||||||
|
ui->addressIn_VM->setValid(false); |
||||||
|
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); |
||||||
|
ui->statusLabel_VM->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again.")); |
||||||
|
return; |
||||||
|
} |
||||||
|
CKeyID keyID; |
||||||
|
if (!addr.GetKeyID(keyID)) |
||||||
|
{ |
||||||
|
ui->addressIn_VM->setValid(false); |
||||||
|
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); |
||||||
|
ui->statusLabel_VM->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again.")); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
bool fInvalid = false; |
||||||
|
std::vector<unsigned char> vchSig = DecodeBase64(ui->signatureIn_VM->text().toStdString().c_str(), &fInvalid); |
||||||
|
|
||||||
|
if (fInvalid) |
||||||
|
{ |
||||||
|
ui->signatureIn_VM->setValid(false); |
||||||
|
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); |
||||||
|
ui->statusLabel_VM->setText(tr("The signature could not be decoded.") + QString(" ") + tr("Please check the signature and try again.")); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
CDataStream ss(SER_GETHASH, 0); |
||||||
|
ss << strMessageMagic; |
||||||
|
ss << ui->messageIn_VM->document()->toPlainText().toStdString(); |
||||||
|
|
||||||
|
CKey key; |
||||||
|
if (!key.SetCompactSignature(Hash(ss.begin(), ss.end()), vchSig)) |
||||||
|
{ |
||||||
|
ui->signatureIn_VM->setValid(false); |
||||||
|
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); |
||||||
|
ui->statusLabel_VM->setText(tr("The signature did not match the message digest.") + QString(" ") + tr("Please check the signature and try again.")); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if (!(CBitcoinAddress(key.GetPubKey().GetID()) == addr)) |
||||||
|
{ |
||||||
|
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); |
||||||
|
ui->statusLabel_VM->setText(QString("<nobr>") + tr("Message verification failed.") + QString("</nobr>")); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
ui->statusLabel_VM->setStyleSheet("QLabel { color: green; }"); |
||||||
|
ui->statusLabel_VM->setText(QString("<nobr>") + tr("Message verified.") + QString("</nobr>")); |
||||||
|
} |
||||||
|
|
||||||
|
void SignVerifyMessageDialog::on_clearButton_VM_clicked() |
||||||
|
{ |
||||||
|
ui->addressIn_VM->clear(); |
||||||
|
ui->signatureIn_VM->clear(); |
||||||
|
ui->messageIn_VM->clear(); |
||||||
|
ui->statusLabel_VM->clear(); |
||||||
|
|
||||||
|
ui->addressIn_VM->setFocus(); |
||||||
|
} |
||||||
|
|
||||||
|
bool SignVerifyMessageDialog::eventFilter(QObject *object, QEvent *event) |
||||||
|
{ |
||||||
|
if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::FocusIn) |
||||||
|
{ |
||||||
|
if (ui->tabWidget->currentIndex() == 0) |
||||||
|
{ |
||||||
|
/* Clear status message on focus change */ |
||||||
|
ui->statusLabel_SM->clear(); |
||||||
|
|
||||||
|
/* Select generated signature */ |
||||||
|
if (object == ui->signatureOut_SM) |
||||||
|
{ |
||||||
|
ui->signatureOut_SM->selectAll(); |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
else if (ui->tabWidget->currentIndex() == 1) |
||||||
|
{ |
||||||
|
/* Clear status message on focus change */ |
||||||
|
ui->statusLabel_VM->clear(); |
||||||
|
} |
||||||
|
} |
||||||
|
return QDialog::eventFilter(object, event); |
||||||
|
} |
@ -0,0 +1,49 @@ |
|||||||
|
#ifndef SIGNVERIFYMESSAGEDIALOG_H |
||||||
|
#define SIGNVERIFYMESSAGEDIALOG_H |
||||||
|
|
||||||
|
#include <QDialog> |
||||||
|
|
||||||
|
namespace Ui { |
||||||
|
class SignVerifyMessageDialog; |
||||||
|
} |
||||||
|
class WalletModel; |
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE |
||||||
|
QT_END_NAMESPACE |
||||||
|
|
||||||
|
class SignVerifyMessageDialog : public QDialog |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
|
||||||
|
public: |
||||||
|
explicit SignVerifyMessageDialog(QWidget *parent = 0); |
||||||
|
~SignVerifyMessageDialog(); |
||||||
|
|
||||||
|
void setModel(WalletModel *model); |
||||||
|
void setAddress_SM(QString address); |
||||||
|
void setAddress_VM(QString address); |
||||||
|
|
||||||
|
void showTab_SM(bool fShow); |
||||||
|
void showTab_VM(bool fShow); |
||||||
|
|
||||||
|
protected: |
||||||
|
bool eventFilter(QObject *object, QEvent *event); |
||||||
|
|
||||||
|
private: |
||||||
|
Ui::SignVerifyMessageDialog *ui; |
||||||
|
WalletModel *model; |
||||||
|
|
||||||
|
private slots: |
||||||
|
/* sign message */ |
||||||
|
void on_addressBookButton_SM_clicked(); |
||||||
|
void on_pasteButton_SM_clicked(); |
||||||
|
void on_signMessageButton_SM_clicked(); |
||||||
|
void on_copySignatureButton_SM_clicked(); |
||||||
|
void on_clearButton_SM_clicked(); |
||||||
|
/* verify message */ |
||||||
|
void on_addressBookButton_VM_clicked(); |
||||||
|
void on_verifyMessageButton_VM_clicked(); |
||||||
|
void on_clearButton_VM_clicked(); |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // SIGNVERIFYMESSAGEDIALOG_H
|
@ -1,119 +0,0 @@ |
|||||||
#include "verifymessagedialog.h" |
|
||||||
#include "ui_verifymessagedialog.h" |
|
||||||
|
|
||||||
#include <string> |
|
||||||
#include <vector> |
|
||||||
|
|
||||||
#include <QDialog> |
|
||||||
#include <QLabel> |
|
||||||
#include <QLineEdit> |
|
||||||
#include <QPlainTextEdit> |
|
||||||
#include <QPushButton> |
|
||||||
|
|
||||||
#include "main.h" |
|
||||||
#include "wallet.h" |
|
||||||
#include "walletmodel.h" |
|
||||||
#include "guiutil.h" |
|
||||||
#include "base58.h" |
|
||||||
|
|
||||||
VerifyMessageDialog::VerifyMessageDialog(QWidget *parent) : |
|
||||||
QDialog(parent), |
|
||||||
ui(new Ui::VerifyMessageDialog) |
|
||||||
{ |
|
||||||
ui->setupUi(this); |
|
||||||
|
|
||||||
#if (QT_VERSION >= 0x040700) |
|
||||||
/* Do not move this to the XML file, Qt before 4.7 will choke on it */ |
|
||||||
ui->lnAddress->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)")); |
|
||||||
ui->lnSig->setPlaceholderText(tr("Enter Bitcoin signature")); |
|
||||||
#endif |
|
||||||
|
|
||||||
GUIUtil::setupAddressWidget(ui->lnAddress, this); |
|
||||||
ui->lnAddress->installEventFilter(this); |
|
||||||
|
|
||||||
ui->lnSig->setFont(GUIUtil::bitcoinAddressFont()); |
|
||||||
|
|
||||||
ui->lnAddress->setFocus(); |
|
||||||
} |
|
||||||
|
|
||||||
VerifyMessageDialog::~VerifyMessageDialog() |
|
||||||
{ |
|
||||||
delete ui; |
|
||||||
} |
|
||||||
|
|
||||||
void VerifyMessageDialog::on_verifyMessage_clicked() |
|
||||||
{ |
|
||||||
CBitcoinAddress addr(ui->lnAddress->text().toStdString()); |
|
||||||
if (!addr.IsValid()) |
|
||||||
{ |
|
||||||
ui->lnAddress->setValid(false); |
|
||||||
ui->lblStatus->setStyleSheet("QLabel { color: red; }"); |
|
||||||
ui->lblStatus->setText(tr("\"%1\" is not a valid address.").arg(ui->lnAddress->text()) + QString(" ") + tr("Please check the address and try again.")); |
|
||||||
return; |
|
||||||
} |
|
||||||
CKeyID keyID; |
|
||||||
if (!addr.GetKeyID(keyID)) |
|
||||||
{ |
|
||||||
ui->lnAddress->setValid(false); |
|
||||||
ui->lblStatus->setStyleSheet("QLabel { color: red; }"); |
|
||||||
ui->lblStatus->setText(tr("\"%1\" does not refer to a key.").arg(ui->lnAddress->text()) + QString(" ") + tr("Please check the address and try again.")); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
bool fInvalid = false; |
|
||||||
std::vector<unsigned char> vchSig = DecodeBase64(ui->lnSig->text().toStdString().c_str(), &fInvalid); |
|
||||||
|
|
||||||
if (fInvalid) |
|
||||||
{ |
|
||||||
ui->lnSig->setValid(false); |
|
||||||
ui->lblStatus->setStyleSheet("QLabel { color: red; }"); |
|
||||||
ui->lblStatus->setText(tr("The signature could not be decoded.") + QString(" ") + tr("Please check the signature and try again.")); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
CDataStream ss(SER_GETHASH, 0); |
|
||||||
ss << strMessageMagic; |
|
||||||
ss << ui->edMessage->document()->toPlainText().toStdString(); |
|
||||||
|
|
||||||
CKey key; |
|
||||||
if (!key.SetCompactSignature(Hash(ss.begin(), ss.end()), vchSig)) |
|
||||||
{ |
|
||||||
ui->lnSig->setValid(false); |
|
||||||
ui->lblStatus->setStyleSheet("QLabel { color: red; }"); |
|
||||||
ui->lblStatus->setText(tr("The signature did not match the message digest.")+ QString(" ") + tr("Please check the signature and try again.")); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
if (!(CBitcoinAddress(key.GetPubKey().GetID()) == addr)) |
|
||||||
{ |
|
||||||
ui->lblStatus->setStyleSheet("QLabel { color: red; }"); |
|
||||||
ui->lblStatus->setText(QString("<nobr>") + tr("Message verification failed.") + QString("</nobr>")); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
ui->lblStatus->setStyleSheet("QLabel { color: green; }"); |
|
||||||
ui->lblStatus->setText(QString("<nobr>") + tr("Message verified.") + QString("</nobr>")); |
|
||||||
} |
|
||||||
|
|
||||||
void VerifyMessageDialog::on_clearButton_clicked() |
|
||||||
{ |
|
||||||
ui->lnAddress->clear(); |
|
||||||
ui->lnSig->clear(); |
|
||||||
ui->edMessage->clear(); |
|
||||||
ui->lblStatus->clear(); |
|
||||||
|
|
||||||
ui->edMessage->setFocus(); |
|
||||||
} |
|
||||||
|
|
||||||
bool VerifyMessageDialog::eventFilter(QObject *object, QEvent *event) |
|
||||||
{ |
|
||||||
if (object == ui->lnAddress && (event->type() == QEvent::MouseButtonPress || |
|
||||||
event->type() == QEvent::FocusIn)) |
|
||||||
{ |
|
||||||
// set lnAddress to valid, as QEvent::FocusIn would not reach QValidatedLineEdit::focusInEvent
|
|
||||||
ui->lnAddress->setValid(true); |
|
||||||
ui->lnAddress->selectAll(); |
|
||||||
return true; |
|
||||||
} |
|
||||||
return QDialog::eventFilter(object, event); |
|
||||||
} |
|
@ -1,33 +0,0 @@ |
|||||||
#ifndef VERIFYMESSAGEDIALOG_H |
|
||||||
#define VERIFYMESSAGEDIALOG_H |
|
||||||
|
|
||||||
#include <QDialog> |
|
||||||
|
|
||||||
namespace Ui { |
|
||||||
class VerifyMessageDialog; |
|
||||||
} |
|
||||||
class AddressTableModel; |
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE |
|
||||||
QT_END_NAMESPACE |
|
||||||
|
|
||||||
class VerifyMessageDialog : public QDialog |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
|
|
||||||
public: |
|
||||||
explicit VerifyMessageDialog(QWidget *parent); |
|
||||||
~VerifyMessageDialog(); |
|
||||||
|
|
||||||
protected: |
|
||||||
bool eventFilter(QObject *object, QEvent *event); |
|
||||||
|
|
||||||
private: |
|
||||||
Ui::VerifyMessageDialog *ui; |
|
||||||
|
|
||||||
private slots: |
|
||||||
void on_verifyMessage_clicked(); |
|
||||||
void on_clearButton_clicked(); |
|
||||||
}; |
|
||||||
|
|
||||||
#endif // VERIFYMESSAGEDIALOG_H
|
|
Loading…
Reference in new issue