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
Matt Corallo
9373c5993f
Make message fields pub(crate) and hide a few internal fns
2018-09-19 23:07:02 -04:00
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