Skip to content

Commit

Permalink
fix message signing issues
Browse files Browse the repository at this point in the history
bar message signing with p2sh addresses for now
  • Loading branch information
goatpig committed Mar 30, 2018
1 parent b1fd719 commit 5067489
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions jasvet.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import CppBlockUtils
from armoryengine.ArmoryUtils import getVersionString, BTCARMORY_VERSION, \
ChecksumError
ChecksumError, ADDRBYTE


FTVerbose=False
Expand Down Expand Up @@ -196,8 +196,10 @@ def hash_160(public_key):
md.update(hashlib.sha256(public_key).digest())
return md.digest()

def public_key_to_bc_address(public_key, v=0):
def public_key_to_bc_address(public_key, v=ADDRBYTE):
h160 = hash_160(public_key)
if isinstance(v, str):
v = ord(v)
return hash_160_to_bc_address(h160, v)

def inverse_mod( a, m ):
Expand Down
13 changes: 9 additions & 4 deletions ui/toolsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ def getPrivateKeyFromAddrInput(self):
atype, addr160 = addrStr_to_hash160(str(self.addressLineEdit.text()))
if atype==P2SHBYTE:
LOGWARN('P2SH address requested')
QMessageBox.critical(self, self.tr('P2SH Address'), \
self.tr('You are attempting to sign a message with a P2SH address. <br><br>This feature is not supported at the moment'), \
QMessageBox.Ok)
return

walletId = self.main.getWalletForAddr160(addr160)
wallet = self.main.walletMap[walletId]
if wallet.useEncryption and wallet.isLocked:
Expand All @@ -128,7 +133,7 @@ def getPrivateKeyFromAddrInput(self):
self.tr('Cannot import private keys without unlocking wallet!'), \
QMessageBox.Ok)
return
return wallet.addrMap[addr160].binPrivKey32_Plain.toBinStr()
return wallet.getAddrObjectForHash(addr160).binPrivKey32_Plain.toBinStr()

def bareSignMessage(self):
messageText = str(self.messageTextEdit.toPlainText())
Expand Down Expand Up @@ -236,13 +241,13 @@ def displayVerifiedBox(self, addrB58, messageString):
# in the Message Signing/Verification dialog
msg = '<br>'.join([line[:60]+ '...'*(len(line)>60) for line in msg.split('<br>')][:12])
MsgBoxCustom(MSGBOX.Good, self.tr('Verified!'), str(self.tr(
'%`'
'%1`'
'<hr>'
'<blockquote>'
'<font face="Courier" color="#000060"><b>%1</b></font>'
'<font face="Courier" color="#000060"><b>%2</b></font>'
'</blockquote>'
'<hr><br>'
'<b>Please</b> make sure that the address above (%2...) matches the '
'<b>Please</b> make sure that the address above (%3...) matches the '
'exact address you were expecting. A valid signature is meaningless '
'unless it is made '
'from a recognized address!').arg(ownerStr, msg, addrB58[:10])))
Expand Down

0 comments on commit 5067489

Please sign in to comment.