Matt Corallo
e5c1716f5c
Refactor HTLCForwardInfo into an enum in prep for delayed-fail
2018-12-20 22:56:32 -05:00
Matt Corallo
4aa814d53c
macro-out a bunch of PendingHTLCsForwardable+forward calls
2018-12-20 22:56:32 -05:00
Matt Corallo
04ff26efa9
Move process_onion_failure into onion_utils
2018-12-20 22:56:32 -05:00
Matt Corallo
3bfea5b659
Merge pull request #275 from TheBlueMatt/2018-12-manager-split
...
Split up ChannelManager
2018-12-20 14:59:22 -05:00
Matt Corallo
28e2480c6e
Drop needless mut found by rustc 1.22
2018-12-20 14:32:02 -05:00
Matt Corallo
2053edbe53
Move ChannelManager network tests into their own module
2018-12-20 14:32:02 -05:00
Matt Corallo
dcaa53d560
Move onion encryption/decryption/etc into an onion_utils module
2018-12-19 20:36:34 -05:00
Matt Corallo
6cf8158519
Drop channel_held_info which was only for the channel fuzz target
2018-12-19 20:36:34 -05:00
Matt Corallo
50ed320503
Merge pull request #270 from TheBlueMatt/2018-12-drop-rust-crypto
...
Drop rust-crypto for bitcoin_hashes
2018-12-19 20:35:46 -05:00
Matt Corallo
f5dc762754
trace_log more in channelmonitor
2018-12-19 20:02:36 -05:00
Matt Corallo
7ea39a13b2
Use bitcoin_hashes' fixed_time_eq, removing the rust-crypto dep
2018-12-19 20:02:36 -05:00
Matt Corallo
202c0aedcb
Drop rust-crypto trait usage
2018-12-19 20:02:36 -05:00
Matt Corallo
7511a82195
Steal rust-crypto's Poly1305 implementation wholesale
2018-12-19 20:02:36 -05:00
Matt Corallo
09c7f2f641
Steal rust-crypto's ChaCha20 implementation wholesale
2018-12-19 20:02:36 -05:00
Matt Corallo
8e07259326
Use bitcoin_hashes' Ripemd160/Hash160 from rust-crypto+rust-bitcoin
...
Note that this requires rewriting full_stack_target tests, which
sucks, but it does let the fuzzer hit more stuff since the real
ripemd160 isn't ever actually called anymore.
2018-12-19 20:02:36 -05:00
Matt Corallo
f1e400f142
Switch Sha256 to using bitcoin_hashes and our own HKDF
2018-12-19 17:13:25 -05:00
Matt Corallo
f904690b00
Change the way channel keys are generated
...
This fixes a somewhat-misuse of HKDF in ChannelKeys::new_from_seed,
but much more importantly removes a use of rust-crypto's HKDF funcs
2018-12-17 23:55:38 -05:00
Matt Corallo
ec513b81df
Merge pull request #274 from TheBlueMatt/2018-12-243-review
...
Onion Error Handling
2018-12-17 23:33:22 -05:00
Matt Corallo
caeff85368
Update incorrect_payment_amount generation/handling for BOLT uptd
...
ie dont generate them as they're a really obvious privacy leak.
Luckily we were already handling them the same aside from log
printing so don't have to touch anything there. I was lazy in
updating tests but it only effects log printing, so whatever.
2018-12-17 22:57:47 -05:00
Yuntai Kyong
3f4ab940d4
Add tests for process_onion_failure return value sanity
2018-12-17 22:55:45 -05:00
Matt Corallo
8783a748bb
Add test_util for overriding session privs for onion crypt
2018-12-17 22:55:45 -05:00
Matt Corallo
38702358d1
Add some additional channel-creation-broadcast-msg sanity checks
2018-12-17 22:55:45 -05:00
Matt Corallo
b7e76c5c40
Always return malformed for BADONION errors
...
Also be willing to forward something with a pubkey that we know is
complete garbage, but upstream will just fail that with BADONION
when they get it.
I think this is kinda intended by the spec, but it definitely needs
to be clarified.
2018-12-17 22:55:45 -05:00
Matt Corallo
7cfb09c797
Add TODO noting confusion over |20 (channel_disabled) definition
2018-12-17 22:55:45 -05:00
Yuntai Kyong
4839ef7b83
Include flags when sending channel_disabled onion errors
2018-12-17 22:55:45 -05:00
Yuntai Kyong
7a8bec750d
Rewrite most of process_onion_failure
2018-12-17 22:55:45 -05:00
Yuntai Kyong
096892cefe
Swap an if let for a match and add some TODO
2018-12-17 22:55:45 -05:00
Matt Corallo
077b8e8c32
Merge pull request #273 from ariard/2018-12-17-replace-by-permanent-channel-failure
...
Replace some unknown_next_peer by permanent_channel_failure
2018-12-17 22:55:22 -05:00
Antoine Riard
b1712eb38e
Replace some unknown_next_peer by permanent_channel_failure
2018-12-17 20:47:19 -05:00
Matt Corallo
832fc4fd44
Merge pull request #269 from TheBlueMatt/2018-12-198-review
...
Detect HTLC-resolving on-chain actions and pass them to ChannelManager
2018-12-17 12:11:36 -05:00
Matt Corallo
d56b47968c
Add some TODOs for correctness in ChannelMonitor
2018-12-14 17:01:12 -05:00
Matt Corallo
d0dfaf8abc
Add constant for HTLC failure anti-reorg delay
2018-12-14 17:01:12 -05:00
Matt Corallo
150e9f0f8c
Include the node id in ChannelManager test logs
2018-12-14 17:01:12 -05:00
Matt Corallo
f5ccd4b4ef
Add additional log traces in channelmonitor/manager
2018-12-14 17:01:12 -05:00
Antoine Riard
ea6e9a7880
Add logging of HTLC outputs resolved by remote peer justice tx
...
In case of broadcast of revoked local commitment tx, we may be
interested that we've screwed up
2018-12-14 17:00:51 -05:00
Antoine Riard
7a483e597c
Typify payment_hash and payment_preimage
...
Fix variable name as payment_hash instead of txid for index
of remote_hash_commitment_number in ChannelMonitor reader
2018-12-14 17:00:50 -05:00
Matt Corallo
cdbd2ef5a2
Add bigger test for failing HTLCs claimed through revocation
2018-12-14 17:00:22 -05:00
Antoine Riard
0e9ac1144b
Add test for failing/fulfilling HTLCs from on-chain actions
...
Including detection of timeout claims, fulfill claims, and
failing all current HTLCs in case of revoked-commitment broadcast.
2018-12-14 17:00:22 -05:00
Antoine Riard
b1e313f26d
Add const ACCEPTED_HTLC_SCRIPT_WEIGHT and OFFERED_HTLC_SCRIPT_WEIGHT to
...
ease readability
Conditionnal compilation for weight of second one to handle test special
cltv values
2018-12-14 17:00:22 -05:00
Matt Corallo
badda94022
Generate PaymentFailed events for outbound payments we fail
2018-12-14 17:00:22 -05:00
Matt Corallo
221bfa6bd4
Move monitor-generated HTLC event handling to manager event-getters
...
This is somewhat awkward, but prevents a slew of duplicate events.
Really this should probably be more explicit, but would be easy to
move that along with a slew of block_connected-event-processing
refactors, see-also GH #80 .
This affects full_stack_target only on accident cause the demo test
didn't continue onwards with another block connection.
2018-12-14 17:00:22 -05:00
Matt Corallo
b9c609eb6a
Fail all pending HTLCs if the remote broadcasts a revoked tx
2018-12-14 16:46:27 -05:00
Antoine Riard
7499a4bf9b
Detect onchain timeout of a HTLC in ChannelManager block_connected
...
Pass failure backward
2018-12-13 11:53:44 -05:00
Antoine Riard
96d17ee737
Add is_resolving_output in ChannelMonitor
...
Called in ChannelMonitor block_connected, returning
HTLCUpdate upstream via ManyChannelMonitor to
link htlcs between monitors. Used by ChannelManager to
fulfill/fail htlcs backwards accordingly
If spurrious HTLCUpdate are generated due to block re-scan
and htlc are already LocalRemoved, discard them in
channel get_update_*_htlc
2018-12-13 11:53:44 -05:00
Matt Corallo
3b7ef49ef6
Return refs from build_commitment_transaction, removing clone()s
2018-12-13 11:12:07 -05:00
Antoine Riard
160d63dba0
Track HTLCSource in ChannelMonitor
...
Insert it in current_local_signed_tx, prev_local_signed_tx,
remote_claimable_outpoints. For so get it provided by
Channel calls to provide_latest_{local,remote}_tx
2018-12-13 11:12:07 -05:00
Antoine Riard
664ae42257
Track outputs fron local commitment tx
...
Aims to detect onchain resolution of channel
Modify in consequence test_txn_broadcast to still pass
channel_monitor_network_test
Modify some tests due to block re-scan caused by
detections extensions
2018-12-11 16:47:02 -05:00
Matt Corallo
302f1314e5
Merge pull request #266 from TheBlueMatt/2018-12-closing_signed-3-leg-commitment
...
Remove check which makes us sometimes never send closing_signed
2018-12-11 16:40:22 -05:00
Matt Corallo
0bf783ee4a
Merge pull request #263 from TheBlueMatt/2018-12-monitor-fail-2
...
Handle monitor update failures in msg-recv functions
2018-12-11 14:55:16 -05:00
Matt Corallo
42da58c0c1
Expand comment on ChannelMonitorUpdateErr::PermanentFailure a bit
2018-12-11 13:17:45 -05:00