electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 61e7f7e75ec491a7d05d15fe9aa0ff6bf736862f
parent 5dc7b5bffe0925737499ab618746f672f0902e53
Author: ThomasV <thomasv@electrum.org>
Date:   Thu, 25 Feb 2021 10:27:55 +0100

Merge pull request #7065 from SomberNight/20210224_mpp_recv_amt_sum

lnpeer: MPP recv: only fulfill htlc if amt sum exact-matches total_msat
Diffstat:
Melectrum/lnchannel.py | 4+++-
Melectrum/lnpeer.py | 9+++------
Melectrum/lnworker.py | 2+-
3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/electrum/lnchannel.py b/electrum/lnchannel.py @@ -1051,7 +1051,9 @@ class Channel(AbstractChannel): if is_sent: self.lnworker.htlc_fulfilled(self, payment_hash, htlc.htlc_id, htlc.amount_msat) else: - self.lnworker.htlc_received(self, payment_hash) + # FIXME + #self.lnworker.htlc_received(self, payment_hash) + pass def balance(self, whose: HTLCOwner, *, ctx_owner=HTLCOwner.LOCAL, ctn: int = None) -> int: assert type(whose) is HTLCOwner diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py @@ -1566,13 +1566,10 @@ class Peer(Logger): else: if payment_secret_from_onion != derive_payment_secret_from_payment_preimage(preimage): raise OnionRoutingFailure(code=OnionFailureCode.INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS, data=b'') - expected_received_msat = info.amount_msat - if expected_received_msat is None: - return preimage - - if not (expected_received_msat <= total_msat <= 2 * expected_received_msat): + invoice_msat = info.amount_msat + if not (invoice_msat is None or invoice_msat <= total_msat <= 2 * invoice_msat): raise OnionRoutingFailure(code=OnionFailureCode.INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS, data=b'') - accepted, expired = self.lnworker.htlc_received(chan.short_channel_id, htlc, expected_received_msat) + accepted, expired = self.lnworker.htlc_received(chan.short_channel_id, htlc, total_msat) if accepted: return preimage elif expired: diff --git a/electrum/lnworker.py b/electrum/lnworker.py @@ -1692,7 +1692,7 @@ class LNWallet(LNWorker): total = sum([htlc.amount_msat for scid, htlc in s]) first_timestamp = min([htlc.timestamp for scid, htlc in s]) expired = time.time() - first_timestamp > MPP_EXPIRY - if total >= expected_msat and not expired: + if total == expected_msat and not expired: # status must be persisted self.set_payment_status(htlc.payment_hash, PR_PAID) util.trigger_callback('request_status', self.wallet, htlc.payment_hash.hex(), PR_PAID)