Commit graph

747 commits

Author SHA1 Message Date
Matt Corallo
823497d5a3 Unify the update pattern in provide_latest_local_commitment_tx_info 2018-12-04 11:24:20 -05:00
Matt Corallo
35bd8c31e8 Simplify ChannelMonitor Storage updates a bit 2018-12-04 11:24:20 -05:00
Matt Corallo
90d2ca37e7 Simplify insert_combine by unimplemented!()ing unimplemented things 2018-12-04 11:24:20 -05:00
Antoine Riard
e86e10b87d Refactor KeyStorage as Storage
Move PrivMode as Local, SigsMode as Watchtower

Cut funnding_txo from ChannelMonitor, move it inside Local

Rename log_funding_option as log_funding_info
2018-12-04 11:24:19 -05:00
Matt Corallo
a2df43d525 Remove check which makes us sometimes never send closing_signed
This is the case pointed out by nayuta-gondo at
https://github.com/lightningnetwork/lightning-rfc/issues/499#issuecomment-438623208
though this doesn't actually solve the issue of ensuring we have a
consistent fee view when we start shutdown processing. There isn't
a clear solution to that however without adding additional state
tracking in Channel.

This also removes an associated test that tests for the correct
behavior (but didn't consider the bug) as we no longer behave
correctly. This should be fine as we'll be removing all the
update_fee garbage with option_simplified_commitment anyway.
2018-12-03 17:04:19 -05:00
Matt Corallo
dfbc6c60a7
Merge pull request #265 from TheBlueMatt/2018-12-fuzz-fix-no-witness
Fix crash on no-witness tx in ChannelMonitor found by fuzzer
2018-12-03 14:38:56 -05:00
Matt Corallo
4f9b0fbd3f Avoid writing to stdout during fuzz tests 2018-12-03 13:58:50 -05:00
Matt Corallo
7e94d3a617 Remove unused import in full_stack_target 2018-12-03 13:30:38 -05:00
Matt Corallo
f9c945e17f Fix crash on no-witness tx in ChannelMonitor found by fuzzer
Tehnically we can't currently hit this, but a theoretical future
watchtower could, and full_stack_target crashes on it.
2018-12-03 13:21:20 -05:00
Matt Corallo
0d7156ffc1
Merge pull request #261 from TheBlueMatt/2018-11-reestablish-fix
Fix channel_reestablish generation/handling around next_remote.
2018-12-03 13:17:54 -05:00
Matt Corallo
23c2cef5f4 Fix channel_reestablish generation/handling around next_remote. 2018-12-02 17:26:16 -05:00
Matt Corallo
26a7192689
Merge pull request #260 from yuntai/201811-sessionkey
Add a method to get session secret for onion packet to KeysInterface
2018-11-26 22:09:42 -05:00
Yuntai Kyong
7e59e1e392 Add a method to get session secret for onion packet to KeysInterface 2018-11-27 10:44:51 +09:00
Matt Corallo
5e9e199279
Merge pull request #258 from TheBlueMatt/2018-11-close-locked
Simplify + document the ChannelManager Err flow, fix close-outside-lock race, finish ChannelError conversion
2018-11-26 10:56:18 -05:00
Matt Corallo
6969fc997b
Merge pull request #259 from TheBlueMatt/2018-11-256-redux
Add test_claim_on_remote_revoked_sizeable_push_msat
2018-11-23 15:21:35 -05:00
Antoine Riard
ab9a98ff5d Add test_claim_on_remote_revoked_sizeable_push_msat 2018-11-23 14:38:02 -05:00
Antoine Riard
546bd37c19 Refactor check spendable outputs macros into one
In consequence, harden spendable outputs tests

Fix vocabulary abuse
2018-11-23 14:38:02 -05:00
Matt Corallo
466d0f61cf Simplify + document the ChannelManager Err flow a bit
This removes all the channel-closure stuff from handle_error!() and
MsgHandleErrInternal, making all the Err handling consistent by
closing the channel before releasing the channel_state lock and
then calling handle_error!() outside of the lock.
2018-11-22 23:57:54 -05:00
Matt Corallo
fe3d706d5b Remove MsgHandleErrInternal::from_chan_maybe_close as it's useless
Technically funding_transaction_generated was fine using it, but
calling force_shutdown on an empty Channel inside the channel_state
lock isn't a big deal and almost any other use of it would be
unsafe.
2018-11-22 23:57:54 -05:00
Matt Corallo
032f20275b Properly handle ChannelError::Close results in update_fee.
Best reviewed with -b
2018-11-22 23:57:54 -05:00
Matt Corallo
9fdc349573 Properly handle ChannelError::Close results in send_payment.
Best reviewed with -b
2018-11-22 23:57:54 -05:00
Matt Corallo
31ec11f446 Close channels on Err returns inside the same channel_state lock
If we never accessed channels for a peer outside of a message
handler for that peer then this wouldn't be a problem since message
handlers are required to be serialized per-peer. However, that
isn't the world we live in - we may want to forward payments or we
may get a send_payment call.
2018-11-22 23:57:54 -05:00
Matt Corallo
bac091cdb9 Stop needlessly returning &HTLCSource out of Channel.
This moves a clone() inside Channel from ChannelManager making
references simpler for the coming refactors.
2018-11-22 23:57:54 -05:00
Matt Corallo
6032099469 Remove remaining uses of HandleError in Channel Err return values
This converts block_connected failures to returning the
ErrorMessage that needs to be sent directly, since it always
results in channel closure and never results in needing to call
force_shutdown. It also converts update_add_htlc and closing_signed
handlers to ChannelError as the rest of the message handlers.
2018-11-22 23:57:54 -05:00
Matt Corallo
dfbcacfe0e Split channel_reserve_test so we don't rely on unfilled Err actions
Currently channel_reserve_test sends a garbage update_add_htlc
message and then relies on it being silently ignored to continue
using the channel. This shouldn't be the case, so take the easy
way out and split the test in two, at first not delivering the
bogus update_add_htlc and then delivering it, but not running the
rest of the test.
2018-11-22 23:57:54 -05:00
Matt Corallo
dae97a4858
Merge pull request #257 from TheBlueMatt/2018-11-007-bump
Bump to 0.0.7 for API rev
2018-11-21 16:45:17 -05:00
Matt Corallo
bde921ea20 Bump to 0.0.7 for API rev 2018-11-21 16:18:18 -05:00
Matt Corallo
241b0cb449
Merge pull request #246 from TheBlueMatt/2018-11-fuzz-crash-redux
Several fuzz-found bugfixes.
2018-11-21 16:17:01 -05:00
Matt Corallo
93c8760086
Merge pull request #255 from TheBlueMatt/2018-11-230-ext
Two post-#230 fixups
2018-11-21 11:41:42 -05:00
Matt Corallo
3af20fd507 Check P2WPKH script against expected before gen'ing an output event
This fixes a bug in 3518f1f85d where
we may generate an output event for a P2WPKH output which is not
ours if the transaction has a sequence/lock_time combination which
false-positives our remote tx detection.

Also note that the TODO is removed as this should already be
covered without issue if the client properly replays the chain on
restart.
2018-11-20 19:03:57 -05:00
Matt Corallo
90b0ed937e Provide commitment point to monitor with the remote txn update
This extends 1b33064554 by
re-simplifying the ChannelMonitor <-> Channel interface a bit as we
never have any use for the latest remote commitment point until we
have knowledge of a remote transaction generated using it.
2018-11-20 19:03:57 -05:00
Matt Corallo
7687e02d6c
Merge pull request #254 from TheBlueMatt/2018-11-channelerror
Move a ton of Channel functions to ChannelError from HandleError
2018-11-20 19:00:49 -05:00
Matt Corallo
f2280e580a Fix two compiler warnings introduced in a51dbb4a4d 2018-11-20 16:34:40 -05:00
Matt Corallo
90816dd9d8 Move a ton of Channel functions to ChannelError from HandleError
This is a big patch, but its all very mechanical, everything here
should be pretty obvious, and it all has to happen at once due to a
few common utility functions all having the same return type.

Note that this exposes a race in channel closure where we may
access a channel via some non-peer-specific mechanism like
forwarding an HTLC or sending a payment during the time between
the channel gave us a Close error and expected us to never call it
again and the time we actually removed it from the channel_state
set outside of the internal_* handler.
2018-11-20 16:33:32 -05:00
Matt Corallo
3155890766 Create simple ChannelMonitor-specific Err type 2018-11-20 16:31:41 -05:00
Matt Corallo
86944d34a1
Merge pull request #231 from philipr-za/philip-204-check-commitment-transaction-fee
Check funder can afford commitment transaction fee when receiving update_fee
2018-11-20 16:29:21 -05:00
Matt Corallo
7efaf2e8ac
Merge pull request #230 from ariard/handle_sizeable_push_msat
Handle sizeable push msat (fix #195) + handle two first per_commitment_point + keys interface tests
2018-11-20 15:51:27 -05:00
Antoine Riard
3a7b40e494 Add test_static_output_closing_tx 2018-11-19 20:51:26 -05:00
Antoine Riard
890d1768b7 Add test_dynamic_spendable_outputs_local_htlc_*
Cover both local HTLC-Timeout/Success case
2018-11-19 20:51:17 -05:00
Antoine Riard
394b11c7b5 Add key_storage selection in ChannelMonitor insert_combine
Based on commitment_number
2018-11-19 20:42:55 -05:00
Antoine Riard
b6b5decfa9 Add test_static_spendable_outputs_justice_tx_revoked_htlc*
Cover both HTLC-Timeout/Success cases
2018-11-19 20:42:55 -05:00
Antoine Riard
73415a8951 Add test_static_spendable_outputs_justice_tx_revoked_commitment_tx 2018-11-19 20:42:55 -05:00
Antoine Riard
e22220d79f Add test_claim_on_remote_sizeable_push_msat
Contrary to sizeable push_msat on local
commitment tx, the output go to a P2WPKH
2018-11-19 20:42:52 -05:00
Antoine Riard
1255885a80 Add check_spend_closing_transaction ChannelMonitor
Aims to send back closing output descriptor to user wallet
2018-11-19 20:40:07 -05:00
Antoine Riard
3518f1f85d Add test_static_spendable_outputs_preimage_tx
Aims to covered both keysinterace preimage tx case and
detection of second remote commitment tx

Split DynamicDescriptor between *P2WSH and *P2WKH
2018-11-19 20:39:38 -05:00
Matt Corallo
3a066ccbf2 Ensure fuzz release builds use codegen-units=1 and LTO 2018-11-18 16:17:06 -05:00
Matt Corallo
e67d8c6314 Don't unwrap() get_channel_update result in HTLC router
This fixes a bug in 78232f2aed found
by fuzzer - if the channel isn't yet fully established we will call
get_channel_update(), get an Err result, and then unwrap() it. If
this actually happens it means someone on the network is making up
short_channel_ids and trying to route over them, but that shouldn't
result in us crashing
2018-11-18 16:17:06 -05:00
Matt Corallo
b4fc5b65e0 Fix pre-noise peer disconnect panic on non-Err disconnect
366e79615b fixed the same crash for
Errs that come up during handshake, but was incomplete and should
have just dropped the node_id being different based on
inbound/outbound. This patch does so and actually fixes the issue.

Found by fuzzer.
2018-11-18 12:59:02 -05:00
Matt Corallo
b14baa03ab
Merge pull request #253 from TheBlueMatt/2018-11-misc-tweaks
Misc Tweaks
2018-11-16 11:47:50 -05:00
Antoine Riard
1b33064554 Split provide_their_next_commitment_point from provide_secret
We needed it to be able to track remote_per_commitment_point
after channel opening and funds locking
2018-11-15 19:08:27 -05:00