Commit Graph

91 Commits

Author SHA1 Message Date
Oliver Gugger
e99e6662cf
multi: update linter, fix new issues 2024-08-20 19:14:44 +02:00
Elle Mouton
48a9a8d20e
zpay32: add functional opt to error out on unknown feature bit
This commit adds two functional options to the zpay32.Decode function.
`WithKnownFeatureBits` allows the caller to overwrite the default set of
known feature bits used by the function.
`WithErrorOnUnknownFeatureBit` allows the caller to instruct the
function to error out if the invoice that is decoded contaijns unknown
feature bits. We then use this new error-out option from the
`rpcServer`'s `extractPaymentIntent` method.
2024-08-07 17:03:12 +02:00
Elle Mouton
be4c3dd9e4
zpay32: enforce a cipher text upper limit
To prevent an attacker from causing us to assign a huge in-memory
buffer, we place a cap on the maximum cipher text size of a blinded path
hop.
2024-07-31 14:11:00 +02:00
Elle Mouton
188dd44b42
zpay32: improve readability of blinded path encoding 2024-07-26 09:53:49 +02:00
Elle Mouton
cd3da40fb9
routing: dont include final hop cltv in blinded path
Only include the final hop's cltv delta in the total timelock
calculation if the route does not include a blinded path. This is
because in a blinded path, the final hops final cltv delta will be
included in the blinded path's accumlated cltv delta value.

With this commit, we remove the responsibility of remembering not to set
the `finalHop.cltvDelta` from the caller of `newRoute`. The relevant
test is updated accordingly.
2024-07-10 17:51:56 +02:00
Elle Mouton
f6a54c2ede
zpay: encoding and decoding of a BlindedPaymentPath
In this commit, the ability is added to encode blinded payment paths and
add them to a Bolt 11 invoice.
2024-07-10 17:51:55 +02:00
Oliver Gugger
648fb22f63
multi: wrap all errors 2024-04-11 15:04:03 +02:00
Slyghtning
7d9589ecbf
routerrpc+zpay32: EstimateRouteFee overhaul
In this commit the mission control based fee estimation
is supplemented with a payment probe estimation which can
lead to more accurate estimation results. The probing
utilizes a hop-hint heurisic to detect routes through LSPs
in order to manually estimate fees to destinations behind
an LSP that would otherwise block the payment probe.
2024-03-05 09:24:27 +01:00
ffranr
cd566eb097
multi: fix fmt.Errorf error wrapping
Refactor fmt.Errorf usage to correctly wrap errors instead of using
non-wrapping format verbs.
2024-02-27 11:13:40 +00:00
ziggie
ec02ffa383
zpay32: Change min_final_cltv_expiry_delta.
We adhere to BOLT 02 and use 18 instead of 9.
2023-12-22 18:16:07 +01:00
Elle Mouton
a24a4c2996 zpay32: remove litecoin tests 2023-10-06 16:34:47 -07:00
Michael Rooke
78d9996620
trivial: Fix spelling errors
- Fixes some spelling in code comments and a couple of function names
2023-09-21 22:35:33 -04:00
Olaoluwa Osuntokun
b368e476c5
lnwire: update Sig to support both ECDSA and schnorr sigs
In this commit, we update the Sig type to support ECDSA and schnorr
signatures. We need to do this as the HTLC signatures will become
schnorr sigs for taproot channels. The current spec draft opts to
overload this field since both the sigs are actually 64 bytes in length.
The only consideration with this move is that callers need to "coerce" a
sig to the proper type if they need schnorr signatures.
2023-08-22 16:29:19 -07:00
Matt Morehouse
9200abf96e
zpay32: allow fuzzer to choose invoice net
We add a parameter to select which network will be used for the fuzz
tests, rather than hardcoding the network.
2023-07-19 09:04:26 -05:00
Matt Morehouse
bd7ec84497
zpay32: help fuzzer generate valid encodings
It is very difficult for the fuzzer to create a valid checksum for each
serialized invoice, and we were therefore unable to fuzz deeper than
invoice decoding. We can help the fuzzer generate valid serialized
invoices by calculating and appending the checksum ourselves.

