Commit Graph

9741 Commits

Author SHA1 Message Date
Christian Decker ad7f59f7a1 keysend: Set an error message if we abort due to missing TLV 2021-03-11 14:09:51 +10:30
Christian Decker 60af8be5ba libplugin: Introduce `payment_abort` to terminate a payment
The main responsibility of this new function is to mark a payment
process as terminated and set a reasonable error message, that will be
displayed to the caller. We also skip the remaining modifiers since
they might end up clobbering the message.
2021-03-11 14:09:51 +10:30
Christian Decker 2e51afcc50 pay: Do not mark in-flight parts as failed
Changelog-Fixed: pay: `pay` was reporting in-flight parts as failed
2021-03-11 14:09:51 +10:30
Christian Decker 8252ac5a6e pay: Keysend tries to send even if featurebit 55 isn't set
As pointed out by @cfromknecht [1] there was no formal standardization of
the featurebit, and lnd would try a keysend whenever TLV was supported
by the recipient. This mimics that behavior by checking only that TLV
is enabled.

Changelog-Fixes: keysend: We now attempt to send with keysend even if the node hasn't explicitly opted in by setting a featurebit.

[1] https://github.com/ElementsProject/lightning/issues/4299#issuecomment-781606865
2021-03-11 14:09:51 +10:30
Christian Decker 1e6626ff43 pyln: Fix listfunds call defaulting to spent=False
The semantics don't change, since `lightningd` will use false as
default as well, however setting it to something other than `None`
causes the RPC library to include the parameter in the query, and
since the parameter was introduced only in 0.9.3 and pyln may be used
with older versions this then results in an error about an unknown
parameter.
Setting this to `None` makes sure pyln filters out the argument before
calling.

Changelog-Fixed: pyln: Fixed an error when calling `listfunds` with an older c-lightning version causing an error about an unknown `spent` parameter
2021-03-11 14:07:47 +10:30
Christian Decker 2a44ad113d configure: Pick up the correct pytest executable
We were looking for `python` in the `pytest --version` output
2021-03-11 14:07:47 +10:30
Christian Decker 0bc8a47226 plugin: Add details about which plugin caused a clash in RPC methods 2021-03-10 12:03:10 -06:00
Christian Decker e59940eb61 plugin: Abort early if we have a misconfiguration in the plugins
We were reporting the failure immediately but still continuing with
the startup. This could happen if an important plugin ends up in a
race with another plugin (important or not) for a contended
resource (CLI option or RPC method name). We would eventually notice
that we were supposed to abort, but at that point we already processed
a couple of blocks, loaded the entire state, etc.

This just aborts early with a sane error message.

Changelog-Added: plugin: If there is a misconfiguration with important plugins we now abort early with a more descriptive error message.

Reported-by: PsySc0rpi0n
Reported-by: Ján Sáreník <@jsarenik>
2021-03-10 12:03:10 -06:00
Christian Decker ba083c8869 pyln: Plugins can be nice if invoked from CLI too
I had way too much fun with this and got a bit carried away with the
letter writing. The idea is to be helpful when users start the plugin
from the command line, rather than run it under the control of
lightningd. We also print detailed information about the user-visible
things such as the methods and options exposed by the plugin.

Changelog-Added: pyln: Plugins that are run from the command line print helpful information on how to configure c-lightning to include them and print metadata about what RPC methods and options are exposed.
Suggested-by: Rusty Russell <@rustyrussell>
2021-03-10 21:02:55 +10:30
Christian Decker 59287c2a53 gci: Disable test for NO_PYTHON
It's been causing me quite some headache, and I don't see the point in
jumping through the hoops for something that can be trivially fixed by
having the required build tools.
2021-03-09 14:58:29 +10:30
Christian Decker 1ed08746d3 wallet: Do not generate basepoints in the hsmd
We now load them from the DB, and don't need the keys to be present at
startup.
2021-03-09 14:58:29 +10:30
Christian Decker 039751b875 wallet: Load local basepoints from the database alongside the hsmd 2021-03-09 14:58:29 +10:30
Christian Decker ae7d722ec5 wallet: Store local channel basepoints when a new channel is created 2021-03-09 14:58:29 +10:30
Christian Decker 4887a5a18f db: Add migration for the local basepoints and the funding pubkey 2021-03-09 14:58:29 +10:30
Christian Decker bc42e8df13 db: Add the migration_context to hold info required by migrations 2021-03-09 14:58:29 +10:30
Christian Decker 2f6e33a7cd wallet: Add migration to cache local basepoints from the HSMd 2021-03-09 14:58:29 +10:30
niftynei bfa5db79b3 df-spec: limit allowable inputs/outputs to 252
The maximum inputs and outputs are capped at 252. This effectively fixes
the byte size of the input and output counts on the transaction to one (1).
2021-03-09 14:55:05 +10:30
niftynei 26e4bae9ce df: fail channel if peer sends witnesses that aren't paid for
The receiving node: ...
      - MUST fail the channel if:
        - the `witness_stack` weight lowers the effective `feerate`
          below the agreed upon transaction `feerate`
