lnworker: set request status after LN payment
This commit is contained in:
@@ -49,6 +49,7 @@ from .interface import GracefulDisconnect
|
|||||||
from .lnrouter import fee_for_edge_msat
|
from .lnrouter import fee_for_edge_msat
|
||||||
from .lnutil import ln_dummy_address
|
from .lnutil import ln_dummy_address
|
||||||
from .json_db import StoredDict
|
from .json_db import StoredDict
|
||||||
|
from .invoices import PR_PAID
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .lnworker import LNGossip, LNWallet, LNBackups
|
from .lnworker import LNGossip, LNWallet, LNBackups
|
||||||
@@ -1562,6 +1563,7 @@ class Peer(Logger):
|
|||||||
log_fail_reason(f"total_msat={total_msat} too different from invoice_msat={invoice_msat}")
|
log_fail_reason(f"total_msat={total_msat} too different from invoice_msat={invoice_msat}")
|
||||||
raise exc_incorrect_or_unknown_pd
|
raise exc_incorrect_or_unknown_pd
|
||||||
self.logger.info(f"maybe_fulfill_htlc. will FULFILL HTLC: chan {chan.short_channel_id}. htlc={str(htlc)}")
|
self.logger.info(f"maybe_fulfill_htlc. will FULFILL HTLC: chan {chan.short_channel_id}. htlc={str(htlc)}")
|
||||||
|
self.lnworker.set_request_status(htlc.payment_hash, PR_PAID)
|
||||||
return preimage, None
|
return preimage, None
|
||||||
|
|
||||||
def fulfill_htlc(self, chan: Channel, htlc_id: int, preimage: bytes):
|
def fulfill_htlc(self, chan: Channel, htlc_id: int, preimage: bytes):
|
||||||
@@ -1569,10 +1571,11 @@ class Peer(Logger):
|
|||||||
assert chan.can_send_ctx_updates(), f"cannot send updates: {chan.short_channel_id}"
|
assert chan.can_send_ctx_updates(), f"cannot send updates: {chan.short_channel_id}"
|
||||||
assert chan.hm.is_add_htlc_irrevocably_committed_yet(htlc_proposer=REMOTE, htlc_id=htlc_id)
|
assert chan.hm.is_add_htlc_irrevocably_committed_yet(htlc_proposer=REMOTE, htlc_id=htlc_id)
|
||||||
chan.settle_htlc(preimage, htlc_id)
|
chan.settle_htlc(preimage, htlc_id)
|
||||||
self.send_message("update_fulfill_htlc",
|
self.send_message(
|
||||||
channel_id=chan.channel_id,
|
"update_fulfill_htlc",
|
||||||
id=htlc_id,
|
channel_id=chan.channel_id,
|
||||||
payment_preimage=preimage)
|
id=htlc_id,
|
||||||
|
payment_preimage=preimage)
|
||||||
|
|
||||||
def fail_htlc(self, *, chan: Channel, htlc_id: int, error_bytes: bytes):
|
def fail_htlc(self, *, chan: Channel, htlc_id: int, error_bytes: bytes):
|
||||||
self.logger.info(f"fail_htlc. chan {chan.short_channel_id}. htlc_id {htlc_id}.")
|
self.logger.info(f"fail_htlc. chan {chan.short_channel_id}. htlc_id {htlc_id}.")
|
||||||
|
|||||||
@@ -1617,9 +1617,6 @@ class LNWallet(LNWorker):
|
|||||||
is_expired = True
|
is_expired = True
|
||||||
elif total == expected_msat:
|
elif total == expected_msat:
|
||||||
is_accepted = True
|
is_accepted = True
|
||||||
if self.get_payment_info(payment_hash) is not None:
|
|
||||||
self.set_payment_status(payment_hash, PR_PAID)
|
|
||||||
util.trigger_callback('request_status', self.wallet, payment_hash.hex(), PR_PAID)
|
|
||||||
if is_accepted or is_expired:
|
if is_accepted or is_expired:
|
||||||
htlc_set.remove(key)
|
htlc_set.remove(key)
|
||||||
if len(htlc_set) > 0:
|
if len(htlc_set) > 0:
|
||||||
@@ -1652,6 +1649,11 @@ class LNWallet(LNWorker):
|
|||||||
self.set_payment_status(bfh(key), status)
|
self.set_payment_status(bfh(key), status)
|
||||||
util.trigger_callback('invoice_status', self.wallet, key)
|
util.trigger_callback('invoice_status', self.wallet, key)
|
||||||
|
|
||||||
|
def set_request_status(self, payment_hash: bytes, status: int) -> None:
|
||||||
|
if self.get_payment_status(payment_hash) != status:
|
||||||
|
self.set_payment_status(payment_hash, status)
|
||||||
|
util.trigger_callback('request_status', self.wallet, payment_hash.hex(), status)
|
||||||
|
|
||||||
def set_payment_status(self, payment_hash: bytes, status: int) -> None:
|
def set_payment_status(self, payment_hash: bytes, status: int) -> None:
|
||||||
info = self.get_payment_info(payment_hash)
|
info = self.get_payment_info(payment_hash)
|
||||||
if info is None:
|
if info is None:
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ class MockLNWallet(Logger, NetworkRetryManager[LNPeerAddr]):
|
|||||||
get_payment_info = LNWallet.get_payment_info
|
get_payment_info = LNWallet.get_payment_info
|
||||||
save_payment_info = LNWallet.save_payment_info
|
save_payment_info = LNWallet.save_payment_info
|
||||||
set_invoice_status = LNWallet.set_invoice_status
|
set_invoice_status = LNWallet.set_invoice_status
|
||||||
|
set_request_status = LNWallet.set_request_status
|
||||||
set_payment_status = LNWallet.set_payment_status
|
set_payment_status = LNWallet.set_payment_status
|
||||||
get_payment_status = LNWallet.get_payment_status
|
get_payment_status = LNWallet.get_payment_status
|
||||||
add_received_htlc = LNWallet.add_received_htlc
|
add_received_htlc = LNWallet.add_received_htlc
|
||||||
|
|||||||
Reference in New Issue
Block a user