lightningd: make failmsg_incorrect_or_unknown take amount, not htlc_in.
This makes it slightly more generic. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -115,7 +115,7 @@ void htlc_set_add(struct lightningd *ld,
|
||||
if (!details) {
|
||||
log_debug(hin->key.channel->log, "payment failed: %s", err);
|
||||
local_fail_in_htlc(hin,
|
||||
take(failmsg_incorrect_or_unknown(NULL, ld, hin)));
|
||||
take(failmsg_incorrect_or_unknown(NULL, ld, hin->msat)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ void htlc_set_add(struct lightningd *ld,
|
||||
log_debug(ld->log, "Missing payment_secret, but required for %s",
|
||||
fmt_sha256(tmpctx, &hin->payment_hash));
|
||||
local_fail_in_htlc(hin,
|
||||
take(failmsg_incorrect_or_unknown(NULL, ld, hin)));
|
||||
take(failmsg_incorrect_or_unknown(NULL, ld, hin->msat)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ void htlc_set_add(struct lightningd *ld,
|
||||
/* We check this now, since we want to fail with this as soon
|
||||
* as possible, to avoid other probing attacks. */
|
||||
if (!payment_secret) {
|
||||
local_fail_in_htlc(hin, take(failmsg_incorrect_or_unknown(NULL, ld, hin)));
|
||||
local_fail_in_htlc(hin, take(failmsg_incorrect_or_unknown(NULL, ld, hin->msat)));
|
||||
return;
|
||||
}
|
||||
tal_arr_expand(&set->htlcs, hin);
|
||||
@@ -215,7 +215,7 @@ void htlc_set_add(struct lightningd *ld,
|
||||
/* This catches the case of the first payment in a set. */
|
||||
if (!payment_secret) {
|
||||
htlc_set_fail(set,
|
||||
take(failmsg_incorrect_or_unknown(NULL, ld, hin)));
|
||||
take(failmsg_incorrect_or_unknown(NULL, ld, hin->msat)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ static const u8 *hook_gives_failmsg(const tal_t *ctx,
|
||||
if (json_tok_streq(buffer, resulttok, "continue")) {
|
||||
return NULL;
|
||||
} else if (json_tok_streq(buffer, resulttok, "reject")) {
|
||||
return failmsg_incorrect_or_unknown(ctx, ld, hin);
|
||||
return failmsg_incorrect_or_unknown(ctx, ld, hin->msat);
|
||||
} else
|
||||
fatal("Invalid invoice_payment hook result: %.*s",
|
||||
toks[0].end - toks[0].start, buffer);
|
||||
@@ -275,7 +275,7 @@ invoice_payment_hooks_done(struct invoice_payment_hook_payload *payload STEALS)
|
||||
* we can also fail */
|
||||
if (!invoices_find_by_label(ld->wallet->invoices, &inv_dbid, payload->label)) {
|
||||
htlc_set_fail(payload->set, take(failmsg_incorrect_or_unknown(
|
||||
NULL, ld, payload->set->htlcs[0])));
|
||||
NULL, ld, payload->set->htlcs[0]->msat)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ invoice_payment_hooks_done(struct invoice_payment_hook_payload *payload STEALS)
|
||||
payload->label, payload->outpoint)) {
|
||||
if (payload->set)
|
||||
htlc_set_fail(payload->set, take(failmsg_incorrect_or_unknown(
|
||||
NULL, ld, payload->set->htlcs[0])));
|
||||
NULL, ld, payload->set->htlcs[0]->msat)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -277,13 +277,13 @@ void local_fail_in_htlc(struct htlc_in *hin, const u8 *failmsg TAKES)
|
||||
/* Helper to create (common) WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS */
|
||||
const u8 *failmsg_incorrect_or_unknown_(const tal_t *ctx,
|
||||
struct lightningd *ld,
|
||||
const struct htlc_in *hin,
|
||||
struct amount_msat msat,
|
||||
const char *file, int line)
|
||||
{
|
||||
log_debug(ld->log, "WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS: %s:%u",
|
||||
file, line);
|
||||
return towire_incorrect_or_unknown_payment_details(
|
||||
ctx, hin->msat,
|
||||
ctx, msat,
|
||||
get_block_height(ld->topology));
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ static void handle_localpay(struct htlc_in *hin,
|
||||
hin->cltv_expiry,
|
||||
get_block_height(ld->topology),
|
||||
ld->config.cltv_final);
|
||||
failmsg = failmsg_incorrect_or_unknown(NULL, ld, hin);
|
||||
failmsg = failmsg_incorrect_or_unknown(NULL, ld, hin->msat);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,11 +62,11 @@ void local_fail_in_htlc_needs_update(struct htlc_in *hin,
|
||||
const struct short_channel_id *failmsg_scid);
|
||||
|
||||
/* Helper to create (common) WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS */
|
||||
#define failmsg_incorrect_or_unknown(ctx, ld, hin) \
|
||||
failmsg_incorrect_or_unknown_((ctx), (ld), (hin), __FILE__, __LINE__)
|
||||
#define failmsg_incorrect_or_unknown(ctx, ld, msat) \
|
||||
failmsg_incorrect_or_unknown_((ctx), (ld), (msat), __FILE__, __LINE__)
|
||||
|
||||
const u8 *failmsg_incorrect_or_unknown_(const tal_t *ctx,
|
||||
struct lightningd *ld,
|
||||
const struct htlc_in *hin,
|
||||
struct amount_msat msat,
|
||||
const char *file, int line);
|
||||
#endif /* LIGHTNING_LIGHTNINGD_PEER_HTLCS_H */
|
||||
|
||||
@@ -254,7 +254,7 @@ u8 *encrypt_tlv_encrypted_data(const tal_t *ctx UNNEEDED,
|
||||
/* Generated stub for failmsg_incorrect_or_unknown_ */
|
||||
const u8 *failmsg_incorrect_or_unknown_(const tal_t *ctx UNNEEDED,
|
||||
struct lightningd *ld UNNEEDED,
|
||||
const struct htlc_in *hin UNNEEDED,
|
||||
struct amount_msat msat UNNEEDED,
|
||||
const char *file UNNEEDED, int line UNNEEDED)
|
||||
{ fprintf(stderr, "failmsg_incorrect_or_unknown_ called!\n"); abort(); }
|
||||
/* Generated stub for fatal */
|
||||
|
||||
Reference in New Issue
Block a user