Commit Graph

12671 Commits

Author SHA1 Message Date
Greg Sanders eef0c087fc More accurate elements commitment tx size estimation 2023-02-06 18:50:26 -06:00
Carl Dong dc4ae9deb4 msggen: Regenerate for addition of SignInvoice
Performed using:
  PYTHONPATH=contrib/msggen python3 contrib/msggen/msggen/__main__.py
2023-02-06 15:54:32 -06:00
Carl Dong 11227d37ba msggen: Enable SignInvoice 2023-02-06 15:54:32 -06:00
Carl Dong 1dbc29b8c0 lightningd: Add `signinvoice` to sign a BOLT11 invoice.
Though there's already a `createinvoice` command, there are usecases where a
user may want to sign an invoice that they don't yet have the preimage to. For
example, they may have an htlc_accepted plugin that pays to obtain the preimage
from someone else and returns a `{ "result": "resolve", ... }`.

This RPC command addresses this usecase without overly complicating the
semantics of the existing `createinvoice` command.

Changelog-Added: JSON-RPC: `signinvoice` new command to sign BOLT11
invoices.
2023-02-06 15:54:32 -06:00
Carl Dong f0b8544eba doc: Correct `createinvoice`'s `invstring` description
The existing description is incorrect. `createinvoice` doesn't actually
work when supplied with a custom-encoded bolt11 invoice without the
final 520 signature bits appended. If a users tries to do so, some of
their tagged fields will be incorrectly truncated.

`createinvoice` actually expects that the signatures are there, and it
simply ignores them.

See common/bolt11.c's bolt11_decode_nosig:

         /* BOLT #11:
          *
          * The data part of a Lightning invoice consists of multiple sections:
          *
          * 1. `timestamp`: seconds-since-1970 (35 bits, big-endian)
          * 1. zero or more tagged parts
          * 1. `signature`: Bitcoin-style signature of above (520 bits)
          */
         if (!pull_uint(&hu5, &data, &data_len, &b11->timestamp, 35))
                 return decode_fail(b11, fail, "Can't get 35-bit timestamp");

