From a152d1e7e9aa92a1f773746005cbc78a3a795e55 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 21 Jun 2021 12:23:47 +0930 Subject: [PATCH 1/4] cleanup: remove unused pyln-spec symlinks. Signed-off-by: Rusty Russell --- contrib/pyln-spec/bolt1/boltsetup.py | 1 - contrib/pyln-spec/bolt2/boltsetup.py | 1 - contrib/pyln-spec/bolt4/boltsetup.py | 1 - contrib/pyln-spec/bolt7/boltsetup.py | 1 - 4 files changed, 4 deletions(-) delete mode 120000 contrib/pyln-spec/bolt1/boltsetup.py delete mode 120000 contrib/pyln-spec/bolt2/boltsetup.py delete mode 120000 contrib/pyln-spec/bolt4/boltsetup.py delete mode 120000 contrib/pyln-spec/bolt7/boltsetup.py diff --git a/contrib/pyln-spec/bolt1/boltsetup.py b/contrib/pyln-spec/bolt1/boltsetup.py deleted file mode 120000 index 7a076c98151c..000000000000 --- a/contrib/pyln-spec/bolt1/boltsetup.py +++ /dev/null @@ -1 +0,0 @@ -../boltsetup.py \ No newline at end of file diff --git a/contrib/pyln-spec/bolt2/boltsetup.py b/contrib/pyln-spec/bolt2/boltsetup.py deleted file mode 120000 index 7a076c98151c..000000000000 --- a/contrib/pyln-spec/bolt2/boltsetup.py +++ /dev/null @@ -1 +0,0 @@ -../boltsetup.py \ No newline at end of file diff --git a/contrib/pyln-spec/bolt4/boltsetup.py b/contrib/pyln-spec/bolt4/boltsetup.py deleted file mode 120000 index 7a076c98151c..000000000000 --- a/contrib/pyln-spec/bolt4/boltsetup.py +++ /dev/null @@ -1 +0,0 @@ -../boltsetup.py \ No newline at end of file diff --git a/contrib/pyln-spec/bolt7/boltsetup.py b/contrib/pyln-spec/bolt7/boltsetup.py deleted file mode 120000 index 7a076c98151c..000000000000 --- a/contrib/pyln-spec/bolt7/boltsetup.py +++ /dev/null @@ -1 +0,0 @@ -../boltsetup.py \ No newline at end of file From b90cc5b368bb79938140d21f9bd162359c5f882f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 21 Jun 2021 12:24:44 +0930 Subject: [PATCH 2/4] EXPERIMENTAL_FEATURES: don't offer to downgrade anchor outputs! We don't support this, even if other side allowed it (which we certainly don't). Signed-off-by: Rusty Russell --- common/initial_channel.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/initial_channel.c b/common/initial_channel.c index 8270f4a1bf16..fb01cd175e0a 100644 --- a/common/initial_channel.c +++ b/common/initial_channel.c @@ -201,6 +201,10 @@ struct channel_type **channel_upgradable_types(const tal_t *ctx, struct channel_type *channel_desired_type(const tal_t *ctx, const struct channel *channel) { + /* We don't actually want to downgrade anchors! */ + if (channel->option_anchor_outputs) + return type_anchor_outputs(ctx); + /* For now, we just want option_static_remotekey */ return type_static_remotekey(ctx); } From d6077b06fd5719ef3e60f5765f48646e05645ec3 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 24 Jun 2021 15:00:52 +0930 Subject: [PATCH 3/4] pyln.proto: fix handling of subtypes in TLVs. This was revealed by using lnprototest on channel_types. Signed-off-by: Rusty Russell --- contrib/pyln-proto/pyln/proto/message/message.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/pyln-proto/pyln/proto/message/message.py b/contrib/pyln-proto/pyln/proto/message/message.py index fea95cb5676f..461d163329ff 100644 --- a/contrib/pyln-proto/pyln/proto/message/message.py +++ b/contrib/pyln-proto/pyln/proto/message/message.py @@ -305,8 +305,8 @@ def write(self, io_out: BufferedIOBase, v: Dict[str, Any], otherfields: Dict[str raise ValueError("Missing field {} {}".format(f.name, otherfields)) val = None - if self.name in otherfields: - otherfields = otherfields[self.name] + if type(f.fieldtype) is SubtypeType: + otherfields = otherfields[f.name] f.fieldtype.write(io_out, val, otherfields) def read(self, io_in: BufferedIOBase, otherfields: Dict[str, Any]) -> Optional[Dict[str, Any]]: @@ -554,7 +554,7 @@ def get_value(tup): for typenum, writefunc, val in ordered: buf = BytesIO() - writefunc(cast(BufferedIOBase, buf), val, otherfields) + writefunc(cast(BufferedIOBase, buf), val, val) BigSizeType.write(io_out, typenum) BigSizeType.write(io_out, len(buf.getvalue())) io_out.write(buf.getvalue()) From 4a1918d303a048532223e54c30367c22ce0630e7 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 24 Jun 2021 15:01:57 +0930 Subject: [PATCH 4/4] pyln.proto: fix receiving unknown fields in TLVs. We can still convert these (e.g. k=1) to Python, by just using hex strings. Signed-off-by: Rusty Russell --- contrib/pyln-proto/pyln/proto/message/message.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contrib/pyln-proto/pyln/proto/message/message.py b/contrib/pyln-proto/pyln/proto/message/message.py index 461d163329ff..eb3d7ec556e5 100644 --- a/contrib/pyln-proto/pyln/proto/message/message.py +++ b/contrib/pyln-proto/pyln/proto/message/message.py @@ -521,8 +521,12 @@ def val_to_py(self, val: Dict[str, Any], otherfields: Dict[str, Any]) -> Dict[st ret: Dict[str, Any] = {} for k, v in val.items(): field = self.find_field(k) - assert field - ret[k] = field.val_to_py(v, val) + if field: + ret[k] = field.val_to_py(v, val) + else: + # Unknown TLV, index by number. + assert isinstance(k, int) + ret[k] = v.hex() return ret def write(self, io_out: BufferedIOBase, v: Optional[Dict[str, Any]], otherfields: Dict[str, Any]) -> None: