Commit Graph

520 Commits

Author SHA1 Message Date
Christian Decker c6fd849aa3 pay: Add notification for pay_success 2021-05-03 11:20:15 +09:30
Christian Decker c8c0c4dc99 libplugin: Add functions to start and end notifications 2021-05-03 11:20:15 +09:30
Christian Decker c1f08a42fe libplugin: Add notification topics to the manifest response 2021-05-03 11:20:15 +09:30
Christian Decker f963a6a551 libplugin: Add notification topics to plugin_main 2021-05-03 11:20:15 +09:30
Christian Decker f08ae49134 plugin: Restrict plugin notifications only to announced topics
We want to have well-behaved notifications that are clearly announced
during the initialization, kill plugins that don't behave.
2021-05-03 11:20:15 +09:30
niftynei 38b992b805 funder: handle RBF callback
Fund an RBF same as you would an open. We dont' do anything fancy with
our inputs -- we dont' have a copy of the last PSBT that was sent.
2021-05-03 11:06:10 +09:30
niftynei 4244fc1a53 funder: `funderupdate` command to see/set configs
Changelog-Added: Plugins: `funder` plugin now has new command `funderupdate` which will show current funding configuration and allow you to modify them
2021-05-03 11:06:10 +09:30
niftynei 6b37b92f8a funder: sanitize inputs
Error out if we've got the wrong info
2021-05-03 11:06:10 +09:30
niftynei 2538956b4d funder-test: tests for our policy configurations 2021-05-03 11:06:10 +09:30
niftynei 89a7479312 funder: use listfunds to fetch utxo data
Compute available_funds locally, instead of getting it from the
openchannel2 hook payload.

Suggested-By: Rusty Russell @rustyrussell
2021-05-03 11:06:10 +09:30
niftynei cd5970243a funder: add a plugin, `funder`. policies for dual-funding
Behold! An immaculately concepted plugin for configuring your node to do
amazing things*

*fund channel open requests

Changelog-Added:  Plugins: Add `funder` plugin, which allows you to setup a policy for funding v2 channel open requests. Requres --experimental-dual-fund option
2021-05-03 11:06:10 +09:30
niftynei 916edaa839 openchannel: add missing string args to format string
Oops
2021-05-03 11:06:10 +09:30
niftynei 15e83925e8 libplugin: add no-op command complete function
When an RPC originates from a plugin, and there's no associated command,
it's useful to be able to signal that you're finished.
2021-05-03 11:06:10 +09:30
niftynei 9c8ce925ef dual-fund: update state before checking for 'doneness'
If we only add a single input/output for the funding transaction,
 we'll only call openchannel_update once, which results in
a crash because the dest->state will never advance to
MULTIFUNDCHANNEL_UPDATED;

Instead, we update to UPDATED before we check for doneness.
2021-04-16 15:33:44 +09:30
Christian Decker c8dbcac38e pay: Use gossmap for reachability check 2021-04-06 11:03:47 +09:30
niftynei 6db6ba6c03 dual-funding: introduce racy state
It's unlikely but possible that a race condition will result in us not
being at the 'secured' state yet here.

Crashlogs. All required msgs are received (in order)
from peers, but the crash suggests they weren't relayed/processed by the
spender plugin in the order received.

WIRE_TX_SIGNATURES is passed the the plugin via a notification;
WIRE_COMMITMENT_SIGNED is returned as the result of an RPC call.

```
021-03-25T12:12:33.5213247Z lightningd-1: 2021-03-25T11:50:13.351Z DEBUG   035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d-dualopend-chan#3: peer_in WIRE_COMMITMENT_SIGNED
2021-03-25T12:12:33.5221140Z lightningd-1: 2021-03-25T11:50:13.659Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-dualopend-chan#1: peer_in WIRE_COMMITMENT_SIGNED
2021-03-25T12:12:33.5228462Z lightningd-1: 2021-03-25T11:50:14.169Z DEBUG   035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d-dualopend-chan#3: peer_in WIRE_TX_SIGNATURES
2021-03-25T12:12:33.5230957Z lightningd-1: 2021-03-25T11:50:14.375Z DEBUG   plugin-spenderp: mfc 275, dest 1: openchannel_update 035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d returned.
2021-03-25T12:12:33.5233307Z lightningd-1: 2021-03-25T11:50:14.539Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-dualopend-chan#1: peer_in WIRE_TX_SIGNATURES
2021-03-25T12:12:33.5235120Z lightningd-1: 2021-03-25T11:50:17.240Z INFO    plugin-spenderp: Killing plugin: exited during normal operation
2021-03-25T12:12:33.5236707Z lightningd-1: 2021-03-25T11:50:17.260Z **BROKEN** plugin-spenderp: Plugin marked as important, shutting down lightningd!
```

Fixes #4455
2021-03-30 13:44:11 +10:30
niftynei 3e8f575f9e dual-funding: convert to runtime flag, --experimental-dual-fund
You can now activate dual-funded channels using the
`--experimental-dual-fund` flag

Changelog-Changed: Config: `--experimental-dual-fund` runtime flag will enable dual-funded protocol on this node
2021-03-25 20:05:11 +10:30
Christian Decker 6cfb72ea1b keysend: Add error when trying to send to self
There is little point in faking a self-payment, but we should also not
crash :-)

Fixes #4438

