Commit Graph

12974 Commits

Author SHA1 Message Date
Rusty Russell
1bb462759d lightningd: simplify listconfigs loop.
Now we can look up the name using opt_find_long, we can do that first,
simplifying this code.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-03 10:50:29 +09:30
Rusty Russell
f45c17450b ccan: update to latest ccan/opt
This adds:
1. ability to search for an option by name.
2. allowance to set our own bits when registering options.
3. show callbacks which can say "don't show", and variable length.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-03 10:50:29 +09:30
Rusty Russell
9b98f9789e bcli: fix type of rpcport.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-03 10:50:29 +09:30
Rusty Russell
d348554ff4 pyln-client: don't try to convert objects to Millisatoshi.
The new listconfigs fields will be objects, and this messes us up!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-03 10:50:29 +09:30
Rusty Russell
45e16180bc lightningd: remove deprecated null for missing plugin options.
We leave the code in contrib/pyln-client/pyln/client/lightning.py to handle
msat null fields for now, though, for a bit more compatibility.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-03 10:50:29 +09:30
Rusty Russell
2bbd9b8a72 common: allow optional fields in json_scan().
Currently it fails if a field is missing, but sometimes that's OK.  So
allow a fieldname ending in `?` to mean "skip over if it's missing".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-03 10:50:29 +09:30
Christian Decker
1e457bd48d rs: Bump version of cln-plugin 2023-06-02 14:47:13 +02:00
Alex Myers
40a50c1ada gossipd: don't fail on gossip deletion
Reported in #6270, there was an attempt to delete gossip overrunning
the end of the gossip_store. This logs the gossip type that was attempted to be deleted and avoids an immediate crash (tombstones would be fine to
skip over at least.)

Changelog-None
2023-06-02 12:02:39 +09:30
Christian Decker
23088911f7 grpc: The plugin needs to use the server feature on cln-grpc 2023-06-01 13:41:21 +09:30
Christian Decker
00ffb39ed6 rs: Guard the cln-rpc dependency behind "server" feature in cln-grpc
The `cln-grpc` crate really has a dual purpose: server and
client. Having the server feature be included by default means that we
are pulling in `cln-rpc` which is a Unix only crate, because of the
use of UDS to talk to CLN. We want to use `cln-grpc` on clients too,
and those might not be Unix variants, hence they'd fail when compiling
`cln-rpc`. This PR guards the Unix-related parts behind the `server`
feature flag.
2023-06-01 13:41:21 +09:30
Rusty Russell
ca34931a29 doc/Makefile: suppress stupid check.
I wasted far too much time on this, disable and reenable later.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-01 09:28:39 +09:30
Rusty Russell
fafeb65012 lightningd: deprecated experimental-websocket-port now we can use bind=ws:
Changelog-Deprecated: `experimental-websocket-port`: use `--bind=ws::<portnum>`.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-01 09:28:39 +09:30
Rusty Russell
3d5367278b lightningd: allow --bind=ws:
Changelog-Added: Config: `bind=ws:...` to explicitly listen on a websocket.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-01 09:28:39 +09:30
Rusty Russell
a6772e9dec common: add new internal type for websockets.
Now it's not a public type, we need a way to refer to it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-01 09:28:39 +09:30
Rusty Russell
7b843e8e58 lightningd: deprecate weird listening options.
These are only likely to confuse users, by silently changing behavior.

Changelog-Deprecated: Config: bind-addr=xxx.onion and addr=xxx.onion, use announce=xxx.onion (which was always equivalent).
Changelog-Deprecated: Config: addr=/socketpath, use listen=/socketpath (which was always equivalent).
2023-06-01 09:28:39 +09:30
Rusty Russell
21958879cf lightningd: deprecated --announce-addr-dns.
This obsoletes the use of --announce-addr-dns which I know Michael
didn't really like either.

Changelog-Deprecated: Config: `announce-addr-dns`; use `--bind-addr=dns:ADDR` for finer control.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-01 09:28:39 +09:30
Rusty Russell
6d0b46c9b1 wireaddr: clean up option parsing, support dns: prefix directly.
This is a major cleanup to how we parse addresses.

1. parse_wireaddr now supports the "dns:" prefix to support dns records (type 5).
2. We are less reliant on separate_address_and_port() which gets confused by
   that colon.
