Commit Graph

9943 Commits

Author SHA1 Message Date
niftynei 062bc12813 rbf: update the channel's funding_txid to match what's mined
If the peer is offline when we see the funding txid, we don't actually
update the channel's info. Here, we move it up to where the scid is set,
so that we always update the channel's funding_txid to the correct
(mined) information.
2021-05-24 12:17:48 +09:30
niftynei e45b09358a inflights: relax assertion channel funding_txid is last inflight txid
This assertion is not valid if a non-last funding tx is mined
2021-05-24 12:17:48 +09:30
niftynei d6bd6cc5cf open-rbf: we broadcast all the commitments for a channel when closed
If you drop an rbf'd channel to chain (before any updates have been
made) we should drop *all* of the inflights to chain
2021-05-24 12:17:48 +09:30
niftynei dff9516cad rbf-tests: check every inflight has signed commitment produced
Little check to make sure that we can produce a signed commitment tx for
every inflight we've got saved.
2021-05-24 12:17:48 +09:30
niftynei 4247ec3a05 inflights: save the whole psbt to the database
Otherwise we're missing info when we go to broadcast these and can't
properly sign the transaction to close it.

Found-by: @jasan
2021-05-24 12:17:48 +09:30
niftynei 1d922bff1c dev-sign-last-tx: include inflight signed txs
For convenience sake, include the inflight's signed txs as well
2021-05-24 12:17:48 +09:30
niftynei f468c204eb listpeers: always show all the inflights
If you close a channel, the state won't be DUALOPEND_AWAITING_LOCKIN
2021-05-24 12:17:48 +09:30
niftynei e6c7928e76 listpeers: show the inflight's 'commitment tx' txid
Changelog-Added: EXPERIMENTAL JSON-RPC: `listpeers` now includes the `scratch_txid` for every inflight (if is a dual-funded channel)
2021-05-24 12:17:48 +09:30
niftynei 5f1ba02ece rbf: on close, drop every inflight transaction's commitment
If it's a unilateral close, we need to drop all the inflights also,
as we don't know which of them ended up being mined.
2021-05-24 12:17:48 +09:30
niftynei 727d7e9493 df-rbf: test that, with enough bumps, we can eventually add to mempool
We don't pass the minimum fee requirement the first few times we attempt
an RBF, so it fails. Keep going until actually replaces
2021-05-24 12:17:48 +09:30
niftynei 024bc83fca listpeers: add inflights info
Changelog-Added: for v2 channels, we now list the inflights information for a channel
2021-05-24 12:17:48 +09:30
niftynei 8925fc8b01 inflights: add checks that there's actually an inflight 2021-05-24 12:17:48 +09:30
niftynei 82fa3fa2ef df-rbf: order inflights by funding_feerate
When we re-populate from disk, we need to know what order to recreate the
inflights list in.

Fixes #4511
2021-05-24 12:17:48 +09:30
niftynei 8ae9f6ac9e df-tests: add better explainer for test logic 2021-05-24 12:17:48 +09:30
niftynei bab5ef4aff df-test: test for a failed rbf attempt, currently crashes
An attempted + failed RBF results in a crashed/dead node
2021-05-24 12:17:48 +09:30
niftynei e2867be609 df-tests: re-write test_funding_cancel_race for v2 commands
test_funding_cancel_race uses fundchannel_open etc; this new test does a
similar (but not exact thing, as 'aborts' dont work after an update
is confirmed) thing, using openchannel_update and openchannel_abort.
2021-05-23 17:42:09 +09:30
niftynei 2d4939fa6d df-tests: re-write the funding wallet corners test for v2 2021-05-23 17:42:09 +09:30
niftynei 8908dd08ec df-bugs: only include the `funding` if we're the opener
`funding` field belongs to the INITIATOR!
2021-05-23 17:42:09 +09:30
niftynei 260adb824e df: differentiate error message between
There's a difference between "no channel" and "channel in progress
but no open available to cancel"
2021-05-23 17:42:09 +09:30
Rusty Russell 4ae9e0c73f CI: Re-enable experimental build.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-23 08:20:59 +09:30
niftynei 477832057d funder: print reason that we don't contribute funds
If we don't put funds into a channel, say why in the logs. Should make
it a bit easier to figure out what's going on.
2021-05-23 08:19:50 +09:30
niftynei c93bd5bd51 funder: test for adding utxos, calculating total available
Make sure that 100% available actually puts in 100% of what we can add
(note that this isn't 'all' -- we don't include uneconomic utxos)
2021-05-23 08:19:50 +09:30
niftynei f6186d5860 funder: subtract the fee of the utxo from the available amount
Adjust our total available funds downward, to account for the fees we'll
be charged to spend them.
2021-05-23 08:19:50 +09:30
niftynei 9a1041ee97 fundpsbt: dont add utxos that are a net-loss
if the utxo can't pay for its own fees, dont put it in the tx

