Commit Graph

183 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
5eb3406b19
channeldb: add new Database method to ChannelGraph 2017-10-10 22:19:26 -07:00
Olaoluwa Osuntokun
81cd954cfc
discovery: don't prune *our* channels during retransmission tick
This commit modifies the recently modified logic for self-channel
retransmission to exclude pruning *our* channels which haven’t been
updated since the broadcastInterval. Instead, we only re-broadcast
channels of ours that haven’t been updated in 24 hours.
2017-10-04 20:46:08 -07:00
Laura Cressman
6253419ce5 channeldb: use binary.Read/Write in waitingproof.go
Use binary.Read/Write when reading and writing booleans
in Encode and Decode functions that operate on the
WaitingProof struct.
2017-10-02 23:13:47 -07:00
Laura Cressman
3f6a58f967 channeldb: use binary.Read/Write in invoices.go
Use binary.Read/Write in when reading and writing
booleans in functions to serialize and deserialize
invoices.
2017-10-02 23:13:47 -07:00
Laura Cressman
156772d04a channeldb: use binary.Read/Write with bools in channel.go
Use binary.Read/Write in functions to serialize and deserialize
channel close summary and HTLC boolean data, as well as in
methods to put and fetch channel funding info. Remove lnd
implementations of readBool and writeBool as they are no
longer needed. Also fix a few minor typos.
2017-10-02 23:13:47 -07:00
Johan T. Halseth
5ed31b1030
channeldb: store payment request with invoices 2017-09-27 12:26:04 +02:00
Olaoluwa Osuntokun
5ff82c92da
channeldb: add commitment transaction fee to ChannelSnapshot 2017-09-24 20:09:28 -07:00
halseth
8693e8babc channeldb: check chanIndex bucket for nilness instead of edges 2017-09-19 05:40:29 +02:00
Dave Collins
916ab454c1 channeldb: Fix payment serialization tests.
This modifies the tests that deal serializing the Invoice type to limit
the creation date to seconds since Go1.9 added the concept of a
monotonic component to times which does not round trip through
MarshalBinary and UnmarshalBinary and therefore causes the tests to fail.

In particular, it modifies the creation dates in the randInvoice,
makeFakePayment, makeRandomFakePayment, and TestInvoiceWorkflow
functions.

