Scope payment preimage in do_test_keysend_payments
authorMatt Corallo <git@bluematt.me>
Tue, 8 Aug 2023 04:15:20 +0000 (04:15 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 8 Aug 2023 04:15:20 +0000 (04:15 +0000)
commitfe6366895a67da62e7be4b295948a8fba43ce5e0
treee75c6db8ccce4d34e2d43de7a603dcd4b9f2c0be
parent100fdbb7e88846f6cce43acba8c26de2db8b263d
Scope payment preimage in do_test_keysend_payments

b0d4ab8cf8c93740674a00546be38a1a5f0a83c3 fixed a nasty bug where
we'd failed to include the payment preimage in keysend onions at
all. Ultimately, this was a test failure - the existing test suite
should which did keysend payments were not structured in a way that
would fail in this case, instead using the same preimage variable
both for sending and receiving.

Here we improve the main keysend test tweaked by b0d4ab8cf8c9374067
to make absolutely sure it cannot work if the preimage doesn't come
from the onion. We make the payment preimage on the sending side a
variable inside a scope which only exists for the send call. Once
that scope completes the payment preimage only exists in the
sending `ChannelManager`, which must have put it in the onion in
order for the receiving node to have it.
lightning/src/ln/payment_tests.rs