Commit graph

38 commits

Author SHA1 Message Date
Matt Corallo
68be3c0353 Test that we do not fail-backwards HTLCs that the remote on-chained 2018-09-14 15:27:54 -04:00
Matt Corallo
a55355e641 Ignore HTLC txn we dont know how to claim instead of unwrap()ing
This fixes a crash introduced in 3e149b1fb6
and introduces a test which will tickle the bug.
2018-09-14 15:27:39 -04:00
Matt Corallo
e9e27f277a There can only be one input in matched txn in ChannelMonitor
This lets us simplify a few tidbits of loop.
2018-09-13 14:05:08 -04:00
Matt Corallo
27d5a3a94f Optimize check_spend_remote HTLC a tad by avoiding indirections
Instead of hopping a pointer, we're only ever going to return one
Transaction at max, so skip the Vec. Also avoid
re-pubkey-converting the revocation key.
2018-09-13 14:05:08 -04:00
Antoine Riard
3e149b1fb6 Implement claiming of revoked HTLC transactions by ChannelMonitor
Refactor check_spend_remote_transaction in part to check_spend_remote_htlc to
avoid lock mess in block_connected. We need
remote_commitment_txn_on_chain to match remote HTLC tx
2018-09-12 23:50:58 +00:00
Antoine Riard
d84c084df7 Implement set_their_delayed_payment_base_key in ChannelMonitor
Needed to build redeemscript on HTLC-Success/HTLC-Timeout tx from
remote revoked commitment tx
2018-09-12 23:17:20 +00:00
Matt Corallo
c2bbeb5814 Update add_update_monitor docs to indicate registration req.
It wasn't entirely clear from the existing docs that it is the
responsibility of the implementor of ManyChannelMonitor to
register the relevant outpoint.
2018-09-08 10:33:32 -04:00
Antoine Riard
4b9adea006 Add registration of commitment tx's outputs from
check_spend_remote_transaction

Fixup more descriptive var names by Matt Corallo <git@bluematt.me>
2018-09-08 02:30:28 +00:00
Matt Corallo
90b545ffe3 Narrow ChainWatchInterface::install_watch_script 2018-09-08 02:30:28 +00:00
Matt Corallo
11e5975523 Update to rust-secp256k1 v0.11 and rust-bitcoin v0.14 2018-08-23 14:52:43 -04:00
Matt Corallo
482648bbf0 Fix fuzztarget insert_combine hash-collision panic 2018-08-02 22:26:44 -04:00
Savil Srivastava
ca6b44b8cc replace use of bitcoin::utils::misc::hex_bytes with hex::decode
as requested in #84 discussion
https://github.com/rust-bitcoin/rust-lightning/pull/84#discussion_r205508845
2018-07-27 18:19:00 -07:00
Matt Corallo
ab22bed7ed Fix OOM crash in ChannelMonitor::deserialize found by AFL 2018-07-23 15:01:25 -04:00
Matt Corallo
a611ae4741 Ensure the funding transaction is registered to be monitored 2018-07-22 13:59:11 -04:00
Savil Srivastava
fd141bbed2 [Error] rename msg field to action
this was a TODO and also briefly discussed in https://github.com/rust-bitcoin/rust-lightning/pull/43#pullrequestreview-135649551

I'm not fully sure how to remove the `Option`, and make it completely required. Would love suggestions. So, have omitted that for now. Plus, better to make smaller, incremental changes.

Test Plan:
`cargo build`
`cargo test`
2018-07-19 20:01:55 -07:00
Matt Corallo
68e6beab7c Expose the script_pubkey being monitored in chain watch (fixes #44) 2018-07-19 22:22:14 -04:00
Matt Corallo
b02176c86b Fix various spec bugs, can now open channels with real nodes!
* commitment transaction number, as used in locktime/sequence
   fields is actually different from commitment transaction number,
   as used for revocation state. This is confusing and never stated
   in the spec, so we have to do the conversion.
 * max_htlc_value_in_flight is never constrained in the spec, but
   we were requiring it be <= channel size. Instead just clamp the
   values the peer sends us when storing.
 * channel_id calculation was incorrect, we now do some crazy
   conversion hops, which we shouldn't, but will need to change our
   types to fix.
 * Our channel_reserve_satoshis value was too low, just change the
   constant and leave the TODO to figure out what it really should
   be for now.
2018-07-19 17:25:47 -04:00
Matt Corallo
4f644f225c Fix channelmonitor fuzz test failure 2018-07-18 13:36:31 -04:00
Matt Corallo
0b82f5584f Test channelmonitor serialization roundtrip doesn't mutate state 2018-07-17 14:59:29 -04:00
Matt Corallo
0553945e21 Implement channelmonitor (de)serialization (fixes #45) 2018-07-17 14:39:50 -04:00
Matt Corallo
9df3053575 Clarify ChannelMonitor remote commitment tracking and fix a race 2018-07-17 12:47:54 -04:00
Matt Corallo
a48fd6ddfa Move channelmonitor-update functions to pub(ln) from pub 2018-07-17 12:47:54 -04:00
Matt Corallo
98e5c5e4d3
Merge pull request #35 from TheBlueMatt/2018-06-post-32
Some cleanups after #32
2018-06-29 17:23:43 -04:00
Matt Corallo
b65aa86ea0
Merge pull request #33 from jeandudey/funding_txo
Use the `TxOutRef` type for the `ChannelMonitor`'s funding_txo field.
2018-06-29 17:23:34 -04:00
Matt Corallo
844097ec01 Greatly simplify channelmonitor pruning tests, and use real funcs
Instead of hooking into internal data structures and modifying
those, call the actual functions Channel will call and then check
that the preimages map is correct.
2018-06-29 17:02:51 -04:00
Matt Corallo
8926c25f53 Also avoid pruning preimages for previous local tx in ChannelMonitor 2018-06-29 16:44:19 -04:00
Matt Corallo
aec0fa485c A few minor test cleanups and remove new warnings from #32 2018-06-29 16:44:19 -04:00
Matt Corallo
04b0acc9dc Skip some a needless temporary vec and clean indentation after #32 2018-06-29 16:44:19 -04:00
Jean Pierre Dudey
d0e9137bc5 Add the OutPoint type for the ChannelMonitor's funding_txo field.
This structure replaces the (Sha256dHash, u16) tuple that was being used
for the funding output.

Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-06-29 12:12:17 -04:00
Antoine Riard
ef166420b0 Add pruning of preimages no longer needed + tests 2018-06-28 23:19:24 +00:00
Matt Corallo
2d8afeccdb Rewrite channelmonitor framework and implement a bunch of it 2018-04-24 20:42:24 -04:00
Matt Corallo
4d75d4c099 Minor cleanups 2018-04-16 20:35:21 -04:00
Matt Corallo
021b3643cc Hand payment preimages into channel monitors when claimed 2018-04-16 20:35:03 -04:00
Matt Corallo
890e3cb165 Update for new rust-bitcoin API, avoid some duplicate hashing 2018-04-02 18:06:59 -04:00
Matt Corallo
ab56b81acd Stub out Sha256 calls when fuzzing 2018-03-23 13:16:24 -04:00
Matt Corallo
a5ec986fad Clean up a few comments after #11 merge. 2018-03-19 17:46:35 -04:00
Tamas Blummer
fbe4f7a442 Split out BroadcastInterface, ChainWatchInterface monitors re-enter from called listeners 2018-03-19 16:14:19 -04:00
Matt Corallo
6185a28190 initial checkin 2018-02-16 18:09:48 -05:00