Merge pull request #2286 from osilkin98/2279-fix

Fixes corner case on comment validation for pending channel
This commit is contained in:
Thomas Zarebczan 2019-07-03 14:14:47 -04:00 committed by GitHub
commit 4f208b6b31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,19 +19,20 @@ def get_encoded_signature(signature):
def is_comment_signed_by_channel(comment: dict, channel: Output):
try:
pieces = [
comment['signing_ts'].encode(),
channel.claim_hash,
comment['comment'].encode()
]
return Output.is_signature_valid(
get_encoded_signature(comment['signature']),
sha256(b''.join(pieces)),
channel.claim.channel.public_key_bytes
)
except KeyError:
pass
if type(channel) is Output:
try:
pieces = [
comment['signing_ts'].encode(),
channel.claim_hash,
comment['comment'].encode()
]
return Output.is_signature_valid(
get_encoded_signature(comment['signature']),
sha256(b''.join(pieces)),
channel.claim.channel.public_key_bytes
)
except KeyError:
pass
return False