Files
palladum-lightning/plugins/bkpr/chain_event.c
Rusty Russell af2e403490 bkpr: use the in-memory event descriptions, not the database ones.
The new access APIs are more symmetrical:

1. edit_utxo_description -> add_utxo_description
2. add_payment_hash_desc -> add_payment_hash_description

And to read it, instead of accessing ->ev_desc (now removed) we use
chain_event_description() & channel_event_description(), threading bkpr though
as needed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-19 13:37:50 +09:30

35 lines
1.1 KiB
C

#include "config.h"
#include <common/json_stream.h>
#include <plugins/bkpr/chain_event.h>
#include <plugins/bkpr/descriptions.h>
void json_add_chain_event(struct json_stream *out,
const struct bkpr *bkpr,
struct chain_event *ev)
{
const char *desc;
json_object_start(out, NULL);
json_add_string(out, "account", ev->acct_name);
if (ev->origin_acct)
json_add_string(out, "origin", ev->origin_acct);
json_add_string(out, "type", "chain");
json_add_string(out, "tag", ev->tag);
json_add_amount_msat(out, "credit_msat", ev->credit);
json_add_amount_msat(out, "debit_msat", ev->debit);
json_add_string(out, "currency", chainparams->lightning_hrp);
json_add_outpoint(out, "outpoint", &ev->outpoint);
desc = chain_event_description(bkpr, ev);
if (ev->spending_txid)
json_add_txid(out, "txid", ev->spending_txid);
if (ev->payment_id) {
json_add_sha256(out, "payment_id", ev->payment_id);
}
json_add_u64(out, "timestamp", ev->timestamp);
json_add_u32(out, "blockheight", ev->blockheight);
if (desc)
json_add_string(out, "description", desc);
json_object_end(out);
}