]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
4 years agoMove BogusHopData generation into test instead of OnionHopData.
Matt Corallo [Thu, 26 Dec 2019 18:45:44 +0000 (13:45 -0500)]
Move BogusHopData generation into test instead of OnionHopData.

This, as it should be, restricts OnionHopData to only being able to
represent valid states, while still allowing for tests to generate
bogus hop data fields to test deserialization.

4 years agoPull hmac out of OnionHopData.
Matt Corallo [Thu, 26 Dec 2019 18:43:43 +0000 (13:43 -0500)]
Pull hmac out of OnionHopData.

Its a bit awkward to have an hmac field covering the struct that
its in, and there is little difference in removing it, so just pull
it out and use a [u8; 32] where we care about the hmac.

4 years agoFlatten OnionHopData struct with the Realm0 struct.
Matt Corallo [Tue, 24 Dec 2019 20:52:47 +0000 (15:52 -0500)]
Flatten OnionHopData struct with the Realm0 struct.

Previously OnionHopData contained a OnionRealm0HopData field however
instead of bumping the realm number, it has been replaced with a
length, used to indicte the length of a TLV-formatted object.

Because a TLV-formatted hop data can contain the same information as
a realm-0 hop data, we flatten the field and simply keep track of
what format it was in.

4 years agoBetter document msg fuzz target behavior and be slightly more strict
Matt Corallo [Fri, 27 Dec 2019 22:29:51 +0000 (17:29 -0500)]
Better document msg fuzz target behavior and be slightly more strict

4 years agoMerge pull request #459 from ariard/2020-01-fix-htlc-height-timer
Matt Corallo [Sat, 25 Jan 2020 22:11:27 +0000 (22:11 +0000)]
Merge pull request #459 from ariard/2020-01-fix-htlc-height-timer

Fix bumping timer for claiming revoked HTLC outputs

4 years agoMerge pull request #460 from lightning-signer/channel-value
Matt Corallo [Sat, 25 Jan 2020 21:17:12 +0000 (21:17 +0000)]
Merge pull request #460 from lightning-signer/channel-value

Channel value to ChannelKeys constructor

4 years agoMerge pull request #458 from TheBlueMatt/2020-01-spendable-docs
Matt Corallo [Sat, 25 Jan 2020 20:50:10 +0000 (20:50 +0000)]
Merge pull request #458 from TheBlueMatt/2020-01-spendable-docs

Clean up documentation around spendable outputs significantly.

4 years agoMerge pull request #443 from valentinewallace/channelmgr-arcs-to-derefs
Matt Corallo [Sat, 25 Jan 2020 20:41:10 +0000 (20:41 +0000)]
Merge pull request #443 from valentinewallace/channelmgr-arcs-to-derefs

Drop ChannelManager's ChannelMonitor Arc for Deref

4 years agoClean up documentation around spendable outputs significantly. 2020-01-spendable-docs
Matt Corallo [Wed, 22 Jan 2020 23:31:57 +0000 (18:31 -0500)]
Clean up documentation around spendable outputs significantly.

 * Fixed a number of grammar issues
 * Clarified the docs for users who are intimately farmiliar with
   arbitrary lines of text copied from the BOLTs
 * Added a bit more text so that things are easier to read and less
   disjoint.
 * Clarified exactly how the witness stack should look since I had
   to go dig for it.

4 years agoUpdate ChannelManager's ChannelMonitor Arc to be a Deref 2020-01-443-final-nits
Valentine Wallace [Thu, 16 Jan 2020 18:26:38 +0000 (13:26 -0500)]
Update ChannelManager's ChannelMonitor Arc to be a Deref

Additional changes:
* Update fuzz crate to match ChannelManager's new API
* Update lightning-net-tokio library to match ChannelManager's new ChannelMonitor Deref API
* Update tests to match ChannelManager's new ChannelMonitor Deref API

4 years agoRemove unnecessary sign_closing_transaction arg
Devrandom [Thu, 23 Jan 2020 22:32:29 +0000 (14:32 -0800)]
Remove unnecessary sign_closing_transaction arg

4 years agochannel value to ChannelKeys constructor
Devrandom [Thu, 23 Jan 2020 21:33:31 +0000 (13:33 -0800)]
channel value to ChannelKeys constructor

