Commit Graph

9736 Commits

Author SHA1 Message Date
Christian Decker d1b3a5b1aa libhsmd: Migrate handle_get_channel_basepoints 2021-05-04 11:18:52 +09:30
Christian Decker 2cb25a16e0 libhsmd: Migrate handle_sign_invoice 2021-05-04 11:18:52 +09:30
Christian Decker 79ec4b4808 libhsmd: Migrate handle_sign_bolt12 2021-05-04 11:18:52 +09:30
Christian Decker 3d959e128d libhsmd: Add dispatcher function 2021-05-04 11:18:52 +09:30
Christian Decker ac836bbd1b libhsmd: Add status functions to report to whoever is listening
These are currently just shims that replicate the old behavior, but
when compiling as a library we can relink the status_* functions to
something that makes sense in the context of the user, and not assume
we're running as a subdaemon.
2021-05-04 11:18:52 +09:30
Christian Decker b5a2ddd384 libhsmd: Migrate check_client_capabilities to libhsmd 2021-05-04 11:18:52 +09:30
Christian Decker ed4676bea8 libhsmd: Add scaffolding to start separating hsmd from io logic 2021-05-04 11:18:52 +09:30
Nalin Bhardwaj ae06bb91ed plugins/bcli: strip trailing whitespace appropriately
Changelog-Fixed: Handle windows-style newlines and other trailing whitespaces correctly in bitcoin-cli interface
2021-05-03 19:00:26 +09:30
Rusty Russell ff6b26b70e plugins/funder: fix up compilation.
I merge Christian's plugin notification API change at the same
time, broke plugins/funder.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-03 11:42:04 +09:30
Christian Decker c58b15de19 docs: Document the custom plugin notifications 2021-05-03 11:20:15 +09:30
Christian Decker ef7f9a8022 pay: Add pay_failure notification 2021-05-03 11:20:15 +09:30
Christian Decker c6fd849aa3 pay: Add notification for pay_success 2021-05-03 11:20:15 +09:30
Christian Decker 98aa3c3da7 plugin: Make unannounced notification topics no longer fatal
Since plugins will start sending them soon, and they are likely to get
it wrong sometimes, be a bit more lenient, warn them in the logs
instead and then make sure it doesn't accidentally work anyway.
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 e02e972729 cleanup: Make lnprototest run only with DEVELOPER=1 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
Christian Decker 62e3358a5b plugin: Wrap custom notifications in a dict with additional origin
This should allow us to differentiate the origin of the notification,
and further prevent plugins from spoofing native notifications.
2021-05-03 11:20:15 +09:30
Christian Decker cfb1107244 plugin: Remember the shortname for a plugin
We use it in a couple of places, so let's remember it for easier
access.
2021-05-03 11:20:15 +09:30
Christian Decker 2e27e4e443 plugin: Move list of notification topics to each plugin
We want to ensure that plugins register their topics before sending
any notification, so we need to remember which plugin registered which
topics.
2021-05-03 11:20:15 +09:30
Christian Decker c8c2c33952 plugin: Prevent plugins from registering native notification topics
They may already have subscribers, and they may crash if presented
with a malformed notification.
2021-05-03 11:20:15 +09:30
Christian Decker f716c55983 plugin: Implement custom notification dispatch for plugins
Changelog-Added: plugin: Plugins may now send custom notifications that other plugins can subscribe to.
2021-05-03 11:20:15 +09:30
Christian Decker 9d310366af plugin: Store the notification topics announced by the plugins 2021-05-03 11:20:15 +09:30
Christian Decker f77a0bcd8f plugin: Move the notification subscription check into a second phase
A plugin might subscribe to a notification topic that is only
registered by another plugin later, so push the check to that
consistency check phase where we do hook ordering as well.
2021-05-03 11:20:15 +09:30
Christian Decker 083b41f090 plugin: Add a list of notification topics registered by plugin
We will eventually start emitting and dispatching custom notifications
from plugins just like we dispatch internal notifications. In order to
get reasonable error messages we need to make sure that the topics
plugins are asking for were correctly registered. When doing this we
don't really care about whether the plugin that registered the
notification is still alive or not (it might have died, but
subscribers should stay up and running), so we keep a list of all
topics attached to the `struct plugins` which gathers global plugin
information.
2021-05-03 11:20:15 +09:30
niftynei 29155c2fe8 tests: add test for funder options 2021-05-03 11:06:10 +09:30
niftynei 473067859f pyln-testing: use provided outnum instead of trying to find it
Dual-funded channels won't match the old amount check. Good news is
we're already returning the outnum so we just use that.
2021-05-03 11:06:10 +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 a293bf3269 rbf_channel hook: add channel_max_msat parameter
Changelog-Added: Plugins: `rbf_channel` hook has `channel_max_msat` parameter
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 bc7875864b contrib: if you're in dev mode, use dual-funding (with matching)
If you're using the regtest node, turn on dual funding and
automatically attempt to dual fund at a 100% match for every channel
open that you do.
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 16c92b7da3 amount: `amount_sat_scale` method
For scaling/multiplying sats
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 56e8d75dbb dualfund: set the locktime for the user-provided PSBT
This is set by the peer and is non-negotiable. We're not even going to
check if you got it right. You were told about it via `openchannel2`.