We also switch to using mainnet invoices to make it easier to find valid
invoices for seeding the fuzzer. We prepend the required "lnbc" prefix
ourselves to further help the fuzzer generate valid invoices.
2023-07-19 09:04:18 -05:00
Matt Morehouse
82753f091b
zpay32: use message signer from unit tests
The message signer from invoice_test.go is identical to the one created
in the fuzz test. We're already using the private key from
invoice_test.go, so we may as well use the complete message signer for
simplicity.
2023-07-19 09:04:13 -05:00
Matt Morehouse
4207be6e50
zpay32: remove unused method calls
The fuzz tests call inv.MinFinalCLTVExpiry() and inv.Expiry() supposedly
to ensure the invoice is well-formed. However, those methods can never
panic or return errors and therefore provide no benefit for this
purpose.
2023-07-19 09:04:03 -05:00
yyforyongyu
84fd911b47
multi: fix make lint
Fixes new lint errors caught by the latest version.
2022-11-18 20:48:23 +08:00
Matt Morehouse
e15d3e898e
brontide,lnwire,wtwire,zpay32: appease linter
Address all linter complaints for the newly migrated fuzz tests.
2022-11-11 08:44:30 -06:00
Matt Morehouse
5a48568806
brontide,lnwire,wtwire,zpay32: use CamelCase
Rename fuzz test functions to use CamelCase.
2022-11-11 08:44:24 -06:00
Conner
782f973298
zpay32: migrate fuzz tests 2022-11-11 08:44:12 -06:00
habibitcoin
0b1e881d18
scripted-diff: replace ⛰ emoji with $ [skip ci]
-BEGIN VERIFY SCRIPT-
sed -i 's/⛰/$/g' $(git grep -l '⛰')
-END VERIFY SCRIPT-
2022-10-28 12:06:49 -04:00
Tommy Volk
9a10c80bcb multi: move many t.Fatalf calls to require.NoError 2022-06-17 04:26:55 +00:00
Joost Jager
135e27ddd3
zpay32: add payment metadata field 2022-04-13 22:55:38 +02:00
Oliver Gugger
7dfe4018ce
multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease
review:
 - 2d746f68: replace imports
 - 4008f0fd: use ecdsa.Signature
 - 849e33d1: remove btcec.S256()
 - b8f6ebbd: use v2 library correctly
 - fa80bca9: bump go modules
