mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
plugins/libplugin-pay.c: Describe the bits of unrecognized failure codes.
This commit is contained in:
committed by
Christian Decker
parent
0d2d85ab5f
commit
d89c77c0ce
@@ -806,6 +806,29 @@ failure_is_blockheight_disagreement(const struct payment *p,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *describe_failcode(const tal_t *ctx, enum onion_type failcode)
|
||||||
|
{
|
||||||
|
char *rv = tal_strdup(ctx, "");
|
||||||
|
if (failcode & BADONION) {
|
||||||
|
tal_append_fmt(&rv, "BADONION|");
|
||||||
|
failcode &= ~BADONION;
|
||||||
|
}
|
||||||
|
if (failcode & PERM) {
|
||||||
|
tal_append_fmt(&rv, "PERM|");
|
||||||
|
failcode &= ~PERM;
|
||||||
|
}
|
||||||
|
if (failcode & NODE) {
|
||||||
|
tal_append_fmt(&rv, "NODE|");
|
||||||
|
failcode &= ~NODE;
|
||||||
|
}
|
||||||
|
if (failcode & UPDATE) {
|
||||||
|
tal_append_fmt(&rv, "UPDATE|");
|
||||||
|
failcode &= ~UPDATE;
|
||||||
|
}
|
||||||
|
tal_append_fmt(&rv, "%u", failcode);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
static struct command_result *
|
static struct command_result *
|
||||||
handle_final_failure(struct command *cmd,
|
handle_final_failure(struct command *cmd,
|
||||||
struct payment *p,
|
struct payment *p,
|
||||||
@@ -893,9 +916,9 @@ handle_final_failure(struct command *cmd,
|
|||||||
|
|
||||||
strange_error:
|
strange_error:
|
||||||
paymod_log(p, LOG_UNUSUAL,
|
paymod_log(p, LOG_UNUSUAL,
|
||||||
"Final node %s reported strange error code %u",
|
"Final node %s reported strange error code %04x (%s)",
|
||||||
type_to_string(tmpctx, struct node_id, final_id),
|
type_to_string(tmpctx, struct node_id, final_id),
|
||||||
failcode);
|
failcode, describe_failcode(tmpctx, failcode));
|
||||||
|
|
||||||
error:
|
error:
|
||||||
p->result->code = PAY_DESTINATION_PERM_FAIL;
|
p->result->code = PAY_DESTINATION_PERM_FAIL;
|
||||||
@@ -983,9 +1006,9 @@ handle_intermediate_failure(struct command *cmd,
|
|||||||
|
|
||||||
strange_error:
|
strange_error:
|
||||||
paymod_log(p, LOG_UNUSUAL,
|
paymod_log(p, LOG_UNUSUAL,
|
||||||
"Intermediate node %s reported strange error code %u",
|
"Intermediate node %s reported strange error code %04x (%s)",
|
||||||
type_to_string(tmpctx, struct node_id, errnode),
|
type_to_string(tmpctx, struct node_id, errnode),
|
||||||
failcode);
|
failcode, describe_failcode(tmpctx, failcode));
|
||||||
|
|
||||||
error:
|
error:
|
||||||
payment_fail(p, "%s", p->result->message);
|
payment_fail(p, "%s", p->result->message);
|
||||||
|
|||||||
Reference in New Issue
Block a user