This results in allowing TestOutgoingPaymentSerialization,
TestOutgoingPaymentWorkflow, and TestInvoiceWorkflow to pass.
2017-08-30 18:57:39 -07:00
Conner Fromknecht
6ffe33f01a lnw+ba+utxon+cdb: reverts OutPoint and TxOut encoding 2017-08-25 17:56:50 -07:00
Conner Fromknecht
4cdce1fc0a breacharbiter+channeldb: resolves rebase conflicts 2017-08-25 17:56:50 -07:00
Philip Hayes
f0aa186a56 channeldb+utxonursery+lnwire: use lnwire's OutPoint,TxOut serialization 2017-08-25 17:56:50 -07:00
Olaoluwa Osuntokun
460c2b0ec1
channeldb: update test to match recent API changes 2017-08-22 00:52:28 -07:00
Olaoluwa Osuntokun
76302a136b
channeldb: in node.ForEachChannel return incoming/outgoing edges
This commit modifies the node.ForEachChannel to *also* return the
incoming edge as well as the outgoing edge. We make this modification
as when we’re doing path finding, we need to return the incoming edge
as well, since we need to use the to properly compute the time lock and
fees for transit on that edge.
2017-08-22 00:52:25 -07:00
Olaoluwa Osuntokun
35d9dc8092
channeldb: add ChainHash to ChannelEdgeInfo to match BOLT-0007 2017-08-22 00:52:22 -07:00
Olaoluwa Osuntokun
59aae249dc
channeldb: use lnwire.MilliSatoshi within the ChannelEdgePolicy struct 2017-08-22 00:52:20 -07:00
Olaoluwa Osuntokun
74470cf7d0
channeldb: update ChannelConstraints+OpenChannel to use lnwire.MilliSatoshi 2017-08-22 00:52:17 -07:00
Olaoluwa Osuntokun
251f8d650f
channeldb: update the Invoice struct to use lnwire.MilliSatoshi 2017-08-22 00:52:15 -07:00
Olaoluwa Osuntokun
063525c6e0
channeldb: update the OutgoingPayment struct to use lnwire.MilliSatoshi 2017-08-22 00:52:12 -07:00
Olaoluwa Osuntokun
8abba7eafc
channeldb: add TODO to add storage for onion adds 2017-08-10 21:15:55 -07:00
Johan T. Halseth
849d0b93b1 fundingManager: persist state in opening process.
Persists the state of a channel opening process after funding
transaction is confirmed. This tracks the messages sent to
the peer such that the process can be continued in case of a
restart. Also introduces that the receiver side forgets about
channel if funding transaction is not confirmed in 48hrs.
2017-08-10 13:14:25 -07:00
Johan T. Halseth
bd0465ee1d channeldb: support adding partial LightningNodes to graph.
Adds a HaveNodeAnnouncement field to the LightningNode
struct, which is used to indicate if we have gotten
all the necessary information to fill the remaining
fields in the struct. If we haven't gotten a node
announcement for this specific node, then we only
know the pubkey, and can only fill that field in
the struct. Still, we should be able to add it to the
channel graph and use it for routes, as long as we
know about channels to this node.
2017-08-02 15:58:58 -07:00
Olaoluwa Osuntokun
88c15abeef
channeldb: remove RevocationDelay field from the HTLC struct
This commit removes the RevocationDelay field from the HTLC struct as
with the latest commitment transaction scheme, it is no longer needed.
This is due to the fact the the delay is now observed when an on-chain
HTLC claim is attempted, rather than from Shane the HTLC itself has
been broadcast.
2017-07-30 17:48:32 -07:00
Olaoluwa Osuntokun
5ad6c23848
channeldb: update tests to reflect latest OpenChannel/HTLC API changes 2017-07-30 17:48:26 -07:00
Olaoluwa Osuntokun
5854ffb644
channeldb: add InsertNextRevocation method to OpenChannel
This commit adds a new method to the OpenChannel struct:
InsertNextRevocation. This functionality is required in order to
properly implement the new funding workflow and commitment transaction
state machine.

In the prior state machine, we utilized the “initial revocation window”
which would provide both sides with the necessary revocation keys that
they needed to create new commitment states. The version of the
commitment state machine within the specification has been simplified a
bit, and instead essentially incorporates a revocation window of 1. The
window is initially filled at the _opening_ of the commitment
transaction, then never extended, only “slid down” from there on.
2017-07-30 17:48:22 -07:00
Olaoluwa Osuntokun
a14072a47e
channeldb: store the second-level HTLC signature along with HTLC's
This commit modifies the HTLC struct within the channeldb struct in
order to accommodate the additional storage that’s now required as a
result of the change to 2-of-2 HTLC covenant transactions within the
commitment transaction.
2017-07-30 17:48:19 -07:00
Olaoluwa Osuntokun
9811b404e4
channeldb: integrate ChannelConfig and ChannelConstraints into OpenChannel
This commit is the next phase in a rather major overhaul of the
OpenChannel struct. With this commit we remove the old ours vs theirs
semantics with channel related state variables, and instead encapsulate
all local vs remote state into a ChannelConfig structure for each party
within the channel.
2017-07-30 17:48:16 -07:00
Olaoluwa Osuntokun
5780992f8d
channeldb: eliminate ChanID in favor of FundingOutpoint
This commit eliminates a bit of redundancy within the OpenChannel
struct by eschewing the ChanID field, in favor of simply the
FundingOutpoint field.
2017-07-30 17:48:13 -07:00
Olaoluwa Osuntokun
a092b0d82c
channeldb: introduce ChannelConfig and ChannelConstraints
This commit introduces two new structs to the channeled package:
ChannelConfig and ChannelConstraints.

The ChannelConfig struct will eliminate many of the fields on the
OpenChannel struct (ours vs theirs), in favor of having a single config
for both sides (local and remote).