2022-03-09 19:02:37 +01:00
Oliver Gugger
895a2e497b
multi: formatting and comment fixes 2022-02-10 11:02:02 +01:00
Oliver Gugger
dfdc2bff8b
multi: run gosimports 2022-02-10 11:02:01 +01:00
Dimitris Apostolou
530a2059e5
multi: Fix typos [skip ci] 2022-01-24 12:19:02 +02:00
Oliver Gugger
8b7c88537c
multi: refactor SignDigestCompact into SignMessageCompact
To make it possible to use a remote lnrpc server as a signer for our
wallet, we need to change our main interface to sign the message instead
of the message's digest. Otherwise we'd need to alter the
lnrpc.SignMessage RPC to accept a digest instead of only the message
which has security implications.
2021-10-08 12:06:52 +02:00
Oliver Gugger
044e1e692f
zpay32: add distinct hrp to invoice
The Core devs decided to us the same bech32 HRP for Signet as is used
for the current Testnet3. This might be okay for on-chain addresses
since they are compatible in theory. But for invoices we want to use a
distinct HRP to distinguish testnet from signet.
Also see spec PR
https://github.com/lightningnetwork/lightning-rfc/pull/844 for more
information about the reasoning.
2021-05-18 13:06:03 +02:00
Oliver Gugger
02267565fe
multi: unify code blocks in READMEs 2021-01-22 09:14:11 +01:00
Yaacov Akiba Slama
af01571fc6 Let invoice.Encode receive a function which hashes itself the message
Modify the SignCompact function passed to invoice.Encode to receive the
message before it's hashed and hash it itself.
With this modification, the SignMessage rpc function from the signrpc
subserver can be used and an invoice can be encoded outside of lnd.
2020-07-29 21:18:24 +03:00
Conner Fromknecht
53ab22305d
zpay32: rename to DefaultAssumedFinalCLTVDelta
This renames the paramter to clarify that this value is only used when
no CLTV value was decoded from the payment request
2020-07-24 13:14:03 -07:00
Conner Fromknecht
73256e6d0e
zpay32: fix linter errors in encode/decode 2020-07-24 13:13:39 -07:00
Conner Fromknecht
49c601e62a
zpay32: split off encoding/decoding into own files
As a preliminary step to isolating zpay32 in migrations 01-11, we'll
split out the encoding and decoding logic into separate files. Migration
11 only requires invoice decoding, so this prevents us from needing to
copy in the encoding logic that would otherwise be unused.
2020-07-24 13:13:29 -07:00
Andras Banki-Horvath
da9d7dd363 zpay32: invoice.MilliSat is uint64 which cannot be negative 2020-04-24 19:15:08 +02:00
Conner Fromknecht
b9b66419ff
zpay32/invoice: remove unknown required fbit check from decode
This commit removes the unknown required feature bit check from the
invoice decoding logic. This allows greater utility to users of the
decodepayreq rpc since it can provide inspection of otherwise invalid
invoices. In the prior commit, this check moved into our path finding
logic, so invalid features taken from an invoice will instead cause a
failure when attempting to pay.
2020-01-08 12:25:21 -08:00
kiwiidb
af1ff291a7 Merge branch 'master' of github.com:lightningnetwork/lnd 2019-12-20 15:00:20 +01:00
Conner Fromknecht
e745798a6e
zpay32: update spec test vectors, write features last
This commit updates the BOLT11 test vectors to use the updated versions
from the spec (with TLV bit set). This also pointed out that the
ordering was inconsistent with the spec, in that the payment secret
should be serialized before the feature vector.
2019-12-19 14:36:28 -08:00
kiwiidb
97b7e0fca5 fix: incomplete comment about minFinalCLTVExpiry 2019-12-19 22:24:09 +01:00
Olaoluwa Osuntokun
eae45f9ad9
zpay32: use new DefaultInvoiceExpiry constant 2019-12-13 19:54:37 -08:00
Andras Banki-Horvath
44f13d1d60 invoices: adding InvoiceExpryWatcher to cancel expired invoices
This commit adds InvoiceExpryWatcher which is a separate class that
receives new invoices (and existing ones upon restart) from InvoiceRegistry
and actively watches their expiry. When an invoice is expired
InvoiceExpiryWatcher will call into InvoiceRegistry to cancel the
invoice and by that notify all subscribers about the state change.
2019-12-13 17:03:08 +01:00
Conner Fromknecht
840476996c
zpay32: ensure feature vector is always populated 2019-12-11 17:37:18 -08:00
Conner Fromknecht
a77e111c52
zpay32: remove unused InvoiceFeatures
Originally the feature namespaces were destined to be split, but this
has changed with the introduction of flat features.
2019-12-10 13:08:40 -08:00
Conner Fromknecht
df72097f2d
zpay32/invoice: parse payment address as type s 2019-12-05 07:59:17 -08:00
Conner Fromknecht
2bf94fa409
zpay32/invoice: consolidate 32-byte array parsing and encoding logic
This commit also consolidates the existing code duplication in parsing
payment hashes and description hashes into a single, combined method for
parsing 32-byte values. A similar change is made for encoding 32-byte
values.

zpay32/invoice: consolidate 32-byte encoding logic
2019-12-05 07:58:55 -08:00
Matheus Degiovani
cf6ae06b30 zpay32: Add tests of checksum malleability
This adds tests for checksum malleability issue of bech32 strings as
used by LN invoices.
2019-11-26 17:09:35 -03:00
Matheus Degiovani
409cf55655 zpay32: Fix broken last tagged field
This fixes an issue where the last tagged field of an invoice could get
broken due to the malleability of bech32 checksums.

The addition of a specific character in the second to last position of
the checksum could cause the previous signature field to mutate and thus
point to a different public node.
2019-11-26 14:26:03 -03:00
Matheus Degiovani
85f9c03797 zpay32: Switch to ErrInvalidFieldLength sentinel
This switches the applicable error to use an exported sentinel error so
that it is more testable.
2019-11-26 14:26:03 -03:00
Conner Fromknecht
4c872c438b
channeldb: complete migration 12 for TLV invoices 2019-11-22 02:24:28 -08:00