Commit Graph

1079 Commits

Author SHA1 Message Date
Christian Decker 415c2bfe3c jsonrpc: Add parsers for routehint-arrays
We'll start passing routehints manually to keysend to reach non-public
nodes as well.
2021-07-15 12:13:06 -04:00
Rusty Russell 28553e9bea route: assume modern TLV support if we don't see a node_announcement.
This is in preparation for removing support (next release?).

Changelog-Changed: Protocol: We now assume nodes support TLV onions (non-legacy) unless we have a node_announcement which says they don't.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-07-14 14:38:00 -05:00
Rusty Russell 2aa833d424 doc: fix up bolt12 quotes.
The one about size needs the offers PR rebased onto the latest
onion-message PR.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-07-14 14:33:18 -05:00
Rusty Russell 3b40bfa801 bolt12_merkle: change offer merkle to latest spec.
And fix up the mess we'd made:
1. We didn't order merkles by lesser-first.
2. We didn't correctly construct tree with last nodes on shortest path.

Now we have tests!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: protocol: offer signature format changed.
2021-07-14 14:33:18 -05:00
Rusty Russell a29847f0c6 DEVELOPER: allow fetchinvoice to force they payer_secret.
We usually assume we're fetching an invoice we are going to pay, so we
look up the previous payment for the payer key, and other sanity
checks.

This adds a developer option to fetchinvoice, which allows it to force
its own payer key, which it uses to sign directly and bypasses these
checks.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-07-14 14:33:18 -05:00
Rusty Russell f9fe814ea3 offers: signatures are now optional.
As per latest spec revision.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: BOLT12 offers can now be unsigned, for really short QR codes.
2021-07-03 12:13:45 +09:30
Rusty Russell 6336d39a95 features: renumber from 102/103 to 38/39.
100+ is for experimentation, modern spec practice is to assign feature bits
sequentially as PRs get added, to avoid later renumbering.

Still respect the old bit for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-07-03 12:13:45 +09:30
Rusty Russell 1a74d8284c common: log at debug level when we update billboard.
Makes for easier postmortem.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-30 14:12:24 +09:30
Christian Decker 45607577b9 jsonrpc: Add parsing for parameter of extra parameters 2021-06-26 10:55:13 +09:30
Christian Decker 477f574569 htlc: Keep the parsed TLV payload around with the htlc_in
We want to show the fields in the invoice_payment hook.
2021-06-26 10:55:13 +09:30
Christian Decker edf4b416c2 htlc: Wire extra TLV types into the HTLC onion decoding 2021-06-26 10:55:13 +09:30
Christian Decker b4ead97517 tlv: Allow passing some extra types to accept when parsing the stream 2021-06-26 10:55:13 +09:30
Rusty Russell b223a6acbb common/read_peer_msg: don't try to handle reestablish/reopen.
Let the callers do that (only channeld needs to do this).