The ChannelConstraints struct will house the channel flow control and
HTLC policies for both sides. The fields of this struct will be used to
control the flow of HTLC’s within the channel. In the occasion that any
of these constraints are violated, either the connection, or the
channel entirely is to be failed.
2017-07-30 17:48:09 -07:00
Olaoluwa Osuntokun
1fb9d2e44e
channeldb: reset database version back to zero
As we removed the prior migration in an earlier commit, we now reset
the version of the database back to zero (no migrations needed).
2017-07-30 17:48:04 -07:00
Olaoluwa Osuntokun
c15cd12dcf
channeldb: fix type in ErrSourceNodeNotSet comment 2017-07-30 17:48:01 -07:00
Olaoluwa Osuntokun
d4916ba9c6
channeldb: remove prior migrations as their no longer needed
This commit removes a database migration that was added to fix a bug
introduced within the first alpha release. This migration is no longer
needed as the underlying database scheme has changed since then.
2017-07-30 17:47:58 -07:00
Johan T. Halseth
ebe05f6568 lnwallet: add update_fee message support.
This commit adds the possibility for the initiator of a
channel to send the update_fee message, as specified
in BOLT#2. After the message is sent and both parties
have committed to the updated fee, all new commitment
messages in the channel will use the specified fee.
2017-07-14 16:39:15 -07:00
Andrey Samokhvalov
8fa2b95c12 lnd: remove seelog logger
The btclog package has been changed to defining its own logging
interface (rather than seelog's) and provides a default implementation
for callers to use.

There are two primary advantages to the new logger implementation.

First, all log messages are created before the call returns.  Compared
to seelog, this prevents data races when mutable variables are logged.

Second, the new logger does not implement any kind of artifical rate
limiting (what seelog refers to as "adaptive logging").  Log messages
are outputted as soon as possible and the application will appear to
perform much better when watching standard output.

Because log rotation is not a feature of the btclog logging
implementation, it is handled by the main package by importing a file
rotation package that provides an io.Reader interface for creating
output to a rotating file output.  The rotator has been configured
with the same defaults that btcd previously used in the seelog config
(10MB file limits with maximum of 3 rolls) but now compresses newly
created roll files.  Due to the high compressibility of log text, the
compressed files typically reduce to around 15-30% of the original
10MB file.
2017-06-25 14:19:56 +01:00
Olaoluwa Osuntokun
1be4d67ce4
multi: run all test instances in parallel 2017-06-17 01:00:07 +02:00
Olaoluwa Osuntokun
4b8d052afc
channeldb: replace opening height will short chan ID in OpenChannel
This commit modifies the OpenChannel struct to include the full short
channel ID rather than simply the opening height. This new field will
be needed by an upcoming change to uniformly switch to using short
channel ID’s when forwarding HTLC’s due to the change in per-hop
payloads.
2017-06-16 22:28:58 +02:00
Olaoluwa Osuntokun
66ba2e862c
channeldb: store the funding transaction broadcast height for channels
This commit expands the field within the OpenChannel struct in order to
start tracking the height that the funding transaction was initially
broadcast. Other sub-systems within lnd can now use this data to give a
more accurate height hint to the ChainNotifier, or to use during the
funding workflow to decide if a channel should be forgotten after it
fails to confirm for N blocks.
2017-06-05 19:15:44 -07:00
Olaoluwa Osuntokun
75d5396445
channeldb: change MinFeePerKb to FeePerKw in OpenChannel struct
This commit modifies the name of a field in the OpenChannel struct to
better reflect its actual usage within this protocol. The FeePerKw
represents the amount of satoshi to be paid as fees per kilo-weight.
This field is set at the opening of a transaction and will be able to
be updated properly via the usage of the update_fee method.
2017-05-16 18:44:01 -07:00
bryanvu
320bed7e6b lnwallet: add CommitFee field to OpenChannel
In order to cleanly handle shutdowns and restarts during state machine operation, the fee for the current
commitment transaction must be persisted. This allows the fee to be
reapplied when the current state is reloaded.
2017-05-15 20:26:11 -07:00
Olaoluwa Osuntokun
68dbbb046b
channeldb: add total time locked balance to CloseChannelSummary
This commit adds the total time locked balance of a closed channel at
closure time to the CloseChannelSummary struct. With this information,
we now provide sub-systems within the daemon further knowledge which
can aide them in properly handling querying for the state of pending
close transactions, or if they should watch a channel for closure or
not.
2017-05-14 19:03:08 -07:00
Olaoluwa Osuntokun
a5113c2439
channeldb+funding: track opening height using MarkChannelAsOpen
This commit modifies the OpenChannel structure on-disk to also track
that opening height of a channel. This change is being made in order to
make and more light client friendly. A follow up commit will modify
several areas of the codebase to use this new functionality.
2017-05-11 15:20:33 -07:00
Olaoluwa Osuntokun
373a1192ce
channeldb: fix panic bug in channeldb, check proper bucket for nil-ness 2017-05-11 15:20:31 -07:00
Olaoluwa Osuntokun
333373f78f
channeldb: add new ChannelView method to the ChannelGraph
This commit introduces a new method to the ChannelGraph struct:
ChannelView. This struct returns all the outpoints that represent the
set of active channels within the network. The set of items returned by
this new method will possibly shrink with each call to `PruneGraph`,
and possibly be expanded by each call to `AddChannelEdge`.

The graph pruning tests have been updated to ensure the description
above holds true.
2017-05-11 15:20:23 -07:00
Andrey Samokhvalov
a3eee453c3 channeldb: add waiting proof storage
In this commit boltdb persistent storage have been added, which allow
as to not loose announcement proofs inside gossiper subsystem.
2017-05-05 17:02:49 -07:00
Olaoluwa Osuntokun
18a2c8a455
channeldb: fix linter errors 2017-05-04 17:46:17 -07:00
Olaoluwa Osuntokun
35fd800083
channeldb: add test for new channel closure persistence 2017-05-04 17:39:05 -07:00
Olaoluwa Osuntokun
826dbbd1f7
channeldb: add new method to db, MarkChanFullyClosed
This commit adds a new method to the database which allows callers to
mark a channel as fully closed once certain conditions have been
reached. If a channel was cooperatively closed, then it can be marked
as fully closed as soon as the channel has been confirmed. If the
channel was marked as force closed, then it should be marked as closed
as soon as _all_ the funds in limbo have been swept.
2017-05-04 17:39:03 -07:00
Olaoluwa Osuntokun
f2f3774cec
channeldb: add new method to db, FetchClosedChannels
This commit builds upon the prior commit by adding a new method to
allows callers to query the state of all closed (fully) and pending
closed channel within the database.
2017-05-04 17:39:00 -07:00
Olaoluwa Osuntokun
bafea35a32
channeldb: expand channel close summaries to include additional data
This commit expands the close summaries within the database to include
additional information such as: how the channel was closed, if the
channel if fully closed, and other balance information. This new
information will be used in an upcoming expansion of the
pendingChannels RPC to display more comprehensive data w.r.t where the
node’s funds are and how soon they’ll be fully available.

The data stored in the closeChannel bucket has been expanded to include
the above. Additionally the CloseChannel method on the OpenChannel
struct now takes in the additional information that details how and who
it was closed by.

This commit borrows heavily from the initial work in #179 by @halseth.
2017-05-04 17:38:58 -07:00
Olaoluwa Osuntokun
b96b180b0b
channeldb: modify ForEachNode/ForEachChannel to accept a db txn
This commit modifies the ForEachNode on the ChannelGraph and
ForEachChannel on the LightningNode struct to accept a database
transaction as its first argument. With this change, it’ll now be
possible to implement graph traversals that typically required a nested
loop with all the vertex loaded into memory using the callback API
instead:
c.ForEachNode(nil, func(tx, node) {
    node.ForEachChannel(tx, func(…) {
    })
})
2017-04-14 13:14:09 -07:00