Enforce explicit claims on payments with even custom TLVs
authorAlec Chen <alecchendev@gmail.com>
Thu, 8 Jun 2023 17:08:25 +0000 (12:08 -0500)
committerAlec Chen <alecchendev@gmail.com>
Tue, 8 Aug 2023 21:16:45 +0000 (16:16 -0500)
commitdec3fb316a7905284d64bb5bad88a898d04744d1
tree7cde363e549dfe9297f0f38a014d9c4417cfab59
parent8ff16046475b39c280b85dede5f0912269aed28c
Enforce explicit claims on payments with even custom TLVs

Because we don't know which custom TLV type numbers the user is
expecting (and it would be cumbersome for them to tell us), instead of
failing unknown even custom TLVs on deserialization, we accept all
custom TLVs, and pass them to the user to check whether they recognize
them and choose to fail back if they don't. However, a user may not
check for custom TLVs, in which case we should reject any even custom
TLVs as unknown.

This commit makes sure a user must explicitly accept a payment with
even custom TLVs, by (1) making the default
`ChannelManager::claim_funds` fail if the payment had even custom TLVs
and (2) adding a new function
`ChannelManager::claim_funds_with_known_custom_tlvs` that accepts them.

This commit also refactors our custom TLVs test and updates various
documentation to account for this.
lightning/src/events/mod.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/payment_tests.rs