Commit Graph

14433 Commits

Author SHA1 Message Date
Matt Morehouse 7d05f07a2b fuzz: test bolt12 decoding
Add fuzz targets for decoding of offers, invoice requests, and invoices.
Mutators are shared in bolt12.h.
2024-01-23 20:21:48 +10:30
Matt Morehouse b73f921a91 fuzz: test bolt12 bech32 decoding 2024-01-23 20:21:48 +10:30
Lagrang3 b19b08d749 fix CI test: uninitialized variable 2024-01-22 15:10:08 +10:30
Lagrang3 020a03fc3b fix CIL maybe-uninitialized variable 2024-01-22 15:10:08 +10:30
Lagrang3 102dce2515 error handling in mcf.c
Adds a "canonical" error handling in the module mcf.c,
adhering to the same convention we have adopted in flow.c.
So that when a function fails it signals the caller with an invalid
return value, or bool false, and it communicates an error message.
2024-01-22 15:10:08 +10:30
Lagrang3 acc8e8e96f move function linear_fee_cost to mcf 2024-01-22 15:10:08 +10:30
Lagrang3 7edf3c2a55 remove unnecessary arguments
Functions chan_extra_can_send and chan_extra_cannot_send
do not need to know the amount, because flow is already allocated in
htlc_total.
2024-01-22 15:10:08 +10:30
Lagrang3 feef829362 remove declaration of derive_mu 2024-01-22 15:10:08 +10:30
Lagrang3 6f3e2521c8 renepay: low level update knowledge failure
failure to update the knowledge on a channel is guaranteed to preserve
the original state.
2024-01-22 15:10:08 +10:30
Lagrang3 1f6772160f uniform error handling pattern for flow.c 2024-01-22 15:10:08 +10:30
Lagrang3 af3bcddc1f renepay: remove unused derive_mu function 2024-01-22 15:10:08 +10:30
Lagrang3 c9c03dedb7 remove amount_accumulate and amount_reduce
These two functions would make 'pay_flow' dependent on 'pay'
which is not cool, 'pay_flow' should be lower level.
2024-01-22 15:10:08 +10:30
Lagrang3 c4cbc10cfa remove flow dependency on payment 2024-01-22 15:10:08 +10:30
Christian Decker 451a1465ed rs: Temporarily remove a test that is failing due to log changes 2024-01-17 20:55:03 +01:00
Ken Sedgwick e9ff50df96 hsmd: Implement hsmd_forget_channel for Channel Deletion in HSMD
Changelog-Added: hsmd: Added hsmd_forget_channel to enable explicit channel deletion. ([#6987])

Motivation: Previously, a signer prematurely forgetting a channel led
to failures in unresolved channel requests. This update introduces
hsmd_forget_channel, allowing nodes to explicitly notify signers when
a channel is irrevocably resolved and can be safely forgotten. This
ensures synchronized channel cleanup between nodes and signers.

This change maintains backward and forward compatibility. Nodes
explicitly check whether a signer has `WIRE_HSMD_FORGET_CHANNEL`
capability before sending the message.  Nodes without
`WIRE_HSMD_FORGET_CHANNEL` capability won't send this message. Signers
capable of handling this message but not receiving it will continue to
use conservative pruning methods.

Fixes #6987
2024-01-17 13:34:20 +01:00
Christian Decker 78deb485fb py: Publish pyln-grpc-proto following new methods 2024-01-16 19:47:50 +01:00
Christian Decker ea6ae31bcd doc: add a nice explainer about how to update PR branches
This is good info to have, that I often forget and have to spend time
looking for. It'd be nice to have it documented in the project somewhere
so people new the project (or new to maintaining maybe?) know where to
find it.
2024-01-16 19:00:34 +01:00
S. Santos 3ce8d20a89 Update installation.md 2024-01-16 18:38:34 +01:00
Christian Decker 60e1532dd8 cln-plugin: Switch from `env_logger` to `tracing-subscriber`
This switches the logging implementation from using the `log`-facade
to using the `tracing-subscriber` instead. This allows us to also tap
into the tracing instrumentation if desired, which was not possible
with `log`.

Changelog-Changed cln-plugin: The logging adapter now uses tracing-subscriber allowing the `tracing` ecosystem to be used. No format changes.
2024-01-16 18:36:12 +01:00
Erik De Smedt 0d877ffb71 cln-plugin: Allow setting `usage` of RPC-method
The `cln-plugin` can be used to create a plugin that registers
additional rpc-methods. However, it doesn't allow to specify the `usage`
of the command.

This change makes it possible to specify the `usage`. It should not
contain any breaking changes.

I've opted to add a new method called `rpcmethod_from_builder` to the
`Builder` struct. This approach allows us to add new parameters in the
future.
2024-01-16 16:55:06 +01:00
Jon Griffiths 43e302cd94 chaintopology: fetch item counts just once when iterating
Removes the tal_count checking overhead when iterating constant arrays.
Separated from the previous commit to make review easier.

Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths d5808d921a chaintopology: do less work when iterating blocks
- Avoid overhead from tal checks when iterating block txs
- Skip pegin txs as well as coinbase txs while iterating
- Early-exit if the txout cannot possibly be p2wsh
- Don't re-calculate the txid when we already have it
- Don't allocate a script for non-policy asset outputs
- Don't copy txids for non-interesting UTXOs

Note the below -Changed line covers the previous wally and PSBT commits
which also provide general block processing speedups.

Changelog-Changed: core: Processing blocks should now be faster

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths 40dd780ea7 bitcoin_block_from_hex: avoid creating PSBT wrappers for finalized block txs
Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths cdb5de0bce fromwire_bitcoin_tx: avoid creating a PSBT wrapper just to throw it away again
Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths 1b37515528 dualfund: avoid creating PSBT wrappers for input UTXOs
Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths d4fdf8b94e interactive-tx: avoid creating PSBT wrappers for input UTXOs
Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths 2137343e7a tx: add pull_bitcoin_tx_only to pull without creating a psbt wrapper
There are many contexts in which it doesn't make sense to create a PSBT
wrapping the tx. There are also tx features that are not supported in
wallys PSBT implementation yet (such as pegins), which fail if a PSBT
wrapper is created, even though such features are unlikely to ever be
used in txs that cln will create/manipulate.

Allow these cases to be explicit that they only want the tx. This avoids
hitting such errors, is clearer on the caller side, and is more efficient.

Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths 2e670a2a62 tx_parts: use wally to clone tx outputs
Input cloning has not been exposed yet; I'll add that to wally in a
future release.

Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths 23a04d1bba base58: use _n api variant to avoid duplicating our input string
Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths 5e63e55b99 psbt: use wally_map_get instead of wally_map_find
Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths 16ac5cf085 psbt: use wally_map_replace instead of coding our own
Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths ffeb5553a5 wally: build debug or release according to the top-level configuration
Wally release builds are significantly faster than debug builds. Plus we
pass down our build flags to libsecp, which means release builds have
been disabling the asm optimisations for both libraries.

Changelog-Changed: Enable optimizations for libwally/libsecp256k1-zkp

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths 1b2d81f7ce wally: remove now-redundant BUILD_ELEMENTS define
As of wally v1.0.0, Elements/Liquid support is enabled and part of the
library ABI by default.

Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths 84ee3d5701 wally: update libwally to 1.0.0
Also removes incorrect/redundant configure flags when building.

Changelog-Changed: Update libwally to 1.0.0

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths 1f45dd1acb wally: rename functions that clash with wally v1.0.0
Rename the offending functions from wally_foo to cln_wally_foo.

For the sake of a minimal diff, only calls which conflict with wally
v1.0.0 have been changed. However it is bad form to use the wally_
function namespace; the remaining such calls should also be renamed.

Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Peter Neuroth 3cbe35e7da devtools: Deduplicate links from linkify
The method linkify just added links for an entry to a list and produced
duplicates if we got more than one changelog line in a PR. We now only
produce a link once per PR.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2024-01-15 18:36:01 +01:00
Erik De Smedt 0da26933ac `cln_plugin` : Add basic test to `cln_plugin` 2024-01-15 15:32:16 +01:00
Erik De Smedt 000fceb215 Rust cln-rpc crate: Fix `call_enum` and `call`
I've broken the error-handling for `call` in a previous commit.
The key problem is that it failed to parse Json-RPC error's
that were returned by the server. It always returned a parse-
error instead.

To fix it I've adapted `call_raw_request`.
In the previous implementation local errors (e.g: Failing to find the
socket-file) where returned in a Result::Err. However, when the
rpc-server returned an error the data was encoded in the Result::Ok.

In this commit every error is returned as a `Result::Err` and
various methods and other calls have been edited to match this behavior.

I've also added additonal testing
2024-01-09 14:12:46 +01:00
Erik De Smedt dba977dfa2 Some basic documentation for `cln_rpc` 2024-01-09 14:12:46 +01:00
Erik De Smedt 4b5dade87f cln_rpc : use `call_typed` with external structs
One limitation of the `call_typed`-method was that it could not be used
with types defined outside of this crate. (See dependency on
`IntoRequest`)

This is useful for types that are not (yet) defined in this crate. A
possible case is an rpc-method that is defined in a plug-in that is
external to core-lightning or any method which isn't yet a part of the
`msggen`-script.

I've implemented a `TypedRequest` trait to make it work.

PS: This change is breaking. Users of `call_typed` must import
`cln_rpc::models::TypedRequest` instead of
`cln_rpc::models::IntoRequest`
2024-01-09 14:12:46 +01:00
Erik De Smedt ce41aa4ccc cln_rpc: Split low- from high-level API calls.
The `cln::ClnRpc` plugin has a `call` and a `call`-typed method
which worked only on structs that are mentioned in
`src::primitives::Request`.

The consequence is that any rpc-method that is not (yet) defined in this
crate could not be used.

I've adapted the `ClnRpc`-method and create a low-level binding named
`call_raw`. All changes in this commit should be backward compatible.
2024-01-09 14:12:46 +01:00
Christian Decker a59dbbdae5 configure: Use the system `PKG_CONFIG_PATH`
I noticed this while working on a nix devShell to work on CLN. We are
blanked overriding the `pkg-config` search path, which can cause some
trouble. Specifically `nix` uses content addressable locations, and
macOS arm64 and x84_64 use separate `pkg-config` search paths, and by
overwriting it we can cause a mix of different architectures failing
the compilation

Changelog-Fixed: configure: We now respect the `PKG_CONFIG_PATH` environment variable
2024-01-03 12:54:12 +01:00
bitcoin-lightning 2369086fd7 doc:correct listrunes's link 2024-01-02 18:45:18 +01:00
Christian Decker d8f410f2e5 gci: Add build step to PyPI publication 2023-12-29 00:35:45 +01:00
Christian Decker 44b7fe7cc6 meta: Fix the `tools/build-release.sh` script to match repro instructions 2023-12-29 00:35:45 +01:00
Christian Decker d30a2c9b68 docker: Use `git clone` as the build basis for reprobuilds
We used to use the zip archive, which comes with some baggage,
especially for some of the submodule-based dependencies. Using `git
clone` ensures that we have a clean snapshot, based on the latest
commit, and we can skip some of the wildcard operations on zip files.

Changelog-None
2023-12-29 00:35:45 +01:00
Christian Decker 5af9d19e94 misc: Improve generated traces from common/trace.c
The integration with opentelemetry was sub-optimal: it was generating
jaeger-style traces, with short traceIds and we were considering the
entire lifetime as a single trace. This PR changes that to a trace for
startup and then a trace for any event that doesn't already have a
parent.

We also allow using the `CLN_TRACEPARENT` envvar to attach the startup
to a remote / external trace, potentially by whatever started the main
process. This is useful to see the startup trace in the wider context
of whatever tooling is built around it.

Changelog-Added: tracing: It is now possible to inject a parent for the startup trace by setting the `CLN_TRACEPARENT` envvar
2023-12-23 15:19:31 +01:00
royalpinto007 b89e4dc51b fix: load script 2023-12-22 14:06:52 +01:00
Alex Myers 8d0ea8a94a invoice: force inclusion of min_final_cltv_expiry for compatibility
As reported by @wtogami, LND nodes are using a default
min_final_cltv_expiry_delta of 9, which makes them unable to pay invoices
using the modern spec default of 18.  Forcing inclusion of the c field
allows interoperability until broader support of the 18 block default.
Fixes: #6956

Changelog-Fixed: Default bolt11 invoices are payable by LND nodes.
2023-12-22 13:10:10 +01:00
daywalker90 56d42ea767 rust: use "map_or" instead of "if let"
Co-authored-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-12-16 12:11:14 +01:00