| 788 | } |
| 789 | |
| 790 | void channel_fail_permanent(struct channel *channel, |
| 791 | enum state_change reason, |
| 792 | const char *fmt, |
| 793 | ...) |
| 794 | { |
| 795 | /* Don't do anything if it's an stub channel because |
| 796 | * peer has already closed it unilatelrally. */ |
| 797 | if (is_stub_scid(channel->scid)) |
| 798 | return; |
| 799 | |
| 800 | struct lightningd *ld = channel->peer->ld; |
| 801 | va_list ap; |
| 802 | char *why; |
| 803 | |
| 804 | va_start(ap, fmt); |
| 805 | why = tal_vfmt(tmpctx, fmt, ap); |
| 806 | va_end(ap); |
| 807 | |
| 808 | log_unusual(channel->log, "Peer permanent failure in %s: %s", |
| 809 | channel_state_name(channel), why); |
| 810 | |
| 811 | /* We can have multiple errors, eg. onchaind failures. */ |
| 812 | if (!channel->error) |
| 813 | channel->error = towire_errorfmt(channel, |
| 814 | &channel->cid, "%s", why); |
| 815 | |
| 816 | channel_set_owner(channel, NULL); |
| 817 | /* Drop non-cooperatively (unilateral) to chain. */ |
| 818 | drop_to_chain(ld, channel, false); |
| 819 | |
| 820 | if (channel_active(channel)) |
| 821 | channel_set_state(channel, |
| 822 | channel->state, |
| 823 | AWAITING_UNILATERAL, |
| 824 | reason, |
| 825 | why); |
| 826 | |
| 827 | tal_free(why); |
| 828 | } |
| 829 | |
| 830 | void channel_fail_forget(struct channel *channel, const char *fmt, ...) |
| 831 | { |
no test coverage detected