Commit Graph

13175 Commits

Author SHA1 Message Date
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
Vincenzo Palazzo 36ff6aa910 log: increase the log for ignore fee to unsual
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-07-10 16:52:17 +09:30
Vincenzo Palazzo 77d787b975 This commit fixes a bug introduced in 64b1ddd761 that does not
ignore the min fee as specified by the user setting.

We explicitly allow the user to ignore the fee limits, although this comes with inherent risks.

By enabling this option, users are explicitly
I was aware of the potential dangers.
There are situations, such as the one described in [1], where it
becomes necessary to bypass the fee limits to resolve issues like a stuck channel.

BTW experimental-anchors should fix this.

[1] https://github.com/ElementsProject/lightning/issues/6362

Reported-by: @pabpas
Fixes: 64b1ddd761
Link: https://github.com/ElementsProject/lightning/issues/6362
Changelog-Fixes: do not ignore the ignore-fee-limit option during
update_fee
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-07-10 16:52:17 +09:30
Matt Morehouse a264e10564 fuzz: initial sha256 seeds
Corpus generated from 100+ CPU hours of fuzzing and then minimized.
2023-07-10 14:56:50 +09:30
Matt Morehouse 8547912708 fuzz: initial ripemd160 seeds
Corpus generated from 100+ CPU hours of fuzzing and then minimized.
2023-07-10 14:56:50 +09:30
Matt Morehouse f0f043c742 fuzz: add sha256 target
The target fuzzes CCAN's implementation of sha256 and compares the hash
results against OpenSSL's implementation.
2023-07-10 14:56:50 +09:30
Matt Morehouse 8d7885abc1 fuzz: add ripemd160 target
The target fuzzes CCAN's implementation of ripemd160 and compares the
hash results against OpenSSL's implementation.
2023-07-10 14:56:50 +09:30
Matt Morehouse 33da575fd0 ccan: rename ripemd160 functions
The symbols were being pulled in from libwally instead of the from our
own CCAN. Do the same trick we use for sha256.
2023-07-10 14:56:50 +09:30
Shahana Farooqui 1606ef1487 lightningd: actually deprecate old notification fields now tests and plugins are all updated.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Deprecated: JSON-RPC: `connect`, `disconnect` and `block_added` notification fields outside the same-named object (use .connect/.disconnect/.block_added sub-objects)
2023-07-10 14:51:11 +09:30
Rusty Russell 99b885c84c plugins: update for new deprecation API where all fields are nicely wrapped.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-10 14:51:11 +09:30
Shahana Farooqui 4e5e38f4b0 tests: notification response fixes
tests: notification response fixes
2023-07-10 14:51:11 +09:30
Shahana Farooqui 8e14b3ff8f doc: Typo in balance_snapshot notification object 2023-07-10 14:51:11 +09:30
Shahana Farooqui b9fba1c0b5 notification: block_added json key updated from block to block_added
Changelog-Added: JSON-RPC: `block_added` notification wraps fields in `block_added` object (notification consistency)
2023-07-10 14:51:11 +09:30
Shahana Farooqui 79092c16b1 notification: disconnect with json key disconnect
Changelog-Added: JSON-RPC: `connect` and `disconnect` notifications now wrap `id` field in a `connect`/`disconnect` object (consistency with other notifications)
2023-07-10 14:51:11 +09:30
Shahana Farooqui e247d16536 notification: connect with json key connect 2023-07-10 14:51:11 +09:30
Vincenzo Palazzo d58414b062 docs: remove the ppa reference from the docs
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-07-10 13:48:36 +09:30
Vincenzo Palazzo b3f72f9eed fix(docs): Fix instructions for installing cln on FreeBSD
This commit is adding the instructions for compiling cln on FreeBSD,
because it looks that we not longer compile with the FreeBSD package
manager, and I have no idea who the mantainer of this package is.

Link: https://github.com/ElementsProject/lightning/issues/6301
Reported-by: @bektar
Changelog-None
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-07-10 13:48:36 +09:30
Christian Decker 706b47587f cln-rpc: Remove wildcard import from model
There is a name clash between request and response for the delinvoicestatus
param.
2023-07-10 13:47:38 +09:30
Christian Decker b81212826f ci: Add pyln-grpc-proto to auto-publication workflow 2023-07-10 13:47:38 +09:30
Christian Decker 6583f0dead pyln: Create a dedicated pyln-grpc-proto package
Having the grpc bindings in the pyln-testing package was always a bit
strange, however it came with additional issues. Due to the way that
protos are handled by protobuf, any name clash, independently of where
we import the protos, would cause an import error. This usually
happens in diamond-pattern dependencies, and so pull out the generated
files into their own package that everyone else can rely on.

