diff --git a/common/coin_mvt.c b/common/coin_mvt.c index 98431b4f6..e9a059108 100644 --- a/common/coin_mvt.c +++ b/common/coin_mvt.c @@ -1,6 +1,5 @@ #include "config.h" #include -#include #include #include #include @@ -180,7 +179,7 @@ static struct chain_coin_mvt *new_chain_coin_mvt(const tal_t *ctx, set_mvt_account_id(&mvt->account, channel, account_name); mvt->timestamp = timestamp; mvt->tx_txid = tx_txid; - mvt->outpoint = outpoint; + mvt->outpoint = *outpoint; mvt->originating_acct = NULL; /* Most chain event's don't have a peer (only channel_opens) */ @@ -484,7 +483,7 @@ void towire_chain_coin_mvt(u8 **pptr, const struct chain_coin_mvt *mvt) towire_wirestring(pptr, mvt->account.alt_account); assert(!mvt->originating_acct); - towire_bitcoin_outpoint(pptr, mvt->outpoint); + towire_bitcoin_outpoint(pptr, &mvt->outpoint); if (mvt->tx_txid) { towire_bool(pptr, true); @@ -518,11 +517,7 @@ void fromwire_chain_coin_mvt(const u8 **cursor, size_t *max, struct chain_coin_m set_mvt_account_id(&mvt->account, NULL, take(fromwire_wirestring(NULL, cursor, max))); mvt->originating_acct = NULL; - /* Read into non-const version */ - struct bitcoin_outpoint *outpoint - = tal(mvt, struct bitcoin_outpoint); - fromwire_bitcoin_outpoint(cursor, max, outpoint); - mvt->outpoint = outpoint; + fromwire_bitcoin_outpoint(cursor, max, &mvt->outpoint); if (fromwire_bool(cursor, max)) { mvt->tx_txid = tal(mvt, struct bitcoin_txid); diff --git a/common/coin_mvt.h b/common/coin_mvt.h index 7f29b1b64..3fffe61ab 100644 --- a/common/coin_mvt.h +++ b/common/coin_mvt.h @@ -2,6 +2,7 @@ #define LIGHTNING_COMMON_COIN_MVT_H #include "config.h" +#include #include #include #include @@ -87,9 +88,9 @@ struct chain_coin_mvt { struct amount_msat credit; struct amount_msat debit; u64 timestamp; + struct bitcoin_outpoint outpoint; const struct bitcoin_txid *tx_txid; - const struct bitcoin_outpoint *outpoint; /* The id of the peer we have this channel with. * Only on our channel_open events */ diff --git a/lightningd/notification.c b/lightningd/notification.c index d01d28be6..2c95ca4d9 100644 --- a/lightningd/notification.c +++ b/lightningd/notification.c @@ -501,15 +501,10 @@ static void chain_movement_notification_serialize(struct json_stream *stream, json_add_string(stream, "txid", fmt_bitcoin_txid(tmpctx, chain_mvt->tx_txid)); - /* some chain ledger entries aren't associated with a utxo - * e.g. journal updates (due to penalty/state loss) and - * chain_fee entries */ - if (chain_mvt->outpoint) { - json_add_string(stream, "utxo_txid", - fmt_bitcoin_txid(tmpctx, - &chain_mvt->outpoint->txid)); - json_add_u32(stream, "vout", chain_mvt->outpoint->n); - } + json_add_string(stream, "utxo_txid", + fmt_bitcoin_txid(tmpctx, + &chain_mvt->outpoint.txid)); + json_add_u32(stream, "vout", chain_mvt->outpoint.n); /* on-chain htlcs include a payment hash */ if (chain_mvt->payment_hash)