It is what it is.
2021-05-03 11:06:10 +09:30
niftynei 5a04dc185c openchannel2/rbf hooks: reject if response malformed
You gotta send over an amount if you send a psbt!
2021-05-03 11:06:10 +09:30
niftynei 9ba2f614bb psbt-open: method to quickly check if has our input
For dual-funding's accepter plugin, we only want to send
psbts that need to be signed to `signpsbt`; this lets us quickly check
if they're "signable"
2021-05-03 11:06:10 +09:30
niftynei 7c76363e20 openchannel2: add channel_max_msat to openchannel2 hook payload
Changelog-Added: Plugins: add a `channel_max_msat` value to the `openchannel2` hook. Tells you the total max funding this channel is allowed to have.
2021-05-03 11:06:10 +09:30
niftynei 382264e207 dualopend: don't use final channel_id for accepter_start2
The other side doesn't know it until *after* it parses this msg.  We
add a quick hack to still allow old nodes to work (for now!).

This also fixes a bug (spotted by @niftynei) where any errors we sent
before accepter_start2 would have the new (unknowable!) channel_id
rather than the temp one.

Authored-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-03 11:06:10 +09:30
niftynei 69cc9201de plugin-tests: cleanup outdated openchannel2 hook fields
We removed/changed the fields on the openchannel2 hook but never
updated this test (which doesn't run with the CI for #reasons)
2021-05-03 11:06:10 +09:30
niftynei 0e753224ae tests: remove EXPERIMENTAL_FEATURE flag from openchannel2 hooks
These are now included in all builds
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
Rusty Russell 7bc78c45b4 test/run-commit_tx: test static remotekey.
Allow generation of static-remote-key variants of testcases.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-03 10:10:32 +09:30
Rusty Russell e7e8fa7b10 test/run-commit_tx: test HTLC differentiation.
As from commit 280e9603e9e4fba820aba2c3d27630c1477a7638.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-03 10:10:32 +09:30
Rusty Russell 5d2c2ff962 tests: make run-commit_tx output match the BOLT test vectors more closely
Still needs some massaging (we print HTLCs as we add them, rather then
in the final order, which requires a manual move in one test vector),
but this makes it more trivial to compare the output with the BOLT 3
text after https://github.com/lightningnetwork/lightning-rfc/pull/852

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-03 10:10:32 +09:30
Rusty Russell c2a6de3042 channeld: fix test code for tx fee calculation (inside `#ifdef PRINT_ACTUAL_FEE`)
Has an out-by-one error, but only used for test-vector generation.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-03 10:10:32 +09:30