lightningd: handle case where channeld fails locally-generated HTLC.

jl777 reported a crash when we try to pay past reserve.  Fix that (and
a whole class of related bugs) and add tests.

In test_lightning.py I had to make non-async path for sendpay() non-threaded
to get the exception passed through for testing.

Closes: #236
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-08-30 10:51:48 +09:30
committed by Christian Decker
parent 52db7fd27b
commit 1cf33eefe2
3 changed files with 44 additions and 6 deletions

View File

@@ -413,7 +413,14 @@ static bool rcvd_htlc_reply(struct subd *subd, const u8 *msg, const int *fds,
}
if (failure_code) {
local_fail_htlc(hout->in, failure_code);
if (!hout->in) {
char *localfail = tal_fmt(msg, "%s: %.*s",
onion_type_name(failure_code),
(int)tal_len(failurestr),
(const char *)failurestr);
payment_failed(hout->key.peer->ld, hout, localfail);
} else
local_fail_htlc(hout->in, failure_code);
return true;
}