3. We explicitly test every possible address type we can get back from
   parsing, and handle them appropriately.

We update the documentation to use the clearer HOSTNAME vs DNS prefixes now
we also have `dns:` as a prefix.

Changelog-Added: Config: `bind` can now take `dns:` prefix to advertize DNS records.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-01 09:28:39 +09:30
Rusty Russell
3f35d48fe4 common: remove websocket type from wireaddr.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-01 09:28:39 +09:30
Rusty Russell
e66cf46a71 connectd: don't advertise websocket addresses.
I never really liked this hack: websockets are useful, advertizing
them not so much.

Note that we never actually documented that we would advertize these!

Changelog-EXPERIMENTAL: Protocol: Removed support for advertizing websocket addresses in gossip.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-01 09:28:39 +09:30
Rusty Russell
d40379885d common/wireaddr.h: simplify parse_wireaddr API.
1. Make it the standard "return the error" pattern.
2. Rather than flags to indicate what types are allowed, have the callers
   check the return explicitly.
3. Document the APIs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-01 09:28:39 +09:30
Rusty Russell
ddb79162ab connectd: clean up add_gossip loops.
This contained cut & paste code, and it wasn't clear to me that
the first loop included DNS entries with IPv6 entries.

Instead, allow the iterator to take multiple types, and use
a switch statement so compile will break as new types are added.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-01 09:28:39 +09:30
Rusty Russell
1b6ff0b2fc staticbackup: don't use wireaddr_internal.
This is an internal type: it has no API guarantees (indeed, I'm about
to change it, which is how I discovered scb was using it).

Fortunately for every case we care about, it is actually a wireaddr
(in theory the peer can connect locally using a local socket, but this
is mostly for testing and is a very strange setup, and so simply don't
do scb for those).

In this case, the wire encoding is a single byte followed by the
wireaddr, so open-code that in scb_wire.csv for compatibility.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-01 09:28:39 +09:30
Rusty Russell
5ccdab71e5 poetry: update grpcio to 1.54.0
Before this, I was getting build errors on installing gcprio on Ubuntu 23.04:

```
       src/python/grpcio/grpc/_cython/cygrpc.cpp: In function ‘_PyErr_StackItem* __Pyx_PyErr_GetTopmostException(PyThreadState*)’:
        src/python/grpcio/grpc/_cython/cygrpc.cpp:126592:23: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        126592 |     while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
               |                       ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:126592:53: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        126592 |     while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
               |                                                     ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp: In function ‘void __Pyx__ExceptionSave(PyThreadState*, PyObject**, PyObject**, PyObject**)’:
        src/python/grpcio/grpc/_cython/cygrpc.cpp:126606:23: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        126606 |     *type = exc_info->exc_type;
               |                       ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:126608:21: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
        126608 |     *tb = exc_info->exc_traceback;
               |                     ^~~~~~~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp: In function ‘void __Pyx__ExceptionReset(PyThreadState*, PyObject*, PyObject*, PyObject*)’:
        src/python/grpcio/grpc/_cython/cygrpc.cpp:126622:26: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        126622 |     tmp_type = exc_info->exc_type;
               |                          ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:126624:24: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
        126624 |     tmp_tb = exc_info->exc_traceback;
               |                        ^~~~~~~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:126625:15: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        126625 |     exc_info->exc_type = type;
               |               ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:126627:15: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
        126627 |     exc_info->exc_traceback = tb;
               |               ^~~~~~~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp: In function ‘int __Pyx__GetException(PyThreadState*, PyObject**, PyObject**, PyObject**)’:
        src/python/grpcio/grpc/_cython/cygrpc.cpp:126709:30: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        126709 |         tmp_type = exc_info->exc_type;
               |                              ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:126711:28: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
        126711 |         tmp_tb = exc_info->exc_traceback;
               |                            ^~~~~~~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:126712:19: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        126712 |         exc_info->exc_type = local_type;
               |                   ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:126714:19: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
        126714 |         exc_info->exc_traceback = local_tb;
               |                   ^~~~~~~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp: In function ‘int __Pyx_PyBytes_Equals(PyObject*, PyObject*, int)’:
        src/python/grpcio/grpc/_cython/cygrpc.cpp:128708:43: warning: ‘PyBytesObject::ob_shash’ is deprecated [-Wdeprecated-declarations]
        128708 |             hash1 = ((PyBytesObject*)s1)->ob_shash;
               |                                           ^~~~~~~~
        In file included from /usr/include/python3.11/bytesobject.h:62,
                         from /usr/include/python3.11/Python.h:50:
        /usr/include/python3.11/cpython/bytesobject.h:7:35: note: declared here
            7 |     Py_DEPRECATED(3.11) Py_hash_t ob_shash;
              |                                   ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:128708:43: warning: ‘PyBytesObject::ob_shash’ is deprecated [-Wdeprecated-declarations]
        128708 |             hash1 = ((PyBytesObject*)s1)->ob_shash;
               |                                           ^~~~~~~~
        /usr/include/python3.11/cpython/bytesobject.h:7:35: note: declared here
            7 |     Py_DEPRECATED(3.11) Py_hash_t ob_shash;
              |                                   ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:128708:43: warning: ‘PyBytesObject::ob_shash’ is deprecated [-Wdeprecated-declarations]
        128708 |             hash1 = ((PyBytesObject*)s1)->ob_shash;
               |                                           ^~~~~~~~
        /usr/include/python3.11/cpython/bytesobject.h:7:35: note: declared here
            7 |     Py_DEPRECATED(3.11) Py_hash_t ob_shash;
              |                                   ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:128709:43: warning: ‘PyBytesObject::ob_shash’ is deprecated [-Wdeprecated-declarations]
        128709 |             hash2 = ((PyBytesObject*)s2)->ob_shash;
               |                                           ^~~~~~~~
        /usr/include/python3.11/cpython/bytesobject.h:7:35: note: declared here
            7 |     Py_DEPRECATED(3.11) Py_hash_t ob_shash;
              |                                   ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:128709:43: warning: ‘PyBytesObject::ob_shash’ is deprecated [-Wdeprecated-declarations]
        128709 |             hash2 = ((PyBytesObject*)s2)->ob_shash;
               |                                           ^~~~~~~~
        /usr/include/python3.11/cpython/bytesobject.h:7:35: note: declared here
            7 |     Py_DEPRECATED(3.11) Py_hash_t ob_shash;
              |                                   ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:128709:43: warning: ‘PyBytesObject::ob_shash’ is deprecated [-Wdeprecated-declarations]
        128709 |             hash2 = ((PyBytesObject*)s2)->ob_shash;
               |                                           ^~~~~~~~
        /usr/include/python3.11/cpython/bytesobject.h:7:35: note: declared here
            7 |     Py_DEPRECATED(3.11) Py_hash_t ob_shash;
              |                                   ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp: In function ‘void __Pyx__ExceptionSwap(PyThreadState*, PyObject**, PyObject**, PyObject**)’:
        src/python/grpcio/grpc/_cython/cygrpc.cpp:128939:26: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        128939 |     tmp_type = exc_info->exc_type;
               |                          ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:128941:24: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
        128941 |     tmp_tb = exc_info->exc_traceback;
               |                        ^~~~~~~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:128942:15: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        128942 |     exc_info->exc_type = *type;
               |               ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:128944:15: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
        128944 |     exc_info->exc_traceback = *tb;
               |               ^~~~~~~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp: In function ‘void __Pyx_Coroutine_ExceptionClear(_PyErr_StackItem*)’:
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129262:20: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        129262 |     t = exc_state->exc_type;
               |                    ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129264:21: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
        129264 |     tb = exc_state->exc_traceback;
               |                     ^~~~~~~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129265:16: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        129265 |     exc_state->exc_type = NULL;
               |                ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129267:16: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
        129267 |     exc_state->exc_traceback = NULL;
               |                ^~~~~~~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp: In function ‘PyObject* __Pyx_Coroutine_SendEx(__pyx_CoroutineObject*, PyObject*, int)’:
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129344:20: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        129344 |     if (exc_state->exc_type) {
               |                    ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129347:24: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
        129347 |         if (exc_state->exc_traceback) {
               |                        ^~~~~~~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129348:70: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
        129348 |             PyTracebackObject *tb = (PyTracebackObject *) exc_state->exc_traceback;
               |                                                                      ^~~~~~~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129352:14: error: invalid use of incomplete type ‘PyFrameObject’ {aka ‘struct _frame’}
        129352 |             f->f_back = PyThreadState_GetFrame(tstate);
               |              ^~
        In file included from /usr/include/python3.11/Python.h:42:
        /usr/include/python3.11/pytypedefs.h:22:16: note: forward declaration of ‘PyFrameObject’ {aka ‘struct _frame’}
           22 | typedef struct _frame PyFrameObject;
              |                ^~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp: In function ‘void __Pyx_Coroutine_ResetFrameBackpointer(_PyErr_StackItem*)’:
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129383:35: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
        129383 |     PyObject *exc_tb = exc_state->exc_traceback;
               |                                   ^~~~~~~~~~~~~
        In file included from /usr/include/python3.11/Python.h:38:
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129389:19: error: invalid use of incomplete type ‘PyFrameObject’ {aka ‘struct _frame’}
        129389 |         Py_CLEAR(f->f_back);
               |                   ^~
        /usr/include/python3.11/pyport.h:24:38: note: in definition of macro ‘_Py_CAST’
           24 | #define _Py_CAST(type, expr) ((type)(expr))
              |                                      ^~~~
        /usr/include/python3.11/object.h:581:29: note: in expansion of macro ‘_PyObject_CAST’
          581 |         PyObject *_py_tmp = _PyObject_CAST(op); \
              |                             ^~~~~~~~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129389:9: note: in expansion of macro ‘Py_CLEAR’
        129389 |         Py_CLEAR(f->f_back);
               |         ^~~~~~~~
        /usr/include/python3.11/pytypedefs.h:22:16: note: forward declaration of ‘PyFrameObject’ {aka ‘struct _frame’}
           22 | typedef struct _frame PyFrameObject;
              |                ^~~~~~
        In file included from /usr/include/python3.11/Python.h:44:
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129389:19: error: invalid use of incomplete type ‘PyFrameObject’ {aka ‘struct _frame’}
        129389 |         Py_CLEAR(f->f_back);
               |                   ^~
        /usr/include/python3.11/object.h:583:14: note: in definition of macro ‘Py_CLEAR’
          583 |             (op) = NULL;                        \
              |              ^~
        /usr/include/python3.11/pytypedefs.h:22:16: note: forward declaration of ‘PyFrameObject’ {aka ‘struct _frame’}
           22 | typedef struct _frame PyFrameObject;
              |                ^~~~~~
        In file included from /usr/include/python3.11/Python.h:45:
        src/python/grpcio/grpc/_cython/cygrpc.cpp: In function ‘int __Pyx_Coroutine_traverse_excstate(_PyErr_StackItem*, visitproc, void*)’:
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129695:25: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        129695 |     Py_VISIT(exc_state->exc_type);
               |                         ^~~~~~~~
        /usr/include/python3.11/objimpl.h:199:13: note: in definition of macro ‘Py_VISIT’
          199 |         if (op) {                                                       \
              |             ^~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129695:25: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        129695 |     Py_VISIT(exc_state->exc_type);
               |                         ^~~~~~~~
        /usr/include/python3.11/pyport.h:24:38: note: in definition of macro ‘_Py_CAST’
           24 | #define _Py_CAST(type, expr) ((type)(expr))
              |                                      ^~~~
        /usr/include/python3.11/objimpl.h:200:30: note: in expansion of macro ‘_PyObject_CAST’
          200 |             int vret = visit(_PyObject_CAST(op), arg);                  \
              |                              ^~~~~~~~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129695:5: note: in expansion of macro ‘Py_VISIT’
        129695 |     Py_VISIT(exc_state->exc_type);
               |     ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129697:25: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
        129697 |     Py_VISIT(exc_state->exc_traceback);
               |                         ^~~~~~~~~~~~~
        /usr/include/python3.11/objimpl.h:199:13: note: in definition of macro ‘Py_VISIT’
          199 |         if (op) {                                                       \
              |             ^~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129697:25: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
        129697 |     Py_VISIT(exc_state->exc_traceback);
               |                         ^~~~~~~~~~~~~
        /usr/include/python3.11/pyport.h:24:38: note: in definition of macro ‘_Py_CAST’
           24 | #define _Py_CAST(type, expr) ((type)(expr))
              |                                      ^~~~
        /usr/include/python3.11/objimpl.h:200:30: note: in expansion of macro ‘_PyObject_CAST’
          200 |             int vret = visit(_PyObject_CAST(op), arg);                  \
              |                              ^~~~~~~~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129697:5: note: in expansion of macro ‘Py_VISIT’
        129697 |     Py_VISIT(exc_state->exc_traceback);
               |     ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp: In function ‘__pyx_CoroutineObject* __Pyx__Coroutine_NewInit(__pyx_CoroutineObject*, __pyx_coroutine_body_t, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*)’:
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129944:23: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        129944 |     gen->gi_exc_state.exc_type = NULL;
               |                       ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:129946:23: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
        129946 |     gen->gi_exc_state.exc_traceback = NULL;
               |                       ^~~~~~~~~~~~~
        x86_64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -D_WIN32_WINNT=1536 -DGRPC_XDS_USER_AGENT_NAME_SUFFIX=\"Python\" -DGRPC_XDS_USER_AGENT_VERSION_SUFFIX=\"1.47.0\" -DGPR_BACKWARDS_COMPATIBILITY_MODE=1 -DHAVE_CONFIG_H=1 -DGRPC_ENABLE_FORK_SUPPORT=1 "-DPyMODINIT_FUNC=extern \"C\" __attribute__((visibility (\"default\"))) PyObject*" -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 -Isrc/python/grpcio -Iinclude -I. -Ithird_party/abseil-cpp -Ithird_party/address_sorting/include -Ithird_party/cares/cares/include -Ithird_party/cares -Ithird_party/cares/cares -Ithird_party/cares/config_linux -Ithird_party/re2 -Ithird_party/boringssl-with-bazel/src/include -Ithird_party/upb -Isrc/core/ext/upb-generated -Isrc/core/ext/upbdefs-generated -Ithird_party/xxhash -Ithird_party/zlib -I/home/rusty/.cache/pypoetry/virtualenvs/cln-meta-project-BgKQHyxC-py3.11/include -I/usr/include/python3.11 -c src/core/lib/debug/trace.cc -o python_build/temp.linux-x86_64-cpython-311/src/core/lib/debug/trace.o -std=c++14 -fvisibility=hidden -fno-wrapv -fno-exceptions -pthread
        src/python/grpcio/grpc/_cython/cygrpc.cpp: In function ‘void __Pyx__ReturnWithStopIteration(PyObject*)’:
        src/python/grpcio/grpc/_cython/cygrpc.cpp:130932:34: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
        130932 |     if (!__pyx_tstate->exc_info->exc_type)
               |                                  ^~~~~~~~
        src/python/grpcio/grpc/_cython/cygrpc.cpp: In function ‘void __Pyx_AddTraceback(const char*, int, int, const char*)’:
        src/python/grpcio/grpc/_cython/cygrpc.cpp:1729:62: error: invalid use of incomplete type ‘PyFrameObject’ {aka ‘struct _frame’}
         1729 |   #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
              |                                                              ^~
        src/python/grpcio/grpc/_cython/cygrpc.cpp:131799:5: note: in expansion of macro ‘__Pyx_PyFrame_SetLineNumber’
        131799 |     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
               |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
        /usr/include/python3.11/pytypedefs.h:22:16: note: forward declaration of ‘PyFrameObject’ {aka ‘struct _frame’}
           22 | typedef struct _frame PyFrameObject;
              |                ^~~~~~
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-01 06:40:47 +09:30
Rusty Russell
56eb24280c pyln-testing: allow protobuf v4
I need to update gprcio-tools, but it needs protobuf v4.  Christian
added this restriction in a99509db36 to
"Update protobuf dependency to silence dependabot", but perhaps it's
time to actually update?

```
$ poetry update
Updating dependencies
Resolving dependencies... (1.0s)