4 years agoFix bumping timer for claiming revoked HTLC outputs
Antoine Riard [Thu, 23 Jan 2020 00:51:19 +0000 (19:51 -0500)]
Fix bumping timer for claiming revoked HTLC outputs

Previously, we were using their_to_self_delay instead of
our_to_self_delay which was falsifying test.

4 years agoMerge pull request #457 from ariard/2020-01-fix-append-onchain
Matt Corallo [Wed, 22 Jan 2020 20:57:36 +0000 (20:57 +0000)]
Merge pull request #457 from ariard/2020-01-fix-append-onchain

Fix spurious calls of broadcast_by_local_state

4 years agoMerge pull request #433 from TheBlueMatt/2019-12-features-in-routes
Matt Corallo [Wed, 22 Jan 2020 20:18:30 +0000 (20:18 +0000)]
Merge pull request #433 from TheBlueMatt/2019-12-features-in-routes

Plumb Features through into Routes

4 years agoFix spurious calls of broadcast_by_local_state
Antoine Riard [Wed, 22 Jan 2020 18:53:12 +0000 (13:53 -0500)]
Fix spurious calls of broadcast_by_local_state

4 years agoDRY-up list_channels by having a common lister that takes a filter 2019-12-features-in-routes
Matt Corallo [Fri, 17 Jan 2020 22:36:46 +0000 (17:36 -0500)]
DRY-up list_channels by having a common lister that takes a filter

4 years agoPass node features through to RouteHops
Matt Corallo [Sat, 28 Dec 2019 06:10:14 +0000 (01:10 -0500)]
Pass node features through to RouteHops

This exposes the latest Init-context features in the ChannelDetails
passed to the Router during route calculation, which combines those
with the Node-context features tracked from node_announcements to
provide the latest Node-context features in RouteHop structs.

Fields are also added for Channel-context features, though those are
only partially used since no such features are defined today anyway.

These will be useful when determining whether to use new
TLV-formatted onion hop datas when generating onions for peers.

4 years agoKeep track of the Init Features for every connected/channel'd peer
Matt Corallo [Sun, 29 Dec 2019 19:22:43 +0000 (14:22 -0500)]
Keep track of the Init Features for every connected/channel'd peer

Since we want to keep track of the Init-context features for every
peer we have channels with, we have to keep them for as long as the
peer is connected (since we may open a channel with them at any
point).

We go ahead and take this opportunity to create a new per-peer-state
struct which has two levels of mutexes which is appropriate for
moving channel storage to.

Since we can't process messages from a given peer in parallel, the
inner lock is a regular mutex, but the outer lock is RW so that we
can process for different peers at the same time with an outer read
lock.

4 years agoPass peer's Init message through to ChannelManager
Matt Corallo [Sat, 28 Dec 2019 03:50:42 +0000 (22:50 -0500)]
Pass peer's Init message through to ChannelManager

4 years agoMerge pull request #451 from lightning-signer/txkeys
Matt Corallo [Mon, 20 Jan 2020 03:46:00 +0000 (03:46 +0000)]
Merge pull request #451 from lightning-signer/txkeys

Provide remote channel public keys to signer

4 years agoUse ChannelPublicKeys in Channel
Devrandom [Fri, 17 Jan 2020 22:31:29 +0000 (14:31 -0800)]
Use ChannelPublicKeys in Channel

4 years agoHide derived fields in TxCreationKeys
Devrandom [Fri, 17 Jan 2020 20:46:54 +0000 (12:46 -0800)]
Hide derived fields in TxCreationKeys

4 years agoProvide remote channel public keys to signer
Devrandom [Fri, 17 Jan 2020 00:51:15 +0000 (16:51 -0800)]
Provide remote channel public keys to signer

4 years agoMerge pull request #447 from ariard/2020-01-fix-weight-computation
Matt Corallo [Fri, 17 Jan 2020 22:32:29 +0000 (22:32 +0000)]
Merge pull request #447 from ariard/2020-01-fix-weight-computation

Bound incoming HTLC witnessScript to min/max limits

4 years agoBound incoming HTLC witnessScript to min/max limits
Antoine Riard [Tue, 14 Jan 2020 18:47:01 +0000 (13:47 -0500)]
Bound incoming HTLC witnessScript to min/max limits

