Skip to content

Commit 6c81e2e

Browse files
common: add the json tok bitcoin tx
Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent ea4b9a7 commit 6c81e2e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

common/json_parse.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,14 @@ bool json_to_txid(const char *buffer, const jsmntok_t *tok,
581581
tok->end - tok->start, txid);
582582
}
583583

584+
bool json_to_tx(const char *buffer, const jsmntok_t *tok,
585+
struct bitcoin_tx *tx)
586+
{
587+
tx = bitcoin_tx_from_hex(buffer, buffer + tok->start, tok->size);
588+
return true;
589+
}
590+
591+
584592
bool json_to_outpoint(const char *buffer, const jsmntok_t *tok,
585593
struct bitcoin_outpoint *op)
586594
{

common/json_parse.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/* Simple helpers are here: this file contains heavier ones */
88
#include <common/json_parse_simple.h>
99
#include <common/jsonrpc_errors.h>
10+
#include <bitcoin/tx.h>
1011

1112
struct json_escape;
1213
struct json_stream;
@@ -102,6 +103,10 @@ bool json_to_msat(const char *buffer, const jsmntok_t *tok,
102103
bool json_to_txid(const char *buffer, const jsmntok_t *tok,
103104
struct bitcoin_txid *txid);
104105

106+
/* Extract a bitcoin tx from this */
107+
bool json_to_tx(const char *buffer, const jsmntok_t *tok,
108+
struct bitcoin_tx *tx);
109+
105110
/* Extract a bitcoin outpoint from this */
106111
bool json_to_outpoint(const char *buffer, const jsmntok_t *tok,
107112
struct bitcoin_outpoint *op);

0 commit comments

Comments
 (0)