mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
htlc_accepted: log BROKEN if both 'failure_msg' + 'failure_onion'
Log an error for incorrect use of API Suggested-By: @cdecker
This commit is contained in:
parent
65cdb78bb4
commit
cefb64cd68
1 changed files with 15 additions and 4 deletions
|
@ -931,17 +931,28 @@ static bool htlc_accepted_hook_deserialize(struct htlc_accepted_hook_payload *re
|
||||||
u8 *failmsg;
|
u8 *failmsg;
|
||||||
const jsmntok_t *failoniontok, *failmsgtok, *failcodetok;
|
const jsmntok_t *failoniontok, *failmsgtok, *failcodetok;
|
||||||
|
|
||||||
if ((failoniontok = json_get_member(buffer, toks, "failure_onion"))) {
|
failoniontok = json_get_member(buffer, toks, "failure_onion");
|
||||||
failonion = json_tok_bin_from_hex(NULL, buffer, failoniontok);
|
failmsgtok = json_get_member(buffer, toks, "failure_message");
|
||||||
|
|
||||||
|
if (failoniontok) {
|
||||||
|
failonion = json_tok_bin_from_hex(tmpctx, buffer,
|
||||||
|
failoniontok);
|
||||||
if (!failonion)
|
if (!failonion)
|
||||||
fatal("Bad failure_onion for htlc_accepted"
|
fatal("Bad failure_onion for htlc_accepted"
|
||||||
" hook: %.*s",
|
" hook: %.*s",
|
||||||
failoniontok->end - failoniontok->start,
|
failoniontok->end - failoniontok->start,
|
||||||
buffer + failoniontok->start);
|
buffer + failoniontok->start);
|
||||||
fail_in_htlc(hin, take(new_onionreply(tmpctx, failonion)));
|
|
||||||
|
if (failmsgtok)
|
||||||
|
log_broken(ld->log, "Both 'failure_onion' and"
|
||||||
|
"'failure_message' provided."
|
||||||
|
" Ignoring 'failure_message'.");
|
||||||
|
|
||||||
|
fail_in_htlc(hin, take(new_onionreply(NULL,
|
||||||
|
failonion)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((failmsgtok = json_get_member(buffer, toks, "failure_message"))) {
|
if (failmsgtok) {
|
||||||
failmsg = json_tok_bin_from_hex(NULL, buffer,
|
failmsg = json_tok_bin_from_hex(NULL, buffer,
|
||||||
failmsgtok);
|
failmsgtok);
|
||||||
if (!failmsg)
|
if (!failmsg)
|
||||||
|
|
Loading…
Add table
Reference in a new issue