Fix a crash where previously we weren't able to detect any accepted
HTLC if its witness-encoded cltv expiry was different from expected
ACCEPTED_HTLC_SCRIPT_WEIGHT. This should work for any cltv expiry
included between 0 and 16777216 on mainnet, testnet and regtest.

4 years agoFix crash when a claim tx has some non-witness inputs.
Matt Corallo [Mon, 13 Jan 2020 18:43:54 +0000 (13:43 -0500)]
Fix crash when a claim tx has some non-witness inputs.

The logger which decides what to refer to an on-chain claim tx was
assuming that all inputs would have a witness. While this was fine
for the one-input case, it broke the fuzzer which was connecting a
consensus-invalid transaction. Further, in the case we have multiple
inputs, some may not have a witness, which we shouldn't crash on.

This fixes 9df0250dbbad7449e3ec8f90532ce9197eb31997.

4 years agoMerge pull request #450 from ariard/2020-01-fix-fst-blk-disconnection
Matt Corallo [Fri, 17 Jan 2020 20:13:46 +0000 (20:13 +0000)]
Merge pull request #450 from ariard/2020-01-fix-fst-blk-disconnection

Fix full_stack_target block disconnection

4 years agoFix full_stack_target mishandling of block disconnection
Antoine Riard [Fri, 17 Jan 2020 19:21:02 +0000 (14:21 -0500)]
Fix full_stack_target mishandling of block disconnection

4 years agoLog block disconnection in ChannelMonitor
Antoine Riard [Fri, 17 Jan 2020 19:20:23 +0000 (14:20 -0500)]
Log block disconnection in ChannelMonitor

4 years agoMerge pull request #448 from lightning-signer/visibility-for-test
Matt Corallo [Thu, 16 Jan 2020 23:54:09 +0000 (23:54 +0000)]
Merge pull request #448 from lightning-signer/visibility-for-test

Increase visibility for external integration tests

4 years agoincrease visibility for external integration tests
Devrandom [Wed, 15 Jan 2020 21:59:23 +0000 (13:59 -0800)]
increase visibility for external integration tests

4 years agoMerge pull request #444 from lightning-signer/funding-script
Matt Corallo [Thu, 16 Jan 2020 22:02:20 +0000 (22:02 +0000)]
Merge pull request #444 from lightning-signer/funding-script

Construct funding redeem script in signer

4 years agoconstruct funding redeem script in signer
Devrandom [Fri, 10 Jan 2020 01:28:48 +0000 (17:28 -0800)]
construct funding redeem script in signer

4 years agoMerge pull request #449 from jkczyz/2020-01-remove-borrow-parts
Matt Corallo [Thu, 16 Jan 2020 20:18:13 +0000 (20:18 +0000)]
Merge pull request #449 from jkczyz/2020-01-remove-borrow-parts

Remove unnecessary borrow_parts() methods

4 years agoRemove unnecessary borrow_parts() methods
Jeffrey Czyz [Thu, 16 Jan 2020 18:48:16 +0000 (10:48 -0800)]
Remove unnecessary borrow_parts() methods

Accessing a struct through an std::syn::MutexGuard using implicit
dereferencing can confuse the borrow checker. This situation arises when
obtaining mutable references to more than one field of the struct, which
is normally allowed.

https://doc.rust-lang.org/nomicon/borrow-splitting.html

However, when using implicit dereferencing, a mutable reference to the
the entire struct is taken. Thus, attempting to access another field in
this manner will lead to a compilation error.

https://doc.rust-lang.org/error-index.html#E0499

A simple way to avoid this is to first obtain a mutable reference to the
struct using explicit dereferencing.

4 years agoMerge pull request #428 from TheBlueMatt/2019-12-flat-features
Matt Corallo [Mon, 13 Jan 2020 22:53:54 +0000 (22:53 +0000)]
Merge pull request #428 from TheBlueMatt/2019-12-flat-features

Implement Flat Features

4 years agoSeal the features contexts 2019-12-flat-features
Matt Corallo [Wed, 8 Jan 2020 00:21:17 +0000 (19:21 -0500)]
Seal the features contexts

4 years agoMove features into a separate module out of msgs.
Matt Corallo [Mon, 6 Jan 2020 22:54:02 +0000 (17:54 -0500)]
Move features into a separate module out of msgs.

