Skip to content

Commit 234d67d

Browse files
ZmnSCPxjcdecker
authored andcommitted
channel_fail_permanent: Use a channel-level error, not an all-channels error.
Fixes: #1229
1 parent d49915c commit 234d67d

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

lightningd/channel.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <bitcoin/script.h>
22
#include <ccan/crypto/hkdf_sha256/hkdf_sha256.h>
33
#include <ccan/tal/str/str.h>
4+
#include <common/wire_error.h>
45
#include <gossipd/gen_gossip_wire.h>
56
#include <inttypes.h>
67
#include <lightningd/channel.h>
@@ -287,6 +288,7 @@ void channel_fail_permanent(struct channel *channel, const char *fmt, ...)
287288
va_list ap;
288289
char *why;
289290
u8 *msg;
291+
struct channel_id cid;
290292

291293
va_start(ap, fmt);
292294
why = tal_vfmt(channel, fmt, ap);
@@ -305,15 +307,10 @@ void channel_fail_permanent(struct channel *channel, const char *fmt, ...)
305307

306308
/* We can have multiple errors, eg. onchaind failures. */
307309
if (!channel->error) {
308-
/* BOLT #1:
309-
*
310-
* The channel is referred to by `channel_id` unless `channel_id` is
311-
* zero (ie. all bytes zero), in which case it refers to all
312-
* channels. */
313-
static const struct channel_id all_channels;
314-
u8 *msg = tal_dup_arr(NULL, u8, (const u8 *)why, strlen(why), 0);
315-
channel->error = towire_error(channel, &all_channels, msg);
316-
tal_free(msg);
310+
derive_channel_id(&cid,
311+
&channel->funding_txid,
312+
channel->funding_outnum);
313+
channel->error = towire_errorfmt(channel, &cid, "%s", why);
317314
}
318315

319316
channel_set_owner(channel, NULL);

tests/test_lightningd.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,8 +1246,9 @@ def test_permfail(self):
12461246
l2.daemon.wait_for_log(' to ONCHAIN')
12471247
l2.daemon.wait_for_log('Propose handling OUR_UNILATERAL/DELAYED_OUTPUT_TO_US by OUR_DELAYED_RETURN_TO_WALLET (.*) after 5 blocks')
12481248

1249+
cid = l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'][0]['channel_id']
12491250
wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'][0]['status'] ==
1250-
['CHANNELD_NORMAL:Received error from peer: channel ALL: Internal error: Failing due to dev-fail command',
1251+
['CHANNELD_NORMAL:Received error from peer: channel {}: Internal error: Failing due to dev-fail command'.format(cid),
12511252
'ONCHAIN:Tracking their unilateral close',
12521253
'ONCHAIN:All outputs resolved: waiting 99 more blocks before forgetting channel'])
12531254

0 commit comments

Comments
 (0)