Changelog-Changed: JSONRPC: fundpsbt will not include UTXOs that aren't economic (can't pay for their own fees), unless 'all'
2021-05-23 08:19:50 +09:30
niftynei 5e7695f6a0 funder: add count of utxos we're signing to the logs
Useful for asserting how many inputs we're contributing
2021-05-23 08:19:50 +09:30
Rusty Russell 14febd4ecc pytest: disable mpp test which is blocking merges.
I'm still diagnosing exactly why this fails, but it will need Christian's
help at this stage.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-23 08:13:27 +09:30
Rusty Russell 46b735c023 dijkstra: add chan pointer argument to path scoring.
For fuzz, we will need some fixed per-channel data (so we always fuzz
a channel the same way).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 3832542d27 common/dijkstra: remove dijkstra_amount().
Unless you're using amount as the sole cost function (we don't!), the
"cost" is not the "amount".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 2bb365a931 common/route: route_from_dijkstra returns route_hop array.
This is what (most) callers actually want, so unify it into one place.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell e531a38963 gossipd / plugin: clean up names in struct route_hop.
We're going to unify them, but the names are not the normal ones.

Fix that first.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 9dadcc858b common/gossip_store: avoid fd pass for new store, use end marker.
This is also simpler.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell c2a88912e1 common/gossmap: reload once we hit end marker.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 0d4f014021 gossip_store: create end marker for EOF.
This is better than using the previous "keep statting the file" approach,
since we can also tell you how long the replacement is, to avoid a
gratitous load.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 167681c709 gossmap: fix gossmap_chan_get_announce() and gossmap_node_get_announce().
These were never used, nor tested.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell d54abd0e36 gossmap: function to get channel features bitmap.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 770a328d56 gossmap: save the offset where the channel updates are, function for details.
This takes an extra 8 bytes per channel, but means we can go back and
get more information about them; this is implemented in
gossmap_chan_get_update_details() which is what listchannels will need.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell d1f8a5f0be gossmap: add gossmap_chan_get_capacity() helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell eb370ab8ff gossmap: remembers when a channel is private.
Steals one bit from the scid_off, and turns that into a relative
offset.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell cc198748d4 common/json_tok: hoist param_short_channel_id from inside lightningd/
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 7ef6dd04d9 plugins/test/run-route-overlong: modern overlong routing test.
gossmap equivalent of gossipd/test/run-overlong.c.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 52e5ca3c11 plugins/libplugin: make headers update-mocks friendly.
In particular, it expects return type at start of line.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 6f71aae336 plugins/libplugin-pay: extreact route function so we can write unit tests.
New "route()" doesn't need a struct payment, so is easier to test.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 088cfced18 common/test/run-route and run-route-specific: modern gossmap tests
Equivalent to gossipd/test/run-find_route.c and gossipd/test/run-find_route-specific.c
except they use gossmap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 0682ad9c48 fetchinvoice: don't produce invalid JSON on sent_inv timeout.
An unrelated bug in the reverse path triggered this code, and boom.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 2e3e4a50ec update-mocks: prefer to find function defs from local includes.
This matters for:
	- common/wallet.h vs wallet/wallet.h
	- common/gossip_store.h vs gossipd/gossip_store.h
	- common/json.h vs lightningd/json.h
	- common/ping.h vs lightningd/ping.h

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell d868d4470a Makefile: don't let update-mocks run unless DEVELOPER and EXPERIMENTAL_FEATURES.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 25b5e1e099 update-mocks: make sure we cover all test programs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell cc6f1fd120 update-mocks: don't try to regenerate files.
If you do update-mocks in a dirty tree, the recursive make that it
uses will try to rebuild things!  Suppress that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-22 17:53:04 +09:30
Rusty Russell 33736b860a lightningd: attach HTLC timeout to htlc itself, fix gratuitous disconnect bug.
We set the timeout on first HTLC, but didn't clear it if that HTLC failed.

It's saner to have a per-HTLC timeout (since that's what it is!) and
also our timer infra is specially coded to scale approximately infinitely so
trying to optimize this is vastly premature.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Protocol: We would sometimes gratuitously disconnect 30 seconds after an HTLC failed.
2021-05-21 14:45:05 +09:30
Rusty Russell 11180e7aa1 pytest: add test for HTLC timeout on failed htlcs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-21 14:45:05 +09:30