4 years agoRefactor features a bit more to describe what the constructors do
Matt Corallo [Mon, 13 Jan 2020 18:52:23 +0000 (13:52 -0500)]
Refactor features a bit more to describe what the constructors do

The Features::new() method is nonsense and doesn't describe what
features were being set - we introduce an empty() and supported()
constructors instead.

4 years agoFix Feature endianness by swapping bytes on read/write.
Matt Corallo [Mon, 13 Jan 2020 18:50:29 +0000 (13:50 -0500)]
Fix Feature endianness by swapping bytes on read/write.

The spec is a bit mum on feature endianness, so I suppose it falls
under the "everything is big endian unless otherwise specified"
clause, but we were treating it as little.

4 years agoRelay/store channel/node announces w/ unknown req'd feature bits
Matt Corallo [Tue, 24 Dec 2019 18:08:33 +0000 (13:08 -0500)]
Relay/store channel/node announces w/ unknown req'd feature bits

This change was made in the flat features BOLT PR, as if a channel
requires some unknown feature bits we should still rumor it, we just
shouldn't route through it.

4 years agoImplement Flat Features
Matt Corallo [Mon, 23 Dec 2019 22:52:58 +0000 (17:52 -0500)]
Implement Flat Features

This merges local and global features into one struct, which is
parameterized by where it appers. The parameterization restricts
which queries can be made and which features can be set, in line
with the latest BOLT 9.

Closes #427.

4 years agoMerge pull request #439 from TheBlueMatt/2020-01-398-fixups
Matt Corallo [Mon, 6 Jan 2020 03:59:03 +0000 (03:59 +0000)]
Merge pull request #439 from TheBlueMatt/2020-01-398-fixups

398 with nits fixed.

4 years agoDrop Result for ChannelMessageHandler methods 2020-01-398-fixups
Antoine Riard [Tue, 5 Nov 2019 23:51:05 +0000 (18:51 -0500)]
Drop Result for ChannelMessageHandler methods

Simplify interfaces between ChannelMessageHandler and PeerManager,
by switching all ChannelMessageHandler errors to HandleError sent
internally instead of being return. With further refactors in Router
and PeerChannelEncryptor, errors management on the PeerManager-side
won't be splitted between try_potential_handleerror and HandleError
processing.

Inside ChannelManager, we now log MsgHandleErrInternal and send
ErrorAction to PeerManager.

On a high-level, it should allow client using API to be more flexible
by polling events instead of waiting function call returns.

We also update handle_error macro to take channel_state_lock from
caller which should avoid some deadlock potential for some edges
cases.

Filter out IgnoreError in handle_error macro, update test in
consequence.

4 years agoAdd assert_log method to TestLogger to harden test
Antoine Riard [Mon, 30 Dec 2019 22:30:27 +0000 (17:30 -0500)]
Add assert_log method to TestLogger to harden test

Extend mock Node with logger.

4 years agoMerge pull request #437 from Aleru/new-api-ping
Matt Corallo [Sun, 5 Jan 2020 17:49:12 +0000 (17:49 +0000)]
Merge pull request #437 from Aleru/new-api-ping

New API for ping generation

4 years agoNew API for ping generation
Aleru [Fri, 20 Sep 2019 15:16:45 +0000 (11:16 -0400)]
New API for ping generation

New API for generating pings

4 years agoMerge pull request #420 from TheBlueMatt/2019-12-chan-ext-signer
Matt Corallo [Sat, 28 Dec 2019 17:50:09 +0000 (17:50 +0000)]
Merge pull request #420 from TheBlueMatt/2019-12-chan-ext-signer

Remove signing from Channel

4 years agoSign local HTLC transactions at broadcast-time, instead of generate 2019-12-chan-ext-signer
Matt Corallo [Fri, 13 Dec 2019 19:56:57 +0000 (14:56 -0500)]
Sign local HTLC transactions at broadcast-time, instead of generate

4 years agoMake ChannelMonitor sign local transactions (at broadcast time)
Matt Corallo [Fri, 13 Dec 2019 06:58:08 +0000 (01:58 -0500)]
Make ChannelMonitor sign local transactions (at broadcast time)