Changelog-Fixed: keysend: Keysend returns an error when a self-payment is requested
2021-03-19 10:18:42 +10:30
Christian Decker 3a031bf0e3 keysend: Fix a use-after-free error
By stealing the underlying buffer we could end up freeing it, causing
the next read to access a freed buffer. Copying is however safe.
2021-03-19 10:18:42 +10:30
niftynei 38fee517d7 mfc: turn "UNKNOWN TYPE channel_id" logs into actually the channel id
Get rid of unuseful "UNKNOWN TYPE channel_id" prints in logs; only
affected usage for `type_to_string` of plugins/Makefile built things
2021-03-17 11:35:37 +10:30
fiatjaf a7af106321 remove duplicated erring_node from paystatus. 2021-03-17 06:05:35 +10:30
Rusty Russell 22e1107581 lightningd/opening_control: deprecate old fundchannel_complete args.
And update all the in-tree callers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Deprecated: JSON-RPC: `fundchannel_complete` `txid` and `txout` parameters (use `psbt`)
2021-03-16 13:10:07 +10:30
Rusty Russell 43a553f5ac txprepare, withdraw: return the PSBT as well as raw tx.
In particular, txprepare gives us a nice way to get a valid PSBT for
testing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `txprepare` and `withdraw` now return a `psbt` field.
2021-03-16 13:10:07 +10:30
Jan Sarenik 1b02d15695 typo: information is an uncountable mass noun
See https://en.wikipedia.org/wiki/Information

In libplugin.c also the word "details" was added (without removing
the 'information').

Changelog-None
2021-03-16 10:45:40 +10:30
niftynei 2586641678 mfc: use consolidated error reporting, reduce reliance on json-str
Previously this ported errors around as JSON. A nicer thing to do is to
deconstruct/reconstruct it; this also allows us to create our own errors
from within the multifundchannel family.
2021-03-15 14:08:44 +10:30
niftynei ef1e36efe5 mfc: check that we can retry when things go haywire
There's a version of this that keeps the PSBT in memory and does some
fancy addition/subtraction of unuseable parts for the v2's, however
it's much easier and simpler to simply error on the peer and re-start
from the very beginning.

This only works if we haven't gotten commitments from the peer yet (in
fact either method would only work if we haven't got commitments from
the peer yet), so if we've got commitments from them we simply mark them
as failed an go again.

In a perfect world, we'd remember what inputs we used last time, and
reuse those again on the re-attempt, which would pefectly guarantee both
that the failed opens (ones w/ commitments exchanged) would be canceled
after this completes (and we could re-try the failed again).

As it is, this is not perfect. It is, however, servicable.
2021-03-15 14:08:44 +10:30
niftynei 9ce07eca61 mfc: have error messages for redos be more robust (include why)
Makes it easiser to figure out what's going on.

Also, make sure that every 'fail_destination' error description includes
quote escapes.
2021-03-15 14:08:44 +10:30
niftynei 822441558c mfc: add convenience method for determining 'parity'
is_v2 instead of protocol == OPEN_CHANNEL
2021-03-15 14:08:44 +10:30
niftynei 452a12fec2 mfc: move input validation down to input acceptance
Move only.
2021-03-11 14:38:57 +10:30
niftynei a9794889bf mfc: final inversion!
Move only.
2021-03-11 14:38:57 +10:30
niftynei 6ccdd1dbab mfc: move fundchannel_starts down
Move only.
2021-03-11 14:38:57 +10:30
niftynei 5bb1f71dbe mfc: move connection beneath funding
Move only.
2021-03-11 14:38:57 +10:30
niftynei 4323b79b10 mfc: invert some more
Move only.
2021-03-11 14:38:57 +10:30
niftynei 6a5f92ada7 mfc: begin inversion, start at bottom as well as re-try
Move only.
2021-03-11 14:38:57 +10:30
niftynei 786c58d333 mfc: rm call chain inversions + declarations
Move only.
2021-03-11 14:38:57 +10:30
niftynei 14cd831508 mfc: invert call-chain, remove declarations
Move only.
2021-03-11 14:38:57 +10:30
niftynei 842dfabb56 mfc: rm declarations; invert call chain
Move only.
2021-03-11 14:38:57 +10:30
niftynei f1113c3208 mfc: rm declarations, invert ordering
Move only.
2021-03-11 14:38:57 +10:30
niftynei 068dc8f5d2 mfc: cleanup static declarations/invert call chain
Move only.
2021-03-11 14:38:57 +10:30
niftynei db87a5010c mfc: uninvert/remove declarations for mfc cleanups
Move only.
2021-03-11 14:38:57 +10:30
Christian Decker a6c857dadb pay: Add functions to tell bolt12 string apart
The functions just look at the hrp, so they're not guaranteed to guess
right, but for this case it's sufficient.
2021-03-11 14:09:51 +10:30
Christian Decker 40e9d60ce0 pay: Do not clobber error messages if we fail decoding a bolt11
We were automatically falling back to bolt12 decoding, clobbering the
fail message. Ultimately resulting in confusing error
messages (expected prefix lni but got lnbtrc). Now we first determine
which decoding we're trying to do, and then only decode accordingly.

Changelog-Fixed: pay: Report the correct decoding error if bolt11 parsing fails.
2021-03-11 14:09:51 +10:30
Christian Decker ea92466025 pay: Abort the payment if destination is unreachable
We were not aborting if we had routehints, even though all routehints
may have been filtered out.

Changelog-Fixed: pay: `pay` will now abort early if the destination is not reachable directly nor via routehints.
2021-03-11 14:09:51 +10:30
Christian Decker cb21a5384b pay: Remove routehints with unreachable entrypoints
Changelog-Added: pay: `pay` will now remove routehints that are unusable due to the entrypoint being unknown or unreachable.
2021-03-11 14:09:51 +10:30
Christian Decker 1e1d7b387c pay: Filter out routehints whose entrypoint is unknown
We would happily spin on attempts that are doomed to fail because we
don't know the entrypoint. Next up: remove routehints whose
entrypoints are known but unreachable.
2021-03-11 14:09:51 +10:30
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
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