Commit Graph

11078 Commits

Author SHA1 Message Date
Oliver Gugger
c623d21bd2
Merge pull request #5083 from guggero/psbt-size-fix
lncli: allow PSBT to be read from file
2021-03-10 23:02:02 +01:00
Conner Fromknecht
7e33548e8b
Merge pull request #4775 from halseth/input-tx-size-constants
[input/size] Check tx size constants
2021-03-10 09:23:40 -08:00
Oliver Gugger
f55aae0068
itest: add new neutrino error to whitelist 2021-03-10 16:55:49 +01:00
Oliver Gugger
b3dfe5d1af
lncli: allow PSBT to be read from file
Fixes #5080.

The N_TTY_BUF_SIZE kernel parameter dictates how many characters can be
pasted into a terminal window. This cannot be circumvented by reading
the input in a different manner.
To avoid the problem fully, we instead allso allow the user to type in a
path to a text file that is read if it exists. That way the PSBT can be
as long as needed.
2021-03-10 12:46:33 +01:00
Olaoluwa Osuntokun
65b0bbcd53
Merge pull request #5033 from robot-dreams/set-channel-status
Add lncli command / RPC for manually setting channel state
2021-03-09 18:12:08 -08:00
Olaoluwa Osuntokun
dd13dbe613
Merge pull request #5072 from cfromknecht/fix-tlv-bench
tlv: fix ESatPerKw in benchmark
2021-03-09 16:42:58 -08:00
Eugene
6dca38c561
Merge pull request #5073 from Crypt-iQ/writemessage_03042021
lnwire: remove MaxPayloadLength from lnwire.Message interface
2021-03-09 04:50:40 -08:00
Yaacov Akiba Slama
4bab68a808 lnrpc: add timestamp_ns field to ForwardingEvent msg
This allows to use FowardingHistory rpc method to receive the data exactly
as it's stored in lnd and to synchronize incrementally the history to an
external database.
2021-03-05 16:26:28 -08:00
Olaoluwa Osuntokun
3c14e3d71d
Merge pull request #4517 from Crypt-iQ/2659_keyloc
multi: store KeyLocator in OpenChannel, use ECDH instead of DerivePrivKey
2021-03-05 16:12:49 -08:00
Conner Fromknecht
8c4e32012e
Merge pull request #5070 from alexbosworth/patch-14
trivial: match newline style
2021-03-05 12:30:20 -08:00
Conner Fromknecht
b121d1da4e
Merge pull request #5078 from carlaKC/fix-comment
lnrpc: correct comment on half life seconds
2021-03-05 12:29:59 -08:00
Conner Fromknecht
e7f3fe3923
Merge pull request #5074 from cfromknecht/add-invalid-onion-payload-rpc
lnrpc: expose INVALID_ONION_PAYLOAD via RPC
2021-03-05 09:50:47 -08:00
eugene
99a7271289
lntest/itest+lnwallet: add legacy chanrestore test
The test makes use of a nextRevocationProducer that is only used during
integration tests.
2021-03-05 12:49:18 -05:00
eugene
bb84f0ebc8
multi: store KeyLocator in OpenChannel, use ECDH
This commit adds a RevocationKeyLocator field to the OpenChannel
struct so that the SCB derivation doesn't have to brute-force the
sha chain root key and match the public key. ECDH derivation is now
used to derive the key instead of regular private key derivation a
la DerivePrivKey. The legacy can still be used to recover old
channels.
2021-03-05 12:49:18 -05:00
eugene
986e69c81b
channeldb: add KeyLocator Record 2021-03-05 12:49:16 -05:00
carla
cd1a8b2d3a
lnrpc: correct comment on half life seconds
Field is not a unix timestamp, it's just number of seconds.
2021-03-05 16:26:02 +02:00
Johan T. Halseth
d30aae43e6
input/size: add txSize test
Similar to what we do for witnesses, check that the HTLC weight
constants check out.

They actually do not, since the spec is off by one. We ensure we agree
with the spec.
2021-03-05 10:58:42 +01:00
Johan T. Halseth
2bc37db61a
lnwallet: export HTLC generating methods 2021-03-05 10:58:42 +01:00
Johan T. Halseth
3a3076397a
input/size: fix comments for constants
We run a script that ensures the constant sizes listed is actually the
value of the constant.
2021-03-05 10:58:42 +01:00
Johan T. Halseth
fe71c905e5
input/size: split constants into confirmed/non-confirmed
This to more easily track mismatches if constants and get more accurate
fee estimates for the two channel types.