Because pyln-testing (23.05rc2) @ file:///home/rusty/devel/cvs/lightning/contrib/pyln-testing depends on protobuf (>=3.20.3,<4)
 and grpcio-tools (1.54.0) depends on protobuf (>=4.21.6,<5.0dev), pyln-testing (23.05rc2) @ file:///home/rusty/devel/cvs/lightning/contrib/pyln-testing is incompatible with grpcio-tools (1.54.0).
So, because cln-meta-project depends on both grpcio-tools (1.54.0) and pyln-testing (23.05rc2) @ file:///home/rusty/devel/cvs/lightning/contrib/pyln-testing, version solving failed.
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-01 06:40:47 +09:30
Chase
ade350e55b Gitlab: updating outdated references 2023-05-30 11:42:21 +00:00
Jon Griffiths
14e942298a psbt: remove redundant re-setting of tx modification flags.
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2023-05-30 13:56:56 +09:30
Jon Griffiths
b2b8722a14 psbt: replace init/create_psbt with just create_psbt, and simplify it.
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2023-05-30 13:56:56 +09:30
Jon Griffiths
909f911ff7 psbt: implement psbt_append_output using psbt_insert_output.
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2023-05-30 13:56:56 +09:30
Christian Decker
5ed6f618b3 rust: Bump the versions of cln-rpc, cln-grpc, cln-plugin and grpc-plugin
We haven't uploaded the new v23.05 version just yet, and this includes
a couple of bugfixes that happened since too.
2023-05-30 10:06:10 +09:30
fanquake
5aa7634753 ci: use Bitcoin Core 25.0 2023-05-30 09:12:43 +09:30
Rusty Russell
a7786ca742 Revert "Put bitcoind logging in stdout for pytest"
This reverts commit 1037bf3c43.
(It broke elementsd: we no longer see "Done loading")
2023-05-29 18:41:46 +09:30
Rusty Russell
d3e33cfd14 wallet: fix crash on listtransactions.
We removed the (experimental-only!) annotation output in 611795beee
but we still loaded them from the db.  Turns out that we were putting bogus
annotations into the db, and accessing out of range when loading them.

