mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
json: add "json-to-psbt" helper
Pull a PSBT out of a json buffer
This commit is contained in:
parent
10237ccb8e
commit
df7c122cb8
2 changed files with 13 additions and 0 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <common/type_to_string.h>
|
||||
#include <common/wireaddr.h>
|
||||
#include <errno.h>
|
||||
#include <wally_psbt.h>
|
||||
|
||||
bool json_to_bitcoin_amount(const char *buffer, const jsmntok_t *tok,
|
||||
uint64_t *satoshi)
|
||||
|
@ -127,6 +128,13 @@ bool json_to_preimage(const char *buffer, const jsmntok_t *tok, struct preimage
|
|||
return hex_decode(buffer + tok->start, hexlen, preimage->r, sizeof(preimage->r));
|
||||
}
|
||||
|
||||
bool json_to_psbt(const tal_t *ctx, const char *buffer,
|
||||
const jsmntok_t *tok, struct wally_psbt **dest)
|
||||
{
|
||||
*dest = psbt_from_b64(ctx, buffer + tok->start, tok->end - tok->start);
|
||||
return dest != NULL;
|
||||
}
|
||||
|
||||
void json_add_node_id(struct json_stream *response,
|
||||
const char *fieldname,
|
||||
const struct node_id *id)
|
||||
|
|
|
@ -17,6 +17,7 @@ struct secret;
|
|||
struct short_channel_id;
|
||||
struct wireaddr;
|
||||
struct wireaddr_internal;
|
||||
struct wally_psbt;
|
||||
|
||||
/* Decode a hex-encoded payment preimage */
|
||||
bool json_to_preimage(const char *buffer, const jsmntok_t *tok, struct preimage *preimage);
|
||||
|
@ -24,6 +25,10 @@ bool json_to_preimage(const char *buffer, const jsmntok_t *tok, struct preimage
|
|||
/* Extract a secret from this. */
|
||||
bool json_to_secret(const char *buffer, const jsmntok_t *tok, struct secret *dest);
|
||||
|
||||
/* Extract a psbt from this. */
|
||||
bool json_to_psbt(const tal_t *ctx, const char *buffer,
|
||||
const jsmntok_t *tok, struct wally_psbt **dest);
|
||||
|
||||
/* Extract a pubkey from this */
|
||||
bool json_to_pubkey(const char *buffer, const jsmntok_t *tok,
|
||||
struct pubkey *pubkey);
|
||||
|
|
Loading…
Add table
Reference in a new issue