decode: new generic API to decode bolt11 and bolt12.

This is experimental for now, but can eventually deprecated
'decodepay' and even decode other kinds of messages.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-01-08 05:18:47 +10:30
parent 84dc943cf5
commit c08ff167b2
10 changed files with 926 additions and 9 deletions

View File

@@ -170,6 +170,23 @@ void json_add_pubkey(struct json_stream *response,
json_add_hex(response, fieldname, der, sizeof(der));
}
void json_add_pubkey32(struct json_stream *response,
const char *fieldname,
const struct pubkey32 *key)
{
u8 output[32];
secp256k1_xonly_pubkey_serialize(secp256k1_ctx, output, &key->pubkey);
json_add_hex(response, fieldname, output, sizeof(output));
}
void json_add_bip340sig(struct json_stream *response,
const char *fieldname,
const struct bip340sig *sig)
{
json_add_hex(response, fieldname, sig->u8, sizeof(sig->u8));
}
void json_add_txid(struct json_stream *result, const char *fieldname,
const struct bitcoin_txid *txid)
{