4 years agoSet basic channel info in chanmon all at once, add a bit more info
Matt Corallo [Thu, 12 Dec 2019 19:56:28 +0000 (14:56 -0500)]
Set basic channel info in chanmon all at once, add a bit more info

4 years agoDrop duplicative current-local-tx storage in channel.
Matt Corallo [Fri, 13 Dec 2019 03:42:08 +0000 (22:42 -0500)]
Drop duplicative current-local-tx storage in channel.

We now have current-local-tx broadcast ability in channel monitors
directly (for ChannelManager deserialization), so we can just use
that instead of always having the Channel store signed ready-to-go
copies of the latest local commitment transaction.

This is further kinda nice since ChannelMonitor is live and can, eg
broadcast HTLC-Success transactions immediately as they will be
generated at broadcast time instead of in advance.

Finally, this lets us clean up a tiny bit in Channel.

4 years agoFix parameter name incorrectly changed in 4ebe64fafd2ca0e17aab31fb0
Matt Corallo [Tue, 24 Dec 2019 17:01:26 +0000 (12:01 -0500)]
Fix parameter name incorrectly changed in 4ebe64fafd2ca0e17aab31fb0

4 years agoMerge pull request #426 from TheBlueMatt/2019-12-bad-lifetimes
Matt Corallo [Sat, 21 Dec 2019 00:35:10 +0000 (00:35 +0000)]
Merge pull request #426 from TheBlueMatt/2019-12-bad-lifetimes

Remove unused lifetimes.

4 years agoRemove unused lifetimes. 2019-12-bad-lifetimes
Matt Corallo [Fri, 20 Dec 2019 19:53:16 +0000 (14:53 -0500)]
Remove unused lifetimes.

f71518365f61a5fe2a0340953ad6592c0d2b72cc added a series of lifetimes
which were required for an earlier version of the patch but not the
final version. They can be freely removed.

4 years agoMerge pull request #419 from TheBlueMatt/2019-12-simple-signer-api-step
Matt Corallo [Fri, 13 Dec 2019 22:04:53 +0000 (22:04 +0000)]
Merge pull request #419 from TheBlueMatt/2019-12-simple-signer-api-step

Few more simple signer API additions

4 years agoUse external key signer to generate closing transaction signatures 2019-12-simple-signer-api-step
Matt Corallo [Fri, 13 Dec 2019 06:57:45 +0000 (01:57 -0500)]
Use external key signer to generate closing transaction signatures

4 years agoSign channel_announcements via a new ChannelKeys API
Matt Corallo [Sat, 7 Dec 2019 22:54:55 +0000 (17:54 -0500)]
Sign channel_announcements via a new ChannelKeys API

4 years agoUse EnforcingChannelKeys in fuzz targets to get more coverage
Matt Corallo [Fri, 6 Dec 2019 19:08:34 +0000 (14:08 -0500)]
Use EnforcingChannelKeys in fuzz targets to get more coverage

4 years agoMerge pull request #404 from TheBlueMatt/2019-11-signer-api
Matt Corallo [Thu, 12 Dec 2019 18:01:46 +0000 (18:01 +0000)]
Merge pull request #404 from TheBlueMatt/2019-11-signer-api

Replace keys API with Signer API to support hardware wallets eventually

4 years agoMerge pull request #417 from TheBlueMatt/2019-12-ver-bump
Matt Corallo [Thu, 12 Dec 2019 16:45:18 +0000 (16:45 +0000)]
Merge pull request #417 from TheBlueMatt/2019-12-ver-bump

Bump to 0.0.10

4 years agoBump versions to 0.0.10 2019-12-ver-bump
Matt Corallo [Wed, 11 Dec 2019 20:41:39 +0000 (15:41 -0500)]
Bump versions to 0.0.10

4 years agoBump bitcoin dep to 0.21
Matt Corallo [Wed, 11 Dec 2019 20:41:24 +0000 (15:41 -0500)]
Bump bitcoin dep to 0.21

4 years agoPre-build fuzz targets at once in travis instead of as we need them
Matt Corallo [Wed, 11 Dec 2019 23:17:03 +0000 (18:17 -0500)]
Pre-build fuzz targets at once in travis instead of as we need them

4 years agoDocument more current security assumption of KeysInterface 2019-11-signer-api
Antoine Riard [Tue, 10 Dec 2019 20:04:53 +0000 (15:04 -0500)]
Document more current security assumption of KeysInterface

