Commit Graph

372 Commits

Author SHA1 Message Date
Rusty Russell e4d7266fff common: add amount_feerate helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-11-01 14:11:28 +10:30
Rusty Russell ef87999f9a common: add option for dev-only parameters.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-21 20:08:24 +09:30
Rusty Russell dee94f215b common/bolt11: remove #if DEVELOPER.
We expose the dev handles directly for the test vectors to use.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-21 20:08:24 +09:30
Rusty Russell 4e39dc0c9b common: add test to check bolt12/offers-test.json test vectors.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-21 13:31:03 +09:30
Rusty Russell fea4eb8968 common: helper to generate bolt12 test vector bolt12/offers-test.json.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-21 13:31:03 +09:30
Rusty Russell be082cdff4 common/test: fix gcc-12.3.0 -O3 warning.
```
common/test/run-bolt12_decode.c:206:17: error: ‘valid’ may be used uninitialized [-Werror=maybe-uninitialized]
  206 |                 printf("%s %s\n", str, valid ? "OK": "INVALID");
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
common/test/run-bolt12_decode.c:191:22: note: ‘valid’ was declared here
  191 |                 bool valid, actual;
      |                      ^~~~~
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-08-15 06:21:23 +09:30
Rusty Russell 15c30f4018 renepay: make pay_plugin a tal object.
Avoids a gratuitous "ctx" field, and the simplified declaration
is now understood by `make update-mocks`.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-08-12 09:41:24 +09:30
Rusty Russell 66a5765725 common: add tal_arr_randomize() to shuffle an array.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-08-12 09:24:06 +09:30
Rusty Russell 84fe3dc940 build: more 32-bit printf fixes.
Reported-by: Shahana
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-08-07 11:52:40 +09:30
Rusty Russell 0f6687ec7b codex32: use "cl" instead of "ms" as our HRP.
This was strongly recommended by Russell O'Connor: the "ms" implies that
it's a BIP-32 master secret, and this is CLN specific.

If we changed the hrp to "cln" it would be better, but apparently that
means we no longer fit in a "standard billfold metal wallet" (and
our code assumes a 2-byte prefix anyway).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-08-02 16:12:32 +09:30
Rusty Russell 4dcd712d6e hsmtool: tighten checks for validity on getcodexsecret
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-08-02 08:42:50 +09:30
Dusty Daemon 4628e3ace8 channeld: Code to implement splicing
Update the lightningd <-> channeld interface with lots of new commands to needed to facilitate spicing.

Implement the channeld splicing protocol leveraging the interactivetx protocol.

Implement lightningd’s channel_control to support channeld in its splicing efforts.

Changelog-Added: Added the features to enable splicing & resizing of active channels.
2023-07-31 21:00:22 +09:30
adi2011 d00efbccde common/codex32: Add codex32_secret_encode to encode seeds in bip93 format. 2023-07-31 20:57:40 +09:30
Rusty Russell 58327a594f codex32: rework.
Firstly, I wanted the results easier to use:
1. Make them always lower case, even if the string was UPPER.
2. Decode the payload for them.
3. Don't give the user any fields they don't need, and make
   the field sizes explicit.

Secondly, I wanted to avoid the pattern of "check in one place, assume
in another", in favour of "check on use".

So, I changed the code to lower the string if it needs to at the start,
and then changed the pull functions so we always use them to get data:
this way we should fail clearly and gracefully if we don't have enough data.

I made all the checks explicit, where we assign the fields.

I also addressed the FIXME: I think the array is *often* one shorter,
but not always, so I trim the last byte at the end if needed.

[ Aditya modified the tests to work ]

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-31 11:29:59 +09:30
adi2011 3b848d84d1 common/test: Added run-codex32 to test codex32.c decoding function. 2023-07-31 11:29:59 +09:30
Rusty Russell 4037594c81 common/json_param: use assert() for param correctness checks.
And do them on the first run (where we check parameters), instead
of every time.  Might as well do them in non-developer mode too,
since they're simply programmer correctness.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-25 14:47:12 +09:30
Rusty Russell c074fe050f lightningd/log: clean up nomenclature.
`struct log` becomes `struct logger`, and the member which points to the
`struct log_book` becomes `->log_book` not `->lr`.

Also, we don't need to keep the log_book in struct plugin, since it has
access to ld's log_book.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-19 19:13:57 +09:30
Vincenzo Palazzo 5f6642a6ff fix(jsonrpc): trim the lightning: prefix from invoice
Previously, our code checked for the presence of the `lightning:`
prefix while decoding a bolt11 string. Although this prefix is valid
and accepted by the core lightning pay command, it was causing issues
with how we managed invoices. Specifically, we were skipping the prefix
when creating a copy of the invoice string and storing the raw invoice
(including the prefix) in the database, which caused inconsistencies
in the user experience.

To address this issue, we need to strip the `lightning:` prefix before
calling each core lightning command. In addition, we should
modify the invstring inside the db with the canonical one.

This commit fixes the issue by stripping the `lightning:` prefix
from the `listsendpays` function, which will improve the
user experience and ensure consistency in our invoice management (see
next commit).

Reported-by: @johngribbin
Link: ElementsProject#6207
Fixes: debbdc0
Changelog-Fixes: trim the `lightning:` prefix from invoice everywhere.
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-07-14 15:04:26 +09:30
Dustin Dettmer aba4d18ed1 signed types: add handlers for signed types
We're adding signed types to the spec! This adds the support mechanisms
for them.
2023-07-13 19:34:47 +09:30
Rusty Russell 0c4426a349 lightningd: remove deprecated_apis global, put into lightningd.
We usually have access to `ld`, so avoid the global.

The only place generic code needs it is for the json command struct,
and that already has accessors: add one for libplugin and lightningd
to tell it if deprecated apis are OK.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-09 16:49:48 +09:30
Rusty Russell db7c608e2d common/utils: remove now-unused softref facility.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-09 16:49:48 +09:30
Rusty Russell ea7d428579 common: add test to generate BOLT formatting vectors.
They needed updating, so let's actually autogenerate them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-06-15 15:05:42 +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
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 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
Greg Sanders 12ecffb197 Add segwit_addr_decode unit tests for invalid bech32(m) 2023-05-25 11:07:45 +09:30
Rusty Russell e7d4c3175a build: remove --enable-experimental-features / EXPERIMENTAL_FEATURES
Changelog-EXPERIMENTAL: Build: all experimental features are now runtime-enabled; no more ./configure --enable-experimental-features
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-23 09:34:08 +09:30
Rusty Russell 4deb552fe9 build: don't generate experimental variants of wire files.
We no longer have any experimental-only wire definitions.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-23 09:34:08 +09:30
Rusty Russell dfa6c0ca52 Makefile: bolt version b38156b9510c0562cf50f8758a64602cc0315c19
"Allow nodes to overshoot final htlc amount and expiry (#1032)"

Note that this also renamed `min_final_cltv_expiry` to the more-correct
`min_final_cltv_expiry_delta`.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-04-07 21:22:56 +09:30
Rusty Russell efeb030eef common: fix build of run-channel_type.c
Broken in master, perhaps due to rebase?

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-04-06 14:43:48 +02:00
Rusty Russell 538854fdce bitcoin: add tx_feerate() to reverse-calculate feerate a tx paid.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-04-06 09:01:48 +09:30
Rusty Russell 4549002105 common: expose routine to map channel_type to feature names.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-03-25 15:28:02 +10:30
Greg Sanders 908f834d66 Update libwally to 0.8.8, support PSBTv2
Libwally update breaks compatibility, so
we do this in one large step.

Changelog-Changed: JSON-RPC: elements network PSET now only supports PSETv2.
Changelog-Added: JSON-RPC: PSBTv2 supported for fundchannel_complete, openchannel_update, reserveinputs, sendpsbt, signpsbt, withdraw and unreserveinputs parameter psbt, openchannel_init and openchannel_bump parameter initialpsbt, openchannel_signed parameter signed_psbt and utxopsbt parameter utxopsbt
2023-03-23 16:10:55 +10:30
Rusty Russell 3f02797e88 lightningd: move bip32_base pointer into struct lightningd.
It's needed as the db and wallet is being set up (db migrations), so
it's simpler this way to always use ld->bip32_base for the next patch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-03-22 13:50:32 +10:30
Rusty Russell 9366e6b39f cleanup: rename json_add_amount_msat_only to json_add_amount_msat
Now there's no compat variant, we can rename this function.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-03-18 15:55:49 +10:30
Rusty Russell 780f32dfc6 global: remove deprecated non-msat-named msat fields.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: JSON-RPC: all the non-msat-named millisatoshi fields deprecated in v0.12.0.
2023-03-18 15:55:49 +10:30
Rusty Russell 0274d88bad common/gossip_store: clean up header.
It's actually two separate u16 fields, so actually treat it as
such!

Cleans up zombie handling code a bit too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-01-30 15:15:41 -06:00
Rusty Russell 9aefe3d40a common: update to latest onion-message spec.
```
make check-source-bolt CHECK_BOLT_PREFIX="--prefix=BOLT-onion-message" BOLTVERSION=guilt/offers
```

Mainly textual, though I neatened the extra fields check for TLVs with
blinding, and implemented the "no other fields" requirement for
non-final onion message hops.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-01-30 13:24:29 +10:30
Rusty Russell 8e630e7c53 common/test: fix up name of test file to match latest version.
Otherwise it's skipped!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-01-30 13:24:29 +10:30
Rusty Russell e9eb5f493b common: update to latest route-blinding spec.
```
make check-source-bolt CHECK_BOLT_PREFIX="--prefix=BOLT-route-blinding" BOLTVERSION=guilt/offers
```

Other than textual changes, this does:

1. Ensures we put total_amount_msat in onion final hop (reported by @t-bast).
2. Require that they put total_amount_msat in onion final hop.
3. Return `invalid_onion_blinding` exactly as defined by the spec (i.e. less
   aggressive when we're the final hop) (also reported by @t-bast, but I already
   knew).

See: #5823
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: `offers` breaking blinded payments change (total_amount_sat required, Eclair compat)
2023-01-30 13:24:29 +10:30
Rusty Russell 5958c9c3d6 common/test: remove unused padding in bolt04/blinded-onion-message-onion-test.json
This was reported by @valentinewallace: Dave would only use padding to
make all his own encrypted_recipient_data equal-length.  We did it
across the entire path, which includes the hop added by Alice, which
Dave wouldn't know about.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-01-30 13:24:29 +10:30
Vincenzo Palazzo 8f94e8b943 comm: make sure that our version check is reliable
Rework the logic of the version check used in the
database migration, and make sure
that it is full functional to avoid confusion
at release time.

Changelog-Fixed: database: Correctly identity official release versions for database upgrade.

Reported-by: @urza
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-01-17 14:15:24 +10:30
Christian Decker bcc75b6e98 tests: Fix a small memory leak in the onion test vector tester
Changelog-None
2023-01-16 13:53:48 +10:30
Rusty Russell efd7a5868b common/test: fix typo in bolt12 test vector generation.
Reported-by: @jkczyz
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-01-06 20:44:50 +01:00
Michael Schmoock 0ae6f4d6fb wireaddr: allow for UpperCase DNS names
This further relaxes the DNS hostname checks to allow for uppercase
input.

Changelog-None
2022-12-07 13:20:33 +01:00
Michael Schmoock fb9d6684ad wireaddr: adds test for punycode
Changelog-None
2022-12-06 14:26:19 +01:00
Michael Schmoock 29f81baac9 wireaddr: is_dnsaddr allow underscore in hostname
The hostname part of a DNS FQDN can allow for additional characters
other than specified in `man 7 hostname`.

This extends is_dnsaddr and the test issue #5657.
Also fixes a typo in a comment.

Changelog-Fixed: wireaddr: #5657 allow '_' underscore in hostname part of DNS FQDN
2022-12-06 14:26:19 +01:00
Rusty Russell 179f573e45 lightningd/invoice.c, plugins/fetchinvoice.c: use tlv_make_fields() instead of towire/fromwire hack.
I forgot this existed!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-11-09 15:08:03 +01:00
Rusty Russell 505356145b bolt12: update to modern signature scheme.
This changed, by popular demands.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-11-09 15:08:03 +01:00