Consider the following db entry in transaction_annotations:

```
CREATE TABLE transaction_annotations (  txid BLOB, idx INTEGER, location INTEGER, type INTEGER, channel INTEGER REFERENCES channels(id), UNIQUE(txid, idx));
...
INSERT INTO transaction_annotations VALUES(X'19706f9af2875508a06c7db1754ef7ecb3da745ead005992e626441e4e83465f',18,1,129,53699);
```

Here is the corresponding entry in txs:

```
INSERT INTO transactions VALUES(X'19706f9af2875508a06c7db1754ef7ecb3da745ead005992e626441e4e83465f',710327,966,X'02000000000101f2add69112a1d557317826120e1f4ea3bc1cbe4674d720325695b26ecfe8355d120000000000000000013634000000000000160014dca21f104359bbb81e88ed7da985549f2cd0cbc30347304402201cdc854b76c4c7523e3ca09f38a81539d3b2f7fbd9a0de6ae10b7ceaa65ed9d402205a1770058cd1ef081c77c2fe957c07a334cb3a11bc0cc502834a29c59424fe010120589da1f809d955c7af150bf53123c27ffc0a741489b5291f6be811189863ec838576a9142f188d0d973c4ad1865a619d3748340b30746e088763ac672103b7bbcd592197ba6501e7176aabd3f908d94b126ae82ab1e7a4c58f5a789782e57c820120876475527c21029bcf62114eb36758fcb1aead7e67b6f707d32f34e67816894d5211ac9f2d6ce752ae67a9144483a115219ba65c63a3844be8445f739703bea988ac686800000000',NULL,NULL);
```