Improve some comments of interface methods.

4 years agoMake commitment transaction signing a part of ChannelKeys.
Matt Corallo [Wed, 27 Nov 2019 21:08:48 +0000 (16:08 -0500)]
Make commitment transaction signing a part of ChannelKeys.

This adds a new fn to ChannelKeys which is called when we generte
a new remote commitment transaction for signing. While it may be
theoretically possible to unwind state updates by disconnecting and
reconnecting as well as making appropriate state machine changes,
the effort required to get it correct likely outweighs the UX cost
of "preflighting" the requests to hardwre wallets.

4 years agoMake ChannelKeys an API and template Channel with it.
Matt Corallo [Tue, 26 Nov 2019 21:46:33 +0000 (16:46 -0500)]
Make ChannelKeys an API and template Channel with it.

Instead of having in-memory access to the list of private keys
associated with a channel, we should have a generic API which
allows us to request signing, allowing the user to store private
keys any way they like.

The first step is the (rather mechanical) process of templating
the entire tree of ChannelManager -> Channel impls by the
key-providing type. In a later commit we should expose only public
keys where possible.

4 years agoBump versions to 0.0.10
Matt Corallo [Wed, 11 Dec 2019 20:41:39 +0000 (15:41 -0500)]
Bump versions to 0.0.10

4 years agoBump bitcoin dep to 0.21
Matt Corallo [Wed, 11 Dec 2019 20:41:24 +0000 (15:41 -0500)]
Bump bitcoin dep to 0.21

4 years agoMerge pull request #416 from TheBlueMatt/2019-12-fuzz-clib
Matt Corallo [Wed, 11 Dec 2019 22:06:46 +0000 (22:06 +0000)]
Merge pull request #416 from TheBlueMatt/2019-12-fuzz-clib

Refactor fuzzing to be a C-callable library plus rust binaries

4 years agoRefactor fuzzing to be a C-callable library plus rust binaries 2019-12-fuzz-clib
Matt Corallo [Wed, 11 Dec 2019 18:18:43 +0000 (13:18 -0500)]
Refactor fuzzing to be a C-callable library plus rust binaries

This should help us avoid rust's at-load syscalls by calling the
tests from a C program.

4 years agoMerge pull request #414 from TheBlueMatt/2019-12-347-nits
Matt Corallo [Wed, 11 Dec 2019 19:50:52 +0000 (19:50 +0000)]
Merge pull request #414 from TheBlueMatt/2019-12-347-nits

347 with travis fix and a few nits.

4 years agoAvoid cloning RBF state when we just want to modify fields. 2019-12-347-nits
Matt Corallo [Tue, 10 Dec 2019 20:38:04 +0000 (15:38 -0500)]
Avoid cloning RBF state when we just want to modify fields.

4 years agoAdd test_bump_txn_sanitize_tracking_maps
Antoine Riard [Tue, 10 Dec 2019 22:25:27 +0000 (17:25 -0500)]
Add test_bump_txn_sanitize_tracking_maps

Extend test visibility of claim-tracking maps to do so.

Cover both "If 2 claimable-outpoint-spending txn are in 1 block,
clean up properly" and "Clean up claimable_outpoints when
pending_claim_requests is cleaned" fix commits in same patchset.

4 years agoSanitize pending_claim_requests if no more outpoints to claim
Antoine Riard [Tue, 10 Dec 2019 20:45:30 +0000 (15:45 -0500)]
Sanitize pending_claim_requests if no more outpoints to claim

4 years agoDont RBF a tx twice if it hits RBF timer when one input is spent
Matt Corallo [Tue, 10 Dec 2019 17:06:50 +0000 (12:06 -0500)]
Dont RBF a tx twice if it hits RBF timer when one input is spent

4 years agoClean up claimable_outpoints when pending_claim_requests is cleaned
Matt Corallo [Tue, 10 Dec 2019 03:51:36 +0000 (22:51 -0500)]
Clean up claimable_outpoints when pending_claim_requests is cleaned

When claimable_outpoints was introduced in "Move
our_claim_txn_waiting_first_conf to pending_claim_requests", removal
of elements from it (which are just pointers into
pending_claim_requests) was never added.

4 years agoIf 2 claimable-outpoint-spending txn are in 1 block, clean up properly
Matt Corallo [Tue, 10 Dec 2019 03:17:31 +0000 (22:17 -0500)]
If 2 claimable-outpoint-spending txn are in 1 block, clean up properly

This resolves an issue where we will never track 2 on-chain events
which are waiting for ANTI_REORG_DELAY at the same height.

This partially reverts and fixes "Move our_claim_txn_waiting_first_conf
to pending_claim_requests".

4 years agoLog block tick in ChannelMonitor
Antoine Riard [Tue, 10 Dec 2019 21:28:33 +0000 (16:28 -0500)]
Log block tick in ChannelMonitor

4 years agoCorrect input comparison for input-subset RBF bump creation
Matt Corallo [Tue, 10 Dec 2019 03:14:47 +0000 (22:14 -0500)]
Correct input comparison for input-subset RBF bump creation

This resolves a regression introduced in "Implement bumping engine in
ChannelMonitor::block_connected" in which not all inputs are checked.
Several opportunities to clarify and clean up comments are also taken.

Fix test_bump_penalty_txn_on_revoked_htlcs as now remote claim txn
build the same way than us are going to be register as cleaning
pending_claim_request after ANTI_REORG_DELAY. It means during this
delay we are going to generate invalid bumped claiming txn on
already claimed outpoints. Previously these txn weren't issued
because all their outpoints would have been removed.

Fix full_stack_target by adding more input for FuzzEstimator

4 years agoDont forget RBF previous-feerate info if tx size changed.
Matt Corallo [Mon, 9 Dec 2019 22:22:02 +0000 (17:22 -0500)]
Dont forget RBF previous-feerate info if tx size changed.

While our fee may change wildly (or even go down), the previous
fee *rate* is still valid, and we should use that as the basis for
our RBF.

4 years agoAdd test_set_outpoints_partial_claiming
Antoine Riard [Fri, 6 Dec 2019 21:01:41 +0000 (16:01 -0500)]
Add test_set_outpoints_partial_claiming

4 years agoTrack and react to remote partial-claiming of pending claim request
Antoine Riard [Mon, 9 Dec 2019 21:59:08 +0000 (16:59 -0500)]
Track and react to remote partial-claiming of pending claim request

A pending claim request may contain a set of multiple outpoints.
If one or multiple of them get claimed by remote party, our in-flight
claiming transactions aren't valid anymore so we need to react
quickly and regenerate claiming transaction with accurate set.

However, a claimed outpoint may be disconnected and we need to resurrect
back outpoint among set of orignal pending claim request.

To guarantee consistency of contentious claimed outpoint we cache it
as OnchainEvent::ContentionsOutpoint and only delete it after
ANTI_REORG_DELAY.

Fix test broken by change, partial claiming on revoked txn
force us to regenerate txn

4 years agoAdd test_bump_penalty_txn_on_remote_commitment
Antoine Riard [Sat, 7 Dec 2019 01:51:51 +0000 (20:51 -0500)]
Add test_bump_penalty_txn_on_remote_commitment

4 years agoAdd test_bump_penalty_txn_on_revoked_htlcs
Antoine Riard [Sat, 7 Dec 2019 01:51:36 +0000 (20:51 -0500)]
Add test_bump_penalty_txn_on_revoked_htlcs

4 years agoAdd test_bump_penalty_txn_on_revoked_commitment
Antoine Riard [Tue, 2 Jul 2019 21:39:55 +0000 (17:39 -0400)]
Add test_bump_penalty_txn_on_revoked_commitment

Test multiple rounds of 25% heuristic in bump_claim_tx on remote revoked commitment
txn with htlcs pending in both directions.

4 years agoAdd RBF-bumping of preimage/timeout txn on remote HTLC outputs
Antoine Riard [Wed, 3 Jul 2019 14:26:17 +0000 (10:26 -0400)]
Add RBF-bumping of preimage/timeout txn on remote HTLC outputs

Given they are only signed by us we can RBF at wish

Fix tests broken by introduction of more txn broadcast
(channel_monitor_network_test)

Add locktime in RemoteHTLC as it's needed to generate
timeout txn.

