lnworker: fix amount in htlc_log after mpp bucket failure
This commit is contained in:
@@ -601,7 +601,7 @@ class LNWallet(LNWorker):
|
|||||||
|
|
||||||
self.sent_htlcs = defaultdict(asyncio.Queue) # type: Dict[bytes, asyncio.Queue[HtlcLog]]
|
self.sent_htlcs = defaultdict(asyncio.Queue) # type: Dict[bytes, asyncio.Queue[HtlcLog]]
|
||||||
self.sent_htlcs_routes = dict() # (RHASH, scid, htlc_id) -> route, payment_secret, amount_msat, bucket_msat
|
self.sent_htlcs_routes = dict() # (RHASH, scid, htlc_id) -> route, payment_secret, amount_msat, bucket_msat
|
||||||
self.sent_buckets = dict()
|
self.sent_buckets = dict() # payment_secret -> (amount_sent, amount_failed)
|
||||||
self.received_htlcs = dict() # RHASH -> mpp_status, htlc_set
|
self.received_htlcs = dict() # RHASH -> mpp_status, htlc_set
|
||||||
|
|
||||||
self.swap_manager = SwapManager(wallet=self.wallet, lnworker=self)
|
self.swap_manager = SwapManager(wallet=self.wallet, lnworker=self)
|
||||||
@@ -1156,8 +1156,10 @@ class LNWallet(LNWorker):
|
|||||||
# if we sent MPP to a trampoline, add item to sent_buckets
|
# if we sent MPP to a trampoline, add item to sent_buckets
|
||||||
if not self.channel_db and amount_msat != total_msat:
|
if not self.channel_db and amount_msat != total_msat:
|
||||||
if payment_secret not in self.sent_buckets:
|
if payment_secret not in self.sent_buckets:
|
||||||
self.sent_buckets[payment_secret] = 0
|
self.sent_buckets[payment_secret] = (0, 0)
|
||||||
self.sent_buckets[payment_secret] += amount_receiver_msat
|
amount_sent, amount_failed = self.sent_buckets[payment_secret]
|
||||||
|
amount_sent += amount_receiver_msat
|
||||||
|
self.sent_buckets[payment_secret] = amount_sent, amount_failed
|
||||||
util.trigger_callback('htlc_added', chan, htlc, SENT)
|
util.trigger_callback('htlc_added', chan, htlc, SENT)
|
||||||
|
|
||||||
|
|
||||||
@@ -1707,15 +1709,18 @@ class LNWallet(LNWorker):
|
|||||||
|
|
||||||
# check sent_buckets if we use trampoline
|
# check sent_buckets if we use trampoline
|
||||||
if self.channel_db is None and payment_secret in self.sent_buckets:
|
if self.channel_db is None and payment_secret in self.sent_buckets:
|
||||||
self.sent_buckets[payment_secret] -= amount_receiver_msat
|
amount_sent, amount_failed = self.sent_buckets[payment_secret]
|
||||||
if self.sent_buckets[payment_secret] > 0:
|
amount_failed += amount_receiver_msat
|
||||||
|
self.sent_buckets[payment_secret] = amount_sent, amount_failed
|
||||||
|
if amount_sent == amount_failed:
|
||||||
|
self.logger.info('bucket still active...')
|
||||||
return
|
return
|
||||||
assert self.sent_buckets[payment_secret] == 0
|
self.logger.info('bucket failed')
|
||||||
|
|
||||||
htlc_log = HtlcLog(
|
htlc_log = HtlcLog(
|
||||||
success=False,
|
success=False,
|
||||||
route=route,
|
route=route,
|
||||||
amount_msat=amount_receiver_msat,
|
amount_msat=amount_sent,
|
||||||
error_bytes=error_bytes,
|
error_bytes=error_bytes,
|
||||||
failure_msg=failure_message,
|
failure_msg=failure_message,
|
||||||
sender_idx=sender_idx)
|
sender_idx=sender_idx)
|
||||||
|
|||||||
Reference in New Issue
Block a user