@@ -1427,6 +1427,8 @@ async def settle_hold_invoice(self, preimage: str, wallet: Abstract_Wallet = Non
14271427 assert payment_hash in wallet .lnworker .dont_settle_htlcs , f"Invoice { payment_hash = } not a hold invoice?"
14281428 assert wallet .lnworker .is_accepted_mpp (bfh (payment_hash )), \
14291429 f"MPP incomplete, cannot settle hold invoice { payment_hash } yet"
1430+ info : Optional ['PaymentInfo' ] = wallet .lnworker .get_payment_info (bfh (payment_hash ))
1431+ assert (wallet .lnworker .get_payment_mpp_amount_msat (bfh (payment_hash )) or 0 ) >= (info .amount_msat or 0 )
14301432 del wallet .lnworker .dont_settle_htlcs [payment_hash ]
14311433 wallet .lnworker .save_preimage (bfh (payment_hash ), bfh (preimage ))
14321434 util .trigger_callback ('wallet_updated' , wallet )
@@ -1474,18 +1476,23 @@ async def check_hold_invoice(self, payment_hash: str, wallet: Abstract_Wallet =
14741476 status = "unknown"
14751477 if info is None :
14761478 pass
1477- elif not is_accepted_mpp :
1479+ elif not is_accepted_mpp and not wallet .lnworker .get_preimage_hex (payment_hash ):
1480+ # is_accepted_mpp is False for settled payments
14781481 status = "unpaid"
14791482 elif is_accepted_mpp and payment_hash in wallet .lnworker .dont_settle_htlcs :
14801483 status = "paid"
1481- elif (payment_hash in wallet .lnworker ._preimages
1482- and payment_hash not in wallet .lnworker .dont_settle_htlcs
1483- and is_accepted_mpp ):
1484+ elif wallet .lnworker .get_preimage_hex (payment_hash ) is not None \
1485+ and payment_hash not in wallet .lnworker .dont_settle_htlcs :
14841486 status = "settled"
1487+ plist = wallet .lnworker .get_payments (status = 'settled' )[bfh (payment_hash )]
1488+ _dir , amount_msat , _fee , _ts = wallet .lnworker .get_payment_value (info , plist )
1489+ amount_sat = amount_msat // 1000
14851490 result = {
14861491 "status" : status ,
1487- "amount_sat " : amount_sat
1492+ "received_amount_sat " : amount_sat ,
14881493 }
1494+ if info is not None :
1495+ result ["invoice_amount_sat" ] = (info .amount_msat or 0 ) // 1000
14891496 return result
14901497
14911498 @command ('w' )
0 commit comments