1
1
#include <bitcoin/script.h>
2
2
#include <ccan/crypto/hkdf_sha256/hkdf_sha256.h>
3
3
#include <ccan/tal/str/str.h>
4
+ #include <common/wire_error.h>
4
5
#include <gossipd/gen_gossip_wire.h>
5
6
#include <inttypes.h>
6
7
#include <lightningd/channel.h>
@@ -287,6 +288,7 @@ void channel_fail_permanent(struct channel *channel, const char *fmt, ...)
287
288
va_list ap ;
288
289
char * why ;
289
290
u8 * msg ;
291
+ struct channel_id cid ;
290
292
291
293
va_start (ap , fmt );
292
294
why = tal_vfmt (channel , fmt , ap );
@@ -305,15 +307,10 @@ void channel_fail_permanent(struct channel *channel, const char *fmt, ...)
305
307
306
308
/* We can have multiple errors, eg. onchaind failures. */
307
309
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 );
317
314
}
318
315
319
316
channel_set_owner (channel , NULL );
0 commit comments