The annotation refers to output 18 of the tx, but it only has one output!

However, decoding the tx shows that it spent output 18 of a previous tx, so
that's probably where the `18` came from.

Remove this logic: we can remove the remaining (clearly broken!) annotation
adding code in another cleanup commit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-29 18:41:46 +09:30
Greg Sanders
2918bbbf36 db_col_tx: report txn hex if transaction pulled is invalid 2023-05-29 14:52:03 +09:30
Christian Decker
c029de7d56 msggen: Add preapproveinvoice and preapprovekeysend to msggen 2023-05-29 14:50:13 +09:30
Rusty Russell
cfa33ce362 lightningd: fix incorrect reuse of dualopend, leading to dev_queryfeerates race
CI hit this issue where it would get a tx_abort in fundchannel.  This
happens when the dualopend we use to query the feerates has not exited
yet (it waits for the tx_abort reply), and we mistakenly reuse it.

With multi-channel support, this is wrong: just run another one and it
all Just Works.

This means we need to rework our dual_open_control.c logic, since it
would previously create an unsaved channel then not clean up if
something went wrong.

Most people will never try to negotiate opening multiple channels to
the same peer at the same time (vs. having an established channel and
opening a new one), so this case is a bit weird.

```
         rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount)
     
         # l1 leases a channel from l2
         l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount,
                            feerate='{}perkw'.format(feerate),
 >                          compact_lease=rates['compact_lease'])
 
 tests/test_opening.py:1611: 
 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
 contrib/pyln-client/pyln/client/lightning.py:833: in fundchannel
     return self.call("fundchannel", payload)
 contrib/pyln-testing/pyln/testing/utils.py:721: in call
     res = LightningRpc.call(self, method, payload, cmdprefix, filter)

 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
 
 self = <pyln.testing.utils.PrettyPrintingLightningRpc object at 0x7f6cbcd97950>
 method = 'fundchannel'
 payload = {'amount': 500000, 'announce': True, 'compact_lease': '029a00640064000000644c4b40', 'feerate': '2000perkw', ...}
 cmdprefix = None, filter = None
 
     def call(self, method, payload=None, cmdprefix=None, filter=None):
         """Generic call API: you can set cmdprefix here, or set self.cmdprefix
...
         if not isinstance(resp, dict):
             raise ValueError("Malformed response, response is not a dictionary %s." % resp)
         elif "error" in resp:
 >           raise RpcError(method, payload, resp['error'])
 E           pyln.client.lightning.RpcError: RPC call failed: method: fundchannel, payload: {'id': '022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59', 'amount': 500000, 'feerate': '2000perkw', 'announce': True, 'request_amt': 500000, 'compact_lease': '029a00640064000000644c4b40'}, error: {'code': -1, 'message': 'Abort requested', 'data': {'id': '022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59', 'method': 'openchannel_init'}}
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-29 13:46:21 +09:30
Rusty Russell
6a86e80a30 dualopend: fix minor memleak report.
It would be freed eventually, but this is clearer.

```
 MEMLEAK: 0x56402bbfb6a8
   label=openingd/dualopend.c:362:char[]
   backtrace:
     ccan/ccan/tal/tal.c:477 (tal_alloc_)
     ccan/ccan/tal/tal.c:506 (tal_alloc_arr_)
     ccan/ccan/tal/tal.c:850 (tal_dup_)
     openingd/dualopend.c:362 (open_abort)
     openingd/dualopend.c:3411 (rbf_wrap_up)
     openingd/dualopend.c:3787 (rbf_remote_start)
     openingd/dualopend.c:4135 (handle_peer_in)
     openingd/dualopend.c:4421 (main)
   parents:
     openingd/dualopend.c:349:char[]
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-29 13:46:21 +09:30
Rusty Russell
1af9b9d0a8 pytest: slow down for bitcoind.
Failure under CI:

