@@ -208,21 +208,22 @@ struct mvt_account_id *new_mvt_account_id(const tal_t *ctx,
208208 return acct ;
209209}
210210
211- struct channel_coin_mvt * new_channel_coin_mvt (const tal_t * ctx ,
212- const struct channel * channel ,
213- u64 timestamp ,
214- const struct sha256 * payment_hash TAKES ,
215- const u64 * part_id ,
216- const u64 * group_id ,
217- enum coin_mvt_dir direction ,
218- struct amount_msat amount ,
219- struct mvt_tags tags ,
220- struct amount_msat fees )
211+ struct channel_coin_mvt * new_channel_coin_mvt_general (const tal_t * ctx ,
212+ const struct channel * channel ,
213+ const struct channel_id * cid ,
214+ u64 timestamp ,
215+ const struct sha256 * payment_hash TAKES ,
216+ const u64 * part_id ,
217+ const u64 * group_id ,
218+ enum coin_mvt_dir direction ,
219+ struct amount_msat amount ,
220+ struct mvt_tags tags ,
221+ struct amount_msat fees )
221222{
222223 struct channel_coin_mvt * mvt = tal (ctx , struct channel_coin_mvt );
223224
224225 assert (mvt_tags_valid (tags ));
225- set_mvt_account_id (& mvt -> account , channel , NULL );
226+ set_mvt_account_id (& mvt -> account , channel , cid ? take ( fmt_channel_id ( NULL , cid )) : NULL );
226227 mvt -> timestamp = timestamp ;
227228 mvt -> payment_hash = tal_dup_or_null (mvt , struct sha256 , payment_hash );
228229 if (!part_id ) {
@@ -252,6 +253,21 @@ struct channel_coin_mvt *new_channel_coin_mvt(const tal_t *ctx,
252253 abort ();
253254}
254255
256+ struct channel_coin_mvt * new_channel_coin_mvt (const tal_t * ctx ,
257+ const struct channel * channel ,
258+ u64 timestamp ,
259+ const struct sha256 * payment_hash TAKES ,
260+ const u64 * part_id ,
261+ const u64 * group_id ,
262+ enum coin_mvt_dir direction ,
263+ struct amount_msat amount ,
264+ struct mvt_tags tags ,
265+ struct amount_msat fees )
266+ {
267+ return new_channel_coin_mvt_general (ctx , channel , NULL , timestamp , payment_hash ,
268+ part_id , group_id , direction , amount , tags , fees );
269+ }
270+
255271static struct chain_coin_mvt * new_chain_coin_mvt (const tal_t * ctx ,
256272 const struct channel * channel ,
257273 const char * account_name TAKES ,
@@ -409,15 +425,17 @@ struct chain_coin_mvt *new_coin_channel_open_proposed(const tal_t *ctx,
409425 return mvt ;
410426}
411427
412- struct chain_coin_mvt * new_coin_channel_open (const tal_t * ctx ,
413- const struct channel * channel ,
414- const struct bitcoin_outpoint * out ,
415- const struct node_id * peer_id ,
416- u32 blockheight ,
417- const struct amount_msat amount ,
418- const struct amount_sat output_val ,
419- bool is_opener ,
420- bool is_leased )
428+ struct chain_coin_mvt * new_coin_channel_open_general (const tal_t * ctx ,
429+ const struct channel * channel ,
430+ const struct channel_id * cid ,
431+ u64 timestamp ,
432+ const struct bitcoin_outpoint * out ,
433+ const struct node_id * peer_id ,
434+ u32 blockheight ,
435+ const struct amount_msat amount ,
436+ const struct amount_sat output_val ,
437+ bool is_opener ,
438+ bool is_leased )
421439{
422440 struct chain_coin_mvt * mvt ;
423441 struct mvt_tags tags = tag_to_mvt_tags (MVT_CHANNEL_OPEN );
@@ -429,7 +447,8 @@ struct chain_coin_mvt *new_coin_channel_open(const tal_t *ctx,
429447 if (is_leased )
430448 tag_set (& tags , MVT_LEASED );
431449
432- mvt = new_chain_coin_mvt (ctx , channel , NULL , time_now ().ts .tv_sec ,
450+ mvt = new_chain_coin_mvt (ctx , channel , cid ? take (fmt_channel_id (NULL , cid )) : NULL ,
451+ timestamp ,
433452 NULL , out , NULL , blockheight ,
434453 tags ,
435454 COIN_CREDIT , amount ,
@@ -439,6 +458,22 @@ struct chain_coin_mvt *new_coin_channel_open(const tal_t *ctx,
439458 return mvt ;
440459}
441460
461+ struct chain_coin_mvt * new_coin_channel_open (const tal_t * ctx ,
462+ const struct channel * channel ,
463+ const struct bitcoin_outpoint * out ,
464+ const struct node_id * peer_id ,
465+ u32 blockheight ,
466+ const struct amount_msat amount ,
467+ const struct amount_sat output_val ,
468+ bool is_opener ,
469+ bool is_leased )
470+ {
471+ return new_coin_channel_open_general (ctx , channel , NULL ,
472+ time_now ().ts .tv_sec ,
473+ out , peer_id , blockheight ,
474+ amount , output_val , is_opener , is_leased );
475+ }
476+
442477struct chain_coin_mvt * new_onchain_htlc_deposit (const tal_t * ctx ,
443478 const struct bitcoin_outpoint * outpoint ,
444479 u32 blockheight ,
@@ -523,16 +558,29 @@ struct chain_coin_mvt *new_coin_wallet_withdraw(const tal_t *ctx,
523558 COIN_DEBIT , amount );
524559}
525560
561+ struct channel_coin_mvt * new_coin_channel_push_general (const tal_t * ctx ,
562+ const struct channel * channel ,
563+ const struct channel_id * cid ,
564+ u64 timestamp ,
565+ enum coin_mvt_dir direction ,
566+ struct amount_msat amount ,
567+ struct mvt_tags tags )
568+ {
569+ return new_channel_coin_mvt_general (ctx , channel , cid , timestamp , NULL ,
570+ NULL , NULL , direction , amount ,
571+ tags ,
572+ AMOUNT_MSAT (0 ));
573+ }
574+
526575struct channel_coin_mvt * new_coin_channel_push (const tal_t * ctx ,
527576 const struct channel * channel ,
528577 enum coin_mvt_dir direction ,
529578 struct amount_msat amount ,
530579 struct mvt_tags tags )
531580{
532- return new_channel_coin_mvt (ctx , channel , time_now ().ts .tv_sec , NULL ,
533- NULL , NULL , direction , amount ,
534- tags ,
535- AMOUNT_MSAT (0 ));
581+ return new_coin_channel_push_general (ctx , channel , NULL ,
582+ time_now ().ts .tv_sec ,
583+ direction , amount , tags );
536584}
537585
538586struct chain_coin_mvt * new_foreign_deposit (const tal_t * ctx ,
0 commit comments