Commit Graph

11809 Commits

Author SHA1 Message Date
niftynei a1d72cef06 bkpr: add a new command `listaccountevents`
Prints all the events for the requested account. If no account
requested, prints out all the events. Ordered by timestamp.

Changelog-Added: bookkeeper: new command `listaccountevents`
2022-07-28 12:08:18 +09:30
niftynei 8039fde5ab bkpr: if we're missing info about an account, add in journal entry
There's two situations where we're missing info.

One is we get a 'channel_closed' event (but there's no 'channel_open')

The other is a balance_snapshot arrives with information about accounts
that doesn't match what's already on disk. (For some of these cases, we
may be missing 'channel_open' events..)

In the easy case (no channel_open missing), we just figure out what the
2022-07-28 12:08:18 +09:30
niftynei ccffac8208 bkpr: put the account name on the event
When we print events out, we need to know the account name. This makes
our lookup a lot easier, since we just pull it out from the database
every time we query for these.
2022-07-28 12:08:18 +09:30
niftynei d943e5e85c bkpr: use pointer for payment_id for channel events
sometimes these are null!
2022-07-28 12:08:18 +09:30
niftynei 8ec35b7eb1 bkpr: turns out these fields are optional
pushes and channel leases don't provide fees or payment_id info
2022-07-28 12:08:18 +09:30
niftynei 899d54edd0 bkpr: have onchain_fee records be write-only, don't update in place
One really rough thing about how we did onchain fees is that the records update
every time a new event comes in.

The better way to do this is to create new entries for every adjustment,
so that reconciliation between printouts isn't a misery.

We add a timestamp and `update_count` to these records, so you can
roughly order them now (and have a good idea of the last time an event
that updated an onchain_fee occurred).
2022-07-28 12:08:18 +09:30
niftynei 29c6884468 bkpr: add journal entry for offset account balances; report listbalances
When the node starts up, it records missing/updated account balances
to the 'channel' events... which is kinda fucked for wallet + external
events now that i think about it but these are all treated the same
anyway so it's fine.

This is the magic piece that lets your bookkeeping data startup ok on an
already running/established node.
2022-07-28 12:08:18 +09:30
niftynei b7d85f1d0b bkpr: wire up our chain fee accting to chain event reception
When we get a chain event, check to see if this updates any onchain fee
records that we have.
2022-07-28 12:08:18 +09:30
Rusty Russell 721ceb7519 patch db-fatal-plugin_err.patch 2022-07-28 12:08:18 +09:30
niftynei 351dc17e46 bkpr: add bookkeeper to PLUGINS list
This makes it start up automatically
2022-07-28 12:08:18 +09:30
niftynei dc113d0a3f bkpr: create onchain fee records for events
clightning doesn't give us any info about onchain fees (how could it?
it only knows about utxo object levels, and doesn't keep track of
how/when those are all related)

Instead, we keep running totals of the onchain fees for utxos. This
implements the master method for accounting for them, plus includes
tests to account for channel opens (across two accounts) as well as a
htlc-tx channel close.

Missing: we don't currently emit an event from cln for `withdraw`
initiated removal of funds, so the accounting for wallet -> external
funds is a bit janky. We don't account for the fees on these
transactions since we don't have the resulting 'external' event to
register them against!
2022-07-28 12:08:18 +09:30
niftynei c12cd99039 bkpr: tests for db crud 2022-07-28 12:08:18 +09:30
niftynei b08ccfec1e bookkeeper: initial crud (no tests) 2022-07-28 12:08:18 +09:30
niftynei cd95d91ed5 bkpr-tests: first test of plugin bkpr database
First test of bookkeeper database, for just the migrations.
2022-07-28 12:08:18 +09:30
niftynei fb951dbbd6 bkpr: first attempt at database code for accounting
A database scheme and first attempt at drivers for the bookkeeper
database.

Also moves bookkeeper plugin into its own subdirectory
2022-07-28 12:08:18 +09:30
niftynei 1a3bfc479f bookkeep: first commit, stub of new plugin
Will manage bookkeeping for cln
2022-07-28 12:08:18 +09:30
niftynei 967c56859f sql: use last " as " to find name token for column
We were using the first ' as ', which causes problems for the following
types of lines

	CAST(SUM(of.debit) AS BIGINT) as debit
