mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
common: json_to_msat and json_to_sat helpers.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include <bitcoin/pubkey.h>
|
#include <bitcoin/pubkey.h>
|
||||||
#include <bitcoin/short_channel_id.h>
|
#include <bitcoin/short_channel_id.h>
|
||||||
|
#include <common/amount.h>
|
||||||
#include <common/json_helpers.h>
|
#include <common/json_helpers.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
@@ -38,6 +39,19 @@ bool json_to_pubkey(const char *buffer, const jsmntok_t *tok,
|
|||||||
tok->end - tok->start, pubkey);
|
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,
|
bool json_to_short_channel_id(const char *buffer, const jsmntok_t *tok,
|
||||||
struct short_channel_id *scid,
|
struct short_channel_id *scid,
|
||||||
bool may_be_deprecated_form)
|
bool may_be_deprecated_form)
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <common/json.h>
|
#include <common/json.h>
|
||||||
|
|
||||||
|
struct amount_msat;
|
||||||
|
struct amount_sat;
|
||||||
struct pubkey;
|
struct pubkey;
|
||||||
struct short_channel_id;
|
struct short_channel_id;
|
||||||
|
|
||||||
@@ -20,4 +22,12 @@ bool json_to_short_channel_id(const char *buffer, const jsmntok_t *tok,
|
|||||||
struct short_channel_id *scid,
|
struct short_channel_id *scid,
|
||||||
bool may_be_deprecated_form);
|
bool may_be_deprecated_form);
|
||||||
|
|
||||||
|
/* Extract a satoshis amount from this */
|
||||||
|
bool json_to_sat(const char *buffer, const jsmntok_t *tok,
|
||||||
|
struct amount_sat *sat);
|
||||||
|
|
||||||
|
/* Extract a millisatoshis amount from this */
|
||||||
|
bool json_to_msat(const char *buffer, const jsmntok_t *tok,
|
||||||
|
struct amount_msat *msat);
|
||||||
|
|
||||||
#endif /* LIGHTNING_COMMON_JSON_HELPERS_H */
|
#endif /* LIGHTNING_COMMON_JSON_HELPERS_H */
|
||||||
|
|||||||
@@ -5,6 +5,12 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/* AUTOGENERATED MOCKS START */
|
/* AUTOGENERATED MOCKS START */
|
||||||
|
/* Generated stub for parse_amount_msat */
|
||||||
|
bool parse_amount_msat(struct amount_msat *msat UNNEEDED, const char *s UNNEEDED, size_t slen UNNEEDED)
|
||||||
|
{ fprintf(stderr, "parse_amount_msat called!\n"); abort(); }
|
||||||
|
/* Generated stub for parse_amount_sat */
|
||||||
|
bool parse_amount_sat(struct amount_sat *sat UNNEEDED, const char *s UNNEEDED, size_t slen UNNEEDED)
|
||||||
|
{ fprintf(stderr, "parse_amount_sat called!\n"); abort(); }
|
||||||
/* AUTOGENERATED MOCKS END */
|
/* AUTOGENERATED MOCKS END */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user