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
90816dd9d8
Move a ton of Channel functions to ChannelError from HandleError
...
This is a big patch, but its all very mechanical, everything here
should be pretty obvious, and it all has to happen at once due to a
few common utility functions all having the same return type.
Note that this exposes a race in channel closure where we may
access a channel via some non-peer-specific mechanism like
forwarding an HTLC or sending a payment during the time between
the channel gave us a Close error and expected us to never call it
again and the time we actually removed it from the channel_state
set outside of the internal_* handler.
2018-11-20 16:33:32 -05:00
Matt Corallo
3155890766
Create simple ChannelMonitor-specific Err type
2018-11-20 16:31:41 -05:00
Matt Corallo
86944d34a1
Merge pull request #231 from philipr-za/philip-204-check-commitment-transaction-fee
...
Check funder can afford commitment transaction fee when receiving update_fee
2018-11-20 16:29:21 -05:00
Matt Corallo
7efaf2e8ac
Merge pull request #230 from ariard/handle_sizeable_push_msat
...
Handle sizeable push msat (fix #195 ) + handle two first per_commitment_point + keys interface tests
2018-11-20 15:51:27 -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
Matt Corallo
b14baa03ab
Merge pull request #253 from TheBlueMatt/2018-11-misc-tweaks
...
Misc Tweaks
2018-11-16 11:47:50 -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
8c638ffc81
Track local_commitment_tx at funding_created
...
Goal to claim sizeable push_msat and in event of
local commitment tx being broadcast without htlcs
2018-11-15 19:07:34 -05:00
Matt Corallo
968720344c
Panic if funding transaction has non-witness inputs
2018-11-15 12:25:09 -05:00
Matt Corallo
ed006f5e46
Clarify get_update_*_htlc docs and tweak one case slightly
2018-11-15 12:22:16 -05:00
Philip Robinson
a51dbb4a4d
Check affordability of new fee during update_fee call #204
2018-11-14 14:14:10 +02:00
Steven Roose
7ff7561f2d
Update to rust-bitcoin v0.15
2018-11-14 11:43:54 +00:00
Matt Corallo
224fb05cc5
Rebroadcast shutdown on channel_reestablish (and reprocess them)
2018-11-02 22:26:51 -04:00
Matt Corallo
527d036c1b
Delay closing_signed until update_fee exchanges complete
...
See https://github.com/lightningnetwork/lightning-rfc/issues/499
for a bit more about the ambiguity we're addressing here.
Also drop holding cell update_fee the same way we drop holding
cell update_add_htlcs when sending shutdown, resolving a bug.
2018-11-02 22:26:51 -04:00
Matt Corallo
78232f2aed
Fail incoming HTLCs sent after we start shutdown, not the chan
2018-11-02 22:26:51 -04:00
Matt Corallo
a11e27d20e
Send closing_signed when appropriate as pending HTLCs clear
2018-11-01 17:08:53 -04:00
Matt Corallo
1993ec0d12
Always send Shutdown resposnes to Shutdown messages
...
We always require that any changes to Channel state be committed
immediately (within the same lock) so we should never have
uncommitted changes which would prevent us from sending a Shutdown
response.
2018-11-01 17:06:07 -04:00
Matt Corallo
7bb598e525
Refactor out first-closing-sent creation
2018-11-01 17:05:56 -04:00
Matt Corallo
4eb8a4905c
Use ChannelError in shutdown handling, clean up, impl err actions
2018-11-01 13:50:03 -04:00
Schalk van Heerden
a0be4d1758
Added config interface to allow users to specify channel limits
2018-10-31 15:45:30 -04:00
Matt Corallo
9189d0e61d
Require at least 1k sat for outbound channels and meet BTC's dust
2018-10-31 15:45:30 -04:00
Matt Corallo
55a74b5dab
Use non-funder's funding block wait instead of max with ours
...
This is both required by the protocol and also makes sense - if
we're the funder we don't mind accepting payment on the channel
after one confirmation because we assume we won't double-spend
ourselves.
2018-10-31 15:45:30 -04:00
Matt Corallo
4a51f4f073
fix broken state comparison (thanks @yuntai!)
2018-10-27 09:58:10 -04:00
Matt Corallo
6ed5a829bb
Fix + test disconnect/reconnect prior to FundingLocked
2018-10-27 09:58:10 -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
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
47fe673c57
Give ChannelMonitor a logger via new ReadableArgs trait
2018-10-27 09:42:04 -04:00
Matt Corallo
c0c139cdc2
Fix and test update_add_htlc but disconnect pre-commitment_signed
2018-10-27 09:42:04 -04:00
Matt Corallo
e2de49ddc4
Respond to channel_reestablish out-of-band for ordered delivery
2018-10-27 09:42:04 -04:00
Antoine Riard
5180686b1d
Integrate destination_script from KeysInterface in ChannelManager/Channel
...
Drop channel_monitor_claim_key from ChannelKeys
2018-10-27 09:42:04 -04:00
Antoine Riard
32a9378909
Integrate shutdown_pubkey from KeysInterface in ChannelManager/Channel
...
Drop channel_close_key from ChannelKeys
2018-10-27 09:42:04 -04:00
Antoine Riard
e361fed0f1
Integrate KeysInterface to ChannelManager with Arc
2018-10-27 09:42:04 -04:00
Antoine Riard
d33cb3cca5
Add a KeysInterface which provides keys from user
...
Move ChannelKeys into keysinterface for generate a set of it from
master_seed and change return type to panic on bogus data
2018-10-27 09:34:45 -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
c36d23107c
Add Channel support for monitor-update-failed pausing
2018-10-23 16:03:30 -04:00
Matt Corallo
695eec23c4
Pull out regenerating RAA/CS in channel_reestablish handling
2018-10-23 16:03:30 -04:00
Matt Corallo
f059d9ce3f
Fix reconnect message order on remote updates while waiting on RAA
2018-10-23 15:26:11 -04:00
Matt Corallo
e86c84b2be
Add message ordering return value to handling channel_reestablish
2018-10-23 15:26:11 -04:00
Yuntai Kyong
d3ca7da672
Some changes in comments and error messages.
2018-10-23 10:50:03 -04:00
Yuntai Kyong
ed30a199e3
Error handling in decoding onion
2018-10-23 10:44:40 -04:00
Matt Corallo
df88525d44
Ensure channel is live, not usable for sending fee updates
...
+ a freebie TODO removal
2018-10-17 21:28:22 -04:00
Matt Corallo
1fe616db5a
Fix + test funding tx confirmation while peer is disconnected
2018-10-16 16:36:29 -04:00
Matt Corallo
17375b0551
Fix channel_reestablish exchanging in case of lost messages
...
This uses the new storage in HTLC state enums to reproduce the
various updates in a CommitmentUpdate group which is obviously
required to re-send a commitment_update after pending unreceived
updates were dropped.
Does not yet handle dropped update_fee updates properly.
2018-10-15 22:03:12 -04:00
Matt Corallo
b4dcbfa569
Store onion packet in OutboundHTLCState so we can regen update_add
2018-10-15 21:52:41 -04:00
Matt Corallo
4b231d5e6d
Store per-state HTLC data in the state enum itself (and store more)
2018-10-15 21:52:41 -04:00
Matt Corallo
99e01b2a64
Further simplify get_{inbound,outbound}_pending_htlc_stats
2018-10-06 12:06:29 +09:00
Yuntai Kyong
1f93a838c7
Split get_pending_htlc_stats
...
to get_inbound_pending_htlc_stats and get_outbound_pending_htlc_stats
2018-10-06 12:06:29 +09:00