2022-07-28 12:08:18 +09:30
Rusty Russell 75c89f0b8e doc: fix bolt 12 link (it's not in master), update bolt 11 to new "bolts" repo.
It's weird that readthedocs.io drops the ".md" suffix though;
let's see if this fixes it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-27 14:51:27 -07:00
Rusty Russell 1c26ebdb31 pytest: fix flake in test_wumbo_channels
We might only have seen one side of the channel, as shown below.  Wait
for both:

```
_____________________________ test_wumbo_channels ______________________________
[gw2] linux -- Python 3.7.13 /opt/hostedtoolcache/Python/3.7.13/x64/bin/python3

node_factory = <pyln.testing.utils.NodeFactory object at 0x7f5d51743b10>
bitcoind = <pyln.testing.utils.BitcoinD object at 0x7f5d51699d10>

    @pytest.mark.openchannel('v1')
    @pytest.mark.openchannel('v2')
    def test_wumbo_channels(node_factory, bitcoind):
        l1, l2, l3 = node_factory.get_nodes(3,
                                            opts=[{'large-channels': None},
                                                  {'large-channels': None},
                                                  {}])
        conn = l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port)
    
        expected_features = expected_peer_features(wumbo_channels=True)
        if l1.config('experimental-dual-fund'):
            expected_features = expected_peer_features(wumbo_channels=True,
                                                       extra=[21, 29])
    
        assert conn['features'] == expected_features
        assert only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['features'] == expected_features
    
        # Now, can we open a giant channel?
        l1.fundwallet(1 << 26)
        l1.rpc.fundchannel(l2.info['id'], 1 << 24)
    
        # Get that mined, and announced.
        bitcoind.generate_block(6, wait_for_mempool=1)
    
        # Connect l3, get gossip.
        l3.rpc.connect(l1.info['id'], 'localhost', port=l1.port)
        wait_for(lambda: len(l3.rpc.listnodes(l1.info['id'])['nodes']) == 1)
        wait_for(lambda: 'features' in only_one(l3.rpc.listnodes(l1.info['id'])['nodes']))
    
        # Make sure channel capacity is what we expected.
>       assert ([c['amount_msat'] for c in l3.rpc.listchannels()['channels']]
                == [Millisatoshi(str(1 << 24) + "sat")] * 2)
E       assert [16777216000msat] == [16777216000m...777216000msat]
E         Right contains one more item: 16777216000msat
E         Full diff:
E         - [16777216000msat, 16777216000msat]
E         + [16777216000msat]
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-27 19:31:04 +09:30
niftynei 79a76a96f7 v2open: dont rely on ordering of interprocess messages
Originally I (incorrectly?) assumed that since TX_COMMITMENT_SIGNED
always came before TX_SIGNATURES, we would always receive a response
from openchannel_update (w/ commitment_secured = true) before getting
notification of receipt of the peer's signatures.

But it's observable in the logs of hung tests that this in fact is a
wrong assumption -- the notification for the tx_sigs arrives at our
spender plugin before the callback from our openchannel_update RPC.

This mis-ordering causes a hang.

Luckily we're pretty much setup to handle this race already w/ states
etc, minus actually calling the method advance the plot in case we're
ready.

2022-07-26T05:37:59.4529095Z lightningd-1 2022-07-26T05:10:07.395Z DEBUG   035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d-dualopend-chan#2: peer_in WIRE_COMMITMENT_SIGNED
2022-07-26T05:37:59.4530452Z lightningd-1 2022-07-26T05:10:07.396Z DEBUG   035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d-hsmd: Got WIRE_HSMD_VALIDATE_COMMITMENT_TX
2022-07-26T05:37:59.4530719Z lightningd-1 2022-07-26T05:10:07.396Z DEBUG   hsmd: Client: Received message 35 from client
2022-07-26T05:37:59.4531386Z lightningd-1 2022-07-26T05:10:07.396Z DEBUG   035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d-dualopend-chan#2: billboard: channel open: commitment received, sending to lightningd to save
2022-07-26T05:37:59.4531856Z lightningd-1 2022-07-26T05:10:07.398Z DEBUG   035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d-dualopend-chan#2: peer_in WIRE_TX_SIGNATURES
>>> 2022-07-26T05:37:59.4532553Z lightningd-1 2022-07-26T05:10:07.400Z DEBUG   plugin-spenderp: mfc 60:`openchannel_peer_sigs` notice received for channel 9d145e763f08ee6f715ba7677f869cbb9580c7406f4d0b0ff3a0987efe501e13 <<<< THIS ONE WAS ASSUMED TO COME AFTER openchannel_update (next line)
2022-07-26T05:37:59.4533048Z lightningd-1 2022-07-26T05:10:07.400Z DEBUG   plugin-spenderp: mfc 60, dest 0: openchannel_update 035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d returned.
2022-07-26T05:37:59.4554292Z lightningd-1 2022-07-26T05:10:07.400Z DEBUG   plugin-spenderp: mfc 60: parallel `openchannel_update`.
2022-07-26T05:37:59.4555485Z lightningd-1 2022-07-26T05:10:07.400Z DEBUG   plugin-spenderp: mfc 60: funding tx 50425e20dbf0ca6fe112a8811b8048edb5bfa8d2922079668c5f353b859b45cb
2022-07-26T05:37:59.4557934Z lightningd-1 2022-07-26T05:10:07.508Z DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-hsmd: Got WIRE_HSMD_CUPDATE_SIG_REQ
2022-07-26T05:37:59.4558244Z lightningd-1 2022-07-26T05:10:07.508Z DEBUG   hsmd: Client: Received message 3 from client
2022-07-26T05:37:59.4558738Z lightningd-3 2022-07-26T05:11:03.234Z DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-gossipd: seeker: startup peer finished
2022-07-26T05:37:59.4559209Z lightningd-3 2022-07-26T05:11:03.234Z DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-gossipd: seeker: state = PROBING_SCIDS Seeking scids 1 - 105

(The last 2 log messages (from a different node) are >1min after the last
log line from lightning-1, because lightning-1 hung)

Hacked lightningd up to test this (such that notification always sent
before the RPC response, works as intended w/ patch)
2022-07-27 19:31:04 +09:30
niftynei 2c2bcc8eb4 flake: permit test_v2_open_sigs_restart_while_dead to succeed/fail
There's a race btw disconnecting and returning a successful RPC call for
openchannel_signed; if we disconnect quickly, we get an RPC error back.

Too slow and it returns w/o an error.

This needs to be cleaned up on a whole, work that I'm planning to get
into as part of a funder re-write. For now, let's just let the test
continue whether this call succeeds or fails.
2022-07-27 19:31:04 +09:30
niftynei d3ba017672 valgrind: rm ref to cmd when cmd is free'd
We were cmd was getting free'd but holding on to reference of the
thing was causing problems.

==523280== Invalid read of size 8
==523280==    at 0x1B3E14: del_notifier_property (tal.c:326)
==523280==    by 0x1B3E14: tal_del_notifier_ (tal.c:569)
==523280==    by 0x1123E7: handle_rpc_reply (libplugin.c:671)
==523280==    by 0x1123E7: rpc_read_response_one (libplugin.c:866)
==523280==    by 0x1123E7: rpc_conn_read_response (libplugin.c:886)
==523280==    by 0x1A7B53: next_plan (io.c:59)
==523280==    by 0x1A7B53: do_plan (io.c:407)
==523280==    by 0x1A7B53: io_ready (io.c:417)
==523280==    by 0x1A9BDB: io_loop (poll.c:453)
==523280==    by 0x1141D0: plugin_main (libplugin.c:1708)
==523280==    by 0x10D7E4: main (commando.c:937)
==523280==  Address 0x52de928 is 8 bytes inside a block of size 40 free'd
==523280==    at 0x483F0C3: free (vg_replace_malloc.c:872)
==523280==    by 0x1B2CDD: del_tree (tal.c:419)
==523280==    by 0x1B37BB: tal_free (tal.c:486)
==523280==    by 0x1B37BB: tal_free (tal.c:474)
==523280==    by 0x110CB2: command_complete (libplugin.c:255)
==523280==    by 0x110CB2: command_done_err (libplugin.c:390)
==523280==    by 0x10F511: handle_reply (commando.c:560)
==523280==    by 0x10F511: handle_custommsg (commando.c:609)
==523280==    by 0x113877: ld_command_handle (libplugin.c:1441)
==523280==    by 0x113877: ld_read_json_one (libplugin.c:1491)
==523280==    by 0x113877: ld_read_json (libplugin.c:1511)
==523280==    by 0x1A7B53: next_plan (io.c:59)
==523280==    by 0x1A7B53: do_plan (io.c:407)
==523280==    by 0x1A7B53: io_ready (io.c:417)
==523280==    by 0x1A9BDB: io_loop (poll.c:453)
==523280==    by 0x1141D0: plugin_main (libplugin.c:1708)
==523280==    by 0x10D7E4: main (commando.c:937)
==523280==  Block was alloc'd at
==523280==    at 0x483C855: malloc (vg_replace_malloc.c:381)
==523280==    by 0x1B3BBD: allocate (tal.c:250)
==523280==    by 0x1B3BBD: add_notifier_property (tal.c:303)
==523280==    by 0x1B3BBD: tal_add_destructor2_ (tal.c:529)
==523280==    by 0x110725: jsonrpc_request_start_ (libplugin.c:181)
==523280==    by 0x10E0EA: send_more_cmd (commando.c:643)
==523280==    by 0x11243C: handle_rpc_reply (libplugin.c:696)
==523280==    by 0x11243C: rpc_read_response_one (libplugin.c:866)
==523280==    by 0x11243C: rpc_conn_read_response (libplugin.c:886)
==523280==    by 0x1A7B53: next_plan (io.c:59)
==523280==    by 0x1A7B53: do_plan (io.c:407)
==523280==    by 0x1A7B53: io_ready (io.c:417)
==523280==    by 0x1A9BDB: io_loop (poll.c:453)
==523280==    by 0x1141D0: plugin_main (libplugin.c:1708)
==523280==    by 0x10D7E4: main (commando.c:937)
==523280==
{
   <insert_a_suppression_name_here>
2022-07-26 15:11:30 -07:00
niftynei 282ab72e2d tests: valgrind barfing on uninitialized value
------------------------------- Valgrind errors --------------------------------
Valgrind error file: valgrind-errors.493330
==493330== Conditional jump or move depends on uninitialised value(s)
==493330==    at 0x154051: opt_add_addr_withtype (options.c:275)
==493330==    by 0x154406: opt_add_announce_addr (options.c:302)
==493330==    by 0x2696E6: parse_one (parse.c:121)
==493330==    by 0x25CFB5: opt_parse (opt.c:228)
==493330==    by 0x155DB6: handle_opts (options.c:1413)
==493330==    by 0x127317: main (lightningd.c:994)
==493330==
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:opt_add_addr_withtype
   fun:opt_add_announce_addr
   fun:parse_one
   fun:opt_parse
   fun:handle_opts
   fun:main
}
--------------------------------------------------------------------------------
Leaving base_dir /tmp/ltests-iyf2dw3n intact, it still has test sub-directories with failure details: ['test_announce_dns_without_port_1']
====================================== short test summary info ======================================
ERROR tests/test_gossip.py::test_announce_dns_without_port - ValueError:
2022-07-26 15:11:30 -07:00
niftynei f4abc3a661 tests: local flake fix; l1 was waiting too long to reconnect
Impacts local tests, when TIMEOUT is set low...
2022-07-26 15:11:30 -07:00
Christian Decker b55df5c626 msggen: Use tempfile + rename to make changes to .msggen.json atomic
This was causing issues when multiple instances of msggen were running
in parallel on CI.

Changelog-None
2022-07-26 09:49:20 -07:00
Rusty Russell 17b9bd5ca3 pytest: fix test_commando_rune flake.
We reset counters every minute, so ratelimit tests can flake since we
might hit that boundary.

Instead, wait for the reset then test explicitly, assuming that takes
less than 60 seconds.

```
        for rune, cmd, params in failures:
            print("{} {}".format(cmd, params))
            with pytest.raises(RpcError, match='Not authorized:') as exc_info:
                l2.rpc.call(method='commando',
                            payload={'peer_id': l1.info['id'],
                                     'rune': rune['rune'],
                                     'method': cmd,
>                                    'params': params})
E               Failed: DID NOT RAISE <class 'pyln.client.lightning.RpcError'>
...
DEBUG:root:Calling commando with payload {'peer_id': '0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518', 'rune': 'O8Zr-ULTBKO3_pKYz0QKE9xYl1vQ4Xx9PtlHuist9Rk9NCZwbnVtPTAmcmF0ZT0zJnJhdGU9MQ==', 'method': 'getinfo', 'params': {}}
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-26 09:48:56 -07:00
Rusty Russell 85180dbfee pytest: fix flake in test_feerates
As the comment in set_feerates says: "Technically, this waits until
it's called, not until it's processed.".

And the wait_for() line doesn't work, since that condition is already true.

```
    @unittest.skipIf(TEST_NETWORK == 'liquid-regtest', "Fees on elements are different")
    @unittest.skipIf(
        not DEVELOPER or DEPRECATED_APIS, "Without DEVELOPER=1 we snap to "
        "FEERATE_FLOOR on testnets, and we test the new API."
    )
    def test_feerates(node_factory):
        l1 = node_factory.get_node(options={'log-level': 'io',
                                            'dev-no-fake-fees': True}, start=False)
        l1.daemon.rpcproxy.mock_rpc('estimatesmartfee', {
            'error': {"errors": ["Insufficient data or no feerate found"], "blocks": 0}
        })
        l1.start()
    
        # All estimation types
        types = ["opening", "mutual_close", "unilateral_close", "delayed_to_us",
                 "htlc_resolution", "penalty"]
    
        # Try parsing the feerates, won't work because can't estimate
        for t in types:
            with pytest.raises(RpcError, match=r'Cannot estimate fees'):
                feerate = l1.rpc.parsefeerate(t)
    
        # Query feerates (shouldn't give any!)
        wait_for(lambda: len(l1.rpc.feerates('perkw')['perkw']) == 2)
        feerates = l1.rpc.feerates('perkw')
        assert feerates['warning_missing_feerates'] == 'Some fee estimates unavailable: bitcoind startup?'
        assert 'perkb' not in feerates
        assert feerates['perkw']['max_acceptable'] == 2**32 - 1
        assert feerates['perkw']['min_acceptable'] == 253
        for t in types:
            assert t not in feerates['perkw']
    
        wait_for(lambda: len(l1.rpc.feerates('perkb')['perkb']) == 2)
        feerates = l1.rpc.feerates('perkb')
        assert feerates['warning_missing_feerates'] == 'Some fee estimates unavailable: bitcoind startup?'
        assert 'perkw' not in feerates
        assert feerates['perkb']['max_acceptable'] == (2**32 - 1)
        assert feerates['perkb']['min_acceptable'] == 253 * 4
        for t in types:
            assert t not in feerates['perkb']
    
        # Now try setting them, one at a time.
        # Set CONSERVATIVE/2 feerate, for max
        l1.set_feerates((15000, 0, 0, 0), True)
        wait_for(lambda: len(l1.rpc.feerates('perkw')['perkw']) == 2)
        feerates = l1.rpc.feerates('perkw')
        assert feerates['warning_missing_feerates'] == 'Some fee estimates unavailable: bitcoind startup?'
        assert 'perkb' not in feerates
>       assert feerates['perkw']['max_acceptable'] == 15000 * 10
E       assert 4294967295 == (15000 * 10)

tests/test_misc.py:1392: AssertionError
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-26 09:48:56 -07:00
Rusty Russell 0a9a87ec10 pytest: fix test_commando_stress
On fast machines, we don't get failures sometimes on commando commands.

(*But* we still got "New cmd replacing old" messages, which is how I
realized we weren't freeing them promptly, hence the previous fix).

```
        # Should have exactly one discard msg from each discard
>       nodes[0].daemon.wait_for_logs([r"New cmd from .*, replacing old"] * discards)

tests/test_plugin.py:2839: 
...
>                   raise TimeoutError('Unable to find "{}" in logs.'.format(exs))
E                   TimeoutError: Unable to find "[]" in logs.

```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-26 09:33:40 -07:00
Rusty Russell 9aa9a8236f commando: free incmd as soon as we use it.
Otherwise we left it in the cache, causing "New cmd replacing old"
messages.
2022-07-26 09:33:40 -07:00
Rusty Russell 8da361b49b pytest: fix flake in test_channel_persistence w/ TEST_CHECK_DBSTMTS
This was weird.  Here is the message (with \n turned into real new lines):

```
2022-07-24T07:20:08.9144998Z Plugin '/home/runner/work/lightning/lightning/tests/plugins/dblog.py' returned an invalid response to the db_write hook: {"jsonrpc": "2.0", "id": 40, "error": {"code": -32600, "message": "Error while processing db_write: UNIQUE constraint failed: shachain_known.shachain_id, shachain_known.pos", "traceback": "Traceback (most recent call last):
  File \"/home/runner/work/lightning/lightning/contrib/pyln-client/pyln/client/plugin.py\", line 631, in _dispatch_request
    result = self._exec_func(method.func, request)
  File \"/home/runner/work/lightning/lightning/contrib/pyln-client/pyln/client/plugin.py\", line 616, in _exec_func
    return func(*ba.args, **ba.kwargs)
  File \"/home/runner/work/lightning/lightning/tests/plugins/dblog.py\", line 45, in db_write
    plugin.conn.execute(c)
sqlite3.IntegrityError: UNIQUE constraint failed: shachain_known.shachain_id, shachain_known.pos
"}}
```

Finally, I realized that we *kill* l2: this means it has updated the
plugin db but not the real db.  This is expected: a real backup plugin
would handle this case.

Simply disable the test for this case.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-26 09:33:40 -07:00
Rusty Russell 008a59b004 lightningd: ignore default if it's a literal 'null' JSON token.
I wondered how `tests/plugins/dblog.py` worked, since it is supposed to fail
unless the `dblog-file` arg is set:

```
@plugin.init()
def init(configuration, options, plugin):
    if not plugin.get_option('dblog-file'):
        raise RpcError("No dblog-file specified")
```

But it was set to "null".  That's because 'None' in python is turned into a literal
JSON "null", and we take that as the default value.

We also cleanup the popt->description double-assignment (a leftover
from when this was optional).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: plugins: setting the default value of a parameter to `null` is the same as not setting it (pyln plugins did this!).
2022-07-26 09:33:40 -07:00
Rusty Russell 1480257644 pytest: set dblog-file when adding the dblog plugin (TEST_CHECK_DBSTMTS=1)
As we'll see in the next patch, this wasn't *supposed* to work wihtout dblog-file,
but it did, creating a dblog called "null".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-26 09:33:40 -07:00
Rusty Russell 9498e14530 connectd: two logging cleanups.
Don't log_io final messages twice (multiplex_final_message already does
this, so it's confusing to see us send e.g. WIRE_ERROR twice!).

And report that the peer has failed to connect out *before* telling
lightningd, otherwise we get a very confusing ordering, e.g.:

```
2022-07-23T05:17:36.096Z DEBUG   027d0de66d08f956a8d606c0d1c34e59bda38c05a3b1cc738fdd6378716c644997-lightningd: Reconnecting in 4 seconds
2022-07-23T05:17:36.096Z DEBUG   027d0de66d08f956a8d606c0d1c34e59bda38c05a3b1cc738fdd6378716c644997-lightningd: Will try reconnect in 4 seconds
2022-07-23T05:17:36.096Z DEBUG   027d0de66d08f956a8d606c0d1c34e59bda38c05a3b1cc738fdd6378716c644997-connectd: Failed connected out:
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-25 15:16:58 -07:00
Rusty Russell da4e33cd0d decode: fix crash when decoding invalid rune.
If rune contains invalid UTF-8, offers (which implements decode) would
produce JSON with invalid UTF-8, which causes lightningd to complain
and kill it, and then die because it's an important plugin.

So don't decode invalid UTF-8!

Reported-by: @jb55
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-25 15:14:01 -07:00
Rusty Russell 0fd8a6492e lightningd: fix fatal() log message in log.
The one to stderr is fine, the log one gets corrupted, like so:

```
2022-07-24T07:20:08.6250702Z lightningd-2 2022-07-24T06:49:19.494Z **BROKEN** lightningd: Plugin '????UH??SH??8H?}?H?u?H?U?H?M?H?M?H?E?H?????' returned an invalid response to the db_write hook: (F???U
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-25 08:11:09 -07:00
Rusty Russell d0c321b43a CI: fix CI scripts to fail if a command fails.
If compilation failed, we didn't stop (though except for fuzzing, we
would fail when we try to run the tests).

Also use make -s instead of redirecting make ooutput.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-25 08:08:32 -07:00
Rusty Russell 8f6afedafe fuzz: fix fuzzing compilation.
It had bitrotted.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-25 08:08:32 -07:00
niftynei 7bbfef5054 tests: flake fix; l1 was waiting too long to reconnect
We were waiting too long for the reconnect to happen (60s default),
which caused this test to timeout.

When testing, let's speed up the reconnect.

L2 tried to reconnect but didn't have connection information in its
gossip -- is there a way to ask/save connection data from a node you're
making a channel with that doesn't rely on their node_announcement?
2022-07-25 16:28:09 +09:30
niftynei 4cc0da7432 nit: speedup retry timeout test 2022-07-25 16:28:09 +09:30
niftynei 9adf5f17de tests:redirect output, so test log passes 2022-07-25 16:28:09 +09:30
niftynei bed00754ad test-flake: dont let `l1` send their unilateral tx
`l1` got their tx in before `l2`, but we're waiting for `l2`'s
commitment tx. (l2 sends an error message to l1 when we call dev-fail,
l1 broadcasts their commitment tx when they get the error)

Instead, we let l1 send their commitment tx, except we blackhole it.

```
        l2.rpc.dev_fail(l1.info['id'])
        l2.daemon.wait_for_log('Failing due to dev-fail command')
>       l2.wait_for_channel_onchain(l1.info['id'])
tests/test_connection.py:2275:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
contrib/pyln-testing/pyln/testing/utils.py:1043: in wait_for_channel_onchain
    wait_for(lambda: txid inself.bitcoin.rpc.getrawmempool())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
success = <function LightningNode.wait_for_channel_onchain.<locals>.<lambda> at 0x7f0f5f7577a0>
timeout = 900
defwait_for(success, timeout=TIMEOUT):
        start_time = time.time()
        interval = 0.25
whilenot success():
            time_left = start_time + timeout - time.time()
if time_left <= 0:
>               raiseValueError("Timeout while waiting for {}", success)
E               ValueError: ('Timeout while waiting for {}', <function LightningNode.wait_for_channel_onchain.<locals>.<lambda> at 0x7f0f5f7577a0>)
contrib/pyln-testing/pyln/testing/utils.py:93: ValueError
```
2022-07-23 11:37:35 -05:00
niftynei bb4da47131 msat: cleanup msat outputs for apis
Don't use the _str() option for msat outputs, use the built-in helpers
which are deprecation aware.

Fixes #5447

Reported-By: @fiatjaf
2022-07-23 16:22:38 +09:30
niftynei b6bf352503 contrib startup-regtest: turn off deprecated apis, update deprecated
Update an out of date config, turn off deprecated apis by default for
all regtest tests. (Makes sense, this is a devtool)
2022-07-23 16:22:38 +09:30
Rusty Russell 53c333a01b pytest: fix flake in test_zeroconf_forward
pay failed (non-DEVELOPER) because one node didn't see blocks in time:

```
        inv = l3.rpc.invoice(42 * 10**6, 'inv1', 'desc')['bolt11']
>       l1.rpc.pay(inv)
tests/test_opening.py:1394:
...
>           raise RpcError(method, payload, resp['error'])
E           pyln.client.lightning.RpcError: RPC call failed: method: pay, payload: {'bolt11': 'lnbcrt420u1p3dnwv7sp5qnquuwndgz35ywfg3p3dtu07ywmju78r8s0379eaxjxkv5d8jueqpp5kmaxgsye02dzmdlkqkedqvrh2evdl45sz7njrm5dff42dvp4v5qsdq8v3jhxccxqyjw5qcqp9rzjqgkjyd3q5dv6gllh77kygly9c3kfy0d9xwyjyxsq2nq3c83u5vw4n0wkf0y9gwfwhgqqqqqpqqqqqzsqqc9qyysgqad2x2zv0axa3hrfz7nurw4plvspvxlld9wtcg3xxjyxqlzm773a4fkyl09gs8uskj4m7len8r4pf4rh7v9snh3grrpawhk9qsd7vwmcqa9rgxg'}, error: {'code': 210, 'message': 'Ran out of routes to try after 176 attempts: see `paystatus`', 'attempts': [{'status': 'pending', 'partid': 1, 'amount_msat': 42000000msat}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 2, 'amount_msat': 9278783msat, 'parent_partid': 1}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 10, 'amount_msat': 9278783msat, 'parent_partid': 2}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 15, 'amount_msat': 9278783msat, 'parent_partid': 10}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 18, 'amount_msat': 9278783msat, 'parent_partid': 15}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 23, 'amount_msat': 9278783msat, 'parent_partid': 18}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 29, 'amount_msat': 9278783msat, 'parent_partid': 23}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 33, 'amount_msat': 9278783msat, 'parent_partid': 29}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 39, 'amount_msat': 9278783msat, 'parent_partid': 33}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 43, 'amount_msat': 9278783msat, 'parent_partid': 39}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 48, 'amount_msat': 9278783msat, 'parent_partid': 43}, {'status': 'pending', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 54, 'amount_msat': 9278783msat, 'parent_partid': 48}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 59, 'amount_msat': 4659837msat, 'parent_partid': 54}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 69, 'amount_msat': 4659837msat, 'parent_partid': 59}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 82, 'amount_msat': 4659837msat, 'parent_partid': 69}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 92, 'amount_msat': 4659837msat, 'parent_partid': 82}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 102, 'amount_msat': 4659837msat, 'parent_partid': 92}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 112, 'amount_msat': 4659837msat, 'parent_partid': 102}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 122, 'amount_msat': 4659837msat, 'parent_partid': 112}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 131, 'amount_msat': 4659837msat, 'parent_partid': 122}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 141, 'amount_msat': 4659837msat, 'parent_partid': 131}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 147, 'amount_msat': 4659837msat, 'parent_partid': 141}, {'status': 'pending', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 158, 'amount_msat': 4659837msat, 'parent_partid': 147}, {'status': 'pending', 'partid': 175, 'amount_msat': 2250620msat, 'parent_partid': 158}, {'status': 'pending', 'partid': 176, 'amount_msat': 2409217msat, 'parent_partid': 158}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 60, 'amount_msat': 4618946msat, 'parent_partid': 54}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 70, 'amount_msat': 4618946msat, 'parent_partid': 60}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 81, 'amount_msat': 4618946msat, 'parent_partid': 70}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 91, 'amount_msat': 4618946msat, 'parent_partid': 81}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 101, 'amount_msat': 4618946msat, 'parent_partid': 91}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 111, 'amount_msat': 4618946msat, 'parent_partid': 101}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 121, 'amount_msat': 4618946msat, 'parent_partid': 111}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 132, 'amount_msat': 4618946msat, 'parent_partid': 121}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 142, 'amount_msat': 4618946msat, 'parent_partid': 132}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 148, 'amount_msat': 4618946msat, 'parent_partid': 142}, {'status': 'pending', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 157, 'amount_msat': 4618946msat, 'parent_partid': 148}, {'status': 'pending', 'partid': 168, 'amount_msat': 2320055msat, 'parent_partid': 157}, {'status': 'pending', 'partid': 169, 'amount_msat': 2298891msat, 'parent_partid': 157}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 3, 'amount_msat': 9016551msat, 'parent_partid': 1}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 7, 'amount_msat': 9016551msat, 'parent_partid': 3}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 12, 'amount_msat': 9016551msat, 'parent_partid': 7}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 17, 'amount_msat': 9016551msat, 'parent_partid': 12}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 21, 'amount_msat': 9016551msat, 'parent_partid': 17}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 25, 'amount_msat': 9016551msat, 'parent_partid': 21}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 30, 'amount_msat': 9016551msat, 'parent_partid': 25}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 36, 'amount_msat': 9016551msat, 'parent_partid': 30}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 40, 'amount_msat': 9016551msat, 'parent_partid': 36}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 47, 'amount_msat': 9016551msat, 'parent_partid': 40}, {'status': 'pending', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 51, 'amount_msat': 9016551msat, 'parent_partid': 47}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 56, 'amount_msat': 4458645msat, 'parent_partid': 51}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 63, 'amount_msat': 4458645msat, 'parent_partid': 56}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 77, 'amount_msat': 4458645msat, 'parent_partid': 63}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 87, 'amount_msat': 4458645msat, 'parent_partid': 77}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 94, 'amount_msat': 4458645msat, 'parent_partid': 87}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 105, 'amount_msat': 4458645msat, 'parent_partid': 94}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 120, 'amount_msat': 4458645msat, 'parent_partid': 105}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 124, 'amount_msat': 4458645msat, 'parent_partid': 120}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 134, 'amount_msat': 4458645msat, 'parent_partid': 124}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 143, 'amount_msat': 4458645msat, 'parent_partid': 134}, {'status': 'pending', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 154, 'amount_msat': 4458645msat, 'parent_partid': 143}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 164, 'amount_msat': 2306527msat, 'parent_partid': 154}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 165, 'amount_msat': 2152118msat, 'parent_partid': 154}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 57, 'amount_msat': 4557906msat, 'parent_partid': 51}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 68, 'amount_msat': 4557906msat, 'parent_partid': 57}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 76, 'amount_msat': 4557906msat, 'parent_partid': 68}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 86, 'amount_msat': 4557906msat, 'parent_partid': 76}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 96, 'amount_msat': 4557906msat, 'parent_partid': 86}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 103, 'amount_msat': 4557906msat, 'parent_partid': 96}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 115, 'amount_msat': 4557906msat, 'parent_partid': 103}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 125, 'amount_msat': 4557906msat, 'parent_partid': 115}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 136, 'amount_msat': 4557906msat, 'parent_partid': 125}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 146, 'amount_msat': 4557906msat, 'parent_partid': 136}, {'status': 'pending', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 161, 'amount_msat': 4557906msat, 'parent_partid': 146}, {'status': 'pending', 'partid': 173, 'amount_msat': 2208152msat, 'parent_partid': 161}, {'status': 'pending', 'partid': 174, 'amount_msat': 2349754msat, 'parent_partid': 161}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 4, 'amount_msat': 10655305msat, 'parent_partid': 1}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 9, 'amount_msat': 10655305msat, 'parent_partid': 4}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 13, 'amount_msat': 10655305msat, 'parent_partid': 9}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 19, 'amount_msat': 10655305msat, 'parent_partid': 13}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 24, 'amount_msat': 10655305msat, 'parent_partid': 19}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 28, 'amount_msat': 10655305msat, 'parent_partid': 24}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 34, 'amount_msat': 10655305msat, 'parent_partid': 28}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 38, 'amount_msat': 10655305msat, 'parent_partid': 34}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 44, 'amount_msat': 10655305msat, 'parent_partid': 38}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 49, 'amount_msat': 10655305msat, 'parent_partid': 44}, {'status': 'pending', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 53, 'amount_msat': 10655305msat, 'parent_partid': 49}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 61, 'amount_msat': 4872267msat, 'parent_partid': 53}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 71, 'amount_msat': 4872267msat, 'parent_partid': 61}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 79, 'amount_msat': 4872267msat, 'parent_partid': 71}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 89, 'amount_msat': 4872267msat, 'parent_partid': 79}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 100, 'amount_msat': 4872267msat, 'parent_partid': 89}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 109, 'amount_msat': 4872267msat, 'parent_partid': 100}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 114, 'amount_msat': 4872267msat, 'parent_partid': 109}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 126, 'amount_msat': 4872267msat, 'parent_partid': 114}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 139, 'amount_msat': 4872267msat, 'parent_partid': 126}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 149, 'amount_msat': 4872267msat, 'parent_partid': 139}, {'status': 'failed', 'failreason': 'Cannot split payment any further without exceeding the maximum number of HTLCs allowed by our channels', 'partid': 162, 'amount_msat': 4872267msat, 'parent_partid': 149}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 62, 'amount_msat': 5783038msat, 'parent_partid': 53}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 72, 'amount_msat': 5783038msat, 'parent_partid': 62}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 80, 'amount_msat': 5783038msat, 'parent_partid': 72}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 90, 'amount_msat': 5783038msat, 'parent_partid': 80}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 99, 'amount_msat': 5783038msat, 'parent_partid': 90}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 110, 'amount_msat': 5783038msat, 'parent_partid': 99}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 117, 'amount_msat': 5783038msat, 'parent_partid': 110}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 128, 'amount_msat': 5783038msat, 'parent_partid': 117}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 138, 'amount_msat': 5783038msat, 'parent_partid': 128}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 150, 'amount_msat': 5783038msat, 'parent_partid': 138}, {'status': 'pending', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 156, 'amount_msat': 5783038msat, 'parent_partid': 150}, {'status': 'pending', 'partid': 170, 'amount_msat': 2902801msat, 'parent_partid': 156}, {'status': 'pending', 'partid': 171, 'amount_msat': 2880237msat, 'parent_partid': 156}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 5, 'amount_msat': 8942693msat, 'parent_partid': 1}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 8, 'amount_msat': 8942693msat, 'parent_partid': 5}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 16, 'amount_msat': 8942693msat, 'parent_partid': 8}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 20, 'amount_msat': 8942693msat, 'parent_partid': 16}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 27, 'amount_msat': 8942693msat, 'parent_partid': 20}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 32, 'amount_msat': 8942693msat, 'parent_partid': 27}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 35, 'amount_msat': 8942693msat, 'parent_partid': 32}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 42, 'amount_msat': 8942693msat, 'parent_partid': 35}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 45, 'amount_msat': 8942693msat, 'parent_partid': 42}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 50, 'amount_msat': 8942693msat, 'parent_partid': 45}, {'status': 'pending', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 58, 'amount_msat': 8942693msat, 'parent_partid': 50}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 64, 'amount_msat': 4159394msat, 'parent_partid': 58}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 78, 'amount_msat': 4159394msat, 'parent_partid': 64}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 84, 'amount_msat': 4159394msat, 'parent_partid': 78}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 98, 'amount_msat': 4159394msat, 'parent_partid': 84}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 108, 'amount_msat': 4159394msat, 'parent_partid': 98}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 116, 'amount_msat': 4159394msat, 'parent_partid': 108}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 123, 'amount_msat': 4159394msat, 'parent_partid': 116}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 135, 'amount_msat': 4159394msat, 'parent_partid': 123}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 144, 'amount_msat': 4159394msat, 'parent_partid': 135}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 155, 'amount_msat': 4159394msat, 'parent_partid': 144}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 163, 'amount_msat': 4159394msat, 'parent_partid': 155}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 65, 'amount_msat': 4783299msat, 'parent_partid': 58}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 73, 'amount_msat': 4783299msat, 'parent_partid': 65}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 83, 'amount_msat': 4783299msat, 'parent_partid': 73}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 93, 'amount_msat': 4783299msat, 'parent_partid': 83}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 104, 'amount_msat': 4783299msat, 'parent_partid': 93}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 119, 'amount_msat': 4783299msat, 'parent_partid': 104}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 127, 'amount_msat': 4783299msat, 'parent_partid': 119}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 140, 'amount_msat': 4783299msat, 'parent_partid': 127}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 151, 'amount_msat': 4783299msat, 'parent_partid': 140}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 160, 'amount_msat': 4783299msat, 'parent_partid': 151}, {'status': 'pending', 'partid': 172, 'amount_msat': 4783299msat, 'parent_partid': 160}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 6, 'amount_msat': 4106668msat, 'parent_partid': 1}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 11, 'amount_msat': 4106668msat, 'parent_partid': 6}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 14, 'amount_msat': 4106668msat, 'parent_partid': 11}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 22, 'amount_msat': 4106668msat, 'parent_partid': 14}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 26, 'amount_msat': 4106668msat, 'parent_partid': 22}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 31, 'amount_msat': 4106668msat, 'parent_partid': 26}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 37, 'amount_msat': 4106668msat, 'parent_partid': 31}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 41, 'amount_msat': 4106668msat, 'parent_partid': 37}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 46, 'amount_msat': 4106668msat, 'parent_partid': 41}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 52, 'amount_msat': 4106668msat, 'parent_partid': 46}, {'status': 'pending', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 55, 'amount_msat': 4106668msat, 'parent_partid': 52}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 66, 'amount_msat': 2165538msat, 'parent_partid': 55}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 75, 'amount_msat': 2165538msat, 'parent_partid': 66}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 85, 'amount_msat': 2165538msat, 'parent_partid': 75}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 95, 'amount_msat': 2165538msat, 'parent_partid': 85}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 107, 'amount_msat': 2165538msat, 'parent_partid': 95}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 113, 'amount_msat': 2165538msat, 'parent_partid': 107}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 130, 'amount_msat': 2165538msat, 'parent_partid': 113}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 137, 'amount_msat': 2165538msat, 'parent_partid': 130}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 152, 'amount_msat': 2165538msat, 'parent_partid': 137}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 159, 'amount_msat': 2165538msat, 'parent_partid': 152}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 167, 'amount_msat': 2165538msat, 'parent_partid': 159}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 67, 'amount_msat': 1941130msat, 'parent_partid': 55}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 74, 'amount_msat': 1941130msat, 'parent_partid': 67}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 88, 'amount_msat': 1941130msat, 'parent_partid': 74}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 97, 'amount_msat': 1941130msat, 'parent_partid': 88}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 106, 'amount_msat': 1941130msat, 'parent_partid': 97}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 118, 'amount_msat': 1941130msat, 'parent_partid': 106}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 129, 'amount_msat': 1941130msat, 'parent_partid': 118}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 133, 'amount_msat': 1941130msat, 'parent_partid': 129}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 145, 'amount_msat': 1941130msat, 'parent_partid': 133}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 153, 'amount_msat': 1941130msat, 'parent_partid': 145}, {'status': 'failed', 'failreason': 'failed: WIRE_EXPIRY_TOO_SOON (reply from remote)', 'partid': 166, 'amount_msat': 1941130msat, 'parent_partid': 153}]}
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-22 17:57:28 +02:00
Rusty Russell 8c38302ab8 hsmtool: implement checkhsm.
This gives a nice way to ensure your secret is the correct one.