The non-anchor weight estimates will now be smaller, this is okay since
these constants are only being used for fee estimation (and will now be
more accurate).
2021-03-05 10:58:42 +01:00
Conner Fromknecht
71db3a83bc
lnrpc: expose INVALID_ONION_PAYLOAD via RPC 2021-03-04 15:27:16 -08:00
eugene
7ff04d8bad
lnwire: remove MaxPayloadLength from Message interface
Removes the MaxPayloadLength function from the Message interface
and checks that each message payload is not greater than MaxMsgBody.
Since all messages are now allowed to be 65535 bytes in size, the
MaxPayloadLength is no longer needed.
2021-03-04 16:48:10 -05:00
Conner Fromknecht
56b61078c5
Merge pull request #4338 from cfromknecht/set-id-index
channeldb+invoices: add set id index for AMP
2021-03-04 12:17:08 -08:00
Conner Fromknecht
68688d6346
invoices: replace all asserts with requires 2021-03-04 10:11:22 -08:00
Conner Fromknecht
d004442efb
lnrpc+itest: expose AMP fields on InvoiceHTLC
We also test that legacy keysend payments are promoted to AMP payments
on the receiver-sdie by asserting basic properties of the fields
returned via the rpc.
2021-03-04 10:11:21 -08:00
Conner Fromknecht
ffddb85e9c
tlv/bench_test: fix ESatPerKw, pass reference to uint64 2021-03-04 10:02:29 -08:00
Conner Fromknecht
7cd78afd1a
tlv/bench_test: check for errors in benchmarks 2021-03-04 10:02:29 -08:00
Alex Bosworth
0e43c8fc4c
trivial: match newline style
Use newline for map key to match other keys
2021-03-03 17:28:21 -08:00
Conner Fromknecht
137258fb58
invoices/invoiceregistry: unbundle invalid preimage error 2021-03-03 16:28:03 -08:00
Conner Fromknecht
9da3e7fc90
invoices: filter HTLC set by set id from AMP payload 2021-03-03 16:28:02 -08:00
Conner Fromknecht
5f34880040
channeldb/invoices: continue cancel loop early 2021-03-03 16:28:02 -08:00
Conner Fromknecht
fc9af92dd9
channeldb: only accept/settle non-empty HTLC sets
Prior to AMP, there could only be one HTLC set. Now that there can be
multiple, we introduce the inherent risk that we might be persisting a
settle/accept of the wrong HTLC set. To migitigate this risk, we add a
check to assert that an invoice can only be transitioned into an
Accepted or Settled state if the specified HTLC set is non-empty, i.e.
has accepted HTLCs.

To do this check, we unroll the loops in UpdateInvoice to first process
any added or canceled HTLCs. This ensures that the set of accepted HTLCs
is up-to-date when we got to transition the invoice into a new state, at
which point we can accurately check that the HTLC set is non-empty.
Previously this sort of check wasn't possible because a newly added HTLC
wouldn't be populated on the invoice when going to call
updateInvoiceState.

Once the invoice-level transition checks have completed, we complete a
final pass to move the HTLCs into their final states and recompute the
amount paid.

With this refactor, it is now possible to make stronger assertions
about the invoice and the state transitions being made by the
invoiceregistry before those changes are ultimately persisted.
2021-03-03 16:28:02 -08:00
Conner Fromknecht
e1b0fe5e98
channeldb/invoices: update AMP invoice htlcs 2021-03-03 16:28:02 -08:00
Conner Fromknecht
fad25f3f26
channeldb/invoices: add invoices to set id index on update 2021-03-03 16:28:01 -08:00
Conner Fromknecht
7c0d1e0093
channeldb/invoice: map zero-value timestamps to 0
Mainly affects ResolveTime which can be 0 before its settled.
2021-03-03 16:26:43 -08:00
Conner Fromknecht
da049ebcf7
channeldb: ensure invoices can't be added with HTLCs 2021-03-03 16:26:43 -08:00
Conner Fromknecht
b2234703f6
invoices+channeldb: add HTLCSet method to invoice 2021-03-03 16:26:43 -08:00
Conner Fromknecht
7f05c9d3bb
channeldb/invoice: persist optional AMP fields on InvoiceHTLC 2021-03-03 16:26:43 -08:00
Conner Fromknecht
464dff09ac
invoices: expose AMPRecord() method on Payload 2021-03-03 16:26:39 -08:00
Olaoluwa Osuntokun
055db6b9ac
Merge pull request #5069 from Roasbeef/v12-99
build: bump version to v0.12.99-beta
2021-03-03 16:24:51 -08:00
Olaoluwa Osuntokun
75eca3a595
Merge pull request #4923 from halseth/the-great-tlv-wire-migration
The great tlv wire migration of 2021
2021-03-03 16:24:31 -08:00
Olaoluwa Osuntokun
6c3d3711f6
build: bump version to v0.12.99-beta
In this commit we bump the version to v0.12.99-beta to reflect that the
master branch is a super set of the recently released v0.12.1-beta.
2021-03-03 15:49:22 -08:00
Olaoluwa Osuntokun
660d37a335
Merge pull request #5049 from Crypt-iQ/commitFee_check_0222
lnd+lnwallet: make capacity check stricter by adding fee
2021-02-24 19:01:34 -08:00
Johan T. Halseth
6842c0ba8c
lnwire: convert the delivery addr in [Open+Accept]Channel to a TLV type in ExtraData
In this commit, we convert the delivery address in the open and accept
channel methods to be a TLV type. This works as an "empty" delivery
address is encoded using a two zero bytes (uint16 length zero), and a
tlv type of 0 is encoded in the same manner (byte for type, byte for
zero length). This change allows us to easily extend these messages in
the future, in a uniform manner.

