MCPcopy Create free account
hub / github.com/ElementsProject/lightning / check_final_tlv

Function check_final_tlv

common/onion_decode.c:41–57  ·  view source on GitHub ↗

BOLT #4: * - If `encrypted_recipient_data` is present: *... * - If it is the final node: * - MUST return an error if the payload contains other tlv fields than * `encrypted_recipient_data`, `current_path_key`, `amt_to_forward`, * `outgoing_cltv_value` and `total_amount_msat`. */

Source from the content-addressed store, hash-verified

39 * `outgoing_cltv_value` and `total_amount_msat`.
40 */
41static bool check_final_tlv(const struct tlv_payload *tlv,
42 u64 *failtlvtype)
43{
44 for (size_t i = 0; i < tal_count(tlv->fields); i++) {
45 switch (tlv->fields[i].numtype) {
46 case TLV_PAYLOAD_ENCRYPTED_RECIPIENT_DATA:
47 case TLV_PAYLOAD_CURRENT_PATH_KEY:
48 case TLV_PAYLOAD_AMT_TO_FORWARD:
49 case TLV_PAYLOAD_OUTGOING_CLTV_VALUE:
50 case TLV_PAYLOAD_TOTAL_AMOUNT_MSAT:
51 continue;
52 }
53 *failtlvtype = tlv->fields[i].numtype;
54 return false;
55 }
56 return true;
57}
58
59static u64 ceil_div(u64 a, u64 b)
60{

Callers 1

handle_blinded_terminalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected