diff --git a/lntopo/parser.py b/lntopo/parser.py index ca23fa8..f196d93 100644 --- a/lntopo/parser.py +++ b/lntopo/parser.py @@ -80,6 +80,7 @@ def __json__(self): 'fee_base_msat': self.fee_base_msat, 'fee_proportional_millionths': self.fee_proportional_millionths, 'htlc_maximum_msat': self.htlc_maximum_msat, + 'disabled': bool(self.disable), 'chain_hash': hexlify(self.chain_hash).decode('ASCII'), } @@ -96,6 +97,11 @@ def direction(self): (b,) = struct.unpack("!B", self.channel_flags) return b & 0x01 + @property + def disable(self): + (b,) = struct.unpack("!B", self.channel_flags) + return (b >> 1) & 0x01 + def serialize(self): raise ValueError() @@ -286,6 +292,8 @@ def parse_address(b): return a # https://github.com/alexbosworth/bolt07/blob/519c94a7837e687bf7478a74779d5ea493a76a44/addresses/encode_base32.js + + def to_base_32(addr): alphabet = 'abcdefghijklmnopqrstuvwxyz234567' byte = 8 @@ -305,9 +313,10 @@ def to_base_32(addr): if bits > 0: base32 += alphabet[(value << (word - bits)) & lastIndex] - + return base32 + def parse_node_announcement(b): if not isinstance(b, io.BytesIO): b = io.BytesIO(b) diff --git a/lntopo/timemachine.py b/lntopo/timemachine.py index 120587f..63c7063 100644 --- a/lntopo/timemachine.py +++ b/lntopo/timemachine.py @@ -29,7 +29,7 @@ def restore(dataset, timestamp=None, fmt='dot'): """ if timestamp is None: - timestamp = time.time() + timestamp = time.time() cutoff = timestamp - 2 * 7 * 24 * 3600 channels = {} @@ -84,6 +84,7 @@ def restore(dataset, timestamp=None, fmt='dot'): if m.htlc_maximum_msat: chan["htlc_maximum_msat"] = m.htlc_maximum_msat chan["cltv_expiry_delta"] = m.cltv_expiry_delta + chan["disabled"] = m.disable elif isinstance(m, NodeAnnouncement): node_id = m.node_id.hex() @@ -123,7 +124,8 @@ def restore(dataset, timestamp=None, fmt='dot'): for scid in todelete: del channels[scid] - nodes = [n for n in nodes.values() if n["in_degree"] > 0 or n['out_degree'] > 0] + nodes = [n for n in nodes.values() if n["in_degree"] > + 0 or n['out_degree'] > 0] if len(channels) == 0: print(