When decoding the message we snip the bytes from the read TLV data.
Similarly, when encoding we concatenate the TLV record for the shutdown
script with the rest of the TLV data.
2021-02-24 17:40:08 +01:00
Olaoluwa Osuntokun
9a6bb19770
lnwire: prep wire messages for TLV extensions
Messages:
- UpdateFulfillHTLC
- UpdateFee
- UpdateFailMalformedHTLC
- UpdateFailHTLC
- UpdateAddHTLC
- Shutdown
- RevokeAndAck
- ReplyShortChanIDsEnd
- ReplyChannelRange
- QueryShortChanIDs
- QueryChannelRange
- NodeAnnouncement
- Init
- GossipTimestampRange
- FundingSigned
- FundingLocked
- FundingCreated
- CommitSig
- ClosingSigned
- ChannelUpdate
- ChannelReestablish
- ChannelAnnouncement
- AnnounceSignatures

lnwire: update quickcheck tests, use constant for Error

multi: update unit tests to pass deep equal assertions with messages

In this commit, we update a series of unit tests in the code base to now
pass due to the new wire message encode/decode logic. In many instances,
we'll now manually set the extra bytes to an empty byte slice to avoid
comparisons that fail due to one message having an empty byte slice and
the other having a nil pointer.
2021-02-24 17:31:55 +01:00
Olaoluwa Osuntokun
a603ac4938
lnwire: create new ExtraOpaqueData type for parsing TLV extensions
In this commit, we create a new `ExtraOpaqueData` based on the field
with the same name that's present in all the announcement related
messages. In later commits, we'll embed this new type in each message,
so we'll have a generic way to add/parse TLV extensions from messages.
2021-02-24 17:31:55 +01:00
Olaoluwa Osuntokun
dd6f0ba931
discovery+lnwire: remove embedding within ReplyChannelRange
In order to prep for allowing TLV extensions for the `ReplyChannelRange`
and `QueryChannelRange` messages, we'll need to remove the struct
embedding as is. If we don't remove this, then we'll attempt to decode
TLV extensions from both the embedded and outer struct.

All relevant call sites have been updated to reflect this minor change.
2021-02-24 17:31:55 +01:00
Johan T. Halseth
466c079bbe
channeldb/migration21: add body and tests for migration 21
In this commit, we migrate all wire messages in the database from the
`legacy` to the `current` encoding.

This affects the way we write the `CommitDiff` and `LogUpdates` struct
to disk. We also need to migrate the network results bucket in the
switch as it includes a wire message without a length prefix.
2021-02-24 17:31:55 +01:00
Johan T. Halseth
d4e90eae83
channeldb/migration21: add new serialization to package 'current'
We copy the new serialization togic to a new package 'current' and
export the methods we will need from the migration. This ensures that we
have isolation between the legacy and current serialization methods,
cleanly inidcating what type we are using during the migration.
2021-02-24 17:31:49 +01:00
Johan T. Halseth
db66fef6cc
channeldb+htlcswitch: write wire messages using length prefix
In this commit, we modify the way we write wire messages across the
entire database. We'll now ensure that we always write wire messages
with a length prefix. We update the `codec.go` file to always write a 2
byte length prefix, this affects the way we write the `CommitDiff` and
`LogUpdates` struct to disk, and the network results bucket in the
switch as it includes a wire message.
2021-02-24 17:15:27 +01:00