mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 14:54:26 +01:00
common/json: add a helper for json to u16
As Rusty pointed out to me, the gossip protocol restricts cltvs to u16 so at least we'll use this helper for them.
This commit is contained in:
@@ -90,6 +90,21 @@ bool json_to_number(const char *buffer, const jsmntok_t *tok,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool json_to_u16(const char *buffer, const jsmntok_t *tok,
|
||||
short unsigned int *num)
|
||||
{
|
||||
uint64_t u64;
|
||||
|
||||
if (!json_to_u64(buffer, tok, &u64))
|
||||
return false;
|
||||
*num = u64;
|
||||
|
||||
/* Just in case it doesn't fit. */
|
||||
if (*num != u64)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool json_to_int(const char *buffer, const jsmntok_t *tok, int *num)
|
||||
{
|
||||
char *end;
|
||||
|
||||
Reference in New Issue
Block a user