common: json_to_msat and json_to_sat helpers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-02-21 11:16:57 +10:30
parent a25e22737c
commit 177cfd9edc
3 changed files with 30 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
#include <bitcoin/pubkey.h>
#include <bitcoin/short_channel_id.h>
#include <common/amount.h>
#include <common/json_helpers.h>
#include <errno.h>
@@ -38,6 +39,19 @@ bool json_to_pubkey(const char *buffer, const jsmntok_t *tok,
tok->end - tok->start, pubkey);
}
bool json_to_msat(const char *buffer, const jsmntok_t *tok,
struct amount_msat *msat)
{
return parse_amount_msat(msat,
buffer + tok->start, tok->end - tok->start);
}
bool json_to_sat(const char *buffer, const jsmntok_t *tok,
struct amount_sat *sat)
{
return parse_amount_sat(sat, buffer + tok->start, tok->end - tok->start);
}
bool json_to_short_channel_id(const char *buffer, const jsmntok_t *tok,
struct short_channel_id *scid,
bool may_be_deprecated_form)