2021-03-09 14:55:05 +10:30
niftynei 9a849d6ba6 bitcoin: method for finding weight of 'wally_tx' 2021-03-09 14:55:05 +10:30
niftynei cca6e8db03 psbt: mark psbt arg as const for `psbt_compute_fee` 2021-03-09 14:55:05 +10:30
niftynei a5fedc4e1f df-spec: use an empty bit-set as the basepoint for chan-id at start
> If the peer's revocation basepoint is unknown (e.g. `open_channel2`),
> a temporary `channel_id` should be found by using a zeroed out basepoint
> for the unknown peer.
2021-03-09 14:55:05 +10:30
niftynei 31e3bdb42d df-spec: consolidate dual-funding patches, update feerate protocol
We consolidate to the latest/singular RFC patch for dual-funding, so
there's just a single patchfile for the change. Plus we move back to the
opener setting the desired feerate, the accepter merely declines to
participate if they disagree with the set rate.
2021-03-09 14:55:05 +10:30
niftynei 71164799f9 dual-fund: remove all references to PODLEs
We're punting on PODLE's for v1 of dual-funded channels
2021-03-09 14:55:05 +10:30
Christian Decker 65bf347ad3 hsmd: Ensure the hsmd is initialized before anything else is called
Just a security measure to avoid alternative use-cases of the hsmd
running into the issue that they need to send a `WIRE_HSMD_INIT`
message as first message. If that is not done, the `secretstuff` won't
get initialized and we'd be producing signatures from uninitialized
memory, which are completely useless.

Changelog-None: Internal change only
2021-03-09 14:40:02 +10:30
Christian Decker 21355edc43 plugin: Do not send the internal framed message over the wire
Looks like #4394 treated a symptom but not the root cause. We were
actually sending the message framed with the WIRE_CUSTOMMSG_OUT and
the length prefix over the encrypted connection to the peer. It just
happened to be a valid custommsg...

This fixes the issue, and this time I made sure we actually send the
raw message over the wire. However for backward compatibility we
needed to imitate the faulty behavior which is 90% of this patch :-)

Changelog-Fixed: plugin: `dev-sendcustommsg` included the type and length prefix when sending a message.
2021-03-09 14:39:22 +10:30
niftynei 8cc2919884 connectd: clean up the channel stuffs when we get a reconnect
If they've disconnected/reconnected we need to terminate all the
inflight stuff, plus go ahead and call 'disconnect' plugin trigger etc.
2021-03-06 15:03:56 +10:30
niftynei 97e64915c5 df: add (over zealous?) note about the usage of `psbt_has_req_fields`
Requested-In-Part-By: Rusty Russell @rustyrussell
2021-03-06 15:03:56 +10:30
niftynei fc411a5925 df-memleak: expose memleak error and fix
We were getting a memleak error that the open_attempt isnt' being
cleaned up in test_rbf_reconnect_tx_construct. I had some trouble
reproducing it, so I removed the reliance on using `tmpctx` to clean it
up and was more surgical about cleaning it up inline.
2021-03-06 15:03:56 +10:30
niftynei 0e8c49e077 Revert "df: turn off integration tests that depend on v2 funding"
This reverts commit 2e40a13508444cb48e63030593400ef34de0bd33.
2021-03-06 15:03:56 +10:30
niftynei 6a89a94fb5 df-tests: check that rbf includes overlapping inputs 2021-03-06 15:03:56 +10:30
niftynei 7ce7577254 df-tests: check that multiple RBFs and tx-sigs errors during RBF work 2021-03-06 15:03:56 +10:30
niftynei c1fcc1c819 df-rbf: test for interrupts during tx construction 2021-03-06 15:03:56 +10:30
niftynei e0a2d47903 df-rbf: reconnection tests (init_rbf + ack_rbf) 2021-03-06 15:03:56 +10:30
niftynei 73ac0fb6ce df-tests: happy path rbf test
I can has RBF?
2021-03-06 15:03:56 +10:30
niftynei 07153bff6a df: cleanup error handling on lightningd side
Make existing methods understand how unsaved channels work, re-work
errors so that we handle everything appropriately
2021-03-06 15:03:56 +10:30
niftynei ad0f92aef1 df-rbf: update rejection criteria for tx_sigs
since we might be in the middle of an RBF, update our checks to be more
robust
2021-03-06 15:03:56 +10:30
niftynei dfdf9259d7 listpeers: include feerate info for RBF-candidate channels
Changelog-Added: JSON-RPC: `listpeers` now includes 'last_feerate', 'next_feerate', 'initial_feerate' and 'next_fee_step' for channels in state DUALOPEND_AWAITING_LOCKIN