```
>       bitcoind.generate_block(1000)

tests/test_closing.py:853: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
contrib/pyln-testing/pyln/testing/utils.py:496: in generate_block
    return self.rpc.generatetoaddress(numblocks, to_addr)
contrib/pyln-testing/pyln/testing/utils.py:374: in f
    res = proxy._call(name, *args)
../../../.cache/pypoetry/virtualenvs/cln-meta-project-AqJ9wMix-py3.7/lib/python3.7/site-packages/bitcoin/rpc.py:246: in _call
    response = self._get_response()
../../../.cache/pypoetry/virtualenvs/cln-meta-project-AqJ9wMix-py3.7/lib/python3.7/site-packages/bitcoin/rpc.py:276: in _get_response
    http_response = self.__conn.getresponse()
/opt/hostedtoolcache/Python/3.7.16/x64/lib/python3.7/http/client.py:1373: in getresponse
    response.begin()
/opt/hostedtoolcache/Python/3.7.16/x64/lib/python3.7/http/client.py:319: in begin
    version, status, reason = self._read_status()
/opt/hostedtoolcache/Python/3.7.16/x64/lib/python3.7/http/client.py:280: in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <socket.SocketIO object at 0x7fa21aa5d710>
b = <memory at 0x7fa21b771390>

    def readinto(self, b):
        """Read up to len(b) bytes into the writable buffer *b* and return
        the number of bytes read.  If the socket is non-blocking and no bytes
        are available, None is returned.
    
        If *b* is non-empty, a 0 return value indicates that the connection
        was shutdown at the other end.
        """
        self._checkClosed()
        self._checkReadable()
        if self._timeout_occurred:
            raise OSError("cannot read from timed out object")
        while True:
            try:
>               return self._sock.recv_into(b)
E               socket.timeout: timed out

/opt/hostedtoolcache/Python/3.7.16/x64/lib/python3.7/socket.py:589: timeout
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-29 13:46:21 +09:30
Rusty Russell
cd222f8c57 CI: restore dual-funding tests.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-29 13:46:21 +09:30
Rusty Russell
63e2619f9e pytest: fix up DF tests after onchaind broadcast rework.
07413c20b9 et al reworked how onchaind
does broadcasts, meaning tests needed to be updated to the new helpers
rather than searching logs themselves.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-29 13:46:21 +09:30
Rusty Russell
548b54e971 pytest: update test_v2_fail_second for listpeers changes.
Now should use listpeerchannels, since listpeers['channels'] is
deprecated.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-29 13:46:21 +09:30
Rusty Russell
ba46849ee2 lightningd: fix DF crash from libwally update.
Broken prior to 23.05 in 908f834d66:

```
lightningd: FATAL SIGNAL 11 (version d1cf88c)
0x56135ea0f865 send_backtrace
	common/daemon.c:33
