Skip to content

Commit b529117

Browse files
cdeckerrustyrussell
authored andcommitted
keysend: Accept a payment with unknown even TLV types
This is because we might allow the main daemon to transparently handle these extra TLVs too.
1 parent 93b6c6f commit b529117

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

plugins/keysend.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,8 @@ static struct command_result *htlc_accepted_call(struct command *cmd,
287287
struct sha256 payment_hash;
288288
size_t max;
289289
struct tlv_tlv_payload *payload;
290-
struct tlv_field *preimage_field = NULL;
290+
struct tlv_field *preimage_field = NULL, *unknown_field = NULL;
291291
bigsize_t s;
292-
bool unknown_even_type = false;
293292
struct tlv_field *field;
294293
struct keysend_in *ki;
295294
struct out_req *req;
@@ -325,8 +324,7 @@ static struct command_result *htlc_accepted_call(struct command *cmd,
325324
preimage_field = field;
326325
break;
327326
} else if (field->numtype % 2 == 0 && field->meta == NULL) {
328-
unknown_even_type = true;
329-
break;
327+
unknown_field = field;
330328
}
331329
}
332330

@@ -335,15 +333,23 @@ static struct command_result *htlc_accepted_call(struct command *cmd,
335333
if (preimage_field == NULL)
336334
return htlc_accepted_continue(cmd, NULL);
337335

338-
if (unknown_even_type) {
336+
if (unknown_field != NULL) {
337+
#if !EXPERIMENTAL_FEATURES
339338
plugin_log(cmd->plugin, LOG_UNUSUAL,
340339
"Payload contains unknown even TLV-type %" PRIu64
341340
", can't safely accept the keysend. Deferring to "
342341
"other plugins.",
343-
preimage_field->numtype);
342+
unknown_field->numtype);
344343
return htlc_accepted_continue(cmd, NULL);
344+
#else
345+
plugin_log(cmd->plugin, LOG_INFORM,
346+
"Experimental: Accepting the keysend payment "
347+
"despite having unknown even TLV type %" PRIu64 ".",
348+
unknown_field->numtype);
349+
#endif
345350
}
346351

352+
347353
/* If the preimage is not 32 bytes long then we can't accept the
348354
* payment. */
349355
if (preimage_field->length != 32) {

0 commit comments

Comments
 (0)