We temporarily send an error on unknown reestablish in openingd, as
this mimic previous behavior and avoids breaking tests (it does leave
a BROKEN message in the logs though, so
test_funding_external_wallet_corners needs to ignore that for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 13:23:28 +09:30
Rusty Russell 9f8a6e2314 lightningd: always pass closing connections through channeld.
It handles all the cases of retransmission, and in the normal case
retransmits shutdown and immediately returns for us to run closingd.

This is actually far simpler and reduces code duplication.

[ Includes fixup to stop warn_unused_result from Christian ]

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Protocol: We could get stuck on signature exchange if we needed to retransmit the final revoke_and_ack.
2021-06-25 13:23:28 +09:30
Rusty Russell 62e1e2467c dev_disconnect: new option to stop using connection, but don't close.
This allows us to ensure a packet is read by the other end, but we
don't read anything else from them or write anything to them.

Using '+' is similar, but because it closes the connection, the peer
might notice before receiving the packet (such as if it does a write).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 13:23:28 +09:30
Rusty Russell eaa2ff23f1 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 <rusty@rustcorp.com.au>
2021-06-24 19:46:38 +09:30
Antoine Poinsot d6f441bdf4 hsm_encryption: merge getline() logic between stdin and non-stdin
Avoid duplicating it, to minimize the potential for divergence.

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-06-18 10:40:07 +09:30
Rusty Russell 976a79094b connectd: fix advertizing for Tor ports.
We were accidentally using the port that the tor service was
connecting to, not the /torport the user said to use.

Fixes: #4597
Reported-by: @openoms
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Config: `addr` autotor and statictor /torport arguments now advertized correctly.
2021-06-17 11:46:48 +09:30
Rusty Russell 41767560d6 common/test: test wireaddr parsing.
In case this was the issue (it wasn't)!.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-17 11:46:48 +09:30
Rusty Russell e734097125 common/wireaddr: fromwire_wireaddr_array helper.
This was previously internal to gossipd and was called "read_addresses".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-16 10:29:17 +09:30
Rusty Russell e784345b55 common: note that command_fail doesn't return NULL.
This suppresses some "may-be-uninitialized" warnings later.  It makes
gcc pickier about how we ignore the result though :(

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-16 10:29:17 +09:30
Rusty Russell 8e74a507d7 common/json_tok: allow non-v0 segwit addresses.
Only v0 has specific length restrictions: taproot is v1 32 bytes long,
but explicitly other lengths remain undefined.

I noticed that I added option_shutdown_anysegwit as EXPERIMENTAL in
the last release, but didn't CHANGELOG it.  Then I changed it to
non-experimental as a spec update, but didn't CHANGELOG it then
either, so let's do that now!

    Changelog-Added: Protocol: We now send and accept `option_shutdown_anysegwit` so you can close channels to v1+ segwit addresses.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `withdraw`, `close` (and others) now accept taproot (and other future) segwit addresses.
2021-06-11 13:54:20 +09:30
Rusty Russell 4cc3eaf79c common/bech32: update to bech32m reference.
I did this by copying the updated bech32 code, and then re-patching in
our minor changes:

1. Headers modded (we need size_t)
2. Explicit length for bech32_encode/decode (not 90).
3. Exposing and bech32_ prefix for convert_bits, charset, charset_rev.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-11 13:54:20 +09:30
Rusty Russell 5526c6797b channeld: set desired_type to upgrade `option_static_remotekey` if not already.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-04 16:13:08 +09:30
Rusty Russell 29f042daac channeld: handle upgrade match.
We don't actually set desired_type yet, but this handles it.

Changelog-EXPERIMENTAL: Protocol: we can now upgrade old channels to `option_static_remotekey` from https://github.com/lightningnetwork/lightning-rfc/pull/868
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-04 16:13:08 +09:30
Rusty Russell d305b8ada6 channeld: send upgradable types, add logging (EXPERIMENTAL_FEATURES)
For now the only upgrade possible is to enable option_static_remotekey.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-04 16:13:08 +09:30
Rusty Russell d2814a957f channeld: send current features (EXPERIMENTAL_FEATURES)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-04 16:13:08 +09:30
Rusty Russell 325d33a902 common/features: helper to pretty-print feature bits.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-04 16:13:08 +09:30
Rusty Russell 2ffd344299 channeld: tweak function to allow testing for pending *uncommitted* changes.
For quiescence, we can't have sent any updates at all.

But for upgrades on reconnection, we may have already added
uncommitted HTLCs for retransmission, but they don't count towards
"are we quiesced" since they're not sent yet.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-04 16:13:08 +09:30
Rusty Russell 2fea448498 gen/impl_template: fix generation of singleton varsize elements.
And as Lisa requested, add testcases.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-04 16:13:08 +09:30
openoms fab1ed6fca hsm_encryption.c: fix source include order 2021-06-03 20:10:07 +02:00
openoms b821de13eb hsm_encryption.c: remove whitespace from line end 2021-06-03 20:10:07 +02:00
openoms b72c05fbda hsm_encryption: read from STDIN if not in a TTY
Changelog-Added: hsmtool: allow piped passwords
2021-06-03 20:10:07 +02:00
niftynei 3c4c8d4fa0 libwally: update to release_0.8.3
Remove hacks to get around empty PSBT deserialization bug
2021-06-03 11:24:33 +09:30
Rusty Russell d3f370944e Makefile: update to latest spec.
This includes anysegwit and the updated HTLC tiebreak test vector.  It
also adds explicit wording for invalid per_commitment_secret (which
nicely matches our code already!).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-26 20:01:03 +09:30
Rusty Russell b6223eb117 lightningd: option_shutdown_anysegwit is no longer experimental.
https://github.com/lightningnetwork/lightning-rfc/pull/672 was merged.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: Protocol: `option_shutdown_anysegwit` allows future segwit versions on shutdown transactions.
2021-05-26 20:01:03 +09:30
Nalin Bhardwaj 94419c7d73 common: Check chain hash in gossip_timestamp_filter
Changelog-Fixed: Validate chain hash for gossip_timestamp_filter messages
2021-05-26 10:43:50 +09:30
Antoine Poinsot fe8074c8c3 Refuse to parse v2 onion addresses without deprecated_apis
Tor v2 hidden services have been deprecated for a while:
https://blog.torproject.org/v2-deprecation-timeline .

This prevents user from being able to set them in the configuration
and to connect to them while still letting us be able to parse them
for gossip.

Changelog-Deprecated: lightningd: v2 Tor addresses.  Use v3.  See https://blog.torproject.org/v2-deprecation-timeline.

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-05-24 20:22:45 +09:30
Antoine Poinsot 7bf17572b5 wireaddr: fix indentation / line breaks for autotor parsing
It really affected readability.

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-05-24 20:22:45 +09:30
Rusty Russell 46b735c023 dijkstra: add chan pointer argument to path scoring.
For fuzz, we will need some fixed per-channel data (so we always fuzz
a channel the same way).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 3832542d27 common/dijkstra: remove dijkstra_amount().
Unless you're using amount as the sole cost function (we don't!), the
"cost" is not the "amount".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 2bb365a931 common/route: route_from_dijkstra returns route_hop array.
This is what (most) callers actually want, so unify it into one place.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 9dadcc858b common/gossip_store: avoid fd pass for new store, use end marker.
This is also simpler.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell c2a88912e1 common/gossmap: reload once we hit end marker.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 167681c709 gossmap: fix gossmap_chan_get_announce() and gossmap_node_get_announce().
These were never used, nor tested.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell d54abd0e36 gossmap: function to get channel features bitmap.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 770a328d56 gossmap: save the offset where the channel updates are, function for details.
This takes an extra 8 bytes per channel, but means we can go back and
get more information about them; this is implemented in
gossmap_chan_get_update_details() which is what listchannels will need.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell d1f8a5f0be gossmap: add gossmap_chan_get_capacity() helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell eb370ab8ff gossmap: remembers when a channel is private.
Steals one bit from the scid_off, and turns that into a relative
offset.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell cc198748d4 common/json_tok: hoist param_short_channel_id from inside lightningd/
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30