mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
pylightning: wrap signmessage/checkmessage.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
ad48814746
commit
ab48ecf07c
@ -991,3 +991,24 @@ class LightningRpc(UnixDomainSocketRpc):
|
||||
"txid": txid
|
||||
}
|
||||
return self.call("txsend", payload)
|
||||
|
||||
def signmessage(self, message):
|
||||
"""
|
||||
Sign a message with this node's secret key.
|
||||
"""
|
||||
payload = {
|
||||
"message": message
|
||||
}
|
||||
return self.call("signmessage", payload)
|
||||
|
||||
def checkmessage(self, message, zbase, pubkey=None):
|
||||
"""
|
||||
Check if a message was signed (with a specific key).
|
||||
Use returned field ['verified'] to get result.
|
||||
"""
|
||||
payload = {
|
||||
"message": message,
|
||||
"zbase": zbase,
|
||||
"pubkey": pubkey,
|
||||
}
|
||||
return self.call("checkmessage", payload)
|
||||
|
@ -1653,7 +1653,7 @@ def test_signmessage(node_factory):
|
||||
|
||||
corpus = [[None,
|
||||
"this is a test!",
|
||||
l1.rpc.call('signmessage', ["this is a test!"])['zbase'],
|
||||
l1.rpc.signmessage("this is a test!")['zbase'],
|
||||
l1.info['id']]]
|
||||
|
||||
# Other contributions from LND users!
|
||||
@ -1683,9 +1683,9 @@ def test_signmessage(node_factory):
|
||||
subprocess.run(['devtools/lightning-checkmessage',
|
||||
c[1] + "modified", c[2], c[3]], check=True)
|
||||
|
||||
assert l1.rpc.call('checkmessage', [c[1], c[2], c[3]])['verified']
|
||||
assert not l1.rpc.call('checkmessage', [c[1] + "modified", c[2], c[3]])['verified']
|
||||
checknokey = l1.rpc.call('checkmessage', [c[1], c[2]])
|
||||
assert l1.rpc.checkmessage(c[1], c[2], c[3])['verified']
|
||||
assert not l1.rpc.checkmessage(c[1] + "modified", c[2], c[3])['verified']
|
||||
checknokey = l1.rpc.checkmessage(c[1], c[2])
|
||||
# Of course, we know our own pubkey
|
||||
if c[3] == l1.info['id']:
|
||||
assert checknokey['verified']
|
||||
@ -1694,7 +1694,7 @@ def test_signmessage(node_factory):
|
||||
assert checknokey['pubkey'] == c[3]
|
||||
|
||||
# l2 knows about l1, so it can validate it.
|
||||
zm = l1.rpc.call('signmessage', ["message for you"])['zbase']
|
||||
checknokey = l2.rpc.call('checkmessage', ["message for you", zm])
|
||||
zm = l1.rpc.signmessage(message="message for you")['zbase']
|
||||
checknokey = l2.rpc.checkmessage(message="message for you", zbase=zm)
|
||||
assert checknokey['pubkey'] == l1.info['id']
|
||||
assert checknokey['verified']
|
||||
|
Loading…
Reference in New Issue
Block a user