Browse Source

channel_fail_permanent: Use a channel-level error, not an all-channels error.

Fixes: #1229
ppa-0.6.1
ZmnSCPxj 7 years ago
committed by Christian Decker
parent
commit
234d67da34
  1. 15
      lightningd/channel.c
  2. 3
      tests/test_lightningd.py

15
lightningd/channel.c

@ -1,6 +1,7 @@
#include <bitcoin/script.h> #include <bitcoin/script.h>
#include <ccan/crypto/hkdf_sha256/hkdf_sha256.h> #include <ccan/crypto/hkdf_sha256/hkdf_sha256.h>
#include <ccan/tal/str/str.h> #include <ccan/tal/str/str.h>
#include <common/wire_error.h>
#include <gossipd/gen_gossip_wire.h> #include <gossipd/gen_gossip_wire.h>
#include <inttypes.h> #include <inttypes.h>
#include <lightningd/channel.h> #include <lightningd/channel.h>
@ -287,6 +288,7 @@ void channel_fail_permanent(struct channel *channel, const char *fmt, ...)
va_list ap; va_list ap;
char *why; char *why;
u8 *msg; u8 *msg;
struct channel_id cid;
va_start(ap, fmt); va_start(ap, fmt);
why = tal_vfmt(channel, fmt, ap); 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. */ /* We can have multiple errors, eg. onchaind failures. */
if (!channel->error) { if (!channel->error) {
/* BOLT #1: derive_channel_id(&cid,
* &channel->funding_txid,
* The channel is referred to by `channel_id` unless `channel_id` is channel->funding_outnum);
* zero (ie. all bytes zero), in which case it refers to all channel->error = towire_errorfmt(channel, &cid, "%s", why);
* 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);
} }
channel_set_owner(channel, NULL); channel_set_owner(channel, NULL);

3
tests/test_lightningd.py

@ -1246,8 +1246,9 @@ class LightningDTests(BaseLightningDTests):
l2.daemon.wait_for_log(' to ONCHAIN') 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') 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'] == 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:Tracking their unilateral close',
'ONCHAIN:All outputs resolved: waiting 99 more blocks before forgetting channel']) 'ONCHAIN:All outputs resolved: waiting 99 more blocks before forgetting channel'])

Loading…
Cancel
Save