4 years agoImplement bumping engine in ChannelMonitor::block_connected
Antoine Riard [Tue, 2 Jul 2019 19:52:58 +0000 (15:52 -0400)]
Implement bumping engine in ChannelMonitor::block_connected

Add RBF-bumping of justice txn, given they are only signed by us we
can RBF at wish.

Aggregation of bump-candidates and more aggresive bumping heuristics
are left open

Fix tests broken by introduction of more txn broadcast.
Some tests may have a relaxed check (claim_htlc_ouputs_single_tx)
as broadcast bumped txn are now interwining in previous broadcast ones
and breaking simple expectations

Use bumping engine to rebuild claiming transaction in case of partial-
claim of its outpoints set.

4 years agoRemove superflous pending_claims
Antoine Riard [Tue, 10 Dec 2019 03:18:41 +0000 (22:18 -0500)]
Remove superflous pending_claims

As local onchain txn are already monitored in block_connected by
check_spend_local_transaction, it's useless to generate twice
pending claims for HTLC outputs on local commitment tx.

We could do the alternative.

4 years agoMove our_claim_txn_waiting_first_conf to pending_claim_requests
Antoine Riard [Tue, 10 Dec 2019 03:18:20 +0000 (22:18 -0500)]
Move our_claim_txn_waiting_first_conf to pending_claim_requests

Add claimable_outpoints maps.

Both structures are tied and should ensure their mutual consistency.

Pending_claim_requests is cached by original claim txid. Medatada
and per input material should be constant between bumped transactions,
only change should be partial-claiming of outpoints set and block
reorgs.

Due to RBF rules, if an input has been part of an aggregate tx
at first claim try, if we want the bumped tx to land nicely
in the mempool, inputs should be distributed in multiple
bumped tx but still be aggregate in a new bumped tx.

4 years agoAdd log_trace on bump candidates tracking-buffer insertions
Antoine Riard [Thu, 4 Jul 2019 20:09:19 +0000 (16:09 -0400)]
Add log_trace on bump candidates tracking-buffer insertions

4 years agoAdd MIN_RELAY_FEE_SAT_PER_1000_WEIGHT
Antoine Riard [Tue, 19 Nov 2019 20:53:52 +0000 (15:53 -0500)]
Add MIN_RELAY_FEE_SAT_PER_1000_WEIGHT

Hardcode min relay fee as its value is fixed on the bitcoin network
and updating it would be done really conservatively.

4 years agoMerge pull request #413 from TheBlueMatt/2019-12-381-nits
Matt Corallo [Mon, 9 Dec 2019 21:41:53 +0000 (21:41 +0000)]
Merge pull request #413 from TheBlueMatt/2019-12-381-nits

381 with a few nits resolved.

4 years agoDocument the default values of configs 2019-12-381-nits
Steven Roose [Thu, 5 Dec 2019 20:29:16 +0000 (20:29 +0000)]
Document the default values of configs

4 years agoChange the new() functions for config to Default::default()
Steven Roose [Fri, 18 Oct 2019 13:19:49 +0000 (14:19 +0100)]
Change the new() functions for config to Default::default()

4 years agoMerge pull request #403 from TheBlueMatt/2019-11-rand-onion
Matt Corallo [Tue, 3 Dec 2019 19:37:34 +0000 (19:37 +0000)]
Merge pull request #403 from TheBlueMatt/2019-11-rand-onion

Randomize initial onion packet data.

4 years agoRandomize initial onion packet data. 2019-11-rand-onion
Matt Corallo [Mon, 25 Nov 2019 21:12:45 +0000 (16:12 -0500)]
Randomize initial onion packet data.

This avoids at least the trivial hop count discovery attack, though
other obvious ones remain and are slightly harder to avoid.

See https://github.com/lightningnetwork/lightning-rfc/pull/697

4 years agoMerge pull request #405 from TheBlueMatt/2019-11-cleanups
Matt Corallo [Sat, 30 Nov 2019 04:00:45 +0000 (04:00 +0000)]
Merge pull request #405 from TheBlueMatt/2019-11-cleanups

Misc Cleanups

4 years agoMerge pull request #407 from TheBlueMatt/2019-11-396-english
Matt Corallo [Sat, 30 Nov 2019 04:00:27 +0000 (04:00 +0000)]
Merge pull request #407 from TheBlueMatt/2019-11-396-english

#396 with a few english fixes