Also, we don't need to suppress VALGRIND for this test, now the output
races are fixed.

Changelog-Added: `hsmtool`: new command `checkhsm` to check BIP39 passphrase against hsm_secret.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-22 16:57:27 +02:00
Rusty Russell c10e385612 commando: add stress test, fix memleak report.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-21 15:37:05 -05:00
Rusty Russell 05a666e424 commando: limit to 16 partially-received incoming commands at a time.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-21 15:37:05 -05:00
Rusty Russell 4cada557ba pytest: don't redirect stderr by default.
Some tests need to inspect it, but most don't, and I suspect I'm missing some
error messages due to this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-21 15:37:05 -05:00
Rusty Russell aaf743e438 commando: fix crash when rune is completely bogus.
The error routine returns a string literal in this case, which we can't take().

Reported-by: @jb55
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-21 15:37:05 -05:00
Rusty Russell 43e5ef3cc4 libplugin: don't call callbacks if cmd completed before response.
This can particularly happen with commando:

```
 commando: FATAL SIGNAL 11 (version 06b36d3)
0x55609e953d51 send_backtrace
	common/daemon.c:33
0x55609e953dfb crashdump
	common/daemon.c:46
0x7f665e3b908f ???
	/build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x55609e9387a3 send_more_cmd
	plugins/commando.c:632
0x55609e93b270 handle_rpc_reply
	plugins/libplugin.c:669
0x55609e93bd50 rpc_read_response_one
	plugins/libplugin.c:842
0x55609e93be86 rpc_conn_read_response
	plugins/libplugin.c:862
0x55609e9f4f68 next_plan
	ccan/ccan/io/io.c:59
0x55609e9f5b70 do_plan
	ccan/ccan/io/io.c:407
0x55609e9f5bb2 io_ready
	ccan/ccan/io/io.c:417
0x55609e9f7ea5 io_loop
	ccan/ccan/io/poll.c:453
0x55609e93eb20 plugin_main
	plugins/libplugin.c:1676
0x55609e9397ab main
	plugins/commando.c:922
0x7f665e39a082 __libc_start_main
	../csu/libc-start.c:308
0x55609e93677d ???
	???:0
0xffffffffffffffff ???
	???:0
```

Reported-by: @adi2011
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-07-21 15:37:05 -05:00