Commit Graph

13452 Commits

Author SHA1 Message Date
Rusty Russell c7026e56a4 wallet: rename enum wallet_payment_status to payment_status.
We use it everywhere, the wallet_ prefix is weird.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-18 14:24:01 +09:30
Rusty Russell 19669d886b invoice: expose invoice_status_str function.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-18 14:24:01 +09:30
Rusty Russell 1c846461ca invoices: keep wallet pointer.
We need this to access ->ld later.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-18 14:24:01 +09:30
Rusty Russell 5132fea44e docs: fix up internal references now files have moved.
And tools/check-markdown.sh didn't do anything: remove it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-16 12:59:40 +09:30
Adi Shankara 9f8889eb8c update workflow to sync readme files 2023-07-16 12:59:40 +09:30
Adi Shankara e5547acaea move old misc file to another folder 2023-07-16 12:59:40 +09:30
Adi Shankara 4e46cdba93 remove mkdocs and sphinx files 2023-07-16 12:59:40 +09:30
Adi Shankara 9e47c16021 move old misc files to another folder 2023-07-16 12:59:40 +09:30
Adi Shankara e4826fbf63 remove legacy docs 2023-07-16 12:59:40 +09:30
Adi Shankara b2caa56c27 update new documentation and move to doc/ 2023-07-16 12:59:40 +09:30
Rusty Russell 5151020224 pytest: fix flake in test_feerates
```
2023-07-14T05:32:54.3688763Z         # Set ECONOMICAL/6 feerate, for unilateral_close and htlc_resolution
2023-07-14T05:32:54.3689123Z         l1.set_feerates((15000, 11000, 0, 0), True)
2023-07-14T05:32:54.3689484Z         feerates = l1.rpc.feerates('perkw')
2023-07-14T05:32:54.3689919Z >       assert feerates['perkw']['unilateral_close'] == 11000
2023-07-14T05:32:54.3690226Z E       assert 15000 == 11000
2023-07-14T05:32:54.3690391Z
2023-07-14T05:32:54.3690514Z tests/test_misc.py:1572: AssertionError
```

The rough checks in set_feerates don't actually ensure that we've digested
the changes, so copy the check from elsewhere that makes sure
feerates['estimates'] has indeed been updated.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-16 12:57:27 +09:30
Rusty Russell 1ddf4bac2c pytest: fix flake in tests/test_closing.py::test_penalty_rbf_normal[True]
We assume that RBFs will happen in order (txid1, txid2) but that doesn't always happen.

