Commit graph

112 commits

Author SHA1 Message Date
Matt Corallo
475bee2bb7
Merge pull request #326 from TheBlueMatt/2019-03-temp-failure-use-cases
Update docs for TemporaryFailure to note other use-cases
2019-03-25 18:36:25 -04:00
Matt Corallo
b031bdf9d8 Update docs for TemporaryFailure to note other use-cases 2019-03-25 17:27:04 -04:00
Antoine Riard
3cc7666c5a Extract preimage from revoked HTLC-Success to claim backward
Tweaks by Matt Corallo <git@bluematt.me>
2019-03-25 16:39:48 -04:00
Tamas Blummer
02b541607b migration to rust-bitcoin 0.17
typedef Sha256dHash with bitcoin_hashes::sha256d::Hash
SecretKey -> PrivateKey.key
assume compressed public keys
2019-03-07 18:50:02 +01:00
Dimitris Apostolou
ab10b05075
Fix typos 2019-01-24 19:07:08 +02:00
Matt Corallo
7a77c9f1d2
Merge pull request #298 from TheBlueMatt/2019-01-271-cleanup
Implement serialize/deserialize for Router
2019-01-23 14:48:13 -05:00
Antoine Riard
70d06b4610 Implement Writeable/Readable for Option<T>
Add OptionalField in OpenChannel, AcceptChannel
ChannelReestablish to avoid serialization implementation
conflicts
2019-01-23 11:31:26 -05:00
Matt Corallo
8678bda576 Ensure Message always unwraps in fuzztarget
Hashes cant be all-0s, so we can normally unwrap, but fuzztarget
can generate all-0 hashes, so we have to handle it and swap for
something else.
2019-01-22 13:49:15 -05:00
Matt Corallo
12d25576c1 Upgrade to secp256k1 v12, bitcoin v16, and crates bitcoin_hashes 2019-01-22 13:49:15 -05:00
Matt Corallo
f065a62d40 Fix comment spelling and clarify algebra a bit. 2019-01-13 13:12:04 -05:00
Matt Corallo
d8707c2b20 Check for timing-out HTLCs in remote unrevoked commitments
This resolves a TODO/issue in would_broadcast_at_height where we
will not fail a channel with HTLCs which time out in remote
broadcastable transactions.
2019-01-13 12:59:19 -05:00
Matt Corallo
78939a7e03 Test for failing channel after local commitment dust HTLC timeout 2019-01-13 12:59:19 -05:00
Matt Corallo
92424ebbfe Merge tracking of HTLCs-in-commitment with outbound-HTLCs
This simplifies a few things, deduplicates a some small memory
overhead, and, most importantly, is a first step to fixing
would_broadcast_at_height.
2019-01-13 12:59:19 -05:00
Matt Corallo
09919d2af0 Make HTLCOutputInCommitment::transaction_output_index an Option
We really shouldn't have split out the with-source HTLCs from the
in-transaction HTLCs when we added back-failing, and will need
almost all of the info in HTLCOutputInCommitment for each HTLC to
fix would_broadcast_at_height, so this is a first step at
recombining them.
2019-01-11 16:03:40 -05:00
Matt Corallo
90ce97198c Simplify and expand logging in is_resolving_htlc_output
This clarifies all the conditions we can hit and also ensures they
are all logged in a clear and consistent manner.
2019-01-08 23:03:07 -05:00
Matt Corallo
bf96c809a5 Fix source name in is_resolving_htlc_output 2019-01-08 22:47:23 -05:00
Matt Corallo
c9df4bd011 Fix multi-remote-HTLC-claim preimage learning
When our counterparty claims multiple HTLCs from offered outputs in
one transaction we should still be able to learn the preimages.
Sadly, due to two bugs we were not previously doing so.
2019-01-08 22:47:23 -05:00
Matt Corallo
a5bcd5651d
Merge pull request #280 from TheBlueMatt/2018-12-no-to-remote-revoked-htlcs
Move fail-backwards up for no to-remote output claims
2019-01-05 17:07:40 -05:00
Matt Corallo
913d56ecab Macro-DRY HTLC back-fails for revoked remote transaction broadcast 2019-01-05 16:24:50 -05:00
Matt Corallo
0faf7bb094
Merge pull request #281 from ariard/harden-inbound-htlc-resolved
Harden test for logging of inbound htlc being resolved
2019-01-04 23:07:29 -05:00
Antoine Riard
cb53ae76f3 Log resolution of offered HTLC by HTLC-timeout tx 2019-01-02 21:06:04 -05:00
Matt Corallo
24577344fa Move fail-backwards up for no to-remote output claims
This fixes HTLC fail-backwards in case we haven't yet sent enough
to have a to_remote output to claim, plus some edge cases where it
could be removed due to a fee update, though hopefully that goes
away with simplified_commitment.
2018-12-31 20:26:07 -05:00
Matt Corallo
608cf1c89d Fail HTLC backwards on unrevoked remote commitment tx broadcast 2018-12-31 19:56:32 -05:00
Matt Corallo
ce08061518 Remove long-stale TODO 2018-12-22 07:03:17 -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