lnworker: move RecvMPPResolution and status to lnutil
it is required both in lnpeer and lnworker, moving it to lnutil seems to make more sense. # Conflicts: # electrum/lnworker.py
This commit is contained in:
@@ -48,7 +48,7 @@ from .lnutil import (Outpoint, LocalConfig, RECEIVED, UpdateAddHtlc, ChannelConf
|
|||||||
IncompatibleLightningFeatures, ChannelType, LNProtocolWarning, validate_features,
|
IncompatibleLightningFeatures, ChannelType, LNProtocolWarning, validate_features,
|
||||||
IncompatibleOrInsaneFeatures, FeeBudgetExceeded,
|
IncompatibleOrInsaneFeatures, FeeBudgetExceeded,
|
||||||
GossipForwardingMessage, GossipTimestampFilter, channel_id_from_funding_tx,
|
GossipForwardingMessage, GossipTimestampFilter, channel_id_from_funding_tx,
|
||||||
PaymentFeeBudget, serialize_htlc_key, Keypair)
|
PaymentFeeBudget, serialize_htlc_key, Keypair, RecvMPPResolution)
|
||||||
from .lntransport import LNTransport, LNTransportBase, LightningPeerConnectionClosed, HandshakeFailed
|
from .lntransport import LNTransport, LNTransportBase, LightningPeerConnectionClosed, HandshakeFailed
|
||||||
from .lnmsg import encode_msg, decode_msg, UnknownOptionalMsgType, FailedToParseMsg
|
from .lnmsg import encode_msg, decode_msg, UnknownOptionalMsgType, FailedToParseMsg
|
||||||
from .interface import GracefulDisconnect
|
from .interface import GracefulDisconnect
|
||||||
@@ -2465,7 +2465,6 @@ class Peer(Logger, EventListener):
|
|||||||
exc_incorrect_or_unknown_pd: OnionRoutingFailure,
|
exc_incorrect_or_unknown_pd: OnionRoutingFailure,
|
||||||
log_fail_reason: Callable[[str], None],
|
log_fail_reason: Callable[[str], None],
|
||||||
) -> bool:
|
) -> bool:
|
||||||
from .lnworker import RecvMPPResolution
|
|
||||||
mpp_resolution = self.lnworker.check_mpp_status(
|
mpp_resolution = self.lnworker.check_mpp_status(
|
||||||
payment_secret=payment_secret,
|
payment_secret=payment_secret,
|
||||||
short_channel_id=short_channel_id,
|
short_channel_id=short_channel_id,
|
||||||
|
|||||||
@@ -1930,6 +1930,30 @@ class UpdateAddHtlc:
|
|||||||
self._validate()
|
self._validate()
|
||||||
|
|
||||||
|
|
||||||
|
# Note: these states are persisted in the wallet file.
|
||||||
|
# Do not modify them without performing a wallet db upgrade
|
||||||
|
class RecvMPPResolution(IntEnum):
|
||||||
|
WAITING = 0
|
||||||
|
EXPIRED = 1
|
||||||
|
ACCEPTED = 2
|
||||||
|
FAILED = 3
|
||||||
|
|
||||||
|
|
||||||
|
class ReceivedMPPStatus(NamedTuple):
|
||||||
|
resolution: RecvMPPResolution
|
||||||
|
expected_msat: int
|
||||||
|
htlc_set: Set[Tuple[ShortChannelID, UpdateAddHtlc]]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
@stored_in('received_mpp_htlcs', tuple)
|
||||||
|
def from_tuple(resolution, expected_msat, htlc_list) -> 'ReceivedMPPStatus':
|
||||||
|
htlc_set = set([(ShortChannelID(bytes.fromhex(scid)), UpdateAddHtlc.from_tuple(*x)) for (scid, x) in htlc_list])
|
||||||
|
return ReceivedMPPStatus(
|
||||||
|
resolution=RecvMPPResolution(resolution),
|
||||||
|
expected_msat=expected_msat,
|
||||||
|
htlc_set=htlc_set)
|
||||||
|
|
||||||
|
|
||||||
class OnionFailureCodeMetaFlag(IntFlag):
|
class OnionFailureCodeMetaFlag(IntFlag):
|
||||||
BADONION = 0x8000
|
BADONION = 0x8000
|
||||||
PERM = 0x4000
|
PERM = 0x4000
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ from .lnutil import (
|
|||||||
LnKeyFamily, LOCAL, REMOTE, MIN_FINAL_CLTV_DELTA_FOR_INVOICE, SENT, RECEIVED, HTLCOwner, UpdateAddHtlc, LnFeatures,
|
LnKeyFamily, LOCAL, REMOTE, MIN_FINAL_CLTV_DELTA_FOR_INVOICE, SENT, RECEIVED, HTLCOwner, UpdateAddHtlc, LnFeatures,
|
||||||
ShortChannelID, HtlcLog, NoPathFound, InvalidGossipMsg, FeeBudgetExceeded, ImportedChannelBackupStorage,
|
ShortChannelID, HtlcLog, NoPathFound, InvalidGossipMsg, FeeBudgetExceeded, ImportedChannelBackupStorage,
|
||||||
OnchainChannelBackupStorage, ln_compare_features, IncompatibleLightningFeatures, PaymentFeeBudget,
|
OnchainChannelBackupStorage, ln_compare_features, IncompatibleLightningFeatures, PaymentFeeBudget,
|
||||||
NBLOCK_CLTV_DELTA_TOO_FAR_INTO_FUTURE, GossipForwardingMessage, MIN_FUNDING_SAT
|
NBLOCK_CLTV_DELTA_TOO_FAR_INTO_FUTURE, GossipForwardingMessage, MIN_FUNDING_SAT,
|
||||||
|
RecvMPPResolution, ReceivedMPPStatus,
|
||||||
)
|
)
|
||||||
from .lnonion import decode_onion_error, OnionFailureCode, OnionRoutingFailure, OnionPacket
|
from .lnonion import decode_onion_error, OnionFailureCode, OnionRoutingFailure, OnionPacket
|
||||||
from .lnmsg import decode_msg
|
from .lnmsg import decode_msg
|
||||||
@@ -125,28 +126,6 @@ class PaymentInfo:
|
|||||||
self.validate()
|
self.validate()
|
||||||
|
|
||||||
|
|
||||||
# Note: these states are persisted in the wallet file.
|
|
||||||
# Do not modify them without performing a wallet db upgrade
|
|
||||||
class RecvMPPResolution(IntEnum):
|
|
||||||
WAITING = 0
|
|
||||||
EXPIRED = 1
|
|
||||||
ACCEPTED = 2
|
|
||||||
FAILED = 3
|
|
||||||
|
|
||||||
|
|
||||||
class ReceivedMPPStatus(NamedTuple):
|
|
||||||
resolution: RecvMPPResolution
|
|
||||||
expected_msat: int
|
|
||||||
htlc_set: Set[Tuple[ShortChannelID, UpdateAddHtlc]]
|
|
||||||
|
|
||||||
@stored_in('received_mpp_htlcs', tuple)
|
|
||||||
def from_tuple(resolution, expected_msat, htlc_list) -> 'ReceivedMPPStatus':
|
|
||||||
htlc_set = set([(ShortChannelID(bytes.fromhex(scid)), UpdateAddHtlc.from_tuple(*x)) for (scid, x) in htlc_list])
|
|
||||||
return ReceivedMPPStatus(
|
|
||||||
resolution=RecvMPPResolution(resolution),
|
|
||||||
expected_msat=expected_msat,
|
|
||||||
htlc_set=htlc_set)
|
|
||||||
|
|
||||||
|
|
||||||
SentHtlcKey = Tuple[bytes, ShortChannelID, int] # RHASH, scid, htlc_id
|
SentHtlcKey = Tuple[bytes, ShortChannelID, int] # RHASH, scid, htlc_id
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user