mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-28 16:01:30 +00:00
remove UnknownPaymentHash (exception used as value)
This commit is contained in:
parent
a5a5048d53
commit
abe1bece2c
4 changed files with 17 additions and 36 deletions
|
@ -38,7 +38,7 @@ from .lnutil import (Outpoint, LocalConfig, RECEIVED, UpdateAddHtlc,
|
|||
funding_output_script, get_per_commitment_secret_from_seed,
|
||||
secret_to_pubkey, PaymentFailure, LnFeatures,
|
||||
LOCAL, REMOTE, HTLCOwner, generate_keypair, LnKeyFamily,
|
||||
ln_compare_features, privkey_to_pubkey, UnknownPaymentHash, MIN_FINAL_CLTV_EXPIRY_ACCEPTED,
|
||||
ln_compare_features, privkey_to_pubkey, MIN_FINAL_CLTV_EXPIRY_ACCEPTED,
|
||||
LightningPeerConnectionClosed, HandshakeFailed, NotFoundChanAnnouncementForUpdate,
|
||||
MINIMUM_MAX_HTLC_VALUE_IN_FLIGHT_ACCEPTED, MAXIMUM_HTLC_MINIMUM_MSAT_ACCEPTED,
|
||||
MAXIMUM_REMOTE_TO_SELF_DELAY_ACCEPTED, RemoteMisbehaving, DEFAULT_TO_SELF_DELAY,
|
||||
|
@ -1218,12 +1218,11 @@ class Peer(Logger):
|
|||
def maybe_fulfill_htlc(self, *, chan: Channel, htlc: UpdateAddHtlc,
|
||||
onion_packet: OnionPacket, processed_onion: ProcessedOnionPacket,
|
||||
) -> Tuple[Optional[bytes], Optional[OnionRoutingFailureMessage]]:
|
||||
try:
|
||||
info = self.lnworker.get_payment_info(htlc.payment_hash)
|
||||
preimage = self.lnworker.get_preimage(htlc.payment_hash)
|
||||
except UnknownPaymentHash:
|
||||
if info is None:
|
||||
reason = OnionRoutingFailureMessage(code=OnionFailureCode.INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS, data=b'')
|
||||
return None, reason
|
||||
preimage = self.lnworker.get_preimage(htlc.payment_hash)
|
||||
try:
|
||||
payment_secret_from_onion = processed_onion.hop_data.payload["payment_data"]["payment_secret"]
|
||||
except:
|
||||
|
|
|
@ -11,7 +11,7 @@ from . import ecc
|
|||
from .lnutil import (make_commitment_output_to_remote_address, make_commitment_output_to_local_witness_script,
|
||||
derive_privkey, derive_pubkey, derive_blinded_pubkey, derive_blinded_privkey,
|
||||
make_htlc_tx_witness, make_htlc_tx_with_open_channel, UpdateAddHtlc,
|
||||
LOCAL, REMOTE, make_htlc_output_witness_script, UnknownPaymentHash,
|
||||
LOCAL, REMOTE, make_htlc_output_witness_script,
|
||||
get_ordered_channel_configs, privkey_to_pubkey, get_per_commitment_secret_from_seed,
|
||||
RevocationStore, extract_ctn_from_tx_and_chan, UnableToDeriveSecret, SENT, RECEIVED,
|
||||
map_htlcs_to_ctx_output_idxs, Direction)
|
||||
|
@ -232,11 +232,7 @@ def create_sweeptxs_for_our_ctx(*, chan: 'AbstractChannel', ctx: Transaction,
|
|||
def create_txns_for_htlc(*, htlc: 'UpdateAddHtlc', htlc_direction: Direction,
|
||||
ctx_output_idx: int, htlc_relative_idx: int):
|
||||
if htlc_direction == RECEIVED:
|
||||
try:
|
||||
preimage = chan.lnworker.get_preimage(htlc.payment_hash)
|
||||
except UnknownPaymentHash as e:
|
||||
_logger.info(f'trying to sweep htlc from our latest ctx but getting {repr(e)}')
|
||||
return
|
||||
else:
|
||||
preimage = None
|
||||
htlctx_witness_script, htlc_tx = create_htlctx_that_spends_from_our_ctx(
|
||||
|
@ -375,11 +371,7 @@ def create_sweeptxs_for_their_ctx(*, chan: 'Channel', ctx: Transaction,
|
|||
def create_sweeptx_for_htlc(htlc: 'UpdateAddHtlc', is_received_htlc: bool,
|
||||
ctx_output_idx: int) -> None:
|
||||
if not is_received_htlc and not is_revocation:
|
||||
try:
|
||||
preimage = chan.lnworker.get_preimage(htlc.payment_hash)
|
||||
except UnknownPaymentHash as e:
|
||||
_logger.info(f'trying to sweep htlc from their latest ctx but getting {repr(e)}')
|
||||
return
|
||||
else:
|
||||
preimage = None
|
||||
htlc_output_witness_script = make_htlc_output_witness_script(
|
||||
|
|
|
@ -245,7 +245,6 @@ class LightningPeerConnectionClosed(LightningError): pass
|
|||
class UnableToDeriveSecret(LightningError): pass
|
||||
class HandshakeFailed(LightningError): pass
|
||||
class ConnStringFormatError(LightningError): pass
|
||||
class UnknownPaymentHash(LightningError): pass
|
||||
class RemoteMisbehaving(LightningError): pass
|
||||
|
||||
class NotFoundChanAnnouncementForUpdate(Exception): pass
|
||||
|
|
|
@ -50,7 +50,7 @@ from .lnutil import (Outpoint, LNPeerAddr,
|
|||
get_compressed_pubkey_from_bech32, extract_nodeid,
|
||||
PaymentFailure, split_host_port, ConnStringFormatError,
|
||||
generate_keypair, LnKeyFamily, LOCAL, REMOTE,
|
||||
UnknownPaymentHash, MIN_FINAL_CLTV_EXPIRY_FOR_INVOICE,
|
||||
MIN_FINAL_CLTV_EXPIRY_FOR_INVOICE,
|
||||
NUM_MAX_EDGES_IN_PAYMENT_PATH, SENT, RECEIVED, HTLCOwner,
|
||||
UpdateAddHtlc, Direction, LnFeatures,
|
||||
ShortChannelID, PaymentAttemptLog, PaymentAttemptFailureDetails,
|
||||
|
@ -606,11 +606,8 @@ class LNWallet(LNWorker):
|
|||
timestamp = htlc.timestamp
|
||||
label = self.wallet.get_label(key)
|
||||
if _direction == SENT:
|
||||
try:
|
||||
inv = self.get_payment_info(bfh(key))
|
||||
fee_msat = - inv.amount*1000 - amount_msat if inv.amount else None
|
||||
except UnknownPaymentHash:
|
||||
fee_msat = None
|
||||
info = self.get_payment_info(bfh(key))
|
||||
fee_msat = - info.amount*1000 - amount_msat if info and info.amount else None
|
||||
else:
|
||||
fee_msat = None
|
||||
else:
|
||||
|
@ -1114,8 +1111,7 @@ class LNWallet(LNWorker):
|
|||
def get_payment_info(self, payment_hash: bytes) -> PaymentInfo:
|
||||
key = payment_hash.hex()
|
||||
with self.lock:
|
||||
if key not in self.payments:
|
||||
raise UnknownPaymentHash(payment_hash)
|
||||
if key in self.payments:
|
||||
amount, direction, status = self.payments[key]
|
||||
return PaymentInfo(payment_hash, amount, direction, status)
|
||||
|
||||
|
@ -1127,12 +1123,8 @@ class LNWallet(LNWorker):
|
|||
self.wallet.save_db()
|
||||
|
||||
def get_payment_status(self, payment_hash):
|
||||
try:
|
||||
info = self.get_payment_info(payment_hash)
|
||||
status = info.status
|
||||
except UnknownPaymentHash:
|
||||
status = PR_UNPAID
|
||||
return status
|
||||
return info.status if info else PR_UNPAID
|
||||
|
||||
def get_invoice_status(self, key):
|
||||
log = self.logs[key]
|
||||
|
@ -1158,9 +1150,8 @@ class LNWallet(LNWorker):
|
|||
return payment_attempt
|
||||
|
||||
def set_payment_status(self, payment_hash: bytes, status):
|
||||
try:
|
||||
info = self.get_payment_info(payment_hash)
|
||||
except UnknownPaymentHash:
|
||||
if info is None:
|
||||
# if we are forwarding
|
||||
return
|
||||
info = info._replace(status=status)
|
||||
|
|
Loading…
Add table
Reference in a new issue