fixup! listpeers: include feerate info for RBF-candidate channels
2021-03-06 15:03:56 +10:30
niftynei 6c76dd338e channel: move inflight + feerate methods to channel.c
Need these more accessible for next patch, which moves the next_feerate
info into listpeers
2021-03-06 15:03:56 +10:30
niftynei a23277af57 listpeers: include info on channels that are in-process
Channels that we're in negotiation for, but don't have a commitment
transaction saved for yet.
2021-03-06 15:03:56 +10:30
niftynei c519c84ef8 df: handle funding_locked + tx_signatures messages out of order
If we're doing an RBF, it's possible that the peer will send us a
funding_locked, shutdown, or tx_signatures message. (We get tx_sigs out
of order on a reconnect)

This lets us gracefully handle a shutdown or funding_locked
sent at any time (after first funding tx) as well.
2021-03-06 15:03:56 +10:30
niftynei 6825a6715e df: move methods around so we can call them elsewhere
Will reuse these elsewhere soon
2021-03-06 15:03:56 +10:30
niftynei 1acc1aa27e rbf: clean up channel on error
Make sure we clean up unsaved channels appropriately on failure.

We forget the peer/channel if it's unsaved!
2021-03-06 15:03:56 +10:30
niftynei ff069ff924 rbf: consolidate failure paths, use "warnings"
We move over to the new "warning" paradigm, instead of using
an "rbf_fail" message.

Every failure is either a warning or an error; on warnings we
hang up and reconnect later, effectively resetting the state.
2021-03-06 15:03:56 +10:30
niftynei 4fb95a9350 df-rbf: separate first-time channel save from update (RBF)
We can't "first save" a channel twice; instead we split in two and just
update the underlying channel on subsequent passes (RBFs)
2021-03-06 15:03:56 +10:30
niftynei f22fed3fd5 df-rbf: only permit the channel initiator to init RBF
We're *mostly* set up for both sides doing RBF, except that it reverses
the callback flow (using the plugin vs RPC calls) and we're not
currently smart enough to flip between them gracefully
2021-03-06 15:03:56 +10:30
niftynei a0cb7bd9b4 df: update reserve calculation
We can use the funding amount to derive the reserve requirement.
2021-03-06 15:03:56 +10:30
niftynei 2719ff8c3b df-rbf: handle rbf failures in lightningd 2021-03-06 15:03:56 +10:30
niftynei d47358848f df-rbf: init an rbf for real, using openchannel_bumpfee
Reorg a bit of the RBF code so we use the same codepaths for we-init vs
they-init starts.
2021-03-06 15:03:56 +10:30
Rusty Russell 4dcd4ca155 listpeers: add latest feerate and actual last fee amount.
Users have no idea what they would pay for unilateral closes.
At least this gives them a clue!

Reported-by: @az0re on IRC.

Changelog-Added: JSON-RPC: `listpeers` now shows latest feerate and unilaral close fee.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-03-05 13:12:41 +10:30
Rusty Russell 4deb9311ce Makefile: fix parallel build error on clean tree.
Caused by missing common/iso4217.c from common/Makefile:

```
In file included from ./common/iso4217.h:4,
                 from common/iso4217.c:3:
./wire/wire.h:7:10: fatal error: secp256k1_recovery.h: No such file or directory
    7 | #include <secp256k1_recovery.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:265: common/iso4217.o] Error 1
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-03-03 16:36:22 -06:00