1
0

prepare a channel to have anchors

* add anchor ln features
* peer.use_anchors is added
* channel.has_anchors is added
This commit is contained in:
bitromortac
2021-09-13 11:00:12 +02:00
committed by ThomasV
parent 19726c4427
commit 3951e07c53
3 changed files with 22 additions and 0 deletions

View File

@@ -496,6 +496,9 @@ class AbstractChannel(Logger, ABC):
"""
pass
def has_anchors(self) -> bool:
pass
class ChannelBackup(AbstractChannel):
"""
@@ -883,6 +886,10 @@ class Channel(AbstractChannel):
assert self.lnworker.wallet.is_mine(addr)
return addr
def has_anchors(self) -> bool:
channel_type = ChannelType(self.storage.get('channel_type'))
return bool(channel_type & ChannelType.OPTION_ANCHOR_OUTPUTS)
def get_wallet_addresses_channel_might_want_reserved(self) -> Sequence[str]:
assert self.is_static_remotekey_enabled()
our_payment_pubkey = self.config[LOCAL].payment_basepoint.pubkey

View File

@@ -656,6 +656,9 @@ class Peer(Logger, EventListener):
def is_upfront_shutdown_script(self):
return self.features.supports(LnFeatures.OPTION_UPFRONT_SHUTDOWN_SCRIPT_OPT)
def use_anchors(self) -> bool:
return self.features.supports(LnFeatures.OPTION_ANCHOR_OUTPUTS_OPT)
def upfront_shutdown_script_from_payload(self, payload, msg_identifier: str) -> Optional[bytes]:
if msg_identifier not in ['accept', 'open']:
raise ValueError("msg_identifier must be either 'accept' or 'open'")

View File

@@ -1181,6 +1181,18 @@ class LnFeatures(IntFlag):
_ln_feature_contexts[OPTION_SUPPORT_LARGE_CHANNEL_OPT] = (LNFC.INIT | LNFC.NODE_ANN)
_ln_feature_contexts[OPTION_SUPPORT_LARGE_CHANNEL_REQ] = (LNFC.INIT | LNFC.NODE_ANN)
OPTION_ANCHOR_OUTPUTS_REQ = 1 << 20
OPTION_ANCHOR_OUTPUTS_OPT = 1 << 21
_ln_feature_direct_dependencies[OPTION_ANCHOR_OUTPUTS_OPT] = {OPTION_STATIC_REMOTEKEY_OPT}
_ln_feature_contexts[OPTION_ANCHOR_OUTPUTS_REQ] = (LNFC.INIT | LNFC.NODE_ANN)
_ln_feature_contexts[OPTION_ANCHOR_OUTPUTS_OPT] = (LNFC.INIT | LNFC.NODE_ANN)
OPTION_ANCHORS_ZERO_FEE_HTLC_REQ = 1 << 22
OPTION_ANCHORS_ZERO_FEE_HTLC_OPT = 1 << 23
_ln_feature_direct_dependencies[OPTION_ANCHORS_ZERO_FEE_HTLC_OPT] = {OPTION_STATIC_REMOTEKEY_OPT}
_ln_feature_contexts[OPTION_ANCHORS_ZERO_FEE_HTLC_REQ] = (LNFC.INIT | LNFC.NODE_ANN)
_ln_feature_contexts[OPTION_ANCHORS_ZERO_FEE_HTLC_OPT] = (LNFC.INIT | LNFC.NODE_ANN)
# Temporary number.
OPTION_TRAMPOLINE_ROUTING_REQ_ECLAIR = 1 << 148
OPTION_TRAMPOLINE_ROUTING_OPT_ECLAIR = 1 << 149