Fix two bugs which access the wrong peer's htlc_minimum_msat value 2020-09-633-bindings
authorMatt Corallo <git@bluematt.me>
Mon, 14 Sep 2020 21:39:42 +0000 (17:39 -0400)
committerMatt Corallo <git@bluematt.me>
Wed, 16 Sep 2020 15:12:51 +0000 (11:12 -0400)
commit0f6b0004c490855ad88ce1bb545268eb6561fdc2
treeb8d6ec574fc57810e927b868087d3b16cac0f735
parenta8be9af7d3af020d64a0c7a4638eeb27c4bb3977
Fix two bugs which access the wrong peer's htlc_minimum_msat value

 * Channel::get_counterparty_htlc_minimum_msat() returned
   holder_htlc_minimum_msat, which was obviously incorrect.
 * ChannelManager::get_channel_update set htlc_minimum_msat to
   Channel::get_holder_htlc_minimum_msat(), but the spec explicitly
   states we "MUST set htlc_minimum_msat to the minimum HTLC value
   (in millisatoshi) that the channel peer will accept." This makes
   sense because the reason we're rejecting the HTLC is because our
   counterparty's HTLC minimum value is too small for us to send to
   them, our own HTLC minimum value plays no role. Further, our
   router already expects this - looking at the same directional
   channel info as it does fees.

Finally, we add a test in the existing onion router test cases
which fails if either of the above is incorrect (the second issue
discovered in the process of writing the test).
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/onion_route_tests.rs