peer+htlcswitch: fix bandwidth update bug when using --debughtlc

This commit fixes a htlcSwitch bandwidth update bug that would manifest
when two sending daemons were started with the —debughtlc flag. The
invoice created for the debug HTLC has a value of 1000BTC. As a result
regardless of the amount sent, the switch’s state which be updated to
reflect that the daemon had just received a 1000BTC transfer.

To fix this bug, we now use the value of the HTLC itself for the
update, rather than the value if the invoice as they should match.
This commit is contained in:
Olaoluwa Osuntokun 2016-12-14 18:03:48 -08:00
parent e3e2ba342c
commit 89326423dc
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -1398,7 +1398,7 @@ func (p *peer) handleUpstreamMsg(state *commitmentState, msg lnwire.Message) {
p.queueMsg(settleMsg, nil)
delete(state.htlcsToSettle, htlc.Index)
bandwidthUpdate += invoice.Terms.Value
bandwidthUpdate += htlc.Amount
settledPayments[htlc.RHash] = struct{}{}
numSettled++