Changelog-None
2023-07-10 13:47:38 +09:30
Shahana Farooqui 5053999ff3 doc: Updated instructions
Updated release instruction after build-release.sh fixes.
Add Docker buildx and QEMU instruction in reproducible
2023-07-10 13:24:51 +09:30
Shahana Farooqui 4bdae80486 build: updated build-release script
Updated build release for:
- force-version and force-mtime checks
- zipfile is not optional anymore, it will be created before all other action
- CLN's amd64, arm32v7 and arm64v8 docker setup
- Verify release feature
2023-07-10 13:24:51 +09:30
Shahana Farooqui fe39047a1b build: passing release version for make
Passing release version for make command to ensure that refresh submodule (from external makefile) runs with --force-version option as well.
2023-07-10 13:24:51 +09:30
Shahana Farooqui 2f489b97d1 docker: cl-repro Dockerfile update
Updating bionic, focal and jammy cl-repro builds:
- Rust version from 1.62 to 1.65
- Removed git clone, only mount option
- Removed sha256sums generation
2023-07-10 13:24:51 +09:30
Shahana Farooqui e752840849 docker: Core lightning Dockerfile updates
- Updated Dockerfile for amd64
- Removed linuxarm32v7.Dockerfile
- Removed linuxarm64v8.Dockerfile
- Added Dockerfile.arm32v7 for grpc enabled image
- Added Dockerfile.arm64v8 for grpc enabled image
2023-07-10 13:24:51 +09:30
Shahana Farooqui 7dda91f7f6 gitignore: Ignore SHA256SUMS from release verify
Ignore SHA256SUMS and SHA256SUMS.asc used for release verification
2023-07-10 13:24:51 +09:30
Rusty Russell 212c4dba76 pytest: fix flake in test_onchain_middleman_simple with anchors.
Greg Sanders helped debug this:

```
        # Payment should succeed.
>       l1.bitcoin.generate_block(1, wait_for_mempool=txid1)

tests/test_closing.py:2145: 
...
>               raise ValueError("Timeout while waiting for {}".format(success))
E               ValueError: Timeout while waiting for <function BitcoinD.generate_block.<locals>.<lambda> at 0x7f7cd7271560>
```

The lgos show the HTLC tx doesn't go through because it double-spent an input but didn't spend enough:

```
2023-07-06T03:05:54.3424456Z lightningd-2 2023-07-06T02:57:37.490Z DEBUG   plugin-bcli: sendrawtx exit 26 (bitcoin-cli -regtest -datadir=/tmp/ltests-yihsd7f4/test_onchain_middleman_simple_1/lightning-2/ -rpcport=39033 -rpcuser=... -stdinrpcpass sendrawtransaction 0200000000010220f632933db174def3b4bd879ad892e28f4422ee6e844bda27c4e5bdbc754fda030000000001000000975e48aeaced953f7c2b85f20e85b5c241258cb9dbd2ba13de3038daba6316330100000000fdffffff02a1860100000000002200202df545ea882889846c52fc5e111ac07ce07e0c09418ac15743a6f6284c2a4fa739391e000000000016001461ed06c0632af284ec9e192e97758fc04692c8290500473044022064446978d7f15d923237d44d7701e4a09a2d03ebb0a7e2c42e22c67435ad2fcc02201c51002fb72920978c79872e427acd90a13423e841b4198717c1771e7355ba4683473044022059ed9e2c536a71fac3cd63c7349c64a4445f0f936270295518a8aa03607d1e9d022064d318669a7602f585c84fe80aa95487816920c2a8ac26836601fbb369068ff38320478171dbde0e1c243e5c1ae23bcce446ab361197ca10d57c1d8f030cc9ff52158c76a914f5fb7361abefe39af0c3ab31d5be71096deeb4198763ac6721034bbdd4e5a933a3a83f6c3d22714cf23c452cb0c5ac8e429eea14992262787e687c8201208763a9147a3d3592e3d93a525beed57acce3eb70ba1b514288527c21039a62150fd6808d6c68aabd1e9d144c93e84a8f54f4e0f9ec5b3c37eee0a051c752ae6775017eb175ac6851b275680247304402200fde6a943a2f7f0287af2f5c5872326a4b8ad7020a098c4e05c28d2c2a0f2018022053a1263f982b98bb8dfcbb3a66641fe9f298e7ab432a78d21a2e79190d74753f012102397b0449a60d9d35634401bceaf3beb6118fc229b8552bd7122f735808b28aee00000000) error code: -26\nerror message:\ninsufficient fee, rejecting replacement 76f438f176d8f9beabb286f53c81aa7dcb4948d12f034f51753f4dd9071d6a74; new feerate 0.00029576 BTC/kvB <= old feerate 0.00054659 BTC/kvB
```

This is because sometimes we reuse the same UTXO for the anchor push spend as we do for the HTLC.  That would be fine, except that we can have bitcoind mine the commitment tx and not the anchor push, and then we fail to replace it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-09 16:49:48 +09:30
Rusty Russell b08791d4fa Makefile: add dependencies to fix parallel build.
```
cc tools/headerversions.c
tools/headerversions.c:3:10: fatal error: 'config.h' file not found
#include "config.h"
         ^~~~~~~~~~
1 error generated.
make: *** [Makefile:299: tools/headerversions.o] Error 1
```

And then:

```
tools/test/enum.c:1:10: fatal error: 'config.h' file not found
#include "config.h"
         ^~~~~~~~~~
1 error generated.
make: *** [Makefile:299: tools/test/enum.o] Error 1
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-09 16:49:48 +09:30