>        while (data_len > 520 / 5) {
                 const char *problem = NULL;
                 u64 type, data_length;
2023-02-06 15:54:32 -06:00
Vincenzo Palazzo 8369ca71b1 cli: accepts long paths as options
This allows to accept safely long paths as options
and does not truncate them
as https://github.com/ElementsProject/lightning/issues/5576
described

Changelog-Fixed: cli: accepts long paths as options

Suggested-by: @rustyrussell <rusty@rustcorp.com.au>
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-02-07 06:38:36 +10:30
Christian Decker 59ed23e6cf make: Add doc/index.rst to generated files
It gets partially regenerated, so include it in the check. This is the
root cause for the v22.11-modded issue some have noticed.
2023-02-06 19:53:44 +01:00
Rusty Russell 7b9f1b72c6 lightningd: don't print zero blockheight while we're syncing.
In v0.11 (71f736678f) we changed lightningd to wait for gossipd to
acknowledge blocks before updating blockheight: this resolved a problem
which lnprototest had where it wanted to know when we'd fully digested
a block.

However, it broke the syncing case: until then we don't even tell
gossipd, so this stayed at zero.  We should use the current blockheight
for that corner case!

Fixes: #5894
Changelog-Fixed: JSON-RPC: `getinfo` `blockheight` no longer sits on 0 while we sync with bitcoind the first time.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-06 10:15:48 -06:00
Rusty Russell e29fd2a8e2 SECURITY.md: Tell them to spam me, and include our GPG fingerprints.
Added Alex since he's Release Captain this time.

Changelog-Added: SECURITY.md: Where to send sensitive bug reports, and dev GPG fingerprints.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-06 09:39:19 -06:00
Rusty Russell d06c1871a9 pytest: fix flake in test_closing_disconnected_notify
We might be disconnected, but the subd isn't dead yet:

```
>       assert out[0] == '# peer is offline, will negotiate once they reconnect (5 seconds before unilateral close).'
E       AssertionError: assert '# Timed out, forcing close.' == ('# peer is offline, will negotiate once they reconnect (5 seconds before '\n 'unilateral close).')
E         - # peer is offline, will negotiate once they reconnect (5 seconds before unilateral close).
E         + # Timed out, forcing close.

tests/test_closing.py:164: AssertionError
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-06 18:51:44 +10:30
Rusty Russell bcab3f7e83 Makefile: don't try to build sql plugin if there's no sqlite3 support.
Reported-by: @whitslack
Fixes: #5940
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-06 09:20:28 +01:00
Rusty Russell 456078150a lightningd: tell connectd we're shutting down.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-05 20:40:47 +01:00
Rusty Russell 2209d0149f connectd: add new start_shutdown message.
We stop listening, and also refuse to send "connectd_peer_spoke" to create
new subdaemons.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-05 20:40:47 +01:00
Rusty Russell 05ac74fc44 connectd: keep array of our listening sockets.
This allows us to free them if we want to stop listening.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-05 20:40:47 +01:00
Rusty Russell 28b31c19dd pytest: fix flake in test_bolt11_null_after_pay
It's possible that l2 hasn't completely processed the connection yet:

```
        # create l2->l1 channel.
        l2.fundwallet(amount_sat * 5)
        l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
>       l2.rpc.fundchannel(l1.info['id'], amount_sat * 3)

tests/test_pay.py:3974:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
contrib/pyln-client/pyln/client/lightning.py:833: in fundchannel
    return self.call("fundchannel", payload)
contrib/pyln-testing/pyln/testing/utils.py:706: in call
    res = LightningRpc.call(self, method, payload, cmdprefix, filter)
...
E           pyln.client.lightning.RpcError: RPC call failed: method: fundchannel, payload: {'id': '0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518', 'amount': 3000000, 'announce': True}, error: {'code': 400, 'message': 'Unable to connect, no address known for peer', 'data': {'id': '0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518', 'method': 'connect'}}

contrib/pyln-client/pyln/client/lightning.py:422: RpcError
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-05 10:02:46 +01:00
niftynei 4342043382 tests: de-flake test that was failing on cltv expiry
make the number of blocks mined father away from the cltv timeout

from borked/flakey test run:

	lightningd-3 2023-01-26T21:45:19.261Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-channeld-chan#2: billboard perm: Received error channel 27a4a4dd880e86
	1e390517de3e786a237c5ad1f00faab277382664e76b5c3870: Fulfilled HTLC 0 SENT_REMOVE_COMMIT cltv 116 hit deadline
2023-02-05 10:02:46 +01:00
niftynei ef4802f74b df: echo back "tx-abort" when we receive 'tx-abort'
Wait until we get a tx-abort back to terminate the process.

Nota Bene: this can cause RPC calls to hang if the peer never
responds back with tx-abort.

Note that we also have to re-route how open-abort + negotiation_failed
handle failures, as open_abort no longer closes the process
automagically.
2023-02-05 10:02:46 +01:00
niftynei 195a2cf44b dual-open: use tx-abort instead of warning/errors
When a channel open fails, we use tx-abort instead of warning/error.

This means that the peer won't disconnect! And instead when a new
message arrives, we'll need to rebuild the dualopend subd (if missing).

Makes opens a bit easer to retry (no reconnect needed), as well as keeps
the connection alive for other channels we may have with that peer.

Changelog-Changed: Experimental-Dual-Fund: open failures don't disconnect, but instead fail the opening process
2023-02-05 10:02:46 +01:00
niftynei 96b3b40765 lightningd: remove duplicate routine `fail_transient_delayreconnect`
Code is identical to `channel_fail_transient`
2023-02-05 10:02:46 +01:00
niftynei b375a35fa0 v2 open tests: don't drop connection when an openchannel fails
Dropping the connection is bad behavior on an openchannel failure,
especially given that there might be other channels currently connected.

We should maintain the connection but close out the dualopend
daemon for that attempt.

This test partially documents the behaivor, but fails

Changelog-None
2023-02-05 10:02:46 +01:00
Rusty Russell 8315c7c906 lightningd: don't send channeld message to onchaind.
```
----------------------------- Captured stderr call -----------------------------
Sending onchaind an invalid message 03ed00000000000000004e52a9129a66619d6809b1024eb9a0159f173a988f3a5d0bdd2447b4fcc24cef
lightningd: FATAL SIGNAL 6 (version 3c57147-modded)
```

The channel state can also be `FUNDING_SPEND_SEEN` if onchaind is still
starting up.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-05 09:41:24 +01:00
Greg Sanders eee7ad3e1c relax log check for test_closing_higherfee 2023-02-05 09:39:11 +01:00
Christian Decker f2cd635175 gci: Re-Add `TEST_NETWORK=liquid-regtest` to CI run
My bad for forgetting it in the Rework CI.

Changelog-None
Suggested-by: Greg Sanders <@instagibbs>
2023-02-05 09:39:11 +01:00
Joel Klabo 0d1ee8d7f5 Need `sudo` for `make install` 2023-02-05 15:41:19 +10:30
Joel Klabo 57874574ae Add protobuf as a Dependency 2023-02-05 15:41:19 +10:30
Joel Klabo 091e8cefd1 Must Specify pip3 on macOS 2023-02-05 15:41:19 +10:30
Joel Klabo 72b83efc4b Use Python 3.7.8 Instead of 3.7.4 for macOS Install 2023-02-05 15:41:19 +10:30
Greg Sanders 296cf181af Update CI to Bitcoin Core 24.0.1 2023-02-05 15:39:50 +10:30
dependabot[bot] 554cbf08c3 build(deps): bump tokio from 1.23.1 to 1.24.2
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.23.1 to 1.24.2.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/commits)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-04 15:09:46 +01:00
niftynei 278fa7a0a4 v2 opens: don't use p2sh inputs for v2 opens
They're not allowed!
2023-02-04 15:31:16 +10:30
niftynei 35f12b4ca1 upgradewallet: JSONRPC call to update p2sh outputs to a native segwit
v2 opens require you to use native segwit inputs

