Antoine Riard
cb53ae76f3
Log resolution of offered HTLC by HTLC-timeout tx
2019-01-02 21:06:04 -05:00
Matt Corallo
f5dc762754
trace_log more in channelmonitor
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
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
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
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
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
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
42da58c0c1
Expand comment on ChannelMonitorUpdateErr::PermanentFailure a bit
2018-12-11 13:17:45 -05:00
Matt Corallo
79c0f98c1f
Check tx output matches monitor output data (and is sufficient len)
...
Fixes a panic found by fuzzer in case the monitor per-commitment
data is garbage. We had a similar check for revoked commitment tx
but didn't copy it down to non-revoked commitment tx, so do that
now.
2018-12-10 15:06:35 -05:00
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
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
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
3155890766
Create simple ChannelMonitor-specific Err type
2018-11-20 16:31:41 -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
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
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
Antoine Riard
f88f826b28
Add TxOut in DynamicOutput
2018-11-15 19:07:34 -05:00
Antoine Riard
04e6be9f00
Implement spendable output to_local output on local commitment tx
2018-11-15 19:07:34 -05:00
Steven Roose
7ff7561f2d
Update to rust-bitcoin v0.15
2018-11-14 11:43:54 +00:00
Matt Corallo
64bd2eaa7f
Give ManyChannelMonitor a logger and trace add_update events
2018-10-29 14:26:05 -04:00
Matt Corallo
a2fb3ccc08
Implement and document Channel/ChannelManager (de)serialization
2018-10-27 09:58:10 -04:00
Matt Corallo
b2bd64d2eb
Store+expose bits of Channel[Monitor] to figure out local state
2018-10-27 09:42:04 -04:00
Matt Corallo
6f08779b04
Track ChannelMonitor-watched-outpoints (+ remove now-uesless Mutex)
2018-10-27 09:42:04 -04:00
Matt Corallo
56513f2927
Track last_block_hash in ChannelMonitor and expose it on deser
...
Also make block_connected take a &mut self to ensure serialized
state will always be self-consistent.
2018-10-27 09:42:04 -04:00
Matt Corallo
612e2801f8
Redo ChannelMonitor deserialization to avoid read_to_end()
...
This slightly changes the serialization format, but we're still
early enough that that's OK.
2018-10-27 09:42:04 -04:00
Matt Corallo
47fe673c57
Give ChannelMonitor a logger via new ReadableArgs trait
2018-10-27 09:42:04 -04:00
Antoine Riard
8c235d9e28
Generate Events from ChannelMonitor to indicate spendable ouputs
...
Extend KeyStorage with delayed_payment_base_key and per_commitment_point
to derive local_delayed private key
2018-10-27 09:34:28 -04:00
Matt Corallo
497643a65b
Add basic sanity testing for channel monitor update failure handle
2018-10-23 16:03:30 -04:00
Matt Corallo
267b9a44df
ChannelManager support for monitor update failure in one place
2018-10-23 16:03:30 -04:00
Matt Corallo
d318184c9e
Avoid needless on-chain channel failing for timing-out HTLCs
...
See new comments in code for more details
2018-10-22 11:49:57 -04:00
Antoine Riard
09831934d1
Test htlc outputs single tx claim due to timeout case
2018-09-29 20:28:15 -04:00
Matt Corallo
ae8bd1ba48
Fix and test simple remote-revoked-commitment-output claiming
2018-09-29 20:27:05 -04:00
Matt Corallo
ea8a1f3506
Narrow check_spend_remote_htlc input/output count check.
...
This fixes a crash found by fuzztester where a 0-output tx causes a
[] panic (though this shouldn't happen in the real-world as
0-output txn should never be able to be mined).
2018-09-26 11:06:28 -04:00
Matt Corallo
6e1318b0e2
Make docs look nicer by adding explicit spacing
2018-09-20 12:58:10 -04:00
Matt Corallo
79a0a0c959
Migrate ChannelMonitor serialization to new ser framework(ish)
...
Sadly we can't straight up use the new serialization framework as
we have a few different serialization variants, but that's OK, it
looks identical and is just missing the Writeable impl
2018-09-20 10:46:13 -04:00
Matt Corallo
28d0d44e44
Move ChannelMonitor deserialization to new ser framework
2018-09-20 10:46:13 -04:00
Matt Corallo
3aeec96470
Add module and all-pub-things docs and deny missing docs
2018-09-19 23:07:02 -04:00