diff --git a/common/coin_mvt.c b/common/coin_mvt.c index 22b642a50..da576926d 100644 --- a/common/coin_mvt.c +++ b/common/coin_mvt.c @@ -48,8 +48,32 @@ enum mvt_tag *new_tag_arr(const tal_t *ctx, enum mvt_tag tag) return tags; } +void set_mvt_account_id(struct mvt_account_id *acct_id, + const struct channel *channel, + const char *account_name TAKES) +{ + if (channel) { + assert(account_name == NULL); + acct_id->channel = channel; + acct_id->alt_account = NULL; + } else { + assert(account_name != NULL); + acct_id->channel = NULL; + acct_id->alt_account = tal_strdup(acct_id, account_name); + } +} + +struct mvt_account_id *new_mvt_account_id(const tal_t *ctx, + const struct channel *channel, + const char *account_name TAKES) +{ + struct mvt_account_id *acct = tal(ctx, struct mvt_account_id); + set_mvt_account_id(acct, channel, account_name); + return acct; +} + struct channel_coin_mvt *new_channel_coin_mvt(const tal_t *ctx, - const struct channel_id *cid, + const struct channel *channel, const struct sha256 *payment_hash TAKES, const u64 *part_id, const u64 *group_id, @@ -60,7 +84,7 @@ struct channel_coin_mvt *new_channel_coin_mvt(const tal_t *ctx, { struct channel_coin_mvt *mvt = tal(ctx, struct channel_coin_mvt); - mvt->chan_id = *cid; + set_mvt_account_id(&mvt->account, channel, NULL); mvt->payment_hash = tal_dup_or_null(mvt, struct sha256, payment_hash); if (!part_id) { assert(!group_id); @@ -89,6 +113,7 @@ struct channel_coin_mvt *new_channel_coin_mvt(const tal_t *ctx, } static struct chain_coin_mvt *new_chain_coin_mvt(const tal_t *ctx, + const struct channel *channel, const char *account_name TAKES, const struct bitcoin_txid *tx_txid, const struct bitcoin_outpoint *outpoint, @@ -102,7 +127,7 @@ static struct chain_coin_mvt *new_chain_coin_mvt(const tal_t *ctx, { struct chain_coin_mvt *mvt = tal(ctx, struct chain_coin_mvt); - mvt->account_name = tal_strdup_or_null(mvt, account_name); + set_mvt_account_id(&mvt->account, channel, account_name); mvt->tx_txid = tx_txid; mvt->outpoint = outpoint; mvt->originating_acct = NULL; @@ -134,7 +159,8 @@ static struct chain_coin_mvt *new_chain_coin_mvt(const tal_t *ctx, } static struct chain_coin_mvt *new_chain_coin_mvt_sat(const tal_t *ctx, - const char *account_name, + const struct channel *channel, + const char *account_name TAKES, const struct bitcoin_txid *tx_txid, const struct bitcoin_outpoint *outpoint, const struct sha256 *payment_hash TAKES, @@ -148,7 +174,7 @@ static struct chain_coin_mvt *new_chain_coin_mvt_sat(const tal_t *ctx, ok = amount_sat_to_msat(&amt_msat, amt_sat); assert(ok); - return new_chain_coin_mvt(ctx, account_name, tx_txid, + return new_chain_coin_mvt(ctx, channel, account_name, tx_txid, outpoint, payment_hash, blockheight, tags, direction, amt_msat, /* All amounts that are sat are @@ -163,7 +189,7 @@ struct chain_coin_mvt *new_onchaind_withdraw(const tal_t *ctx, struct amount_sat amount, enum mvt_tag tag) { - return new_chain_coin_mvt_sat(ctx, NULL, spend_txid, + return new_chain_coin_mvt_sat(ctx, NULL, "", spend_txid, outpoint, NULL, blockheight, take(new_tag_arr(NULL, tag)), @@ -176,7 +202,7 @@ struct chain_coin_mvt *new_onchaind_deposit(const tal_t *ctx, struct amount_sat amount, enum mvt_tag tag) { - return new_chain_coin_mvt_sat(ctx, NULL, NULL, + return new_chain_coin_mvt_sat(ctx, NULL, "", NULL, outpoint, NULL, blockheight, take(new_tag_arr(NULL, tag)), @@ -184,7 +210,8 @@ struct chain_coin_mvt *new_onchaind_deposit(const tal_t *ctx, } struct chain_coin_mvt *new_coin_channel_close(const tal_t *ctx, - const struct channel_id *chan_id, + const struct channel *channel, + const char *alt_account, const struct bitcoin_txid *txid, const struct bitcoin_outpoint *out, u32 blockheight, @@ -199,20 +226,17 @@ struct chain_coin_mvt *new_coin_channel_close(const tal_t *ctx, if (is_splice) tal_arr_expand(&tags, SPLICE); - mvt = new_chain_coin_mvt(ctx, NULL, txid, + mvt = new_chain_coin_mvt(ctx, channel, alt_account, txid, out, NULL, blockheight, take(tags), COIN_DEBIT, amount, output_val, output_count); - if (chan_id) - mvt->account_name = fmt_channel_id(mvt, chan_id); - return mvt; } struct chain_coin_mvt *new_coin_channel_open_proposed(const tal_t *ctx, - const struct channel_id *chan_id, + const struct channel *channel, const struct bitcoin_outpoint *out, const struct node_id *peer_id, const struct amount_msat amount, @@ -222,10 +246,9 @@ struct chain_coin_mvt *new_coin_channel_open_proposed(const tal_t *ctx, { struct chain_coin_mvt *mvt; - mvt = new_chain_coin_mvt(ctx, NULL, NULL, out, NULL, 0, + mvt = new_chain_coin_mvt(ctx, channel, NULL, NULL, out, NULL, 0, take(new_tag_arr(NULL, CHANNEL_PROPOSED)), COIN_CREDIT, amount, output_val, 0); - mvt->account_name = fmt_channel_id(mvt, chan_id); mvt->peer_id = tal_dup(mvt, struct node_id, peer_id); /* If we're the opener, add to the tag list */ @@ -239,7 +262,7 @@ struct chain_coin_mvt *new_coin_channel_open_proposed(const tal_t *ctx, } struct chain_coin_mvt *new_coin_channel_open(const tal_t *ctx, - const struct channel_id *chan_id, + const struct channel *channel, const struct bitcoin_outpoint *out, const struct node_id *peer_id, u32 blockheight, @@ -250,11 +273,10 @@ struct chain_coin_mvt *new_coin_channel_open(const tal_t *ctx, { struct chain_coin_mvt *mvt; - mvt = new_chain_coin_mvt(ctx, NULL, NULL, out, NULL, blockheight, + mvt = new_chain_coin_mvt(ctx, channel, NULL, NULL, out, NULL, blockheight, take(new_tag_arr(NULL, CHANNEL_OPEN)), COIN_CREDIT, amount, output_val, 0); - mvt->account_name = fmt_channel_id(mvt, chan_id); mvt->peer_id = tal_dup(mvt, struct node_id, peer_id); /* If we're the opener, add to the tag list */ @@ -273,7 +295,7 @@ struct chain_coin_mvt *new_onchain_htlc_deposit(const tal_t *ctx, struct amount_sat amount, const struct sha256 *payment_hash) { - return new_chain_coin_mvt_sat(ctx, NULL, NULL, + return new_chain_coin_mvt_sat(ctx, NULL, "", NULL, outpoint, payment_hash, blockheight, take(new_tag_arr(NULL, HTLC_FULFILL)), @@ -289,7 +311,7 @@ struct chain_coin_mvt *new_onchain_htlc_withdraw(const tal_t *ctx, { /* An onchain htlc fulfillment to peer is a *deposit* of * that output into their (external) account */ - return new_chain_coin_mvt_sat(ctx, EXTERNAL, NULL, + return new_chain_coin_mvt_sat(ctx, NULL, EXTERNAL, NULL, outpoint, payment_hash, blockheight, take(new_tag_arr(NULL, HTLC_FULFILL)), @@ -303,7 +325,7 @@ struct chain_coin_mvt *new_coin_external_spend_tags(const tal_t *ctx, struct amount_sat amount, enum mvt_tag *tags TAKES) { - return new_chain_coin_mvt(ctx, EXTERNAL, txid, + return new_chain_coin_mvt(ctx, NULL, EXTERNAL, txid, outpoint, NULL, blockheight, take(tags), COIN_CREDIT, AMOUNT_MSAT(0), amount, 0); @@ -327,7 +349,7 @@ struct chain_coin_mvt *new_coin_external_deposit_tags(const tal_t *ctx, struct amount_sat amount, enum mvt_tag *tags TAKES) { - return new_chain_coin_mvt_sat(ctx, EXTERNAL, NULL, outpoint, NULL, + return new_chain_coin_mvt_sat(ctx, NULL, EXTERNAL, NULL, outpoint, NULL, blockheight, take(tags), COIN_CREDIT, amount); } @@ -339,14 +361,14 @@ struct chain_coin_mvt *new_coin_external_deposit(const tal_t *ctx, struct amount_sat amount, enum mvt_tag tag) { - return new_chain_coin_mvt_sat(ctx, EXTERNAL, NULL, outpoint, NULL, + return new_chain_coin_mvt_sat(ctx, NULL, EXTERNAL, NULL, outpoint, NULL, blockheight, take(new_tag_arr(NULL, tag)), COIN_CREDIT, amount); } bool chain_mvt_is_external(const struct chain_coin_mvt *mvt) { - return streq(mvt->account_name, EXTERNAL); + return mvt->account.alt_account && streq(mvt->account.alt_account, EXTERNAL); } struct chain_coin_mvt *new_coin_wallet_deposit(const tal_t *ctx, @@ -355,7 +377,7 @@ struct chain_coin_mvt *new_coin_wallet_deposit(const tal_t *ctx, struct amount_sat amount, enum mvt_tag tag) { - return new_chain_coin_mvt_sat(ctx, WALLET, NULL, + return new_chain_coin_mvt_sat(ctx, NULL, WALLET, NULL, outpoint, NULL, blockheight, take(new_tag_arr(NULL, tag)), COIN_CREDIT, amount); @@ -367,7 +389,7 @@ struct chain_coin_mvt *new_coin_wallet_deposit_tagged(const tal_t *ctx, struct amount_sat amount, enum mvt_tag *tags TAKES) { - return new_chain_coin_mvt_sat(ctx, WALLET, NULL, + return new_chain_coin_mvt_sat(ctx, NULL, WALLET, NULL, outpoint, NULL, blockheight, take(tags), @@ -381,37 +403,30 @@ struct chain_coin_mvt *new_coin_wallet_withdraw(const tal_t *ctx, struct amount_sat amount, enum mvt_tag tag) { - return new_chain_coin_mvt_sat(ctx, WALLET, spend_txid, + return new_chain_coin_mvt_sat(ctx, NULL, WALLET, spend_txid, outpoint, NULL, blockheight, take(new_tag_arr(NULL, tag)), COIN_DEBIT, amount); } struct channel_coin_mvt *new_coin_channel_push(const tal_t *ctx, - const struct channel_id *cid, + const struct channel *channel, enum coin_mvt_dir direction, struct amount_msat amount, enum mvt_tag tag) { - return new_channel_coin_mvt(ctx, cid, NULL, + return new_channel_coin_mvt(ctx, channel, NULL, NULL, NULL, direction, amount, take(new_tag_arr(NULL, tag)), AMOUNT_MSAT(0)); } +/* This is used solely by onchaind. It always uses alt_account, with "" meaning + * the channel itself. */ void towire_chain_coin_mvt(u8 **pptr, const struct chain_coin_mvt *mvt) { - if (mvt->account_name) { - towire_bool(pptr, true); - towire_wirestring(pptr, mvt->account_name); - } else - towire_bool(pptr, false); - - if (mvt->originating_acct) { - towire_bool(pptr, true); - towire_wirestring(pptr, mvt->originating_acct); - } else - towire_bool(pptr, false); + towire_wirestring(pptr, mvt->account.alt_account); + assert(!mvt->originating_acct); towire_bitcoin_outpoint(pptr, mvt->outpoint); @@ -446,15 +461,8 @@ void towire_chain_coin_mvt(u8 **pptr, const struct chain_coin_mvt *mvt) void fromwire_chain_coin_mvt(const u8 **cursor, size_t *max, struct chain_coin_mvt *mvt) { - if (fromwire_bool(cursor, max)) { - mvt->account_name = fromwire_wirestring(mvt, cursor, max); - } else - mvt->account_name = NULL; - - if (fromwire_bool(cursor, max)) { - mvt->originating_acct = fromwire_wirestring(mvt, cursor, max); - } else - mvt->originating_acct = NULL; + 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 diff --git a/common/coin_mvt.h b/common/coin_mvt.h index aa6968446..f9a4a6971 100644 --- a/common/coin_mvt.h +++ b/common/coin_mvt.h @@ -49,9 +49,15 @@ struct channel_coin_mvt_id { u64 group_id; }; +/* Only one of these is set. */ +struct mvt_account_id { + const struct channel *channel; + const char *alt_account; +}; + struct channel_coin_mvt { /* account_id */ - struct channel_id chan_id; + struct mvt_account_id account; /* identifier */ struct sha256 *payment_hash; @@ -73,7 +79,7 @@ struct channel_coin_mvt { struct chain_coin_mvt { /* account_id */ - const char *account_name; + struct mvt_account_id account; const struct bitcoin_txid *tx_txid; const struct bitcoin_outpoint *outpoint; @@ -99,7 +105,7 @@ struct chain_coin_mvt { /* When we pay to external accounts, it's useful * to track which internal account it originated from */ - const char *originating_acct; + const struct mvt_account_id *originating_acct; /* Number of outputs in spending tx; used by the * `channel_close` event */ @@ -108,9 +114,19 @@ struct chain_coin_mvt { enum mvt_tag *new_tag_arr(const tal_t *ctx, enum mvt_tag tag); +/* Useful constructor for mvt_account_id: exactly one of channel/account_name must be NULL */ +void set_mvt_account_id(struct mvt_account_id *acct_id, + const struct channel *channel, + const char *account_name TAKES); + +/* Allocating version */ +struct mvt_account_id *new_mvt_account_id(const tal_t *ctx, + const struct channel *channel, + const char *account_name TAKES); + /* Either part_id and group_id both NULL, or neither are */ struct channel_coin_mvt *new_channel_coin_mvt(const tal_t *ctx, - const struct channel_id *cid, + const struct channel *channel, const struct sha256 *payment_hash TAKES, const u64 *part_id, const u64 *group_id, @@ -136,7 +152,8 @@ struct chain_coin_mvt *new_onchaind_deposit(const tal_t *ctx, NON_NULL_ARGS(2); struct chain_coin_mvt *new_coin_channel_close(const tal_t *ctx, - const struct channel_id *chan_id, + const struct channel *channel, + const char *alt_account, const struct bitcoin_txid *txid, const struct bitcoin_outpoint *out, u32 blockheight, @@ -144,20 +161,20 @@ struct chain_coin_mvt *new_coin_channel_close(const tal_t *ctx, const struct amount_sat output_val, u32 output_count, bool is_splice) - NON_NULL_ARGS(3, 4); + NON_NULL_ARGS(4, 5); struct chain_coin_mvt *new_coin_channel_open_proposed(const tal_t *ctx, - const struct channel_id *chan_id, + const struct channel *channel, const struct bitcoin_outpoint *out, const struct node_id *peer_id, const struct amount_msat amount, const struct amount_sat output_val, bool is_opener, bool is_leased) - NON_NULL_ARGS(2, 3); + NON_NULL_ARGS(2, 3, 4); struct chain_coin_mvt *new_coin_channel_open(const tal_t *ctx, - const struct channel_id *chan_id, + const struct channel *channel, const struct bitcoin_outpoint *out, const struct node_id *peer_id, u32 blockheight, @@ -165,7 +182,7 @@ struct chain_coin_mvt *new_coin_channel_open(const tal_t *ctx, const struct amount_sat output_val, bool is_opener, bool is_leased) - NON_NULL_ARGS(2, 3); + NON_NULL_ARGS(2, 3, 4); struct chain_coin_mvt *new_onchain_htlc_deposit(const tal_t *ctx, const struct bitcoin_outpoint *outpoint, @@ -234,7 +251,7 @@ struct chain_coin_mvt *new_coin_external_deposit(const tal_t *ctx, NON_NULL_ARGS(2); struct channel_coin_mvt *new_coin_channel_push(const tal_t *ctx, - const struct channel_id *cid, + const struct channel *channel, enum coin_mvt_dir direction, struct amount_msat amount, enum mvt_tag tag) diff --git a/common/test/run-route_blinding_test.c b/common/test/run-route_blinding_test.c index 3358319df..799c540ef 100644 --- a/common/test/run-route_blinding_test.c +++ b/common/test/run-route_blinding_test.c @@ -17,9 +17,6 @@ #include /* AUTOGENERATED MOCKS START */ -/* Generated stub for fmt_channel_id */ -char *fmt_channel_id(const tal_t *ctx UNNEEDED, const struct channel_id *channel_id UNNEEDED) -{ fprintf(stderr, "fmt_channel_id called!\n"); abort(); } /* Generated stub for fromwire_channel_id */ bool fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct channel_id *channel_id UNNEEDED) diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index 223865746..e6ab5169c 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -960,13 +960,15 @@ static void channel_record_splice(struct channel *channel, struct amount_msat orig_our_msats, struct amount_sat orig_funding_sats, struct bitcoin_outpoint *funding, - u32 blockheight, struct bitcoin_txid *txid, const struct channel_inflight *inflight) + u32 blockheight, + const struct bitcoin_txid *txid, + const struct channel_inflight *inflight) { struct chain_coin_mvt *mvt; u32 output_count; output_count = inflight->funding_psbt->num_outputs; - mvt = new_coin_channel_close(tmpctx, &channel->cid, + mvt = new_coin_channel_close(tmpctx, channel, NULL, txid, funding, blockheight, @@ -1002,7 +1004,7 @@ void channel_record_open(struct channel *channel, u32 blockheight, bool record_p /* If it's not in a block yet, send a proposal */ if (blockheight > 0) mvt = new_coin_channel_open(tmpctx, - &channel->cid, + channel, &channel->funding, &channel->peer->id, blockheight, @@ -1012,7 +1014,7 @@ void channel_record_open(struct channel *channel, u32 blockheight, bool record_p is_leased); else mvt = new_coin_channel_open_proposed(tmpctx, - &channel->cid, + channel, &channel->funding, &channel->peer->id, start_balance, @@ -1025,7 +1027,7 @@ void channel_record_open(struct channel *channel, u32 blockheight, bool record_p /* If we pushed sats, *now* record them */ if (is_pushed && record_push) notify_channel_mvt(channel->peer->ld, - new_coin_channel_push(tmpctx, &channel->cid, + new_coin_channel_push(tmpctx, channel, channel->opener == REMOTE ? COIN_CREDIT : COIN_DEBIT, channel->push, is_leased ? LEASE_FEE : PUSHED)); diff --git a/lightningd/coin_mvts.c b/lightningd/coin_mvts.c index 26df00b5c..c365a7bf1 100644 --- a/lightningd/coin_mvts.c +++ b/lightningd/coin_mvts.c @@ -10,7 +10,7 @@ struct channel_coin_mvt *new_channel_mvt_invoice_hin(const tal_t *ctx, const struct htlc_in *hin, const struct channel *channel) { - return new_channel_coin_mvt(ctx, &channel->cid, + return new_channel_coin_mvt(ctx, channel, &hin->payment_hash, NULL, NULL, COIN_CREDIT, hin->msat, new_tag_arr(ctx, INVOICE), @@ -30,7 +30,7 @@ struct channel_coin_mvt *new_channel_mvt_routed_hin(const tal_t *ctx, hin->payload->amt_to_forward)) return NULL; - return new_channel_coin_mvt(ctx, &channel->cid, + return new_channel_coin_mvt(ctx, channel, &hin->payment_hash, NULL, NULL, COIN_CREDIT, hin->msat, new_tag_arr(ctx, ROUTED), @@ -41,7 +41,7 @@ struct channel_coin_mvt *new_channel_mvt_invoice_hout(const tal_t *ctx, const struct htlc_out *hout, const struct channel *channel) { - return new_channel_coin_mvt(ctx, &channel->cid, + return new_channel_coin_mvt(ctx, channel, &hout->payment_hash, &hout->partid, &hout->groupid, @@ -54,7 +54,7 @@ struct channel_coin_mvt *new_channel_mvt_routed_hout(const tal_t *ctx, const struct htlc_out *hout, const struct channel *channel) { - return new_channel_coin_mvt(ctx, &channel->cid, + return new_channel_coin_mvt(ctx, channel, &hout->payment_hash, NULL, NULL, COIN_DEBIT, hout->msat, new_tag_arr(ctx, ROUTED), diff --git a/lightningd/notification.c b/lightningd/notification.c index 6368ec274..7bef9feb3 100644 --- a/lightningd/notification.c +++ b/lightningd/notification.c @@ -445,6 +445,16 @@ void notify_sendpay_failure(struct lightningd *ld, notify_send(ld, n); } +static void json_add_mvt_account_id(struct json_stream *stream, + const char *fieldname, + const struct mvt_account_id *account_id) +{ + if (account_id->channel) + json_add_channel_id(stream, fieldname, &account_id->channel->cid); + else + json_add_string(stream, fieldname, account_id->alt_account); +} + static void chain_movement_notification_serialize(struct json_stream *stream, struct lightningd *ld, const struct chain_coin_mvt *chain_mvt) @@ -454,10 +464,11 @@ static void chain_movement_notification_serialize(struct json_stream *stream, json_add_node_id(stream, "node_id", &ld->our_nodeid); if (chain_mvt->peer_id) json_add_node_id(stream, "peer_id", chain_mvt->peer_id); - json_add_string(stream, "account_id", chain_mvt->account_name); + json_add_mvt_account_id(stream, "account_id", &chain_mvt->account); + if (chain_mvt->originating_acct) - json_add_string(stream, "originating_account", - chain_mvt->originating_acct); + json_add_mvt_account_id(stream, "originating_account", chain_mvt->originating_acct); + /* some 'journal entries' don't have a txid */ if (chain_mvt->tx_txid) json_add_string(stream, "txid", @@ -501,7 +512,7 @@ static void channel_movement_notification_serialize(struct json_stream *stream, json_add_num(stream, "version", COIN_MVT_VERSION); json_add_string(stream, "type", "channel_mvt"); json_add_node_id(stream, "node_id", &ld->our_nodeid); - json_add_channel_id(stream, "account_id", &chan_mvt->chan_id); + json_add_mvt_account_id(stream, "account_id", &chan_mvt->account); /* push funding / leases don't have a payment_hash */ if (chan_mvt->payment_hash) json_add_sha256(stream, "payment_hash", chan_mvt->payment_hash); diff --git a/lightningd/onchain_control.c b/lightningd/onchain_control.c index b82ef73df..e7758ce52 100644 --- a/lightningd/onchain_control.c +++ b/lightningd/onchain_control.c @@ -346,13 +346,14 @@ static void handle_onchain_log_coin_move(struct channel *channel, const u8 *msg) return; } - /* Any 'ignored' payments get registered to the wallet */ - if (!mvt->account_name) - mvt->account_name = fmt_channel_id(mvt, - &channel->cid); - else - mvt->originating_acct = fmt_channel_id(mvt, - &channel->cid); + /* onchaind uses an empty string to mean "this channel" */ + if (streq(mvt->account.alt_account, "")) { + tal_free(mvt->account.alt_account); + set_mvt_account_id(&mvt->account, channel, NULL); + } else { + mvt->originating_acct = new_mvt_account_id(mvt, channel, NULL); + } + notify_chain_mvt(channel->peer->ld, mvt); tal_free(mvt); } @@ -578,8 +579,7 @@ static void onchain_add_utxo(struct channel *channel, const u8 *msg) mvt = new_coin_wallet_deposit(msg, &outpoint, blockheight, amount, DEPOSIT); - mvt->originating_acct = fmt_channel_id(mvt, - &channel->cid); + mvt->originating_acct = new_mvt_account_id(mvt, channel, NULL); notify_chain_mvt(channel->peer->ld, mvt); } diff --git a/onchaind/onchaind.c b/onchaind/onchaind.c index 5dcb1d266..21c42c798 100644 --- a/onchaind/onchaind.c +++ b/onchaind/onchaind.c @@ -3465,7 +3465,7 @@ int main(int argc, char *argv[]) FUNDING_OUTPUT, NULL, NULL, NULL); /* Record funding output spent */ - send_coin_mvt(take(new_coin_channel_close(NULL, NULL, &tx->txid, + send_coin_mvt(take(new_coin_channel_close(NULL, NULL, "", &tx->txid, &funding, tx_blockheight, our_msat, funding_sats, diff --git a/onchaind/test/run-grind_feerate-bug.c b/onchaind/test/run-grind_feerate-bug.c index 30a31b0b8..ab6866139 100644 --- a/onchaind/test/run-grind_feerate-bug.c +++ b/onchaind/test/run-grind_feerate-bug.c @@ -103,7 +103,8 @@ void memleak_status_broken(void *unused UNNEEDED, const char *fmt UNNEEDED, ...) { fprintf(stderr, "memleak_status_broken called!\n"); abort(); } /* Generated stub for new_coin_channel_close */ struct chain_coin_mvt *new_coin_channel_close(const tal_t *ctx UNNEEDED, - const struct channel_id *chan_id UNNEEDED, + const struct channel *channel UNNEEDED, + const char *alt_account UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, const struct bitcoin_outpoint *out UNNEEDED, u32 blockheight UNNEEDED, diff --git a/onchaind/test/run-grind_feerate.c b/onchaind/test/run-grind_feerate.c index ac714fcd4..cb944889d 100644 --- a/onchaind/test/run-grind_feerate.c +++ b/onchaind/test/run-grind_feerate.c @@ -153,7 +153,8 @@ void memleak_status_broken(void *unused UNNEEDED, const char *fmt UNNEEDED, ...) { fprintf(stderr, "memleak_status_broken called!\n"); abort(); } /* Generated stub for new_coin_channel_close */ struct chain_coin_mvt *new_coin_channel_close(const tal_t *ctx UNNEEDED, - const struct channel_id *chan_id UNNEEDED, + const struct channel *channel UNNEEDED, + const char *alt_account UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, const struct bitcoin_outpoint *out UNNEEDED, u32 blockheight UNNEEDED, diff --git a/plugins/bkpr/test/run-bkpr_db.c b/plugins/bkpr/test/run-bkpr_db.c index 13801dcab..75505df51 100644 --- a/plugins/bkpr/test/run-bkpr_db.c +++ b/plugins/bkpr/test/run-bkpr_db.c @@ -51,9 +51,6 @@ bool deprecated_ok_(bool deprecated_apis UNNEEDED, /* Generated stub for first_fee_state */ enum htlc_state first_fee_state(enum side opener UNNEEDED) { fprintf(stderr, "first_fee_state called!\n"); abort(); } -/* Generated stub for fmt_channel_id */ -char *fmt_channel_id(const tal_t *ctx UNNEEDED, const struct channel_id *channel_id UNNEEDED) -{ fprintf(stderr, "fmt_channel_id called!\n"); abort(); } /* Generated stub for fmt_wireaddr_without_port */ char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED) { fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); } diff --git a/plugins/bkpr/test/run-recorder.c b/plugins/bkpr/test/run-recorder.c index a6efe59c0..8a887f956 100644 --- a/plugins/bkpr/test/run-recorder.c +++ b/plugins/bkpr/test/run-recorder.c @@ -57,9 +57,6 @@ bool deprecated_ok_(bool deprecated_apis UNNEEDED, /* Generated stub for first_fee_state */ enum htlc_state first_fee_state(enum side opener UNNEEDED) { fprintf(stderr, "first_fee_state called!\n"); abort(); } -/* Generated stub for fmt_channel_id */ -char *fmt_channel_id(const tal_t *ctx UNNEEDED, const struct channel_id *channel_id UNNEEDED) -{ fprintf(stderr, "fmt_channel_id called!\n"); abort(); } /* Generated stub for fmt_wireaddr_without_port */ char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED) { fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); } diff --git a/wallet/walletrpc.c b/wallet/walletrpc.c index a2ec3571a..726361937 100644 --- a/wallet/walletrpc.c +++ b/wallet/walletrpc.c @@ -948,7 +948,8 @@ static void maybe_notify_new_external_send(struct lightningd *ld, 0, amount, DEPOSIT); - mvt->originating_acct = WALLET; + mvt->originating_acct = new_mvt_account_id(mvt, NULL, WALLET); + notify_chain_mvt(ld, mvt); tal_free(mvt); }