Skip to content

routerrpc: reject payment to invoice that don't have payment secret or blinded paths #9752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/release-notes/release-notes-0.20.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
# Technical and Architectural Updates
## BOLT Spec Updates

* [Required invoices to include a payment address or blinded paths](https://github.com/lightningnetwork/lnd/pull/9752)
to comply with updated BOLT specifications before accepting payments.

## Testing

## Database
Expand All @@ -72,3 +75,5 @@
## Tooling and Documentation

# Contributors (Alphabetical Order)

Erick Cestari
10 changes: 9 additions & 1 deletion lnrpc/routerrpc/router_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,14 @@
return nil, err
}

// An invoice must include either a payment address or
// blinded paths.
if payReq.PaymentAddr.IsNone() &&
len(payReq.BlindedPaymentPaths) == 0 {

Check failure on line 991 in lnrpc/routerrpc/router_backend.go

View workflow job for this annotation

GitHub Actions / lint code

multi-line statement should be followed by a newline (whitespace)
return nil, errors.New("payment request must contain " +
"either a payment address or blinded paths")
}

// If the amount was not included in the invoice, then we let
// the payer specify the amount of satoshis they wish to send.
// We override the amount to pay with the amount provided from
Expand All @@ -1001,7 +1009,7 @@
if reqAmt != 0 {
return nil, errors.New("amount must not be " +
"specified when paying a non-zero " +
" amount invoice")
"amount invoice")
}

payIntent.Amount = *payReq.MilliSat
Expand Down
24 changes: 24 additions & 0 deletions lnrpc/routerrpc/router_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,13 @@ func TestExtractIntentFromSendRequest(t *testing.T) {
"g6aykds4ydvf2x9lpngqcfux3hv8qlraan9v3s9296r5w5eh959yzadgh5ck" +
"gjydgyfxdpumxtuk3p3caugmlqpz5necs"

const paymentReqMissingAddr = "lnbcrt100p1p70xwfzpp5qqqsyqcyq5rqwzqfq" +
"qqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kge" +
"tjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaqnp4q0n326hr8v9zprg8" +
"gsvezcch06gfaqqhde2aj730yg0durunfhv669qypqqqz3uu8wnr7883qzxr" +
"566nuhled49fx6e6q0jn06w6gpgyznwzxwf8xdmye87kpx0y8lqtcgwywsau" +
"0jkm66evelkw7cggwlegp4anv3cq62wusm"

destNodeBytes, err := hex.DecodeString(destKey)
require.NoError(t, err)

Expand Down Expand Up @@ -714,6 +721,23 @@ func TestExtractIntentFromSendRequest(t *testing.T) {
valid: false,
expectedErrorMsg: "invoice expired.",
},
{
name: "Invoice missing payment address",
backend: &RouterBackend{
ShouldSetExpEndorsement: func() bool {
return false
},
ActiveNetParams: &chaincfg.RegressionNetParams,
MaxTotalTimelock: 1000,
},
sendReq: &SendPaymentRequest{
PaymentRequest: paymentReqMissingAddr,
CltvLimit: 22,
},
valid: false,
expectedErrorMsg: "payment request must contain " +
"either a payment address or blinded paths",
},
{
name: "Invalid dest vertex length",
backend: &RouterBackend{
Expand Down
Loading