Files
lightning/lightningd/coin_mvts.c
niftynei b6463174d6 coin moves: turn 'tag' into 'tags' array, add OPENER tag
Channels that the node has hopened will now be tagged with 'opener' in a
list of tags.
2021-12-28 04:42:42 +10:30

68 lines
1.8 KiB
C

#include "config.h"
#include <lightningd/channel.h>
#include <lightningd/coin_mvts.h>
#include <lightningd/notification.h>
void notify_channel_mvt(struct lightningd *ld, const struct channel_coin_mvt *mvt)
{
const struct coin_mvt *cm;
u32 timestamp;
timestamp = time_now().ts.tv_sec;
cm = finalize_channel_mvt(mvt, mvt, chainparams->lightning_hrp,
timestamp, &ld->id);
notify_coin_mvt(ld, cm);
}
void notify_chain_mvt(struct lightningd *ld, const struct chain_coin_mvt *mvt)
{
const struct coin_mvt *cm;
u32 timestamp;
timestamp = time_now().ts.tv_sec;
cm = finalize_chain_mvt(mvt, mvt, chainparams->onchain_hrp,
timestamp, &ld->id);
notify_coin_mvt(ld, cm);
}
struct channel_coin_mvt *new_channel_mvt_invoice_hin(const tal_t *ctx,
struct htlc_in *hin,
struct channel *channel)
{
return new_channel_coin_mvt(ctx, &channel->cid,
hin->payment_hash, NULL,
hin->msat, new_tag_arr(ctx, INVOICE),
true);
}
struct channel_coin_mvt *new_channel_mvt_routed_hin(const tal_t *ctx,
struct htlc_in *hin,
struct channel *channel)
{
return new_channel_coin_mvt(ctx, &channel->cid,
hin->payment_hash, NULL,
hin->msat, new_tag_arr(ctx, ROUTED),
true);
}
struct channel_coin_mvt *new_channel_mvt_invoice_hout(const tal_t *ctx,
struct htlc_out *hout,
struct channel *channel)
{
return new_channel_coin_mvt(ctx, &channel->cid,
hout->payment_hash, &hout->partid,
hout->msat, new_tag_arr(ctx, INVOICE),
false);
}
struct channel_coin_mvt *new_channel_mvt_routed_hout(const tal_t *ctx,
struct htlc_out *hout,
struct channel *channel)
{
return new_channel_coin_mvt(ctx, &channel->cid,
hout->payment_hash, NULL,
hout->msat, new_tag_arr(ctx, ROUTED),
false);
}