diff --git a/lightningd/channel.c b/lightningd/channel.c index cd74f650b..18a1cb8a7 100644 --- a/lightningd/channel.c +++ b/lightningd/channel.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -287,6 +288,7 @@ void channel_fail_permanent(struct channel *channel, const char *fmt, ...) va_list ap; char *why; u8 *msg; + struct channel_id cid; va_start(ap, fmt); why = tal_vfmt(channel, fmt, ap); @@ -305,15 +307,10 @@ void channel_fail_permanent(struct channel *channel, const char *fmt, ...) /* We can have multiple errors, eg. onchaind failures. */ if (!channel->error) { - /* BOLT #1: - * - * The channel is referred to by `channel_id` unless `channel_id` is - * zero (ie. all bytes zero), in which case it refers to all - * channels. */ - static const struct channel_id all_channels; - u8 *msg = tal_dup_arr(NULL, u8, (const u8 *)why, strlen(why), 0); - channel->error = towire_error(channel, &all_channels, msg); - tal_free(msg); + derive_channel_id(&cid, + &channel->funding_txid, + channel->funding_outnum); + channel->error = towire_errorfmt(channel, &cid, "%s", why); } channel_set_owner(channel, NULL); diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index 73d0797b1..d2bf82fbe 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -1246,8 +1246,9 @@ class LightningDTests(BaseLightningDTests): l2.daemon.wait_for_log(' to ONCHAIN') l2.daemon.wait_for_log('Propose handling OUR_UNILATERAL/DELAYED_OUTPUT_TO_US by OUR_DELAYED_RETURN_TO_WALLET (.*) after 5 blocks') + cid = l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'][0]['channel_id'] wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'][0]['status'] == - ['CHANNELD_NORMAL:Received error from peer: channel ALL: Internal error: Failing due to dev-fail command', + ['CHANNELD_NORMAL:Received error from peer: channel {}: Internal error: Failing due to dev-fail command'.format(cid), 'ONCHAIN:Tracking their unilateral close', 'ONCHAIN:All outputs resolved: waiting 99 more blocks before forgetting channel'])