Skip to content

Commit

Permalink
signmessage: improve the UX of the rpc command when zbase is not a va…
Browse files Browse the repository at this point in the history
…lid one

Changelog-Fixed: signmessage: improve the UX of the rpc command when zbase is not a valid one

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
  • Loading branch information
vincenzopalazzo committed Jun 6, 2022
1 parent 74ddc15 commit db36d2c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lightningd/signmessage.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ static const u8 *from_zbase32(const tal_t *ctx, const char *msg)
if (!bech32_convert_bits(u8arr, &len, 8,
u5arr, tal_bytelen(u5arr), 5, false))
return tal_free(u8arr);
assert(len == tal_bytelen(u8arr));
return u8arr;
return len == tal_bytelen(u8arr) ? u8arr : NULL;
}

static struct command_result *json_signmessage(struct command *cmd,
Expand Down Expand Up @@ -235,4 +234,3 @@ static const struct json_command json_checkmessage_cmd = {
"Verify a digital signature {zbase} of {message} signed with {pubkey}",
};
AUTODATA(json_command, &json_checkmessage_cmd);

4 changes: 4 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1867,6 +1867,10 @@ def test_signmessage(node_factory):
checknokey = l2.rpc.checkmessage(message="message for you", zbase=zm)
assert checknokey['pubkey'] == l1.info['id']
assert checknokey['verified']
# check that checkmassage used with a wrong zbase format throws an RPC exception
with pytest.raises(RpcError):
l2.rpc.checkmessage(message="wrong zbase format", zbase="wrong zbase format")



def test_include(node_factory):
Expand Down

0 comments on commit db36d2c

Please sign in to comment.