Changelog-Added: JSONRPC: `upgradewallet` command, sweeps all p2sh-wrapped outputs to a native segwit output
2023-02-04 15:31:16 +10:30
niftynei 679a473f9a fundpsbt: add option to filter out wrapped p2sh inputs
We need to be able to only use non-wrapped inputs for v2/interactive tx
protocol.

Changelog-Added: JSONRPC: `fundpsbt` option `nonwrapped` filters out p2sh wrapped inputs
2023-02-04 15:31:16 +10:30
niftynei 4c46750001 dual-open-rbf: remember the requested lease amount btw restarts
Don't forget the requested lease across restarts.
2023-02-04 15:31:16 +10:30
niftynei 314c021e2c test: restart node during rbf
state isn't kept around for lease amount, so it should fail
2023-02-04 15:31:16 +10:30
niftynei df4bd6287a dual-fund: patch in channel_type logic
There's no reason not to use the channel-types (same as v1s) for v2
opens.

Brings us into compliance with ACINQ's implementation afaict
2023-02-04 15:31:16 +10:30
niftynei 4fe8e1eccf tests: check that non-anchor opens can't use liquidity ads
liquidity ads (as proposed) rely on the CSV addition to the to_remote output
that anchors introduced.
2023-02-04 15:31:16 +10:30
niftynei cbe38dd350 tests: anchors is only EXPERIMENTAL_FEATURES
we've removed the EXPERIMENTAL_DUAL_FUND requirement
2023-02-04 15:31:16 +10:30
niftynei 0b8ea2299a connectd: patch valgrind error w/ buffers for error msgs
The `tmpctx` is free'd before the error is read out/sent over the wire;
there's a call that will copy the array before sending it, let's use
that instead and take() the object?