```
        for depth in range(2, 10):
            bitcoind.generate_block(1)
            # l2 should RBF, twice even, one for the l1 main output,
            # one for the l1 HTLC output.
            # Don't assume a specific order!
            start = l2.daemon.logsearch_start
>           txid1 = get_rbf_txid(l2, txid1)

tests/test_closing.py:1671: 
...
                            print("({} was previously in logs!)".format(r))
>                   raise TimeoutError('Unable to find "{}" in logs.'.format(exs))
E                   TimeoutError: Unable to find "[re.compile('RBF onchain .*1fe38fe22852baaedccc3a9fd9d897e46bae5b7ca31daf23e0aa456fb235475e')]" in logs.

contrib/pyln-testing/pyln/testing/utils.py:328: TimeoutError
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-16 12:57:27 +09:30
Rusty Russell 8de3b89aac pytest: test for bad estimatefees results.
See: #6183
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-16 12:57:27 +09:30
Rusty Russell 81cfd3799e lightningd: don't crash when we get a bogus estimatefees subfield.
We hand "estimatefees.feerate_floor" as method, for example, and then
crash instead of reporting the plugin which gave us the bad answer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-16 12:57:27 +09:30
Vincenzo Palazzo 5afd0ab6bb fix(db): normalize all the invoice string stored in the database
This commit make a db migration to canonicalize all the
invoice string stored inside the database.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-07-14 15:04:26 +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
niftynei e366c19d09 dual-fund: send the next_funding_txid to peer
As per cd3c99e722
we should send the next_funding_txid if we've sent our commitment sigs,
but we haven't received the peer's tx_signatures.

Note that we send here, but don't verify that it's arrived.
2023-07-13 19:34:47 +09:30
niftynei 0cd7fe5089 spec: update to latest dual-funding wire changes
the witnesses are maddeningly weird now (you concat everything together)

we also changed some things to be s64's (it's a teeny tiny change)
2023-07-13 19:34:47 +09:30
niftynei 388f27edce varint: make helper public 2023-07-13 19:34:47 +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 ad592d8b0d plugins: fix shutdown notification to contain object.
We fixed the others.  There are no fields, but this keeps it consistent.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `shutdown` notification contains `shutdown` object (notification consistency)
2023-07-13 18:59:37 +09:30
Rusty Russell 4d507065f3 libplugin: support wildcard subscriptions.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-13 18:59:37 +09:30
Rusty Russell 279b3aa7e8 pyln: add ability to subscribe to all notifications.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-13 18:59:37 +09:30
Rusty Russell 46fc14c51d plugins: add support for wildcard subscription.
Requested-by: Shahana Farooqui @Shahana
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: Plugins: plugins can subscribe to all notifications using "*".
2023-07-13 18:59:37 +09:30
niftynei 3a18d8b355 mac-fix: `sed` doesn't work the same on macos
https://stackoverflow.com/a/14813278

Found-by: @ddustin
2023-07-13 18:59:20 +09:30
Vincenzo Palazzo eff160cbae ci: Fix flakiness of lnprototest on CI
The lnprototest occasionally fails on our CI due to the
timeout duration we set while waiting for cln to start up.
This timeout is insufficient for machines like the ones
used in the GitHub CI environment.

To address this issue, this commit introduces the use of
environment variables to increase the lnprototest timeout,
ensuring sufficient time for cln to initialize.

Changelog-None
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-07-13 08:54:21 +02:00
Vincenzo Palazzo 2a7d14bcf1 feat: increase the lnprototest version
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-07-13 08:54:21 +02:00
Vincenzo Palazzo 55f0515d20 hsmtool: Add support for Signet network
This commit addresses a limitation in our CLI argument
checking for the hsmtool. With this update, we introduce
support for the Signet network.

In addition, it introduce a code semplification by directly passing the
BIP32 version instead of using network testnet flag. This change
improves code readability and minimaze code changes
to support other networks.

Link: https://github.com/ElementsProject/lightning/issues/6371
Reported-by: @grubles
Changelog-Fixes: hsmtool: Add support for Signet network
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-07-11 21:38:17 +02:00
Vincenzo Palazzo da91e70d3e build: Regenerate the generated file as the default target
When modifying the schema, regenerating the file can be challenging.
This change sets the autogenerate file as the default target, m
aking the process more convenient and simplifying our workflow.

Fixes https://github.com/ElementsProject/lightning/issues/6365
Report-by: Dusty Daemon
Changelog-None
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-07-11 11:41:15 +09:30
Greg Sanders 4b70736d13 Support p2tr deposit addresses
Changelog-Added: JSON-RPC: newaddr: p2tr option to create taproot addresses.
Changelog-Changed: Wallet: we now use taproot change addresses.
2023-07-11 11:41:15 +09:30
Greg Sanders 55cad79d82 cleanup comments, variables with respect to bech32(m) 2023-07-11 11:41:15 +09:30
Greg Sanders 01a79fcd59 txfilter_add_derkey: track p2tr scripts 2023-07-11 11:41:15 +09:30
Greg Sanders fdbb31e4d0 is_segwit_output: properly detect all known segwit script types 2023-07-11 11:41:15 +09:30
Greg Sanders fa046ab80f encode_scriptpubkey_to_addr: support p2tr 2023-07-11 11:41:15 +09:30
Greg Sanders 3c689cdaff p2tr script utilities 2023-07-11 11:41:15 +09:30
Greg Sanders 0097e2c666 psbt_input_add_pubkey: support taproot 2023-07-11 11:41:15 +09:30
Vincenzo Palazzo 011f3c1e14 lightnind: cleanup not necessary logs
This is just housekeeping that allows up
to do not spam the logs of people with not
useful information.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-07-11 09:24:31 +09:30
Rusty Russell e993818ffe pyln-proto: make point release.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-10 18:22:43 +02:00
Rusty Russell 2109f0b0ea pyln-client: make point release to prepare for next release.
People running master notice that calling listconfigs fails, because
we don't handle objects called xxx_msat correctly (see
d348554ff4).  This makes it painful
to test, until we release a pyln-client version.

Fortunately, the three changes in master are all fully backwards compatible,
so we can simply cut a release now and upload to pipy.org.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-10 18:22:43 +02:00
Rusty Russell cd25bd4b13 CHANGELOG.md: import changes from 23.05.2 branch.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-10 18:22:43 +02:00
Christian Decker f09871d739 cln-plugin: Remove unused `nonnumericids` field in `Builder`
It wasn't used, and we always return `true` in the manifest, because
we support them.
2023-07-10 18:22:11 +02:00
Christian Decker 53b37ca1c1 cln-rpc: Allow access to deprecated fields in conversions
This silences a compilation warning about accessing a deprecated
field. This was triggering on each build and we'll notice when they go
away, so why upset users with it?
2023-07-10 18:22:11 +02:00
Christian Decker 557cd183ac cln-rpc: Generate ToString for Enums
This will return the stringified name of the variant.
2023-07-10 18:22:11 +02:00
Christian Decker 32f9d78096 msggen: Derive `Eq` on generated Enums as well 2023-07-10 18:22:11 +02:00
Paul Miller a298f00229 rs: derive PartialEq for simple rust enums 2023-07-10 18:22:11 +02:00
Rusty Russell 29bf5151f1 pytest: fix flake in test_closing_anchorspend_htlc_tx_rbf
Turns out we resubmit two txs (the commitment tx, and the anchor spend), but only wait
for one of them: if we mine a block before the anchor spend, it doesn't go in:

```
    @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd anchors unsupported')
    @pytest.mark.developer("needs dev_disconnect")
    def test_closing_anchorspend_htlc_tx_rbf(node_factory, bitcoind):