0x56135ea0fa50 crashdump
	common/daemon.c:75
0x7f00d263bcef ???
	./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x56135e9887d9 validate_input_unspent
	lightningd/dual_open_control.c:2632
0x56135e989a55 handle_validate_inputs
	lightningd/dual_open_control.c:3026
0x56135e98a9a3 dual_opend_msg
	lightningd/dual_open_control.c:3357
0x56135e9df230 sd_msg_read
	lightningd/subd.c:557
0x56135eb0b6aa next_plan
	ccan/ccan/io/io.c:59
0x56135eb0c2d9 do_plan
	ccan/ccan/io/io.c:407
0x56135eb0c31b io_ready
	ccan/ccan/io/io.c:417
0x56135eb0e6b5 io_loop
	ccan/ccan/io/poll.c:453
0x56135e99b682 io_loop_with_timers
	lightningd/io_loop_with_timers.c:22
0x56135e9a230c main
	lightningd/lightningd.c:1231
0x7f00d262350f __libc_start_call_main
	../sysdeps/nptl/libc_start_call_main.h:58
0x7f00d26235c8 __libc_start_main_impl
	../csu/libc-start.c:381
0x56135e96ff24 ???
	???:0
0xffffffffffffffff ???
	???:0
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: Fixed crash in dual-funding.
2023-05-29 13:46:21 +09:30
Matt Morehouse
34d104b809 fuzz: new fuzz-bech32 seeds
Add new seeds generated after improving the fuzz-bech32 target.
2023-05-27 15:06:31 +09:30
Matt Morehouse
ecdbab5813 fuzz: simplify fuzz-bech32.c
Use a short loop to eliminate redundant code.
2023-05-27 15:06:31 +09:30
Matt Morehouse
7db1e06fb5 fuzz: check decoded values
Decoded values should match the original values before encoding.
2023-05-27 15:06:31 +09:30
Matt Morehouse
255413377b fuzz: allow bech32_encode to succeed
We were passing a max_output_len that was too small, so every call to
bech32_encode was failing. Now we set max_output_len to the full size of
bech32_str.
2023-05-27 15:06:31 +09:30
Matt Morehouse
513bd29330 common: rename bech32_encode parameter
s/max_input_len/max_output_len

This maximum length applies to the output parameter, not the data
parameter. Thus it is more intuitive to name it max_output_len.
2023-05-27 15:06:31 +09:30
Greg Sanders
eec30b1847 db_col_psbt: convert to PSBTv2 on load from db 2023-05-25 11:36:34 +09:30
Greg Sanders
1037bf3c43 Put bitcoind logging in stdout for pytest 2023-05-25 11:07:45 +09:30
Greg Sanders
12ecffb197 Add segwit_addr_decode unit tests for invalid bech32(m) 2023-05-25 11:07:45 +09:30
Greg Sanders
90fefe0c3d test_withdraw_bech32m: test that expected outputs exist for bech32(m) withdrawals 2023-05-25 11:07:45 +09:30