------------------------------- Valgrind errors --------------------------------
Valgrind error file: valgrind-errors.2181501
==2181501== Syscall param write(buf) points to unaddressable byte(s)
==2181501==    at 0x49E4077: write (write.c:26)
==2181501==    by 0x1C79A3: do_write (io.c:189)
==2181501==    by 0x1C80AB: do_plan (io.c:394)
==2181501==    by 0x1C81BA: io_ready (io.c:423)
==2181501==    by 0x1CA45B: io_loop (poll.c:453)
==2181501==    by 0x118593: main (connectd.c:2053)
==2181501==  Address 0x4afb158 is 40 bytes inside a block of size 140 free'd
==2181501==    at 0x483F0C3: free (vg_replace_malloc.c:872)
==2181501==    by 0x1D103C: del_tree (tal.c:421)
==2181501==    by 0x1D130A: tal_free (tal.c:486)
==2181501==    by 0x1364B8: clean_tmpctx (utils.c:172)
==2181501==    by 0x1266DD: daemon_poll (daemon.c:87)
==2181501==    by 0x1CA334: io_loop (poll.c:420)
==2181501==    by 0x118593: main (connectd.c:2053)
==2181501==  Block was alloc'd at
==2181501==    at 0x483C855: malloc (vg_replace_malloc.c:381)
==2181501==    by 0x1D0AC5: allocate (tal.c:250)
==2181501==    by 0x1D1086: tal_alloc_ (tal.c:428)
==2181501==    by 0x1D124F: tal_alloc_arr_ (tal.c:471)
==2181501==    by 0x126204: cryptomsg_encrypt_msg (cryptomsg.c:161)
==2181501==    by 0x11335F: peer_connected (connectd.c:318)
==2181501==    by 0x118A8A: peer_init_received (peer_exchange_initmsg.c:135)
==2181501==    by 0x1C751E: next_plan (io.c:59)
==2181501==    by 0x1C8126: do_plan (io.c:407)
==2181501==    by 0x1C8168: io_ready (io.c:417)
==2181501==    by 0x1CA45B: io_loop (poll.c:453)
==2181501==    by 0x118593: main (connectd.c:2053)
==2181501==
{
   <insert_a_suppression_name_here>
   Memcheck:Param
   write(buf)
   fun:write
   fun:do_write
   fun:do_plan
   fun:io_ready
   fun:io_loop
   fun:main
}
--------------------------------------------------------------------------------
2023-02-04 15:31:16 +10:30
niftynei 89f382cf39 dual-fund: only allow for liquidity ads if both nodes support anchors
Otherwise we'd have to update the liquidity ads spec to get this
shipped.
2023-02-04 15:31:16 +10:30
niftynei c9c367d770 dual-fund: remove anchor assumption for all dual-funded channels
Only add the anchor channel_type if it's negotiated separately!
2023-02-04 15:31:16 +10:30
niftynei efe66f9689 dual-fund: check features to print (anchors not assumed) 2023-02-04 15:31:16 +10:30
niftynei ad1893f83f opening: helper for anchor flagged, use in dualopend also
There's two anchor flags, we should check both. Also have dualopend
check this as well!
2023-02-04 15:31:16 +10:30
niftynei ef3f05b52a dual-fund: validate upfront shutdown using taproot + anchors
Re-use validation from openingd
2023-02-04 15:31:16 +10:30
niftynei 46dc37dff1 openingd: pull out validation for shutdown script
We're gonna reuse it in dualopend.
2023-02-04 15:31:16 +10:30
niftynei 976f6ef51a df tests: use the amount from the logs to check for! 2023-02-04 15:31:16 +10:30
niftynei db448df277 dual-fund: on re-init, re-populate opener_funding/accepter_funding
We use them in the RBF case!
2023-02-04 15:31:16 +10:30
niftynei 4da0d6230e dual-fund: update to latest, add in updates to rbf amounts
You can now pick a different amount during the RBF phase
2023-02-04 15:31:16 +10:30
Michael Schmoock ad249607d6 dual-fund: update extracted CSVs to latest bolt draft
Changelog-None
2023-02-04 15:31:16 +10:30
Rusty Russell 35acdc112f offers: fix pay where we are using deprecated apis.
In this case, "fee_base_msat" from `listincoming` has `msat` appended.

Fixes: #5850
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-03 16:59:51 +01:00
Rusty Russell e8f9366a29 pytest: add test for using offers with allow-deprecated-apis=True
Demonstrates that offers doesn't handle msat fields correctly.

Reported-by: @SimonVrouwe
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-03 16:59:51 +01:00