...
        l1.daemon.wait_for_log('Peer permanent failure in CHANNELD_NORMAL: Offered HTLC 0 SENT_ADD_ACK_REVOCATION cltv 116 hit deadline')
        l1.daemon.wait_for_log('Creating anchor spend for CPFP')
    
        wait_for(lambda: len(bitcoind.rpc.getrawmempool()) == 2)
    
        # But we don't mine it!  And fees go up again!
        l1.set_feerates((3000, 3000, 3000, 3000))
        bitcoind.generate_block(1, needfeerate=5000)
    
        l1.daemon.wait_for_log('RBF anchor spend')
        l1.daemon.wait_for_log('sendrawtx exit 0')
    
        # And now we'll get it in (there's some rounding, so feerate a bit lower!)
        bitcoind.generate_block(1, needfeerate=2990)
    
>       wait_for(lambda: 'ONCHAIN:Tracking our own unilateral close' in only_one(l1.rpc.listpeerchannels()['channels'])['status'])
```
2023-07-10 13:37:22 +02:00
Rusty Russell 4b9537730b pytest: fix flake in test_routing_gossip.
If we mine too fast, gossip can reach a node which considers it too far in the guture.  Break it up.

```
    @pytest.mark.developer("Too slow without --dev-fast-gossip")
    def test_routing_gossip(node_factory, bitcoind):
        nodes = node_factory.get_nodes(5)
    
        for i in range(len(nodes) - 1):
            src, dst = nodes[i], nodes[i + 1]
            src.rpc.connect(dst.info['id'], 'localhost', dst.port)
            src.openchannel(dst, CHANNEL_SIZE, confirm=False, wait_for_announce=False)
    
        # openchannel calls fundwallet which mines a block; so first channel
        # is 4 deep, last is unconfirmed.
    
        # Allow announce messages.
        mine_funding_to_announce(bitcoind, nodes, num_blocks=6, wait_for_mempool=1)
    
        # Deep check that all channels are in there
        comb = []
        for i in range(len(nodes) - 1):
            comb.append((nodes[i].info['id'], nodes[i + 1].info['id']))
            comb.append((nodes[i + 1].info['id'], nodes[i].info['id']))
    
        def check_gossip(n):
            seen = []
            channels = n.rpc.listchannels()['channels']
            for c in channels:
                seen.append((c['source'], c['destination']))
            missing = set(comb) - set(seen)
            logging.debug("Node {id} is missing channels {chans}".format(
                id=n.info['id'],
                chans=missing)
            )
            return len(missing) == 0
    
        for n in nodes:
>           wait_for(lambda: check_gossip(n))

tests/test_gossip.py:721: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

success = <function test_routing_gossip.<locals>.<lambda> at 0x7f3200534ef0>
timeout = 180

    def wait_for(success, timeout=TIMEOUT):
        start_time = time.time()
        interval = 0.25
        while not success():
            time_left = start_time + timeout - time.time()
            if time_left <= 0:
>               raise ValueError("Timeout while waiting for {}".format(success))
E               ValueError: Timeout while waiting for <function test_routing_gossip.<locals>.<lambda> at 0x7f3200534ef0>
2023-07-10 13:37:22 +02:00
Rusty Russell b197b713be bcli: don't feed CLN massive feerates.
Stay classy, signet!

Reported-by: Anthony Towns
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-10 13:37:22 +02:00
Rusty Russell 0d1c46a5e5 Makefile: rebuild ccan when ccan_compat.h changes.
As it did recently:

```
/usr/bin/ld: bitcoin/pubkey.o: in function `pubkey_to_hash160':
/home/rusty/devel/cvs/lightning/bitcoin/pubkey.c:101: undefined reference to `ccan_ripemd160'
/usr/bin/ld: bitcoin/script.o: in function `hash160':
/home/rusty/devel/cvs/lightning/bitcoin/script.c:22: undefined reference to `ccan_ripemd160'
/usr/bin/ld: bitcoin/script.o: in function `bitcoin_wscript_htlc_offer':
/home/rusty/devel/cvs/lightning/bitcoin/script.c:662: undefined reference to `ccan_ripemd160'
/usr/bin/ld: bitcoin/script.o: in function `bitcoin_wscript_htlc_receive':
/home/rusty/devel/cvs/lightning/bitcoin/script.c:780: undefined reference to `ccan_ripemd160'
collect2: error: ld returned 1 exit status
make: *** [Makefile:660: devtools/create-gossipstore] Error 1
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-10 13:37:22 +02:00
Rusty Russell e289695012 lightningd: fix rebase clash.
`deprecated_apis` is now inside `ld`.

```
lightningd/notification.c: In function ‘connect_notification_serialize’:
lightningd/notification.c:60:13: error: ‘deprecated_apis’ undeclared (first use in this function)
   60 |         if (deprecated_apis)
      |             ^~~~~~~~~~~~~~~
lightningd/notification.c:60:13: note: each undeclared identifier is reported only once for each function it appears in
lightningd/notification.c: In function ‘disconnect_notification_serialize’:
lightningd/notification.c:97:13: error: ‘deprecated_apis’ undeclared (first use in this function)
   97 |         if (deprecated_apis)
      |             ^~~~~~~~~~~~~~~
lightningd/notification.c: In function ‘block_added_notification_serialize’:
lightningd/notification.c:612:13: error: ‘deprecated_apis’ undeclared (first use in this function)
  612 |         if (deprecated_apis) {
      |             ^~~~~~~~~~~~~~~
make: *** [Makefile:299: lightningd/notification.o] Error 1
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-10 13:37:22 +02:00